Pick Ref: Change [...] button in log dialog in a clickable ref name
[TortoiseGit.git] / src / TortoiseProc / LogDlg.h
blob742d2548aefa6dd798f3bdfe149d7e3c0ae0b6b7
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - 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
21 #include "resource.h"
22 #include "Git.h"
23 #include "ProjectProperties.h"
24 #include "StandAloneDlg.h"
25 #include "TGitPath.h"
26 #include "registry.h"
27 #include "SplitterControl.h"
28 #include "Colors.h"
29 #include "MenuButton.h"
30 #include "LogDlgHelper.h"
31 #include "FilterEdit.h"
32 #include "GitRev.h"
33 #include "Tooltip.h"
34 #include "HintListCtrl.h"
35 #include <regex>
36 #include "GitLogList.h"
37 #include "GitStatusListCtrl.h"
38 #include "HyperLink.h"
40 using namespace std;
43 #define MERGE_REVSELECTSTART 1
44 #define MERGE_REVSELECTEND 2
45 #define MERGE_REVSELECTSTARTEND 3 ///< both
46 #define MERGE_REVSELECTMINUSONE 4 ///< first with N-1
49 #define LOGFILTER_TIMER 101
51 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
53 /**
54 * \ingroup TortoiseProc
55 * Shows log messages of a single file or folder in a listbox.
57 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator
59 DECLARE_DYNAMIC(CLogDlg)
61 friend class CStoreSelection;
63 public:
64 CLogDlg(CWnd* pParent = NULL); // standard constructor
65 virtual ~CLogDlg();
66 #if 0
67 enum
69 LOGLIST_GRAPH,
70 LOGLIST_ACTION,
71 LOGLIST_MESSAGE,
72 LOGLIST_AUTHOR,
73 LOGLIST_DATE,
74 LOGLIST_BUG,
75 LOGLIST_MESSAGE_MAX=250
77 #endif
78 enum
80 FILELIST_ACTION,
81 FILELIST_ADD,
82 FILELIST_DEL,
83 FILELIST_PATH
86 void SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit);
87 void SetIncludeMerge(bool bInclude = true) {m_bIncludeMerges = bInclude;}
88 void SetProjectPropertiesPath(const CTGitPath& path) {m_ProjectProperties.ReadProps(path);}
89 bool IsThreadRunning() {return !!m_LogList.m_bThreadRunning;}
90 void SetDialogTitle(const CString& sTitle) {m_sTitle = sTitle;}
91 void SetSelect(bool bSelect) {m_bSelect = bSelect;}
92 void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}
93 void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}
94 void SetMergePath(const CTGitPath& mergepath) {m_mergePath = mergepath;}
95 void SetStartRef(const CString& StartRef);
96 void ShowStartRef();
97 /**
98 * Provides selected commit hash if available, call after OK return from here
99 * Empty if none
101 CString GetSelectedHash(){ return m_sSelectedHash; }
103 // const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}
105 // Dialog Data
106 enum { IDD = IDD_LOGMESSAGE };
108 protected:
109 //implement the virtual methods from Git base class
110 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);
111 virtual BOOL Cancel();
112 virtual bool Validate(LPCTSTR string);
114 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
116 afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
117 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
118 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
119 afx_msg LRESULT OnLogListLoading(WPARAM wParam, LPARAM lParam);
121 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
122 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
123 afx_msg void OnBnClickedGetall();
124 afx_msg void OnNMDblclkChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
125 afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);
126 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
127 afx_msg void OnBnClickedHelp();
128 afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);
129 afx_msg void OnBnClickedStatbutton();
131 afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
132 afx_msg void OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
133 afx_msg void OnEnChangeSearchedit();
134 afx_msg void OnTimer(UINT_PTR nIDEvent);
135 afx_msg void OnDtnDatetimechangeDateto(NMHDR *pNMHDR, LRESULT *pResult);
136 afx_msg void OnDtnDatetimechangeDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
137 afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
138 afx_msg void OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
139 afx_msg void OnBnClickShowWholeProject();
140 afx_msg void OnBnClickedHidepaths();
141 afx_msg void OnBnClickedAllBranch();
142 afx_msg void OnBnClickedBrowseRef();
143 afx_msg void OnBnClickedCheckStoponcopy();
145 afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
146 afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);
147 afx_msg void OnSize(UINT nType, int cx, int cy);
148 afx_msg void OnBnClickedFirstParent();
149 afx_msg void OnBnClickedRefresh();
150 afx_msg void OnRefresh();
151 afx_msg void OnFind();
152 afx_msg void OnFocusFilter();
153 afx_msg void OnEditCopy();
155 virtual void OnCancel();
156 virtual void OnOK();
157 virtual BOOL OnInitDialog();
158 virtual BOOL PreTranslateMessage(MSG* pMsg);
160 void FillLogMessageCtrl(bool bShow = true);
161 void DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);
163 static void LogCallBack(void *data, int cur){((CLogDlg*)data)->LogRunStatus(cur);}
164 void LogRunStatus(int cur);
166 DECLARE_MESSAGE_MAP()
168 private:
171 void Refresh (bool autoGoOnline = false);
172 BOOL IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev);
173 BOOL Open(bool bOpenWith, CString changedpath, git_revnum_t rev);
174 void EditAuthor(const CLogDataVector& logs);
175 void EditLogMessage(int index);
176 void DoSizeV1(int delta);
177 void DoSizeV2(int delta);
178 void AdjustMinSize();
179 void SetSplitterRange();
180 void SetFilterCueText();
182 void CopySelectionToClipBoard();
183 void CopyChangedSelectionToClipBoard();
184 CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);
185 void SortShownListArray();
187 void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);
188 void SortByColumn(int nSortColumn, bool bAscending);
190 void EnableOKButton();
191 void GetAll(bool bIsShowProjectOrBranch = false);
192 void UpdateLogInfoLabel();
193 void SaveSplitterPos();
194 bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase);
195 void CheckRegexpTooltip();
196 void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);
197 void DiffSelectedFile();
198 void DiffSelectedRevWithPrevious();
199 void SetDlgTitle(bool bOffline);
200 CString GetAbsoluteUrlFromRelativeUrl(const CString& url);
203 * Extracts part of commit message suitable for displaying in revision list.
205 CString MakeShortMessage(const CString& message);
206 // inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }
209 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
210 static int __cdecl SortCompare(const void * pElem1, const void * pElem2); ///< sort callback function
212 void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point);
213 void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point);
214 public:
215 CWnd * m_pNotifyWindow;
216 ProjectProperties m_ProjectProperties;
217 WORD m_wParam;
218 private:
219 //HFONT m_boldFont;
220 CString m_sRelativeRoot;
221 CString m_sRepositoryRoot;
222 CString m_sSelfRelativeURL;
223 CString m_sURL;
224 CString m_sUUID; ///< empty if the log cache is not used
225 CGitLogList m_LogList;
226 CGitStatusListCtrl m_ChangedFileListCtrl;
227 CFilterEdit m_cFilter;
228 CHyperLink m_staticRef;
229 CProgressCtrl m_LogProgress;
230 CMenuButton m_btnShow;
231 CMenuButton m_btnShowWholeProject;
232 CTGitPath m_path;
233 CTGitPath m_mergePath;
234 GitRev m_pegrev;
235 GitRev m_startrev;
236 GitRev m_LogRevision;
237 GitRev m_endrev;
238 //GitRev m_wcRev;
239 // GitRevRangeArray m_selectedRevs;
240 // GitRevRangeArray m_selectedRevsOneRange;
241 CString m_sSelectedHash; // set to selected commit hash on OK if appropriate
242 bool m_bSelectionMustBeContinuous;
243 bool m_bSelectionMustBeSingle;
244 long m_logcounter;
245 bool m_bCancelled;
247 BOOL m_bIncludeMerges;
248 BOOL m_bFirstParent;
249 BOOL m_bAllBranch;
250 BOOL m_bWholeProject;
252 git_revnum_t m_lowestRev;
253 CTGitPathList * m_currentChangedArray;
254 LogChangedPathArray m_CurrentFilteredChangedArray;
255 CTGitPathList m_currentChangedPathList;
256 //CPtrArray m_arShownList;
257 bool m_hasWC;
258 int m_nSearchIndex;
259 bool m_bFilterWithRegex;
260 static const UINT m_FindDialogMessage;
261 CFindReplaceDialog *m_pFindDialog;
262 CFont m_logFont;
263 CString m_sMessageBuf;
264 CSplitterControl m_wndSplitter1;
265 CSplitterControl m_wndSplitter2;
266 CRect m_DlgOrigRect;
267 CRect m_MsgViewOrigRect;
268 CRect m_LogListOrigRect;
269 CRect m_ChgOrigRect;
270 // CString m_sFilterText;
272 //volatile LONG m_bNoDispUpdates;
273 CDateTimeCtrl m_DateFrom;
274 CDateTimeCtrl m_DateTo;
275 int m_limit;
276 int m_limitcounter;
277 int m_nSortColumn;
278 bool m_bAscending;
279 static int m_nSortColumnPathList;
280 static bool m_bAscendingPathList;
281 //CRegDWORD m_regMaxBugIDColWidth;
282 CButton m_cHidePaths;
283 bool m_bShowedAll;
284 CString m_sTitle;
285 bool m_bSelect;
286 bool m_bShowBugtraqColumn;
287 CString m_sLogInfo;
288 std::set<git_revnum_t> m_mergedRevs;
290 CToolTips m_tooltips;
292 CColors m_Colors;
293 CImageList m_imgList;
294 #if 0
295 HICON m_hModifiedIcon;
296 HICON m_hReplacedIcon;
297 HICON m_hAddedIcon;
298 HICON m_hDeletedIcon;
299 #endif
301 DWORD m_childCounter;
302 DWORD m_maxChild;
303 HACCEL m_hAccel;
308 //CXPTheme theme;
309 bool m_bVista;
311 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
312 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
313 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));