1 // TortoiseGit - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseGit
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
21 #include "resource.h"
\r
23 #include "ProjectProperties.h"
\r
24 #include "StandAloneDlg.h"
\r
25 #include "TGitPath.h"
\r
26 #include "registry.h"
\r
27 #include "SplitterControl.h"
\r
29 #include "MenuButton.h"
\r
30 #include "LogDlgHelper.h"
\r
31 #include "FilterEdit.h"
\r
33 #include "Tooltip.h"
\r
34 #include "HintListCtrl.h"
\r
36 #include "GitLogList.h"
\r
37 #include "GitStatusListCtrl.h"
\r
38 using namespace std;
\r
41 #define MERGE_REVSELECTSTART 1
\r
42 #define MERGE_REVSELECTEND 2
\r
43 #define MERGE_REVSELECTSTARTEND 3 ///< both
\r
44 #define MERGE_REVSELECTMINUSONE 4 ///< first with N-1
\r
46 #define LOGFILTER_ALL 1
\r
47 #define LOGFILTER_MESSAGES 2
\r
48 #define LOGFILTER_PATHS 3
\r
49 #define LOGFILTER_AUTHORS 4
\r
50 #define LOGFILTER_REVS 5
\r
51 #define LOGFILTER_REGEX 6
\r
52 #define LOGFILTER_BUGID 7
\r
55 #define LOGFILTER_TIMER 101
\r
57 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
\r
60 * \ingroup TortoiseProc
\r
61 * Shows log messages of a single file or folder in a listbox.
\r
63 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator
\r
65 DECLARE_DYNAMIC(CLogDlg)
\r
67 friend class CStoreSelection;
\r
70 CLogDlg(CWnd* pParent = NULL); // standard constructor
\r
81 LOGLIST_MESSAGE_MAX=250
\r
92 void SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit,
\r
93 BOOL bStrict = CRegDWORD(_T("Software\\TortoiseGit\\LastLogStrict"), FALSE), BOOL bSaveStrict = TRUE);
\r
94 void SetIncludeMerge(bool bInclude = true) {m_bIncludeMerges = bInclude;}
\r
95 void SetProjectPropertiesPath(const CTGitPath& path) {m_ProjectProperties.ReadProps(path);}
\r
96 bool IsThreadRunning() {return !!m_LogList.m_bThreadRunning;}
\r
97 void SetDialogTitle(const CString& sTitle) {m_sTitle = sTitle;}
\r
98 void SetSelect(bool bSelect) {m_bSelect = bSelect;}
\r
99 void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}
\r
100 void SetMergePath(const CTGitPath& mergepath) {m_mergePath = mergepath;}
\r
102 // const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}
\r
105 enum { IDD = IDD_LOGMESSAGE };
\r
108 //implement the virtual methods from Git base class
\r
109 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);
\r
110 virtual BOOL Cancel();
\r
111 virtual bool Validate(LPCTSTR string);
\r
113 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
\r
115 afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
\r
116 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
\r
117 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
\r
118 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
\r
119 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
\r
120 afx_msg void OnBnClickedGetall();
\r
121 afx_msg void OnNMDblclkChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
\r
122 afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);
\r
123 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
\r
124 afx_msg void OnBnClickedHelp();
\r
125 afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);
\r
126 afx_msg void OnBnClickedStatbutton();
\r
128 afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
\r
129 afx_msg void OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
\r
130 afx_msg void OnEnChangeSearchedit();
\r
131 afx_msg void OnTimer(UINT_PTR nIDEvent);
\r
132 afx_msg void OnDtnDatetimechangeDateto(NMHDR *pNMHDR, LRESULT *pResult);
\r
133 afx_msg void OnDtnDatetimechangeDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
\r
134 afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
\r
135 afx_msg void OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);
\r
136 afx_msg void OnBnClickedNexthundred();
\r
137 afx_msg void OnBnClickedHidepaths();
\r
138 afx_msg void OnBnClickedCheckStoponcopy();
\r
140 afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);
\r
141 afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);
\r
142 afx_msg void OnSize(UINT nType, int cx, int cy);
\r
143 afx_msg void OnBnClickedIncludemerge();
\r
144 afx_msg void OnBnClickedRefresh();
\r
145 afx_msg void OnRefresh();
\r
146 afx_msg void OnFind();
\r
147 afx_msg void OnFocusFilter();
\r
148 afx_msg void OnEditCopy();
\r
150 virtual void OnCancel();
\r
151 virtual void OnOK();
\r
152 virtual BOOL OnInitDialog();
\r
153 //virtual BOOL PreTranslateMessage(MSG* pMsg);
\r
155 void FillLogMessageCtrl(bool bShow = true);
\r
156 void DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);
\r
158 static void LogCallBack(void *data, int cur){((CLogDlg*)data)->LogRunStatus(cur);}
\r
159 void LogRunStatus(int cur);
\r
161 DECLARE_MESSAGE_MAP()
\r
166 void Refresh (bool autoGoOnline = false);
\r
167 BOOL IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev);
\r
168 BOOL Open(bool bOpenWith, CString changedpath, git_revnum_t rev);
\r
169 void EditAuthor(const CLogDataVector& logs);
\r
170 void EditLogMessage(int index);
\r
171 void DoSizeV1(int delta);
\r
172 void DoSizeV2(int delta);
\r
173 void AdjustMinSize();
\r
174 void SetSplitterRange();
\r
175 void SetFilterCueText();
\r
176 BOOL IsEntryInDateRange(int i);
\r
177 void CopySelectionToClipBoard();
\r
178 void CopyChangedSelectionToClipBoard();
\r
179 CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);
\r
180 void SortShownListArray();
\r
181 void RecalculateShownList(CPtrArray * pShownlist);
\r
182 void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);
\r
183 void SortByColumn(int nSortColumn, bool bAscending);
\r
185 void EnableOKButton();
\r
186 void GetAll(bool bForceAll = false);
\r
187 void UpdateLogInfoLabel();
\r
188 void SaveSplitterPos();
\r
189 bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase);
\r
190 void CheckRegexpTooltip();
\r
191 void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);
\r
192 void DiffSelectedFile();
\r
193 void DiffSelectedRevWithPrevious();
\r
194 void SetDlgTitle(bool bOffline);
\r
195 CString GetAbsoluteUrlFromRelativeUrl(const CString& url);
\r
198 * Extracts part of commit message suitable for displaying in revision list.
\r
200 CString MakeShortMessage(const CString& message);
\r
201 // inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }
\r
204 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
\r
205 static int __cdecl SortCompare(const void * pElem1, const void * pElem2); ///< sort callback function
\r
207 void ResizeAllListCtrlCols();
\r
209 void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point);
\r
210 void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point);
\r
212 CWnd * m_pNotifyWindow;
\r
213 ProjectProperties m_ProjectProperties;
\r
216 //HFONT m_boldFont;
\r
217 CString m_sRelativeRoot;
\r
218 CString m_sRepositoryRoot;
\r
219 CString m_sSelfRelativeURL;
\r
221 CString m_sUUID; ///< empty if the log cache is not used
\r
222 CGitLogList m_LogList;
\r
223 //CListCtrl m_ChangedFileListCtrl;
\r
225 CGitStatusListCtrl m_ChangedFileListCtrl;
\r
227 CFilterEdit m_cFilter;
\r
228 CProgressCtrl m_LogProgress;
\r
229 CMenuButton m_btnShow;
\r
231 CTGitPath m_mergePath;
\r
234 GitRev m_LogRevision;
\r
237 // GitRevRangeArray m_selectedRevs;
\r
238 // GitRevRangeArray m_selectedRevsOneRange;
\r
239 bool m_bSelectionMustBeContinuous;
\r
245 BOOL m_bIncludeMerges;
\r
246 git_revnum_t m_lowestRev;
\r
247 BOOL m_bSaveStrict;
\r
248 CTGitPathList * m_currentChangedArray;
\r
249 LogChangedPathArray m_CurrentFilteredChangedArray;
\r
250 CTGitPathList m_currentChangedPathList;
\r
251 //CPtrArray m_arShownList;
\r
253 int m_nSearchIndex;
\r
254 bool m_bFilterWithRegex;
\r
255 static const UINT m_FindDialogMessage;
\r
256 CFindReplaceDialog *m_pFindDialog;
\r
258 CString m_sMessageBuf;
\r
259 CSplitterControl m_wndSplitter1;
\r
260 CSplitterControl m_wndSplitter2;
\r
261 CRect m_DlgOrigRect;
\r
262 CRect m_MsgViewOrigRect;
\r
263 CRect m_LogListOrigRect;
\r
264 CRect m_ChgOrigRect;
\r
265 CString m_sFilterText;
\r
266 int m_nSelectedFilter;
\r
267 //volatile LONG m_bNoDispUpdates;
\r
268 CDateTimeCtrl m_DateFrom;
\r
269 CDateTimeCtrl m_DateTo;
\r
273 int m_limitcounter;
\r
276 static int m_nSortColumnPathList;
\r
277 static bool m_bAscendingPathList;
\r
278 CRegDWORD m_regLastStrict;
\r
279 //CRegDWORD m_regMaxBugIDColWidth;
\r
280 CButton m_cHidePaths;
\r
284 bool m_bShowBugtraqColumn;
\r
285 CString m_sLogInfo;
\r
286 std::set<git_revnum_t> m_mergedRevs;
\r
288 CToolTips m_tooltips;
\r
293 CImageList m_imgList;
\r
295 HICON m_hModifiedIcon;
\r
296 HICON m_hReplacedIcon;
\r
297 HICON m_hAddedIcon;
\r
298 HICON m_hDeletedIcon;
\r
301 DWORD m_childCounter;
\r
311 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));
\r
312 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));
\r
313 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));
\r