Improve log speed.
[TortoiseGit.git] / src / TortoiseProc / GitLogListBase.h
blob94be5ba1132b20a86835a5c15387b497f679a719
1 #pragma once
3 #include "HintListCtrl.h"
4 #include "XPTheme.h"
5 #include "CommonResource.h"
6 #include "Git.h"
7 #include "ProjectProperties.h"
8 #include "TGitPath.h"
9 #include "registry.h"
10 #include "SplitterControl.h"
11 #include "Colors.h"
12 #include "MenuButton.h"
13 #include "LogDlgHelper.h"
14 #include "FilterEdit.h"
15 #include "GitRev.h"
16 #include "Tooltip.h"
17 #include "HintListCtrl.h"
18 //#include "GitLogList.h"
19 #include "lanes.h"
20 #include "GitLogCache.h"
21 #include <regex>
22 // CGitLogList
23 #if (NTDDI_VERSION < NTDDI_LONGHORN)
25 enum LISTITEMSTATES_MINE {
26 LISS_NORMAL = 1,
27 LISS_HOT = 2,
28 LISS_SELECTED = 3,
29 LISS_DISABLED = 4,
30 LISS_SELECTEDNOTFOCUS = 5,
31 LISS_HOTSELECTED = 6,
34 #define MCS_NOTRAILINGDATES 0x0040
35 #define MCS_SHORTDAYSOFWEEK 0x0080
36 #define MCS_NOSELCHANGEONNAV 0x0100
38 #define DTM_SETMCSTYLE (DTM_FIRST + 11)
40 #endif
42 #define ICONITEMBORDER 5
44 #define GITLOG_START 0
45 #define GITLOG_START_ALL 1
46 #define GITLOG_END 100
48 #define LOGFILTER_ALL 1
49 #define LOGFILTER_MESSAGES 2
50 #define LOGFILTER_PATHS 3
51 #define LOGFILTER_AUTHORS 4
52 #define LOGFILTER_REVS 5
53 #define LOGFILTER_REGEX 6
54 #define LOGFILTER_BUGID 7
56 //typedef void CALLBACK_PROCESS(void * data, int progress);
57 #define MSG_LOADED (WM_USER+110)
58 #define MSG_LOAD_PERCENTAGE (WM_USER+111)
59 #define MSG_REFLOG_CHANGED (WM_USER+112)
61 class CGitLogListBase : public CHintListCtrl
63 DECLARE_DYNAMIC(CGitLogListBase)
65 public:
66 CGitLogListBase();
67 virtual ~CGitLogListBase();
68 volatile LONG m_bNoDispUpdates;
69 BOOL m_IsIDReplaceAction;
70 BOOL m_IsOldFirst;
71 BOOL m_IsRebaseReplaceGraph;
74 BOOL m_bStrictStopped;
75 BOOL m_bShowBugtraqColumn;
76 BOOL m_bSearchIndex;
77 BOOL m_bCancelled;
78 unsigned __int64 m_ContextMenuMask;
80 bool m_hasWC;
81 GitRev m_wcRev;
82 volatile LONG m_bThreadRunning;
83 CLogCache m_LogCache;
85 enum
87 LOGLIST_GRAPH,
88 LOGLIST_ACTION,
89 LOGLIST_MESSAGE,
90 LOGLIST_AUTHOR,
91 LOGLIST_DATE,
92 LOGLIST_BUG,
93 LOGLIST_MESSAGE_MAX=300,
94 LOGLIST_MESSAGE_MIN=200
97 enum
99 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
100 ID_COMPARE = 1,
101 ID_SAVEAS,
102 ID_COMPARETWO,
103 ID_UPDATE,
104 ID_COPY,
105 ID_REVERTREV,
106 ID_MERGEREV,
107 ID_GNUDIFF1,
108 ID_GNUDIFF2,
109 ID_FINDENTRY,
110 ID_OPEN,
111 ID_BLAME,
112 ID_REPOBROWSE,
113 ID_LOG,
114 ID_POPPROPS,
115 ID_EDITAUTHOR,
116 ID_EDITLOG,
117 ID_DIFF,
118 ID_OPENWITH,
119 ID_COPYCLIPBOARD,
120 ID_COPYHASH,
121 ID_CHECKOUT,
122 ID_REVERTTOREV,
123 ID_BLAMECOMPARE,
124 ID_BLAMETWO,
125 ID_BLAMEDIFF,
126 ID_VIEWREV,
127 ID_VIEWPATHREV,
128 ID_EXPORT,
129 ID_COMPAREWITHPREVIOUS,
130 ID_BLAMEWITHPREVIOUS,
131 ID_GETMERGELOGS,
132 ID_REVPROPS,
133 ID_CHERRY_PICK,
134 ID_CREATE_BRANCH,
135 ID_CREATE_TAG,
136 ID_SWITCHTOREV,
137 ID_RESET,
138 ID_REBASE_PICK,
139 ID_REBASE_EDIT,
140 ID_REBASE_SQUASH,
141 ID_REBASE_SKIP,
142 ID_COMBINE_COMMIT,
143 ID_STASH_APPLY,
144 ID_REFLOG_DEL,
145 ID_REBASE_TO_VERSION,
147 inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<<i ;}
148 void InsertGitColumn();
149 void ResizeAllListCtrlCols();
150 void CopySelectionToClipBoard(bool hashonly=FALSE);
151 void DiffSelectedRevWithPrevious();
152 bool IsSelectionContinuous();
153 int FillGitShortLog();
154 int FillGitLog(CTGitPath *path,int infomask=CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE,CString *from=NULL,CString *to=NULL);
156 inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }
157 int FetchLogAsync(void * data=NULL);
158 CPtrArray m_arShownList;
159 void Refresh();
160 void RecalculateShownList(CPtrArray * pShownlist);
161 void Clear();
163 int m_nSelectedFilter;
164 CLogDataVector m_logEntries;
165 void RemoveFilter();
166 void StartFilter();
167 bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase = false );
168 CString m_sFilterText;
169 CTime m_From;
170 CTime m_To;
172 CTGitPath m_Path;
173 int m_ShowMask;
175 void GetTimeRange(CTime &oldest,CTime &latest);
176 virtual void ContextMenuAction(int cmd,int FirstSelect, int LastSelect)=0;
177 void ReloadHashMap()
179 m_HashMap.clear();
180 g_Git.GetMapHashToFriendName(m_HashMap);
181 m_CurrentBranch=g_Git.GetCurrentBranch();
182 this->m_HeadHash=g_Git.GetHash(CString(_T("HEAD"))).Left(40);
184 void TerminateThread()
186 if(this->m_LoadingThread)
187 AfxTermThread((HINSTANCE)m_LoadingThread->m_hThread);
190 bool IsInWorkingThread()
192 return (AfxGetThread() == m_LoadingThread);
195 volatile bool m_bExitThread;
196 CWinThread* m_LoadingThread;
197 protected:
198 DECLARE_MESSAGE_MAP()
199 afx_msg void OnDestroy();
200 virtual afx_msg void OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult);
201 virtual afx_msg void OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult);
202 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
203 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
204 afx_msg LRESULT OnLoad(WPARAM wParam, LPARAM lParam);
205 void OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult);
206 afx_msg void OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult);
207 void PreSubclassWindow();
208 virtual BOOL PreTranslateMessage(MSG* pMsg);
209 static UINT LogThreadEntry(LPVOID pVoid);
210 UINT LogThread();
211 void FetchLastLogInfo();
212 void FetchFullLogInfo(CString &from, CString &to);
213 void FillBackGround(HDC hdc, int Index,CRect &rect);
214 void DrawTagBranch(HDC,CRect &rect,INT_PTR index);
215 void DrawGraph(HDC,CRect &rect,INT_PTR index);
217 BOOL GetShortName(CString ref, CString &shortname,CString prefix);
218 void paintGraphLane(HDC hdc,int laneHeight, int type, int x1, int x2,
219 const COLORREF& col,int top) ;
220 void DrawLine(HDC hdc, int x1, int y1, int x2, int y2){::MoveToEx(hdc,x1,y1,NULL);::LineTo(hdc,x2,y2);}
222 * Save column widths to the registry
224 void SaveColumnWidths(); // save col widths to the registry
226 BOOL IsEntryInDateRange(int i);
228 int GetHeadIndex();
230 bool m_bFilterWithRegex;
233 CXPTheme m_Theme;
234 BOOL m_bVista;
236 HICON m_hModifiedIcon;
237 HICON m_hReplacedIcon;
238 HICON m_hAddedIcon;
239 HICON m_hDeletedIcon;
241 HFONT m_boldFont;
243 CRegDWORD m_regMaxBugIDColWidth;
244 int m_nSearchIndex;
246 void *m_ProcData;
247 CStoreSelection* m_pStoreSelection;
248 MAP_HASH_NAME m_HashMap;
250 CColors m_Colors;
252 CString m_CurrentBranch;
253 CString m_HeadHash;
255 CString m_ColumnRegKey;
257 COLORREF m_LineColors[Lanes::COLORS_NUM];
258 DWORD m_DateFormat; // DATE_SHORTDATE or DATE_LONGDATE
259 bool m_bRelativeTimes; // Show relative times