OSDN Git Service

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