1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2009 - 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.
24 #include "StandAloneDlg.h"
27 #include "RegHistory.h"
28 #include "SplitterControl.h"
30 #include "LogDlgHelper.h"
31 #include "FilterEdit.h"
34 #include "HintListCtrl.h"
36 #include "GitLogList.h"
37 #include "GitStatusListCtrl.h"
38 #include "HyperLink.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
47 #define FILEFILTER_TIMER 105
49 typedef int (__cdecl
*GENERICCOMPAREFN
)(const void * elem1
, const void * elem2
);
52 * \ingroup TortoiseProc
53 * Shows log messages of a single file or folder in a listbox.
55 class CLogDlg
: public CResizableStandAloneDialog
, IFilterEditValidator
, IHasPatchView
57 DECLARE_DYNAMIC(CLogDlg
)
59 friend class CStoreSelection
;
62 CLogDlg(CWnd
* pParent
= NULL
); // standard constructor
64 void SetParams(const CTGitPath
& orgPath
, const CTGitPath
& path
, CString hightlightRevision
, CString range
, int limit
);
65 void SetFilter(const CString
& findstr
, LONG findtype
, bool findregex
);
66 bool IsThreadRunning() {return !!m_LogList
.m_bThreadRunning
;}
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
);
72 afx_msg LRESULT
OnRefLogChanged(WPARAM wParam
, LPARAM lParam
);
74 * Provides selected commit hash if available, call after OK return from here
77 CString
GetSelectedHash(){ return m_sSelectedHash
; }
80 enum { IDD
= IDD_LOGMESSAGE
};
82 void FillLogMessageCtrl(bool bShow
= true);
84 void UpdateLogInfoLabel();
91 //implement the virtual methods from Git base class
92 virtual BOOL
Cancel();
93 virtual bool Validate(LPCTSTR string
);
95 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
97 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
98 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
100 afx_msg LRESULT
OnRefreshSelection(WPARAM wParam
, LPARAM lParam
);
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 OnLvnItemchangedLogmsg(NMHDR
*pNMHDR
, LRESULT
*pResult
);
110 afx_msg
void OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
);
111 afx_msg
void OnBnClickedStatbutton();
112 afx_msg
void OnSelectSearchField();
114 afx_msg
void OnNMCustomdrawChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
115 afx_msg
void OnLvnGetdispinfoChangedFileList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
116 afx_msg
void OnEnChangeSearchedit();
117 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
118 afx_msg
void OnDtnDatetimechangeDateto(NMHDR
*pNMHDR
, LRESULT
*pResult
);
119 afx_msg
void OnDtnDatetimechangeDatefrom(NMHDR
*pNMHDR
, LRESULT
*pResult
);
120 afx_msg
void OnCbnSelchangeJumpType();
121 afx_msg
void OnBnClickedJumpUp();
122 afx_msg
void OnBnClickedJumpDown();
123 afx_msg
void OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
);
124 afx_msg
void OnBnClickedWalkBehaviour();
125 afx_msg
void OnBnClickedView();
126 afx_msg
void OnBnClickShowWholeProject();
127 void OnBnClickedHidepaths();
128 afx_msg
void OnBnClickedAllBranch();
129 void OnBnClickedFollowRenames();
130 void HandleShowLabels(bool var
, int flag
);
131 void OnBnClickedCompressedGraph();
132 afx_msg
void OnBnClickedBrowseRef();
134 afx_msg
void GoBack();
135 afx_msg
void GoForward();
136 afx_msg
void GoBackAndSelect();
137 afx_msg
void GoForwardAndSelect();
138 void GoBackForward(bool select
, bool bForward
);
140 afx_msg
void OnDtnDropdownDatefrom(NMHDR
*pNMHDR
, LRESULT
*pResult
);
141 afx_msg
void OnDtnDropdownDateto(NMHDR
*pNMHDR
, LRESULT
*pResult
);
142 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
143 void OnBnClickedFirstParent();
144 afx_msg
void OnBnClickedRefresh();
145 afx_msg
void OnRefresh();
146 afx_msg
void OnFocusFilter();
147 afx_msg
void OnEditCopy();
148 afx_msg
void OnEnChangeFileFilter();
149 afx_msg
void OnEnscrollMsgview();
151 virtual void OnCancel();
153 virtual BOOL
OnInitDialog();
154 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
156 void DoDiffFromLog(INT_PTR selIndex
, GitRev
*rev1
, GitRev
*rev2
, bool blame
, bool unified
);
158 DECLARE_MESSAGE_MAP()
161 CRegDWORD m_regbAllBranch
;
162 CRegDWORD m_regbShowTags
;
163 CRegDWORD m_regbShowLocalBranches
;
164 CRegDWORD m_regbShowRemoteBranches
;
165 CRegDWORD m_regbShowGravatar
;
166 CRegDWORD m_regShowWholeProject
;
168 void Refresh (bool clearfilter
= false);
169 void MoveToSameTop(CWnd
*pWndRef
, CWnd
*pWndTarget
);
170 void DoSizeV1(int delta
);
171 void DoSizeV2(int delta
);
172 void AdjustMinSize();
173 void SetSplitterRange();
174 void SetFilterCueText();
176 void CopySelectionToClipBoard();
177 void CopyChangedSelectionToClipBoard();
178 CTGitPathList
GetChangedPathsFromSelectedRevisions(bool bRelativePaths
= false, bool bUseFilter
= true);
179 void SortShownListArray();
181 void SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
);
182 void SortByColumn(int nSortColumn
, bool bAscending
);
184 void EnableOKButton();
186 void SaveSplitterPos();
187 bool ValidateRegexp(LPCTSTR regexp_str
, std::tr1::wregex
& pat
, bool bMatchCase
);
188 void CheckRegexpTooltip();
189 void GetChangedPaths(std::vector
<CString
>& changedpaths
, std::vector
<LogChangedPath
*>& changedlogpaths
);
191 CString
GetAbsoluteUrlFromRelativeUrl(const CString
& url
);
194 CPatchViewDlg m_patchViewdlg
;
195 void FillPatchView(bool onlySetTimer
= false);
196 CWnd
* GetPatchViewParentWnd() { return this; }
197 virtual void TogglePatchView();
198 LRESULT
OnFileListCtrlItemChanged(WPARAM
/*wparam*/, LPARAM
/*lparam*/);
199 afx_msg
void OnMoving(UINT fwSide
, LPRECT pRect
);
200 afx_msg
void OnSizing(UINT fwSide
, LPRECT pRect
);
202 virtual LRESULT
DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
);
205 CWnd
* m_pNotifyWindow
;
208 CString m_sRelativeRoot
;
209 CString m_sRepositoryRoot
;
210 CGitLogList m_LogList
;
211 CGitStatusListCtrl m_ChangedFileListCtrl
;
212 CFilterEdit m_cFilter
;
213 CHyperLink m_staticRef
;
214 CProgressCtrl m_LogProgress
;
217 CString m_hightlightRevision
;
219 CString m_sSelectedHash
; // set to selected commit hash on OK if appropriate
220 bool m_bSelectionMustBeContinuous
;
221 bool m_bSelectionMustBeSingle
;
224 CFilterEdit m_cFileFilter
;
229 BOOL m_bWholeProject
;
230 bool m_bFollowRenames
;
231 BOOL m_bShowUnversioned
;
233 bool m_bShowLocalBranches
;
234 bool m_bShowRemoteBranches
;
235 bool m_bShowGravatar
;
236 bool m_bShowDescribe
;
238 int m_iCompressedGraph
;
239 BOOL m_bWalkBehavior
;
240 bool m_bNavigatingWithSelect
;
241 bool m_bAsteriskLogPrefix
;
243 CTGitPathList
* m_currentChangedArray
;
244 LogChangedPathArray m_CurrentFilteredChangedArray
;
245 CTGitPathList m_currentChangedPathList
;
247 bool m_bFilterWithRegex
;
248 bool m_bFilterCaseSensitively
;
251 CSplitterControl m_wndSplitter1
;
252 CSplitterControl m_wndSplitter2
;
254 CRect m_MsgViewOrigRect
;
255 CRect m_LogListOrigRect
;
258 //volatile LONG m_bNoDispUpdates;
259 CDateTimeCtrl m_DateFrom
;
260 CDateTimeCtrl m_DateTo
;
261 CComboBox m_JumpType
;
267 static int m_nSortColumnPathList
;
268 static bool m_bAscendingPathList
;
273 CToolTips m_tooltips
;
276 CImageList m_imgList
;
280 CRegHistory m_History
;
282 CGravatar m_gravatar
;
284 static UINT WM_REVSELECTED
= RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
285 static UINT WM_REVLIST
= RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
286 static UINT WM_REVLISTONERANGE
= RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));