Modify position of filter and date at log dialog
[TortoiseGit.git] / src / TortoiseProc / RevisionGraph / GraphNodeState.h
blob92789ce82a8940ecbe5d19ec11c4cebe3d0e7c3d
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 ///////////////////////////////////////////////////////////////
22 // required includes
23 ///////////////////////////////////////////////////////////////
25 #include "./Containers/DictionaryBasedTempPath.h"
27 using namespace LogCache;
29 ///////////////////////////////////////////////////////////////
30 // forward declarations
31 ///////////////////////////////////////////////////////////////
33 class CFullGraph;
34 class CFullGraphNode;
35 class CVisibleGraphNode;
37 /**
38 * This is a container that stores all nodes that have been
39 * collapsed or cut.
42 class CGraphNodeStates
44 public:
46 /** All possible node states. All freely combinable.
47 * Not all of them are in use.
50 enum
52 COLLAPSED_ABOVE = 0x01, ///< hide previous or copy source node, respectively
53 COLLAPSED_BELOW = 0x02, ///< hide next node (and following) in the same line
54 COLLAPSED_LEFT = 0x04, ///< not used, yet
55 COLLAPSED_RIGHT = 0x08, ///< hide sub-trees that expand to the right side
57 COLLAPSED_ALL = CGraphNodeStates::COLLAPSED_ABOVE
58 | CGraphNodeStates::COLLAPSED_RIGHT
59 | CGraphNodeStates::COLLAPSED_LEFT
60 | CGraphNodeStates::COLLAPSED_BELOW,
62 SPLIT_ABOVE = 0x10, ///< make this a new graph root node
63 SPLIT_BELOW = 0x20, ///< make the next node a new graph root node
64 SPLIT_LEFT = 0x40, ///< not used, yet
65 SPLIT_RIGHT = 0x80, ///< show all sub-trees as separate graphs
67 SPLIT_ALL = CGraphNodeStates::SPLIT_ABOVE
68 | CGraphNodeStates::SPLIT_RIGHT
69 | CGraphNodeStates::SPLIT_LEFT
70 | CGraphNodeStates::SPLIT_BELOW,
73 /// used tempoarily to hold the status while the query is re-run
74 /// (i.e. when the node pointers will become invalid)
76 typedef std::pair<revision_t, CDictionaryBasedTempPath> TNodeDescriptor;
77 typedef std::map<TNodeDescriptor, DWORD> TSavedStates;
79 typedef TSavedStates TSavedData;
81 private:
83 /// associates a state to the given graph node
85 typedef std::map<const CFullGraphNode*, DWORD> TStates;
86 TStates states;
88 /// utiltiy methods: restore state from saved data
90 void RestoreStates ( const TSavedStates& saved
91 , const CFullGraphNode* node);
93 /// \ref ResetFlags() may call this multiple times if links are defined
95 void InternalResetFlags (const CFullGraphNode* node, DWORD flags);
97 /// traverse the unfiltered tree in the given direction
98 /// and look for a suitable node state.
100 typedef std::pair<const CFullGraphNode*, DWORD> TFlaggedNode;
101 typedef std::vector<const CFullGraphNode*> TFlaggedNodes;
103 TFlaggedNode FindPreviousRelevant ( const CVisibleGraphNode* node
104 , DWORD flags
105 , bool withinAsWell) const;
107 TFlaggedNode FindNextRelevant ( const CVisibleGraphNode* node
108 , DWORD flags
109 , bool withinAsWell) const;
111 TFlaggedNode FindRightRelevant (const CVisibleGraphNode* node) const;
112 TFlaggedNodes FindSplitSubtrees (const CVisibleGraphNode* node) const;
114 /// store, update and qeuery state
116 void SetFlags (const CFullGraphNode* node, DWORD flags);
117 void ResetFlags (const CFullGraphNode* node, DWORD flags);
118 DWORD GetFlags (const CFullGraphNode* node) const;
120 public:
122 /// construction / destruction
124 CGraphNodeStates(void);
125 ~CGraphNodeStates(void);
127 /// store, update and qeuery state
129 void SetFlags (const CVisibleGraphNode* node, DWORD flags);
130 void ResetFlags (const CVisibleGraphNode* node, DWORD flags);
132 /// crawl the tree, find the next relavant entries and combine
133 /// the status info. Include (or don't) flags between visible
134 /// nodes of the same branch.
136 DWORD GetFlags (const CVisibleGraphNode* node, bool withinAsWell = false) const;
138 /// quick update all
140 void ResetFlags (DWORD flags);
142 /// disjuctive combination of all flags currently set
144 DWORD GetCombinedFlags() const;
146 /// re-qeuery support
148 TSavedData SaveData() const;
149 void LoadData (const TSavedData& saved, const CFullGraph* graph);