OSDN Git Service

Get Log From Git
[tortoisegit/TortoiseGitJp.git] / TortoiseProc / LogDlgHelper.h
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2007 - TortoiseGit\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 #include "Git.h"\r
21 #include "GitRev.h"\r
22 #include "GitStatus.h"\r
23 #include "ILogReceiver.h"\r
24 \r
25 class CLogDlg;\r
26 \r
27 /**\r
28  * \ingroup TortoiseProc\r
29  * Instances of CStoreSelection save the selection of the CLogDlg. When the instance\r
30  * is deleted the destructor restores the selection.\r
31  */\r
32 class CStoreSelection\r
33 {\r
34 public:\r
35         CStoreSelection(CLogDlg* dlg);\r
36         ~CStoreSelection();\r
37 protected:\r
38         CLogDlg* m_logdlg;\r
39         std::set<LONG> m_SetSelectedRevisions;\r
40 };\r
41 \r
42 /**\r
43  * \ingroup TortoiseProc\r
44  * Contains the data of one log entry, used in the log dialog\r
45  */\r
46 #if 0\r
47 typedef struct LogEntryData\r
48 {   \r
49         git_revnum_t Rev;\r
50         __time64_t tmDate;\r
51         CString sDate;\r
52         CString sAuthor;\r
53         CString sMessage;\r
54         CString sShortMessage;\r
55         CString sBugIDs;\r
56         DWORD dwFileChanges;\r
57         LogChangedPathArray* pArChangedPaths;\r
58         BOOL bCopies;\r
59         BOOL bCopiedSelf;\r
60         DWORD actions;\r
61         BOOL haschildren;\r
62         DWORD childStackDepth;\r
63 } LOGENTRYDATA, *PLOGENTRYDATA;\r
64 #endif\r
65 /**\r
66  * \ingroup TortoiseProc\r
67  * Helper class for the log dialog, handles all the log entries, including\r
68  * sorting.\r
69  */\r
70 class CLogDataVector :  public std::vector<GitRev>\r
71 {\r
72 public:\r
73         /// De-allocates log items.\r
74         void ClearAll();\r
75         int  ParserFromLog();\r
76 #if 0\r
77         /// Ascending date sorting.\r
78         struct AscDateSort\r
79         {\r
80                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
81                 {\r
82                         return pStart->tmDate < pEnd->tmDate;\r
83                 }\r
84         };\r
85         /// Descending date sorting.\r
86         struct DescDateSort\r
87         {\r
88                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
89                 {\r
90                         return pStart->tmDate > pEnd->tmDate;\r
91                 }\r
92         };\r
93         /// Ascending revision sorting.\r
94         struct AscRevSort\r
95         {\r
96                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
97                 {\r
98                         return pStart->Rev < pEnd->Rev;\r
99                 }\r
100         };\r
101         /// Descending revision sorting.\r
102         struct DescRevSort\r
103         {\r
104                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
105                 {\r
106                         return pStart->Rev > pEnd->Rev;\r
107                 }\r
108         };\r
109         /// Ascending author sorting.\r
110         struct AscAuthorSort\r
111         {\r
112                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
113                 {\r
114                         int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);\r
115                         if (ret == 0)\r
116                                 return pStart->Rev < pEnd->Rev;\r
117                         return ret<0;\r
118                 }\r
119         };\r
120         /// Descending author sorting.\r
121         struct DescAuthorSort\r
122         {\r
123                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
124                 {\r
125                         int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);\r
126                         if (ret == 0)\r
127                                 return pStart->Rev > pEnd->Rev;\r
128                         return ret>0;\r
129                 }\r
130         };\r
131         /// Ascending bugID sorting.\r
132         struct AscBugIDSort\r
133         {\r
134                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
135                 {\r
136                         int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);\r
137                         if (ret == 0)\r
138                                 return pStart->Rev < pEnd->Rev;\r
139                         return ret<0;\r
140                 }\r
141         };\r
142         /// Descending bugID sorting.\r
143         struct DescBugIDSort\r
144         {\r
145                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
146                 {\r
147                         int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);\r
148                         if (ret == 0)\r
149                                 return pStart->Rev > pEnd->Rev;\r
150                         return ret>0;\r
151                 }\r
152         };\r
153         /// Ascending message sorting.\r
154         struct AscMessageSort\r
155         {\r
156                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
157                 {\r
158                         return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)<0;\r
159                 }\r
160         };\r
161         /// Descending message sorting.\r
162         struct DescMessageSort\r
163         {\r
164                 bool operator()(GitRev& pStart, GitRev& pEnd)\r
165                 {\r
166                         return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)>0;\r
167                 }\r
168         };\r
169         /// Ascending action sorting\r
170         struct AscActionSort\r
171         {\r
172                 bool operator() (GitRev& pStart, GitRev& pEnd)\r
173                 {\r
174                         if (pStart->actions == pEnd->actions)\r
175                                 return pStart->Rev < pEnd->Rev;\r
176                         return pStart->actions < pEnd->actions;\r
177                 }\r
178         };\r
179         /// Descending action sorting\r
180         struct DescActionSort\r
181         {\r
182                 bool operator() (GitRev& pStart, GitRev& pEnd)\r
183                 {\r
184                         if (pStart->actions == pEnd->actions)\r
185                                 return pStart->Rev > pEnd->Rev;\r
186                         return pStart->actions > pEnd->actions;\r
187                 }\r
188         };\r
189 #endif\r
190 };\r