diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
commit | 8bf668665b107469086f16cb8ad23e47d479d2b4 (patch) | |
tree | 66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /ui/grid_view.cpp | |
parent | 3.21 (diff) | |
download | FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2 FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip |
4.0
Diffstat (limited to 'ui/grid_view.cpp')
-rw-r--r-- | ui/grid_view.cpp | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/ui/grid_view.cpp b/ui/grid_view.cpp index 0614b3e5..17fb3ff4 100644 --- a/ui/grid_view.cpp +++ b/ui/grid_view.cpp @@ -8,6 +8,7 @@ #include "sorting.h" #include "../synchronization.h" #include <boost/bind.hpp> +#include "../shared/stl_tools.h" using namespace zen; @@ -258,8 +259,7 @@ void GridView::removeInvalidRows() viewRef.clear(); //remove rows that have been deleted meanwhile - sortedRef.erase(std::remove_if(sortedRef.begin(), sortedRef.end(), - boost::bind(&GridView::isInvalidRow, this, _1)), sortedRef.end()); + vector_remove_if(sortedRef, [&](const RefIndex& refIdx) { return this->isInvalidRow(refIdx); }); } @@ -278,29 +278,24 @@ public: index_(index), sortedRef_(sortedRef) {} - void execute(const HierarchyObject& hierObj) + void execute(HierarchyObject& hierObj) { - //add file references std::for_each(hierObj.refSubFiles().begin(), hierObj.refSubFiles().end(), *this); - - //add symlink references std::for_each(hierObj.refSubLinks().begin(), hierObj.refSubLinks().end(), *this); - - //add dir references - std::for_each(hierObj.refSubDirs().begin(), hierObj.refSubDirs().end(), *this); + std::for_each(hierObj.refSubDirs ().begin(), hierObj.refSubDirs ().end(), *this); } - void operator()(const FileMapping& fileObj) + void operator()(FileMapping& fileObj) { sortedRef_.push_back(RefIndex(index_, fileObj.getId())); } - void operator()(const SymLinkMapping& linkObj) + void operator()(SymLinkMapping& linkObj) { sortedRef_.push_back(RefIndex(index_, linkObj.getId())); } - void operator()(const DirMapping& dirObj) + void operator()(DirMapping& dirObj) { sortedRef_.push_back(RefIndex(index_, dirObj.getId())); execute(dirObj); //add recursion here to list sub-objects directly below parent! @@ -319,7 +314,7 @@ void GridView::setData(FolderComparison& newData) folderCmp.swap(newData); //fill sortedRef - for (FolderComparison::const_iterator j = folderCmp.begin(); j != folderCmp.end(); ++j) + for (auto j = begin(folderCmp); j != end(folderCmp); ++j) SerializeHierarchy(sortedRef, j - folderCmp.begin()).execute(*j); } @@ -338,7 +333,7 @@ public: }; -template <bool ascending, zen::SelectedSide side> +template <bool ascending> class GridView::LessRelativeName : public std::binary_function<RefIndex, RefIndex, bool> { public: @@ -359,7 +354,7 @@ public: else if (fsObjB == NULL) return true; - return lessRelativeName<ascending, side>(*fsObjA, *fsObjB); + return lessRelativeName<ascending>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -526,10 +521,8 @@ void GridView::sortView(SortType type, bool onLeft, bool ascending) switch (type) { case SORT_BY_REL_NAME: - if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<true, LEFT_SIDE>(*this)); - else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<true, RIGHT_SIDE>(*this)); - else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<false, LEFT_SIDE >(*this)); - else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<false, RIGHT_SIDE>(*this)); + if ( ascending) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<true>(*this)); + else if (!ascending) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<false>(*this)); break; case SORT_BY_FILENAME: if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessShortFileName<true, LEFT_SIDE >(*this)); |