From 110fc5dee14fc7988f631a158e50d283446aba7a Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:24:09 +0200 Subject: 5.15 --- ui/tree_view.h | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'ui/tree_view.h') diff --git a/ui/tree_view.h b/ui/tree_view.h index af269d53..9ea7d0e4 100644 --- a/ui/tree_view.h +++ b/ui/tree_view.h @@ -7,10 +7,11 @@ #ifndef TREE_H_INCLUDED_841703190201835280256673425 #define TREE_H_INCLUDED_841703190201835280256673425 +#include +#include #include -#include "../file_hierarchy.h" #include "column_attr.h" -#include +#include "../file_hierarchy.h" namespace zen { @@ -56,31 +57,32 @@ public: //--------------------------------------------------------------------- struct Node { - Node(int percent, size_t level, NodeStatus status, UInt64 bytes) : - percent_(percent), level_(level), status_(status), bytes_(bytes) {} + Node(int percent, UInt64 bytes, int itemCount, size_t level, NodeStatus status) : + percent_(percent), level_(level), status_(status), bytes_(bytes), itemCount_(itemCount) {} virtual ~Node() {} const int percent_; //[0, 100] const size_t level_; const NodeStatus status_; const UInt64 bytes_; + const int itemCount_; }; struct FilesNode : public Node { - FilesNode(int percent, size_t level, UInt64 bytes, FileSystemObject& firstFile) : Node(percent, level, STATUS_EMPTY, bytes), firstFile_(firstFile) {} - FileSystemObject& firstFile_; //or symlink + FilesNode(int percent, UInt64 bytes, int itemCount, size_t level, const std::vector& filesAndLinks) : Node(percent, bytes, itemCount, level, STATUS_EMPTY), filesAndLinks_(filesAndLinks) {} + std::vector filesAndLinks_; //files or symlinks; pointers are bound! }; struct DirNode : public Node { - DirNode(int percent, size_t level, NodeStatus status, UInt64 bytes, DirMapping& dirObj) : Node(percent, level, status, bytes), dirObj_(dirObj) {} + DirNode(int percent, UInt64 bytes, int itemCount, size_t level, NodeStatus status, DirMapping& dirObj) : Node(percent, bytes, itemCount, level, status), dirObj_(dirObj) {} DirMapping& dirObj_; }; struct RootNode : public Node { - RootNode(int percent, NodeStatus status, UInt64 bytes, BaseDirMapping& baseMap) : Node(percent, 0, status, bytes), baseMap_(baseMap) {} + RootNode(int percent, UInt64 bytes, int itemCount, NodeStatus status, BaseDirMapping& baseMap) : Node(percent, bytes, itemCount, 0, status), baseMap_(baseMap) {} BaseDirMapping& baseMap_; }; @@ -101,11 +103,17 @@ private: struct Container { - Container() : firstFile(nullptr) {} + Container() : itemCountGross(), itemCountNet(), firstFileId(nullptr) {} UInt64 bytesGross; - UInt64 bytesNet; //files in this directory only + UInt64 bytesNet; //bytes for files on view in this directory only + int itemCountGross; + int itemCountNet; //number of files on view for in this directory only + std::vector subDirs; - FileSystemObject::ObjectId firstFile; //weak pointer to first FileMapping or SymLinkMapping + FileSystemObject::ObjectId firstFileId; //weak pointer to first FileMapping or SymLinkMapping + //- "compress" algorithm may hide file nodes for directories with a single included file, i.e. itemCountGross == itemCountNet == 1 + //- a HierarchyObject* would a better fit, but we need weak pointer semantics! + //- a std::vector would be a better design, but we don't want a second memory structure as large as custom grid! }; struct DirNodeImpl : public Container @@ -134,13 +142,13 @@ private: size_t level_; int percent_; //[0, 100] const Container* node_; // - NodeType type_; //we choose to increase size of "flatTree" rather than "folderCmpView" by not using dynamic polymorphism! + NodeType type_; //we choose to increase size of "flatTree" rather than "folderCmpView" by not using dynamic polymorphism! }; static void compressNode(Container& cont); template static void extractVisibleSubtree(HierarchyObject& hierObj, Container& cont, Function includeObject); - void getChildren(const Container& cont, size_t level, std::vector& output); + void getChildren(const Container& cont, size_t level, std::vector& output); template void updateView(Predicate pred); void applySubView(std::vector&& newView); @@ -152,6 +160,7 @@ private: | (update...) | */ std::vector folderCmpView; //partial view on folderCmp -> unsorted (cannot be, because files are not a separate entity) + std::function lastViewFilterPred; //buffer view filter predicate for lazy evaluation of files/symlinks corresponding to a TYPE_FILES node /* /|\ | (update...) | */ -- cgit