OSDN Git Service

BrowseRefs: Added option to delete branch or tag.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / GraphNodeState.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 \r
21 ///////////////////////////////////////////////////////////////\r
22 // required includes\r
23 ///////////////////////////////////////////////////////////////\r
24 \r
25 #include "./Containers/DictionaryBasedTempPath.h"\r
26 \r
27 using namespace LogCache;\r
28 \r
29 ///////////////////////////////////////////////////////////////\r
30 // forward declarations\r
31 ///////////////////////////////////////////////////////////////\r
32 \r
33 class CFullGraph;\r
34 class CFullGraphNode;\r
35 class CVisibleGraphNode;\r
36 \r
37 /**\r
38  * This is a container that stores all nodes that have been\r
39  * collapsed or cut.\r
40  */\r
41 \r
42 class CGraphNodeStates\r
43 {\r
44 public:\r
45 \r
46     /** All possible node states. All freely combinable.\r
47      * Not all of them are in use.\r
48      */\r
49 \r
50     enum\r
51     {\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
56 \r
57         COLLAPSED_ALL   =  CGraphNodeStates::COLLAPSED_ABOVE\r
58                          | CGraphNodeStates::COLLAPSED_RIGHT\r
59                          | CGraphNodeStates::COLLAPSED_LEFT\r
60                          | CGraphNodeStates::COLLAPSED_BELOW,\r
61 \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
66 \r
67         SPLIT_ALL       =  CGraphNodeStates::SPLIT_ABOVE\r
68                          | CGraphNodeStates::SPLIT_RIGHT\r
69                          | CGraphNodeStates::SPLIT_LEFT\r
70                          | CGraphNodeStates::SPLIT_BELOW,\r
71     };\r
72 \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
75 \r
76     typedef std::pair<revision_t, CDictionaryBasedTempPath> TNodeDescriptor;\r
77     typedef std::map<TNodeDescriptor, DWORD> TSavedStates;\r
78 \r
79     typedef TSavedStates TSavedData;\r
80 \r
81 private:\r
82 \r
83     /// associates a state to the given graph node\r
84 \r
85     typedef std::map<const CFullGraphNode*, DWORD> TStates;\r
86     TStates states;\r
87 \r
88     /// utiltiy methods: restore state from saved data\r
89 \r
90     void RestoreStates ( const TSavedStates& saved\r
91                        , const CFullGraphNode* node);\r
92 \r
93     /// \ref ResetFlags() may call this multiple times if links are defined\r
94 \r
95     void InternalResetFlags (const CFullGraphNode* node, DWORD flags);\r
96 \r
97     /// traverse the unfiltered tree in the given direction\r
98     /// and look for a suitable node state.\r
99 \r
100     typedef std::pair<const CFullGraphNode*, DWORD> TFlaggedNode;\r
101     typedef std::vector<const CFullGraphNode*> TFlaggedNodes;\r
102 \r
103     TFlaggedNode FindPreviousRelevant ( const CVisibleGraphNode* node\r
104                                       , DWORD flags\r
105                                       , bool withinAsWell) const;\r
106 \r
107     TFlaggedNode FindNextRelevant ( const CVisibleGraphNode* node\r
108                                   , DWORD flags\r
109                                   , bool withinAsWell) const;\r
110 \r
111     TFlaggedNode FindRightRelevant (const CVisibleGraphNode* node) const;\r
112     TFlaggedNodes FindSplitSubtrees (const CVisibleGraphNode* node) const;\r
113 \r
114     /// store, update and qeuery state\r
115 \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
119 \r
120 public:\r
121 \r
122     /// construction / destruction\r
123 \r
124     CGraphNodeStates(void);\r
125     ~CGraphNodeStates(void);\r
126 \r
127     /// store, update and qeuery state\r
128 \r
129     void SetFlags (const CVisibleGraphNode* node, DWORD flags);\r
130     void ResetFlags (const CVisibleGraphNode* node, DWORD flags);\r
131 \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
135 \r
136     DWORD GetFlags (const CVisibleGraphNode* node, bool withinAsWell = false) const;\r
137 \r
138     /// quick update all\r
139 \r
140     void ResetFlags (DWORD flags);\r
141 \r
142     /// disjuctive combination of all flags currently set\r
143 \r
144     DWORD GetCombinedFlags() const;\r
145 \r
146     /// re-qeuery support\r
147 \r
148     TSavedData SaveData() const;\r
149     void LoadData (const TSavedData& saved, const CFullGraph* graph);\r
150 };\r