Merge QGit2.3 graphic tree
[TortoiseGit.git] / src / TortoiseProc / GitLogListBase.h
blob9de078558d905ee77542b91a5409026185d2d577
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;
73 void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
74 void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
76 BOOL m_bStrictStopped;
77 BOOL m_bShowBugtraqColumn;
78 BOOL m_bSearchIndex;
79 BOOL m_bCancelled;
80 unsigned __int64 m_ContextMenuMask;
82 bool m_hasWC;
83 GitRev m_wcRev;
84 volatile LONG m_bThreadRunning;
85 CLogCache m_LogCache;
87 enum
89 LOGLIST_GRAPH,
90 LOGLIST_ACTION,
91 LOGLIST_MESSAGE,
92 LOGLIST_AUTHOR,
93 LOGLIST_DATE,
94 LOGLIST_BUG,
95 LOGLIST_MESSAGE_MAX=300,
96 LOGLIST_MESSAGE_MIN=200
99 enum
101 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
102 ID_COMPARE = 1,
103 ID_SAVEAS,
104 ID_COMPARETWO,
105 ID_UPDATE,
106 ID_COPY,
107 ID_REVERTREV,
108 ID_MERGEREV,
109 ID_GNUDIFF1,
110 ID_GNUDIFF2,
111 ID_FINDENTRY,
112 ID_OPEN,
113 ID_BLAME,
114 ID_REPOBROWSE,
115 ID_LOG,
116 ID_POPPROPS,
117 ID_EDITAUTHOR,
118 ID_EDITLOG,
119 ID_DIFF,
120 ID_OPENWITH,
121 ID_COPYCLIPBOARD,
122 ID_COPYHASH,
123 ID_CHECKOUT,
124 ID_REVERTTOREV,
125 ID_BLAMECOMPARE,
126 ID_BLAMETWO,
127 ID_BLAMEDIFF,
128 ID_VIEWREV,
129 ID_VIEWPATHREV,
130 ID_EXPORT,
131 ID_COMPAREWITHPREVIOUS,
132 ID_BLAMEWITHPREVIOUS,
133 ID_GETMERGELOGS,
134 ID_REVPROPS,
135 ID_CHERRY_PICK,
136 ID_CREATE_BRANCH,
137 ID_CREATE_TAG,
138 ID_SWITCHTOREV,
139 ID_RESET,
140 ID_REBASE_PICK,
141 ID_REBASE_EDIT,
142 ID_REBASE_SQUASH,
143 ID_REBASE_SKIP,
144 ID_COMBINE_COMMIT,
145 ID_STASH_APPLY,
146 ID_REFLOG_DEL,
147 ID_REBASE_TO_VERSION,
148 ID_CREATE_PATCH,
149 ID_DELETE,
151 inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<<i ;}
152 void InsertGitColumn();
153 void ResizeAllListCtrlCols();
154 void CopySelectionToClipBoard(bool hashonly=FALSE);
155 void DiffSelectedRevWithPrevious();
156 bool IsSelectionContinuous();
157 int FillGitShortLog();
158 int FillGitLog(CTGitPath *path,int infomask=CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,CString *from=NULL,CString *to=NULL);
160 inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }
161 int FetchLogAsync(void * data=NULL);
162 CPtrArray m_arShownList;
163 void Refresh();
164 void RecalculateShownList(CPtrArray * pShownlist);
165 void Clear();
167 int m_nSelectedFilter;
168 CLogDataVector m_logEntries;
169 void RemoveFilter();
170 void StartFilter();
171 bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase = false );
172 CString m_sFilterText;
173 CTime m_From;
174 CTime m_To;
176 CTGitPath m_Path;
177 int m_ShowMask;
179 void GetTimeRange(CTime &oldest,CTime &latest);
180 virtual void ContextMenuAction(int cmd,int FirstSelect, int LastSelect)=0;
181 void ReloadHashMap()
183 m_HashMap.clear();
184 g_Git.GetMapHashToFriendName(m_HashMap);
185 m_CurrentBranch=g_Git.GetCurrentBranch();
186 this->m_HeadHash=g_Git.GetHash(CString(_T("HEAD"))).Left(40);
188 void TerminateThread()
190 if(this->m_LoadingThread)
191 AfxTermThread((HINSTANCE)m_LoadingThread->m_hThread);
194 bool IsInWorkingThread()
196 return (AfxGetThread() == m_LoadingThread);
199 void SetStartRef(const CString& StartRef)
201 m_StartRef=StartRef;
205 volatile bool m_bExitThread;
206 CWinThread* m_LoadingThread;
207 protected:
208 DECLARE_MESSAGE_MAP()
209 afx_msg void OnDestroy();
210 virtual afx_msg void OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult);
211 virtual afx_msg void OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult);
212 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
213 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
214 afx_msg LRESULT OnLoad(WPARAM wParam, LPARAM lParam);
215 void OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult);
216 afx_msg void OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult);
217 void PreSubclassWindow();
218 virtual BOOL PreTranslateMessage(MSG* pMsg);
219 static UINT LogThreadEntry(LPVOID pVoid);
220 UINT LogThread();
221 void FetchLastLogInfo();
222 void FetchFullLogInfo(CString &from, CString &to);
223 void FillBackGround(HDC hdc, int Index,CRect &rect);
224 void DrawTagBranch(HDC,CRect &rect,INT_PTR index);
225 void DrawGraph(HDC,CRect &rect,INT_PTR index);
227 BOOL GetShortName(CString ref, CString &shortname,CString prefix);
228 void paintGraphLane(HDC hdc,int laneHeight, int type, int x1, int x2,
229 const COLORREF& col,const COLORREF& activeColor, int top) ;
230 void DrawLine(HDC hdc, int x1, int y1, int x2, int y2){::MoveToEx(hdc,x1,y1,NULL);::LineTo(hdc,x2,y2);}
232 * Save column widths to the registry
234 void SaveColumnWidths(); // save col widths to the registry
236 BOOL IsEntryInDateRange(int i);
238 int GetHeadIndex();
240 bool m_bFilterWithRegex;
243 CXPTheme m_Theme;
244 BOOL m_bVista;
246 HICON m_hModifiedIcon;
247 HICON m_hReplacedIcon;
248 HICON m_hAddedIcon;
249 HICON m_hDeletedIcon;
251 HFONT m_boldFont;
253 CRegDWORD m_regMaxBugIDColWidth;
254 int m_nSearchIndex;
256 void *m_ProcData;
257 CStoreSelection* m_pStoreSelection;
258 MAP_HASH_NAME m_HashMap;
260 CColors m_Colors;
262 CString m_CurrentBranch;
263 CString m_HeadHash;
265 CString m_StartRef; //Ref of the top-commit
267 CString m_ColumnRegKey;
269 COLORREF m_LineColors[Lanes::COLORS_NUM];
270 DWORD m_DateFormat; // DATE_SHORTDATE or DATE_LONGDATE
271 bool m_bRelativeTimes; // Show relative times