Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -re912e0a6b456c2eed24bec7303a908d3ff0aa59a -r09d557ffefb1dd57e7606695e16c3151e42285f2 --- src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision e912e0a6b456c2eed24bec7303a908d3ff0aa59a) +++ src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 09d557ffefb1dd57e7606695e16c3151e42285f2) @@ -242,7 +242,7 @@ lvc.cx=static_cast(0.1*rc.Width()); m_ctlFilters.InsertColumn(6, &lvc); - m_bFilters=!!m_ccData.m_afFilters.GetSize(); + m_bFilters = !m_ccData.m_afFilters.IsEmpty(); // other custom flags m_bAdvanced=(m_ccData.m_bIgnoreFolders | m_ccData.m_bCreateStructure); @@ -341,8 +341,12 @@ // refresh the entries in filters' list m_ctlFilters.DeleteAllItems(); - for (int i=0;im_bUseMask) + dlg.m_astrAddMask.Add(pFilter->GetCombinedMask(strData)); + if(pFilter->m_bUseExcludeMask) + dlg.m_astrAddExcludeMask.Add(pFilter->GetCombinedExcludeMask(strData)); + } } if (dlg.DoModal() == IDOK) @@ -749,28 +758,36 @@ { int iItem=m_ctlFilters.GetNextSelectedItem(pos); CFilterDlg dlg; - dlg.m_ffFilter=m_ccData.m_afFilters.GetAt(iItem); + const CFileFilter* pFilter = m_ccData.m_afFilters.GetAt(iItem); + BOOST_ASSERT(pFilter); + if(pFilter) + dlg.m_ffFilter = *pFilter; CString strData; - for (int i=0;im_bUseMask && i != iItem) + dlg.m_astrAddMask.Add(pFilter->GetCombinedMask(strData)); + if (pFilter->m_bUseExcludeMask && i != iItem) + dlg.m_astrAddExcludeMask.Add(pFilter->GetCombinedExcludeMask(strData)); + } } if (dlg.DoModal() == IDOK) { // delete old element m_ctlFilters.DeleteItem(iItem); - m_ccData.m_afFilters.RemoveAt(iItem); + //m_ccData.m_afFilters.RemoveAt(iItem); // insert new if needed if (dlg.m_ffFilter.m_bUseMask || dlg.m_ffFilter.m_bUseExcludeMask || dlg.m_ffFilter.m_bUseSize || dlg.m_ffFilter.m_bUseDate || dlg.m_ffFilter.m_bUseAttributes) { - m_ccData.m_afFilters.InsertAt(iItem, dlg.m_ffFilter); + m_ccData.m_afFilters.SetAt(iItem, dlg.m_ffFilter); AddFilter(dlg.m_ffFilter, iItem); } } Index: src/ch/FileFilter.cpp =================================================================== diff -u -r52e4374b1e7044f77439e34581780750675125a7 -r09d557ffefb1dd57e7606695e16c3151e42285f2 --- src/ch/FileFilter.cpp (.../FileFilter.cpp) (revision 52e4374b1e7044f77439e34581780750675125a7) +++ src/ch/FileFilter.cpp (.../FileFilter.cpp) (revision 09d557ffefb1dd57e7606695e16c3151e42285f2) @@ -552,15 +552,27 @@ } } +CFiltersArray& CFiltersArray::operator=(const CFiltersArray& rSrc) +{ + if(this != &rSrc) + { + m_vFilters = rSrc.m_vFilters; + } + + return *this; +} + bool CFiltersArray::Match(const CFileInfo& rInfo) const { - if (GetSize() == 0) + if(m_vFilters.empty()) return true; // if only one of the filters matches - return true - for (int i=0;i::const_iterator iterFilter = m_vFilters.begin(); iterFilter != m_vFilters.end(); iterFilter++) + { + if((*iterFilter).Match(rInfo)) return true; + } return false; } @@ -569,21 +581,74 @@ { if (ar.is_storing()) { - ar<::iterator iterFilter = m_vFilters.begin(); iterFilter != m_vFilters.end(); iterFilter++) + { + (*iterFilter).Serialize(ar); + } } else { - int iSize; + m_vFilters.clear(); + + size_t stSize; CFileFilter ff; - ar>>iSize; - SetSize(iSize); - for (int i=0;i> stSize; + m_vFilters.reserve(stSize); + while(stSize--) { ff.Serialize(ar); - SetAt(i, ff); + m_vFilters.push_back(ff); } } } + +bool CFiltersArray::IsEmpty() const +{ + return m_vFilters.empty(); +} + +void CFiltersArray::Add(const CFileFilter& rFilter) +{ + m_vFilters.push_back(rFilter); +} + +bool CFiltersArray::SetAt(size_t stIndex, const CFileFilter& rNewFilter) +{ + BOOST_ASSERT(stIndex < m_vFilters.size()); + if(stIndex < m_vFilters.size()) + { + CFileFilter& rFilter = m_vFilters.at(stIndex); + rFilter = rNewFilter; + return true; + } + else + return false; +} + +const CFileFilter* CFiltersArray::GetAt(size_t stIndex) const +{ + BOOST_ASSERT(stIndex < m_vFilters.size()); + if(stIndex < m_vFilters.size()) + return &m_vFilters.at(stIndex); + else + return NULL; +} + +bool CFiltersArray::RemoveAt(size_t stIndex) +{ + BOOST_ASSERT(stIndex < m_vFilters.size()); + if(stIndex < m_vFilters.size()) + { + m_vFilters.erase(m_vFilters.begin() + stIndex); + return true; + } + else + return false; +} + +size_t CFiltersArray::GetSize() const +{ + return m_vFilters.size(); +} Index: src/ch/FileFilter.h =================================================================== diff -u -r52e4374b1e7044f77439e34581780750675125a7 -r09d557ffefb1dd57e7606695e16c3151e42285f2 --- src/ch/FileFilter.h (.../FileFilter.h) (revision 52e4374b1e7044f77439e34581780750675125a7) +++ src/ch/FileFilter.h (.../FileFilter.h) (revision 09d557ffefb1dd57e7606695e16c3151e42285f2) @@ -98,11 +98,25 @@ int m_iDirectory; }; -class CFiltersArray : public CArray +class CFiltersArray { public: + CFiltersArray() {} + ~CFiltersArray() {} + + CFiltersArray& operator=(const CFiltersArray& rSrc); bool Match(const CFileInfo& rInfo) const; void Serialize(icpf::archive& ar); + bool IsEmpty() const; + + void Add(const CFileFilter& rFilter); + bool SetAt(size_t stIndex, const CFileFilter& rNewFilter); + const CFileFilter* GetAt(size_t stIndex) const; + bool RemoveAt(size_t stIndex); + size_t GetSize() const; + +protected: + std::vector m_vFilters; }; #endif \ No newline at end of file Index: src/ch/MainWnd.cpp =================================================================== diff -u -re912e0a6b456c2eed24bec7303a908d3ff0aa59a -r09d557ffefb1dd57e7606695e16c3151e42285f2 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision e912e0a6b456c2eed24bec7303a908d3ff0aa59a) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 09d557ffefb1dd57e7606695e16c3151e42285f2) @@ -1753,7 +1753,7 @@ iPriority=dlg.m_ccData.m_iPriority; strDstPath=dlg.m_ccData.m_strDestPath; bsSizes=dlg.m_ccData.m_bsSizes; - ffFilters.Copy(dlg.m_ccData.m_afFilters); + ffFilters = dlg.m_ccData.m_afFilters; bIgnoreDirs=dlg.m_ccData.m_bIgnoreFolders; bForceDirectories=dlg.m_ccData.m_bForceDirectories; bOnlyCreate=dlg.m_ccData.m_bCreateStructure; Index: src/ch/Structs.cpp =================================================================== diff -u -re912e0a6b456c2eed24bec7303a908d3ff0aa59a -r09d557ffefb1dd57e7606695e16c3151e42285f2 --- src/ch/Structs.cpp (.../Structs.cpp) (revision e912e0a6b456c2eed24bec7303a908d3ff0aa59a) +++ src/ch/Structs.cpp (.../Structs.cpp) (revision 09d557ffefb1dd57e7606695e16c3151e42285f2) @@ -939,13 +939,13 @@ else if ((m_nStatus & ST_OPERATION_MASK) == ST_COPY ) { _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+1)); - if (m_afFilters.GetSize()) + if(!m_afFilters.IsEmpty()) _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_FILTERING_STRING)); } else if ( (m_nStatus & ST_OPERATION_MASK) == ST_MOVE ) { _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+2)); - if (m_afFilters.GetSize()) + if(!m_afFilters.IsEmpty()) _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_FILTERING_STRING)); } else @@ -1052,8 +1052,12 @@ void CTask::SetFilters(const CFiltersArray* pFilters) { + BOOST_ASSERT(pFilters); + if(!pFilters) + return; + m_cs.Lock(); - m_afFilters.Copy(*pFilters); + m_afFilters = *pFilters; m_cs.Unlock(); }