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