Change Log Code structure Unfinished
[TortoiseGit.git] / src / TortoiseProc / LogDlgHelper.h
blobce2db33f9b4aee02479932d82767b775ff343efe
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseGit
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
20 #include "Git.h"
21 #include "GitRev.h"
22 #include "GitStatus.h"
23 #include "ILogReceiver.h"
24 #include "lanes.h"
25 #include <set>
26 #include "GitHash.h"
27 #include "GitLogCache.h"
28 class CLogDlg;
30 /**
31 * \ingroup TortoiseProc
32 * Instances of CStoreSelection save the selection of the CLogDlg. When the instance
33 * is deleted the destructor restores the selection.
35 typedef std::map<CString, int> MAP_HASH_REV;
37 class CStoreSelection
39 public:
40 CStoreSelection(CLogDlg* dlg);
41 ~CStoreSelection();
42 protected:
43 CLogDlg* m_logdlg;
44 std::set<LONG> m_SetSelectedRevisions;
48 /**
49 * \ingroup TortoiseProc
50 * Helper class for the log dialog, handles all the log entries, including
51 * sorting.
53 class CLogDataVector : public std::vector<CGitHash>
55 public:
56 CLogCache *m_pLogCache;
57 /// De-allocates log items.
58 CLogDataVector(CLogCache *pLogCache)
60 m_pLogCache=pLogCache;
61 m_FirstFreeLane=0;
63 GitRev & GetGitRevAt(int i)
65 ASSERT(i<size());
66 return m_pLogCache->m_HashMap[(*this)[i]];
68 void ClearAll();
69 int ParserFromLog(CTGitPath *path =NULL,int count = -1,int infomask=CGit::LOG_INFO_STAT|CGit::LOG_INFO_FILESTATE|CGit::LOG_INFO_SHOW_MERGEDFILE,
70 CString *from=NULL,CString *to=NULL);
72 int FetchShortLog(CTGitPath *path , CString &hash,int count=-1 ,int mask=CGit::LOG_INFO_ONLY_HASH, int showWC=0 );
73 int ParserShortLog(CTGitPath *path ,CString &hash,int count=-1 ,int mask=CGit::LOG_INFO_ONLY_HASH );
75 int ParserFromRefLog(CString ref);
77 int FetchFullInfo(int i);
78 // void AddFullInfo(
80 Lanes m_Lns;
81 int m_FirstFreeLane;
82 MAP_HASH_REV m_HashMap;
83 void updateLanes(GitRev& c, Lanes& lns, CString &sha) ;
84 void setLane(CString& sha) ;
86 BYTE_VECTOR m_RawlogData;
87 std::vector<int> m_RawLogStart;
89 #if 0
90 /// Ascending date sorting.
91 struct AscDateSort
93 bool operator()(GitRev& pStart, GitRev& pEnd)
95 return pStart->tmDate < pEnd->tmDate;
98 /// Descending date sorting.
99 struct DescDateSort
101 bool operator()(GitRev& pStart, GitRev& pEnd)
103 return pStart->tmDate > pEnd->tmDate;
106 /// Ascending revision sorting.
107 struct AscRevSort
109 bool operator()(GitRev& pStart, GitRev& pEnd)
111 return pStart->Rev < pEnd->Rev;
114 /// Descending revision sorting.
115 struct DescRevSort
117 bool operator()(GitRev& pStart, GitRev& pEnd)
119 return pStart->Rev > pEnd->Rev;
122 /// Ascending author sorting.
123 struct AscAuthorSort
125 bool operator()(GitRev& pStart, GitRev& pEnd)
127 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
128 if (ret == 0)
129 return pStart->Rev < pEnd->Rev;
130 return ret<0;
133 /// Descending author sorting.
134 struct DescAuthorSort
136 bool operator()(GitRev& pStart, GitRev& pEnd)
138 int ret = pStart->sAuthor.CompareNoCase(pEnd->sAuthor);
139 if (ret == 0)
140 return pStart->Rev > pEnd->Rev;
141 return ret>0;
144 /// Ascending bugID sorting.
145 struct AscBugIDSort
147 bool operator()(GitRev& pStart, GitRev& pEnd)
149 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
150 if (ret == 0)
151 return pStart->Rev < pEnd->Rev;
152 return ret<0;
155 /// Descending bugID sorting.
156 struct DescBugIDSort
158 bool operator()(GitRev& pStart, GitRev& pEnd)
160 int ret = pStart->sBugIDs.CompareNoCase(pEnd->sBugIDs);
161 if (ret == 0)
162 return pStart->Rev > pEnd->Rev;
163 return ret>0;
166 /// Ascending message sorting.
167 struct AscMessageSort
169 bool operator()(GitRev& pStart, GitRev& pEnd)
171 return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)<0;
174 /// Descending message sorting.
175 struct DescMessageSort
177 bool operator()(GitRev& pStart, GitRev& pEnd)
179 return pStart->sShortMessage.CompareNoCase(pEnd->sShortMessage)>0;
182 /// Ascending action sorting
183 struct AscActionSort
185 bool operator() (GitRev& pStart, GitRev& pEnd)
187 if (pStart->actions == pEnd->actions)
188 return pStart->Rev < pEnd->Rev;
189 return pStart->actions < pEnd->actions;
192 /// Descending action sorting
193 struct DescActionSort
195 bool operator() (GitRev& pStart, GitRev& pEnd)
197 if (pStart->actions == pEnd->actions)
198 return pStart->Rev > pEnd->Rev;
199 return pStart->actions > pEnd->actions;
202 #endif