From 75c07011b7c4d06acd7b45dabdcd60ab9d80f385 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:29:28 +0200 Subject: 5.23 --- ui/tree_view.h | 186 --------------------------------------------------------- 1 file changed, 186 deletions(-) delete mode 100644 ui/tree_view.h (limited to 'ui/tree_view.h') diff --git a/ui/tree_view.h b/ui/tree_view.h deleted file mode 100644 index 719212dd..00000000 --- a/ui/tree_view.h +++ /dev/null @@ -1,186 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * -// ************************************************************************** - -#ifndef TREE_H_INCLUDED_841703190201835280256673425 -#define TREE_H_INCLUDED_841703190201835280256673425 - -#include -#include -#include -#include "column_attr.h" -#include "../file_hierarchy.h" - -namespace zen -{ -//tree view of FolderComparison -class TreeView -{ -public: - TreeView() : - sortColumn(defaultValueLastSortColumn), - sortAscending(defaultValueLastSortAscending) {} - - void setData(FolderComparison& newData); //set data, taking (partial) ownership - - //apply view filter: comparison results - void updateCmpResult(bool hideFiltered, - bool leftOnlyFilesActive, - bool rightOnlyFilesActive, - bool leftNewerFilesActive, - bool rightNewerFilesActive, - bool differentFilesActive, - bool equalFilesActive, - bool conflictFilesActive); - - //apply view filter: synchronization preview - void updateSyncPreview(bool hideFiltered, - bool syncCreateLeftActive, - bool syncCreateRightActive, - bool syncDeleteLeftActive, - bool syncDeleteRightActive, - bool syncDirOverwLeftActive, - bool syncDirOverwRightActive, - bool syncDirNoneActive, - bool syncEqualActive, - bool conflictFilesActive); - - enum NodeStatus - { - STATUS_EXPANDED, - STATUS_REDUCED, - STATUS_EMPTY - }; - - //--------------------------------------------------------------------- - struct Node - { - Node(int percent, UInt64 bytes, int itemCount, unsigned int level, NodeStatus status) : - percent_(percent), level_(level), status_(status), bytes_(bytes), itemCount_(itemCount) {} - virtual ~Node() {} - - const int percent_; //[0, 100] - const unsigned int level_; - const NodeStatus status_; - const UInt64 bytes_; - const int itemCount_; - }; - - struct FilesNode : public Node - { - FilesNode(int percent, UInt64 bytes, int itemCount, unsigned int 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, UInt64 bytes, int itemCount, unsigned int level, NodeStatus status, DirPair& dirObj) : Node(percent, bytes, itemCount, level, status), dirObj_(dirObj) {} - DirPair& dirObj_; - }; - - struct RootNode : public Node - { - RootNode(int percent, UInt64 bytes, int itemCount, NodeStatus status, BaseDirPair& baseDirObj) : Node(percent, bytes, itemCount, 0, status), baseDirObj_(baseDirObj) {} - BaseDirPair& baseDirObj_; - }; - - std::unique_ptr getLine(size_t row) const; //return nullptr on error - size_t linesTotal() const { return flatTree.size(); } - - void expandNode(size_t row); - void reduceNode(size_t row); - NodeStatus getStatus(size_t row) const; - ptrdiff_t getParent(size_t row) const; //return < 0 if none - - void setSortDirection(ColumnTypeNavi colType, bool ascending); //apply permanently! - std::pair getSortDirection() { return std::make_pair(sortColumn, sortAscending); } - static bool getDefaultSortDirection(ColumnTypeNavi colType); //ascending? - -private: - struct DirNodeImpl; - - struct Container - { - Container() : itemCountGross(), itemCountNet(), firstFileId(nullptr) {} - UInt64 bytesGross; - 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 firstFileId; //weak pointer to first FilePair or SymlinkPair - //- "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 - { - DirNodeImpl() : objId(nullptr) {} - FileSystemObject::ObjectId objId; //weak pointer to DirPair - }; - - struct RootNodeImpl : public Container - { - RootNodeImpl() {} - std::shared_ptr baseDirObj; - }; - - enum NodeType - { - TYPE_ROOT, //-> RootNodeImpl - TYPE_DIRECTORY, //-> DirNodeImpl - TYPE_FILES //-> Container - }; - - struct TreeLine - { - TreeLine(unsigned int level, int percent, const Container* node, enum NodeType type) : level_(level), percent_(percent), node_(node), type_(type) {} - - unsigned int 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! - }; - - static void compressNode(Container& cont); - template - static void extractVisibleSubtree(HierarchyObject& hierObj, Container& cont, Function includeObject); - void getChildren(const Container& cont, unsigned int level, std::vector& output); - template void updateView(Predicate pred); - void applySubView(std::vector&& newView); - - template static void sortSingleLevel(std::vector& items, ColumnTypeNavi columnType); - template struct LessShortName; - - std::vector flatTree; //collapsable/expandable sub-tree of folderCmpView -> always sorted! - /* /|\ - | (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...) - | */ - std::vector> folderCmp; //full raw data - - ColumnTypeNavi sortColumn; - bool sortAscending; -}; - - -namespace treeview -{ -void init(Grid& grid, const std::shared_ptr& treeDataView); - -void setShowPercentage(Grid& grid, bool value); -bool getShowPercentage(const Grid& grid); - -std::vector convertConfig(const std::vector& attribs); //+ make consistent -std::vector convertConfig(const std::vector& attribs); // -} -} - -#endif //TREE_H_INCLUDED_841703190201835280256673425 -- cgit