Log: Support arbitrary revisions
[TortoiseGit.git] / src / TortoiseProc / LogDlg.h
blob3803e9f74d421ef5b7bd566a4b4746ca815b9c60
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2013 - 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 LOGFILTER_TIMER 101
46 #define LOGFTIME_TIMER 102
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
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 SetDialogTitle(const CString& sTitle) {m_sTitle = sTitle;}
67 void SetSelect(bool bSelect) {m_bSelect = bSelect;}
68 void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}
69 void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}
70 void SetRange(const CString& range);
71 void ShowStartRef();
72 afx_msg LRESULT OnRefLogChanged(WPARAM wParam, LPARAM lParam);
73 /**
74 * Provides selected commit hash if available, call after OK return from here
75 * Empty if none
76 **/
77 CString GetSelectedHash(){ return m_sSelectedHash; }
79 // Dialog Data
80 enum { IDD = IDD_LOGMESSAGE };
82 void FillLogMessageCtrl(bool bShow = true);
83 CString GetTagInfo(GitRev* pLogEntry);
85 void UpdateLogInfoLabel();
87 afx_msg void OnFind()
89 m_LogList.OnFind();
91 protected:
92 //implement the virtual methods from Git base class
93 virtual BOOL Cancel();
94 virtual bool Validate(LPCTSTR string);
96 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
98 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
99 CComPtr<ITaskbarList3> m_pTaskbarList;
101 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
102 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
103 afx_msg LRESULT OnLogListLoading(WPARAM wParam, LPARAM lParam);
105 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
106 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
107 afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);
108 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
109 afx_msg void OnBnClickedHelp();
110 afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);
111 afx_msg void OnBnClickedStatbutton();
113 afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
114 afx_msg void OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
115 afx_msg void OnEnChangeSearchedit();
116 afx_msg void OnTimer(UINT_PTR nIDEvent);
117 afx_msg void OnDtnDatetimechangeDateto(NMHDR *pNMHDR, LRESULT *pResult);
118 afx_msg void OnDtnDatetimechangeDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
119 afx_msg void OnCbnSelchangeJumpType();
120 afx_msg void OnBnClickedJumpUp();
121 afx_msg void OnBnClickedJumpDown();
122 afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
123 afx_msg void OnBnClickShowWholeProject();
124 afx_msg void OnBnClickedHidepaths();
125 afx_msg void OnBnClickedAllBranch();
126 afx_msg void OnBnClickedFollowRenames();
127 afx_msg void OnBnClickedShowTags();
128 afx_msg void OnBnClickedBrowseRef();
130 afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
131 afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);
132 afx_msg void OnSize(UINT nType, int cx, int cy);
133 afx_msg void OnBnClickedFirstParent();
134 afx_msg void OnBnClickedRefresh();
135 afx_msg void OnBnClickedDownAuthor();
136 afx_msg void OnRefresh();
137 afx_msg void OnFocusFilter();
138 afx_msg void OnEditCopy();
140 virtual void OnCancel();
141 virtual void OnOK();
142 virtual BOOL OnInitDialog();
143 virtual BOOL PreTranslateMessage(MSG* pMsg);
145 void DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);
147 DECLARE_MESSAGE_MAP()
149 private:
150 CRegDWORD m_regbAllBranch;
151 CRegDWORD m_regbShowTags;
153 void Refresh (bool clearfilter = false);
154 void DoSizeV1(int delta);
155 void DoSizeV2(int delta);
156 void AdjustMinSize();
157 void SetSplitterRange();
158 void SetFilterCueText();
160 void CopySelectionToClipBoard();
161 void CopyChangedSelectionToClipBoard();
162 CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);
163 void SortShownListArray();
165 void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);
166 void SortByColumn(int nSortColumn, bool bAscending);
168 void EnableOKButton();
170 void SaveSplitterPos();
171 bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase);
172 void CheckRegexpTooltip();
173 void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);
174 void SetDlgTitle();
175 CString GetAbsoluteUrlFromRelativeUrl(const CString& url);
178 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
180 public:
181 CWnd * m_pNotifyWindow;
182 WORD m_wParam;
183 private:
184 CString m_sRelativeRoot;
185 CString m_sRepositoryRoot;
186 CGitLogList m_LogList;
187 CGitStatusListCtrl m_ChangedFileListCtrl;
188 CFilterEdit m_cFilter;
189 CHyperLink m_staticRef;
190 CProgressCtrl m_LogProgress;
191 CMenuButton m_btnShowWholeProject;
192 CTGitPath m_path;
193 CTGitPath m_orgPath;
194 CString m_hightlightRevision;
196 CString m_sSelectedHash; // set to selected commit hash on OK if appropriate
197 bool m_bSelectionMustBeContinuous;
198 bool m_bSelectionMustBeSingle;
199 bool m_bCancelled;
201 BOOL m_bFirstParent;
202 BOOL m_bAllBranch;
203 BOOL m_bWholeProject;
204 BOOL m_bFollowRenames;
205 BOOL m_bShowUnversioned;
206 BOOL m_bShowTags;
208 CTGitPathList * m_currentChangedArray;
209 LogChangedPathArray m_CurrentFilteredChangedArray;
210 CTGitPathList m_currentChangedPathList;
212 bool m_bFilterWithRegex;
214 CFont m_logFont;
215 CSplitterControl m_wndSplitter1;
216 CSplitterControl m_wndSplitter2;
217 CRect m_DlgOrigRect;
218 CRect m_MsgViewOrigRect;
219 CRect m_LogListOrigRect;
220 CRect m_ChgOrigRect;
222 //volatile LONG m_bNoDispUpdates;
223 CDateTimeCtrl m_DateFrom;
224 CDateTimeCtrl m_DateTo;
225 CComboBox m_JumpType;
226 CButton m_JumpUp;
227 CButton m_JumpDown;
228 int m_limit;
229 int m_nSortColumn;
230 bool m_bAscending;
231 static int m_nSortColumnPathList;
232 static bool m_bAscendingPathList;
233 CButton m_cHidePaths;
234 CString m_sTitle;
235 bool m_bSelect;
236 CString m_sLogInfo;
238 CToolTips m_tooltips;
240 CColors m_Colors;
241 CImageList m_imgList;
243 HACCEL m_hAccel;
245 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
246 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
247 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));