better check when to enable statistics button
[TortoiseGit.git] / src / TortoiseProc / LogDlg.h
blob053f695521595c860327b8c54613b11fed8ef5e9
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2011 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include "resource.h"
23 #include "Git.h"
24 #include "ProjectProperties.h"
25 #include "StandAloneDlg.h"
26 #include "TGitPath.h"
27 #include "registry.h"
28 #include "SplitterControl.h"
29 #include "Colors.h"
30 #include "MenuButton.h"
31 #include "LogDlgHelper.h"
32 #include "FilterEdit.h"
33 #include "GitRev.h"
34 #include "Tooltip.h"
35 #include "HintListCtrl.h"
36 #include <regex>
37 #include "GitLogList.h"
38 #include "GitStatusListCtrl.h"
39 #include "HyperLink.h"
40 #include "Win7.h"
42 using namespace std;
45 #define MERGE_REVSELECTSTART 1
46 #define MERGE_REVSELECTEND 2
47 #define MERGE_REVSELECTSTARTEND 3 ///< both
48 #define MERGE_REVSELECTMINUSONE 4 ///< first with N-1
51 #define LOGFILTER_TIMER 101
52 #define LOGFTIME_TIMER 102
54 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
56 /**
57 * \ingroup TortoiseProc
58 * Shows log messages of a single file or folder in a listbox.
60 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator
62 DECLARE_DYNAMIC(CLogDlg)
64 friend class CStoreSelection;
66 public:
67 CLogDlg(CWnd* pParent = NULL); // standard constructor
68 virtual ~CLogDlg();
69 #if 0
70 enum
72 LOGLIST_GRAPH,
73 LOGLIST_ACTION,
74 LOGLIST_MESSAGE,
75 LOGLIST_AUTHOR,
76 LOGLIST_DATE,
77 LOGLIST_BUG,
78 LOGLIST_MESSAGE_MAX=250
80 #endif
81 enum
83 FILELIST_ACTION,
84 FILELIST_ADD,
85 FILELIST_DEL,
86 FILELIST_PATH
89 void SetParams(const CTGitPath& orgPath, const CTGitPath& path, CString hightlightRevision, CString startrev, CString endrev, int limit);
90 void SetIncludeMerge(bool bInclude = true) {m_bIncludeMerges = bInclude;}
91 bool IsThreadRunning() {return !!m_LogList.m_bThreadRunning;}
92 void SetDialogTitle(const CString& sTitle) {m_sTitle = sTitle;}
93 void SetSelect(bool bSelect) {m_bSelect = bSelect;}
94 void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}
95 void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}
96 void SetMergePath(const CTGitPath& mergepath) {m_mergePath = mergepath;}
97 void SetStartRef(const CString& StartRef);
98 void ShowStartRef();
99 afx_msg LRESULT OnRefLogChanged(WPARAM wParam, LPARAM lParam);
101 * Provides selected commit hash if available, call after OK return from here
102 * Empty if none
104 CString GetSelectedHash(){ return m_sSelectedHash; }
106 // const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}
108 // Dialog Data
109 enum { IDD = IDD_LOGMESSAGE };
111 void FillLogMessageCtrl(bool bShow = true);
112 CString GetTagInfo(GitRev* pLogEntry);
114 void UpdateLogInfoLabel();
116 afx_msg void OnFind()
118 m_LogList.OnFind();
120 protected:
121 //implement the virtual methods from Git base class
122 virtual BOOL Log(git_revnum_t rev, const CString& author, const CString& date, const CString& message, LogChangedPathArray * cpaths, int filechanges, BOOL copies, DWORD actions, BOOL haschildren);
123 virtual BOOL Cancel();
124 virtual bool Validate(LPCTSTR string);
126 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
128 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
129 CComPtr<ITaskbarList3> m_pTaskbarList;
131 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
132 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
133 afx_msg LRESULT OnLogListLoading(WPARAM wParam, LPARAM lParam);
135 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
136 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
137 afx_msg void OnBnClickedGetall();
138 afx_msg void OnNMDblclkChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
139 afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);
140 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
141 afx_msg void OnBnClickedHelp();
142 afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);
143 afx_msg void OnBnClickedStatbutton();
145 afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
146 afx_msg void OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
147 afx_msg void OnEnChangeSearchedit();
148 afx_msg void OnTimer(UINT_PTR nIDEvent);
149 afx_msg void OnDtnDatetimechangeDateto(NMHDR *pNMHDR, LRESULT *pResult);
150 afx_msg void OnDtnDatetimechangeDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
151 afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
152 afx_msg void OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
153 afx_msg void OnBnClickShowWholeProject();
154 afx_msg void OnBnClickedHidepaths();
155 afx_msg void OnBnClickedAllBranch();
156 afx_msg void OnBnClickedBrowseRef();
157 afx_msg void OnBnClickedCheckStoponcopy();
159 afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
160 afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);
161 afx_msg void OnSize(UINT nType, int cx, int cy);
162 afx_msg void OnBnClickedFirstParent();
163 afx_msg void OnBnClickedRefresh();
164 afx_msg void OnRefresh();
165 afx_msg void OnFocusFilter();
166 afx_msg void OnEditCopy();
168 virtual void OnCancel();
169 virtual void OnOK();
170 virtual BOOL OnInitDialog();
171 virtual BOOL PreTranslateMessage(MSG* pMsg);
173 void DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);
175 static void LogCallBack(void *data, int cur){((CLogDlg*)data)->LogRunStatus(cur);}
176 void LogRunStatus(int cur);
178 DECLARE_MESSAGE_MAP()
180 private:
181 CRegDWORD m_regbAllBranch;
183 void Refresh (bool clearfilter = false);
184 BOOL IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev);
185 BOOL Open(bool bOpenWith, CString changedpath, git_revnum_t rev);
186 void EditAuthor(const CLogDataVector& logs);
187 void EditLogMessage(int index);
188 void DoSizeV1(int delta);
189 void DoSizeV2(int delta);
190 void AdjustMinSize();
191 void SetSplitterRange();
192 void SetFilterCueText();
194 void CopySelectionToClipBoard();
195 void CopyChangedSelectionToClipBoard();
196 CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);
197 void SortShownListArray();
199 void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);
200 void SortByColumn(int nSortColumn, bool bAscending);
202 void EnableOKButton();
203 void GetAll(bool bIsShowProjectOrBranch = false);
205 void SaveSplitterPos();
206 bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase);
207 void CheckRegexpTooltip();
208 void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);
209 void DiffSelectedFile();
210 void DiffSelectedRevWithPrevious();
211 void SetDlgTitle();
212 CString GetAbsoluteUrlFromRelativeUrl(const CString& url);
215 * Extracts part of commit message suitable for displaying in revision list.
217 CString MakeShortMessage(const CString& message);
218 // inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }
221 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
222 static int __cdecl SortCompare(const void * pElem1, const void * pElem2); ///< sort callback function
224 void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point);
225 void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point);
226 public:
227 CWnd * m_pNotifyWindow;
228 WORD m_wParam;
229 private:
230 //HFONT m_boldFont;
231 CString m_sRelativeRoot;
232 CString m_sRepositoryRoot;
233 CString m_sSelfRelativeURL;
234 CString m_sURL;
235 CString m_sUUID; ///< empty if the log cache is not used
236 CGitLogList m_LogList;
237 CGitStatusListCtrl m_ChangedFileListCtrl;
238 CFilterEdit m_cFilter;
239 CHyperLink m_staticRef;
240 CProgressCtrl m_LogProgress;
241 CMenuButton m_btnShow;
242 CMenuButton m_btnShowWholeProject;
243 CTGitPath m_path;
244 CTGitPath m_orgPath;
245 CTGitPath m_mergePath;
246 CString m_hightlightRevision;
248 CString m_LogRevision;
250 // GitRev m_wcRev;
251 // GitRevRangeArray m_selectedRevs;
252 // GitRevRangeArray m_selectedRevsOneRange;
253 CString m_sSelectedHash; // set to selected commit hash on OK if appropriate
254 bool m_bSelectionMustBeContinuous;
255 bool m_bSelectionMustBeSingle;
256 long m_logcounter;
257 bool m_bCancelled;
259 BOOL m_bIncludeMerges;
260 BOOL m_bFirstParent;
261 BOOL m_bAllBranch;
262 BOOL m_bWholeProject;
264 git_revnum_t m_lowestRev;
265 CTGitPathList * m_currentChangedArray;
266 LogChangedPathArray m_CurrentFilteredChangedArray;
267 CTGitPathList m_currentChangedPathList;
268 //CPtrArray m_arShownList;
269 bool m_hasWC;
271 bool m_bFilterWithRegex;
274 CFont m_logFont;
275 CString m_sMessageBuf;
276 CSplitterControl m_wndSplitter1;
277 CSplitterControl m_wndSplitter2;
278 CRect m_DlgOrigRect;
279 CRect m_MsgViewOrigRect;
280 CRect m_LogListOrigRect;
281 CRect m_ChgOrigRect;
282 // CString m_sFilterText;
284 //volatile LONG m_bNoDispUpdates;
285 CDateTimeCtrl m_DateFrom;
286 CDateTimeCtrl m_DateTo;
287 int m_limit;
288 int m_limitcounter;
289 int m_nSortColumn;
290 bool m_bAscending;
291 static int m_nSortColumnPathList;
292 static bool m_bAscendingPathList;
293 CButton m_cHidePaths;
294 bool m_bShowedAll;
295 CString m_sTitle;
296 bool m_bSelect;
297 //bool m_bShowBugtraqColumn;
298 CString m_sLogInfo;
299 std::set<git_revnum_t> m_mergedRevs;
301 CToolTips m_tooltips;
303 CColors m_Colors;
304 CImageList m_imgList;
305 #if 0
306 HICON m_hModifiedIcon;
307 HICON m_hReplacedIcon;
308 HICON m_hAddedIcon;
309 HICON m_hDeletedIcon;
310 #endif
312 DWORD m_childCounter;
313 DWORD m_maxChild;
314 HACCEL m_hAccel;
316 bool m_bVista;
318 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
319 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
320 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));