No need for an extra lookup for HEAD
[TortoiseGit.git] / src / TortoiseProc / LogDlg.h
blob37db323e36d188c7a725762a709aad945b8c9106
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
47 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
49 /**
50 * \ingroup TortoiseProc
51 * Shows log messages of a single file or folder in a listbox.
53 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator, IHasPatchView
55 DECLARE_DYNAMIC(CLogDlg)
57 friend class CStoreSelection;
59 public:
60 CLogDlg(CWnd* pParent = NULL); // standard constructor
61 virtual ~CLogDlg();
62 void SetParams(const CTGitPath& orgPath, const CTGitPath& path, CString hightlightRevision, CString range, int limit);
63 void SetFilter(const CString& findstr, LONG findtype, bool findregex);
64 bool IsThreadRunning() {return !!m_LogList.m_bThreadRunning;}
65 void SetSelect(bool bSelect) {m_bSelect = bSelect;}
66 void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}
67 void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}
68 void SetRange(const CString& range);
69 void ShowStartRef();
70 afx_msg LRESULT OnRefLogChanged(WPARAM wParam, LPARAM lParam);
71 /**
72 * Provides selected commit hash if available, call after OK return from here
73 * Empty if none
74 **/
75 CString GetSelectedHash(){ return m_sSelectedHash; }
77 // Dialog Data
78 enum { IDD = IDD_LOGMESSAGE };
80 void FillLogMessageCtrl(bool bShow = true);
82 void UpdateLogInfoLabel();
84 afx_msg void OnFind()
86 m_LogList.OnFind();
88 protected:
89 //implement the virtual methods from Git base class
90 virtual BOOL Cancel();
91 virtual bool Validate(LPCTSTR string);
93 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
95 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
96 CComPtr<ITaskbarList3> m_pTaskbarList;
98 afx_msg LRESULT OnRefreshSelection(WPARAM wParam, LPARAM lParam);
99 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
100 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
101 afx_msg LRESULT OnLogListLoading(WPARAM wParam, LPARAM lParam);
103 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
104 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
105 afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);
106 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
107 afx_msg void OnLvnItemchangedLogmsg(NMHDR *pNMHDR, LRESULT *pResult);
108 afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);
109 afx_msg void OnBnClickedStatbutton();
111 afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
112 afx_msg void OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
113 afx_msg void OnEnChangeSearchedit();
114 afx_msg void OnTimer(UINT_PTR nIDEvent);
115 afx_msg void OnDtnDatetimechangeDateto(NMHDR *pNMHDR, LRESULT *pResult);
116 afx_msg void OnDtnDatetimechangeDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
117 afx_msg void OnCbnSelchangeJumpType();
118 afx_msg void OnBnClickedJumpUp();
119 afx_msg void OnBnClickedJumpDown();
120 afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
121 afx_msg void OnBnClickedWalkBehaviour();
122 afx_msg void OnBnClickedView();
123 afx_msg void OnBnClickShowWholeProject();
124 void OnBnClickedHidepaths();
125 afx_msg void OnBnClickedAllBranch();
126 void OnBnClickedFollowRenames();
127 void HandleShowLabels(bool var, int flag);
128 void OnBnClickedCompressedGraph();
129 afx_msg void OnBnClickedBrowseRef();
131 afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
132 afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);
133 afx_msg void OnSize(UINT nType, int cx, int cy);
134 void OnBnClickedFirstParent();
135 afx_msg void OnBnClickedRefresh();
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;
152 CRegDWORD m_regbShowLocalBranches;
153 CRegDWORD m_regbShowRemoteBranches;
154 CRegDWORD m_regbShowGravatar;
155 CRegDWORD m_regShowWholeProject;
157 void Refresh (bool clearfilter = false);
158 void MoveToSameTop(CWnd *pWndRef, CWnd *pWndTarget);
159 void DoSizeV1(int delta);
160 void DoSizeV2(int delta);
161 void AdjustMinSize();
162 void SetSplitterRange();
163 void SetFilterCueText();
165 void CopySelectionToClipBoard();
166 void CopyChangedSelectionToClipBoard();
167 CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);
168 void SortShownListArray();
170 void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);
171 void SortByColumn(int nSortColumn, bool bAscending);
173 void EnableOKButton();
175 void SaveSplitterPos();
176 bool ValidateRegexp(LPCTSTR regexp_str, std::tr1::wregex& pat, bool bMatchCase);
177 void CheckRegexpTooltip();
178 void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);
179 void SetDlgTitle();
180 CString GetAbsoluteUrlFromRelativeUrl(const CString& url);
181 void ShowGravatar();
183 CPatchViewDlg m_patchViewdlg;
184 void FillPatchView(bool onlySetTimer = false);
185 CWnd * GetPatchViewParentWnd() { return this; }
186 virtual void TogglePatchView();
187 LRESULT OnFileListCtrlItemChanged(WPARAM /*wparam*/, LPARAM /*lparam*/);
188 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
189 afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
191 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
193 public:
194 CWnd * m_pNotifyWindow;
195 WORD m_wParam;
196 private:
197 CString m_sRelativeRoot;
198 CString m_sRepositoryRoot;
199 CGitLogList m_LogList;
200 CGitStatusListCtrl m_ChangedFileListCtrl;
201 CFilterEdit m_cFilter;
202 CHyperLink m_staticRef;
203 CProgressCtrl m_LogProgress;
204 CTGitPath m_path;
205 CTGitPath m_orgPath;
206 CString m_hightlightRevision;
208 CString m_sSelectedHash; // set to selected commit hash on OK if appropriate
209 bool m_bSelectionMustBeContinuous;
210 bool m_bSelectionMustBeSingle;
211 bool m_bCancelled;
213 BOOL m_iHidePaths;
214 bool m_bFirstParent;
215 BOOL m_bAllBranch;
216 BOOL m_bWholeProject;
217 bool m_bFollowRenames;
218 BOOL m_bShowUnversioned;
219 bool m_bShowTags;
220 bool m_bShowLocalBranches;
221 bool m_bShowRemoteBranches;
222 bool m_bShowGravatar;
223 bool m_bNoMerges;
224 int m_iCompressedGraph;
225 BOOL m_bWalkBehavior;
227 CTGitPathList * m_currentChangedArray;
228 LogChangedPathArray m_CurrentFilteredChangedArray;
229 CTGitPathList m_currentChangedPathList;
231 bool m_bFilterWithRegex;
233 CFont m_logFont;
234 CSplitterControl m_wndSplitter1;
235 CSplitterControl m_wndSplitter2;
236 CRect m_DlgOrigRect;
237 CRect m_MsgViewOrigRect;
238 CRect m_LogListOrigRect;
239 CRect m_ChgOrigRect;
241 //volatile LONG m_bNoDispUpdates;
242 CDateTimeCtrl m_DateFrom;
243 CDateTimeCtrl m_DateTo;
244 CComboBox m_JumpType;
245 CButton m_JumpUp;
246 CButton m_JumpDown;
247 int m_limit;
248 int m_nSortColumn;
249 bool m_bAscending;
250 static int m_nSortColumnPathList;
251 static bool m_bAscendingPathList;
252 CString m_sTitle;
253 bool m_bSelect;
254 CString m_sLogInfo;
256 CToolTips m_tooltips;
258 CColors m_Colors;
259 CImageList m_imgList;
261 HACCEL m_hAccel;
263 CRegHistory m_History;
265 CGravatar m_gravatar;
267 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
268 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
269 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));