diff options
Diffstat (limited to 'ui/grid_view.cpp')
-rw-r--r-- | ui/grid_view.cpp | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/ui/grid_view.cpp b/ui/grid_view.cpp index fa1e9915..e1e16e47 100644 --- a/ui/grid_view.cpp +++ b/ui/grid_view.cpp @@ -297,34 +297,26 @@ void GridView::removeInvalidRows() class GridView::SerializeHierarchy { public: + static void execute(HierarchyObject& hierObj, std::vector<GridView::RefIndex>& sortedRef, size_t index) { SerializeHierarchy(sortedRef, index).recurse(hierObj); } + +private: SerializeHierarchy(std::vector<GridView::RefIndex>& sortedRef, size_t index) : index_(index), sortedRef_(sortedRef) {} - void execute(HierarchyObject& hierObj) - { - std::for_each(hierObj.refSubFiles().begin(), hierObj.refSubFiles().end(), *this); - std::for_each(hierObj.refSubLinks().begin(), hierObj.refSubLinks().end(), *this); - std::for_each(hierObj.refSubDirs ().begin(), hierObj.refSubDirs ().end(), *this); - } - - void operator()(FilePair& fileObj) - { - sortedRef_.push_back(RefIndex(index_, fileObj.getId())); - } - - void operator()(SymlinkPair& linkObj) - { - sortedRef_.push_back(RefIndex(index_, linkObj.getId())); - } - - void operator()(DirPair& dirObj) + void recurse(HierarchyObject& hierObj) { - sortedRef_.push_back(RefIndex(index_, dirObj.getId())); - execute(dirObj); //add recursion here to list sub-objects directly below parent! + for (FilePair& fileObj : hierObj.refSubFiles()) + sortedRef_.push_back(RefIndex(index_, fileObj.getId())); + for (SymlinkPair& linkObj : hierObj.refSubLinks()) + sortedRef_.push_back(RefIndex(index_, linkObj.getId())); + for (DirPair& dirObj : hierObj.refSubDirs()) + { + sortedRef_.push_back(RefIndex(index_, dirObj.getId())); + recurse(dirObj); //add recursion here to list sub-objects directly below parent! + } } -private: size_t index_; std::vector<GridView::RefIndex>& sortedRef_; }; @@ -345,7 +337,7 @@ void GridView::setData(FolderComparison& folderCmp) }); for (auto it = begin(folderCmp); it != end(folderCmp); ++it) - SerializeHierarchy(sortedRef, it - begin(folderCmp)).execute(*it); + SerializeHierarchy::execute(*it, sortedRef, it - begin(folderCmp)); } |