Unify code that does Navigate Back / Forward
[TortoiseGit.git] / src / TortoiseProc / LogDlg.h
blobca855bbce7c663a104349329196af638afe36c47
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2014 - 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 "StandAloneDlg.h"
25 #include "TGitPath.h"
26 #include "registry.h"
27 #include "RegHistory.h"
28 #include "SplitterControl.h"
29 #include "Colors.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"
39 #include "Win7.h"
40 #include "GravatarPictureBox.h"
41 #include "PatchViewDlg.h"
43 #define LOGFILTER_TIMER 101
44 #define LOGFTIME_TIMER 102
45 #define LOG_FILLPATCHVTIMER 103
46 #define LOG_HEADER_ORDER_TIMER 104
48 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
50 /**
51 * \ingroup TortoiseProc
52 * Shows log messages of a single file or folder in a listbox.
54 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator, IHasPatchView
56 DECLARE_DYNAMIC(CLogDlg)
58 friend class CStoreSelection;
60 public:
61 CLogDlg(CWnd* pParent = NULL); // standard constructor
62 virtual ~CLogDlg();
63 void SetParams(const CTGitPath& orgPath, const CTGitPath& path, CString hightlightRevision, CString range, int limit);
64 void SetFilter(const CString& findstr, LONG findtype, bool findregex);
65 bool IsThreadRunning() {return !!m_LogList.m_bThreadRunning;}
66 void SetSelect(bool bSelect) {m_bSelect = bSelect;}
67 void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}
68 void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}
69 void SetRange(const CString& range);
70 void ShowStartRef();
71 afx_msg LRESULT OnRefLogChanged(WPARAM wParam, LPARAM lParam);
72 /**
73 * Provides selected commit hash if available, call after OK return from here
74 * Empty if none
75 **/
76 CString GetSelectedHash(){ return m_sSelectedHash; }
78 // Dialog Data
79 enum { IDD = IDD_LOGMESSAGE };
81 void FillLogMessageCtrl(bool bShow = true);
83 void UpdateLogInfoLabel();
85 afx_msg void OnFind()
87 m_LogList.OnFind();
89 protected:
90 //implement the virtual methods from Git base class
91 virtual BOOL Cancel();
92 virtual bool Validate(LPCTSTR string);
94 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
96 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
97 CComPtr<ITaskbarList3> m_pTaskbarList;
99 afx_msg LRESULT OnRefreshSelection(WPARAM wParam, LPARAM lParam);
100 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
101 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
102 afx_msg LRESULT OnLogListLoading(WPARAM wParam, LPARAM lParam);
104 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
105 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
106 afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);
107 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
108 afx_msg void OnLvnItemchangedLogmsg(NMHDR *pNMHDR, LRESULT *pResult);
109 afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);
110 afx_msg void OnBnClickedStatbutton();
112 afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
113 afx_msg void OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
114 afx_msg void OnEnChangeSearchedit();
115 afx_msg void OnTimer(UINT_PTR nIDEvent);
116 afx_msg void OnDtnDatetimechangeDateto(NMHDR *pNMHDR, LRESULT *pResult);
117 afx_msg void OnDtnDatetimechangeDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
118 afx_msg void OnCbnSelchangeJumpType();
119 afx_msg void OnBnClickedJumpUp();
120 afx_msg void OnBnClickedJumpDown();
121 afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
122 afx_msg void OnBnClickedWalkBehaviour();
123 afx_msg void OnBnClickedView();
124 afx_msg void OnBnClickShowWholeProject();
125 void OnBnClickedHidepaths();
126 afx_msg void OnBnClickedAllBranch();
127 void OnBnClickedFollowRenames();
128 void HandleShowLabels(bool var, int flag);
129 void OnBnClickedCompressedGraph();
130 afx_msg void OnBnClickedBrowseRef();
132 afx_msg void GoBack();
133 afx_msg void GoForward();
134 void GoBackForward(bool bForward);
136 afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
137 afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);
138 afx_msg void OnSize(UINT nType, int cx, int cy);
139 void OnBnClickedFirstParent();
140 afx_msg void OnBnClickedRefresh();
141 afx_msg void OnRefresh();
142 afx_msg void OnFocusFilter();
143 afx_msg void OnEditCopy();
145 virtual void OnCancel();
146 virtual void OnOK();
147 virtual BOOL OnInitDialog();
148 virtual BOOL PreTranslateMessage(MSG* pMsg);
150 void DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);
152 DECLARE_MESSAGE_MAP()
154 private:
155 CRegDWORD m_regbAllBranch;
156 CRegDWORD m_regbShowTags;
157 CRegDWORD m_regbShowLocalBranches;
158 CRegDWORD m_regbShowRemoteBranches;
159 CRegDWORD m_regbShowGravatar;
160 CRegDWORD m_regShowWholeProject;
162 void Refresh (bool clearfilter = false);
163 void MoveToSameTop(CWnd *pWndRef, CWnd *pWndTarget);
164 void DoSizeV1(int delta);
165 void DoSizeV2(int delta);
166 void AdjustMinSize();
167 void SetSplitterRange();
168 void SetFilterCueText();
170 void CopySelectionToClipBoard();
171 void CopyChangedSelectionToClipBoard();
172 CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);
173 void SortShownListArray();
175 void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);
176 void SortByColumn(int nSortColumn, bool bAscending);
178 void EnableOKButton();
180 void SaveSplitterPos();
181 bool ValidateRegexp(LPCTSTR regexp_str, std::tr1::wregex& pat, bool bMatchCase);
182 void CheckRegexpTooltip();
183 void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);
184 void SetDlgTitle();
185 CString GetAbsoluteUrlFromRelativeUrl(const CString& url);
186 void ShowGravatar();
188 CPatchViewDlg m_patchViewdlg;
189 void FillPatchView(bool onlySetTimer = false);
190 CWnd * GetPatchViewParentWnd() { return this; }
191 virtual void TogglePatchView();
192 LRESULT OnFileListCtrlItemChanged(WPARAM /*wparam*/, LPARAM /*lparam*/);
193 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
194 afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
196 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
198 public:
199 CWnd * m_pNotifyWindow;
200 WORD m_wParam;
201 private:
202 CString m_sRelativeRoot;
203 CString m_sRepositoryRoot;
204 CGitLogList m_LogList;
205 CGitStatusListCtrl m_ChangedFileListCtrl;
206 CFilterEdit m_cFilter;
207 CHyperLink m_staticRef;
208 CProgressCtrl m_LogProgress;
209 CTGitPath m_path;
210 CTGitPath m_orgPath;
211 CString m_hightlightRevision;
213 CString m_sSelectedHash; // set to selected commit hash on OK if appropriate
214 bool m_bSelectionMustBeContinuous;
215 bool m_bSelectionMustBeSingle;
216 bool m_bCancelled;
218 BOOL m_iHidePaths;
219 bool m_bFirstParent;
220 BOOL m_bAllBranch;
221 BOOL m_bWholeProject;
222 bool m_bFollowRenames;
223 BOOL m_bShowUnversioned;
224 bool m_bShowTags;
225 bool m_bShowLocalBranches;
226 bool m_bShowRemoteBranches;
227 bool m_bShowGravatar;
228 bool m_bNoMerges;
229 int m_iCompressedGraph;
230 BOOL m_bWalkBehavior;
232 CTGitPathList * m_currentChangedArray;
233 LogChangedPathArray m_CurrentFilteredChangedArray;
234 CTGitPathList m_currentChangedPathList;
236 bool m_bFilterWithRegex;
238 CFont m_logFont;
239 CSplitterControl m_wndSplitter1;
240 CSplitterControl m_wndSplitter2;
241 CRect m_DlgOrigRect;
242 CRect m_MsgViewOrigRect;
243 CRect m_LogListOrigRect;
244 CRect m_ChgOrigRect;
246 //volatile LONG m_bNoDispUpdates;
247 CDateTimeCtrl m_DateFrom;
248 CDateTimeCtrl m_DateTo;
249 CComboBox m_JumpType;
250 CButton m_JumpUp;
251 CButton m_JumpDown;
252 int m_limit;
253 int m_nSortColumn;
254 bool m_bAscending;
255 static int m_nSortColumnPathList;
256 static bool m_bAscendingPathList;
257 CString m_sTitle;
258 bool m_bSelect;
259 CString m_sLogInfo;
261 CToolTips m_tooltips;
263 CColors m_Colors;
264 CImageList m_imgList;
266 HACCEL m_hAccel;
268 CRegHistory m_History;
270 CGravatar m_gravatar;
272 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
273 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
274 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));