OSDN Git Service

Add Pull Push Fetch Clone Dialog
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / LogDlg.h
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseGit\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 \r
21 #include "resource.h"\r
22 #include "Git.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
28 #include "Colors.h"\r
29 #include "MenuButton.h"\r
30 #include "LogDlgHelper.h"\r
31 #include "FilterEdit.h"\r
32 #include "GitRev.h"\r
33 #include "Tooltip.h"\r
34 #include "HintListCtrl.h"\r
35 \r
36 #include <regex>\r
37 using namespace std;\r
38 \r
39 \r
40 #define MERGE_REVSELECTSTART     1\r
41 #define MERGE_REVSELECTEND       2\r
42 #define MERGE_REVSELECTSTARTEND  3              ///< both\r
43 #define MERGE_REVSELECTMINUSONE  4              ///< first with N-1\r
44 \r
45 #define LOGFILTER_ALL      1\r
46 #define LOGFILTER_MESSAGES 2\r
47 #define LOGFILTER_PATHS    3\r
48 #define LOGFILTER_AUTHORS  4\r
49 #define LOGFILTER_REVS     5\r
50 #define LOGFILTER_REGEX    6\r
51 #define LOGFILTER_BUGID    7\r
52 \r
53 \r
54 #define LOGFILTER_TIMER         101\r
55 \r
56 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);\r
57 \r
58 /**\r
59  * \ingroup TortoiseProc\r
60  * Shows log messages of a single file or folder in a listbox. \r
61  */\r
62 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator\r
63 {\r
64         DECLARE_DYNAMIC(CLogDlg)\r
65         \r
66         friend class CStoreSelection;\r
67 \r
68 public:\r
69         CLogDlg(CWnd* pParent = NULL);   // standard constructor\r
70         virtual ~CLogDlg();\r
71 \r
72         enum\r
73         {\r
74                 LOGLIST_GRAPH,\r
75                 LOGLIST_ACTION,\r
76                 LOGLIST_MESSAGE,\r
77                 LOGLIST_AUTHOR,\r
78                 LOGLIST_DATE,\r
79                 LOGLIST_BUG,\r
80                 LOGLIST_MESSAGE_MAX=250\r
81         };\r
82 \r
83         enum\r
84         {\r
85                 FILELIST_ACTION,\r
86                 FILELIST_ADD,\r
87                 FILELIST_DEL,\r
88                 FILELIST_PATH\r
89         };\r
90 \r
91         void SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit, \r
92                 BOOL bStrict = CRegDWORD(_T("Software\\TortoiseGit\\LastLogStrict"), FALSE), BOOL bSaveStrict = TRUE);\r
93         void SetIncludeMerge(bool bInclude = true) {m_bIncludeMerges = bInclude;}\r
94         void SetProjectPropertiesPath(const CTGitPath& path) {m_ProjectProperties.ReadProps(path);}\r
95         bool IsThreadRunning() {return !!m_bThreadRunning;}\r
96         void SetDialogTitle(const CString& sTitle) {m_sTitle = sTitle;}\r
97         void SetSelect(bool bSelect) {m_bSelect = bSelect;}\r
98         void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}\r
99         void SetMergePath(const CTGitPath& mergepath) {m_mergePath = mergepath;}\r
100 \r
101 //      const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}\r
102 \r
103 // Dialog Data\r
104         enum { IDD = IDD_LOGMESSAGE };\r
105 \r
106 protected:\r
107         //implement the virtual methods from Git base class\r
108         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
109         virtual BOOL Cancel();\r
110         virtual bool Validate(LPCTSTR string);\r
111 \r
112         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
113 \r
114         afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);\r
115         afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);\r
116         afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);\r
117         afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);\r
118         afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);\r
119         afx_msg void OnBnClickedGetall();\r
120         afx_msg void OnNMDblclkChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);\r
121         afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);\r
122         afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);\r
123         afx_msg void OnBnClickedHelp();\r
124         afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);\r
125         afx_msg void OnBnClickedStatbutton();\r
126         afx_msg void OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult);\r
127         afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);\r
128         afx_msg void OnLvnGetdispinfoLoglist(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
139         afx_msg void OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult);\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
149 \r
150         virtual void OnCancel();\r
151         virtual void OnOK();\r
152         virtual BOOL OnInitDialog();\r
153         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
154 \r
155         void    FillLogMessageCtrl(bool bShow = true);\r
156         void    DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);\r
157 \r
158         DECLARE_MESSAGE_MAP()\r
159 \r
160 private:\r
161         static UINT LogThreadEntry(LPVOID pVoid);\r
162         UINT LogThread();\r
163         void Refresh (bool autoGoOnline = false);\r
164         BOOL IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev);\r
165         BOOL Open(bool bOpenWith, CString changedpath, git_revnum_t rev);\r
166         void EditAuthor(const CLogDataVector& logs);\r
167         void EditLogMessage(int index);\r
168         void DoSizeV1(int delta);\r
169         void DoSizeV2(int delta);\r
170         void AdjustMinSize();\r
171         void SetSplitterRange();\r
172         void SetFilterCueText();\r
173         BOOL IsEntryInDateRange(int i);\r
174         void CopySelectionToClipBoard();\r
175         void CopyChangedSelectionToClipBoard();\r
176         CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);\r
177     void SortShownListArray();\r
178         void RecalculateShownList(CPtrArray * pShownlist);\r
179     void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);\r
180         void SortByColumn(int nSortColumn, bool bAscending);\r
181         bool IsSelectionContinuous();\r
182         void EnableOKButton();\r
183         void GetAll(bool bForceAll = false);\r
184         void UpdateLogInfoLabel();\r
185         void SaveSplitterPos();\r
186         bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase);\r
187         void CheckRegexpTooltip();\r
188         void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);\r
189         void DiffSelectedFile();\r
190         void DiffSelectedRevWithPrevious();\r
191         void SetDlgTitle(bool bOffline);\r
192         CString GetAbsoluteUrlFromRelativeUrl(const CString& url);\r
193 \r
194         /**\r
195          * Extracts part of commit message suitable for displaying in revision list.\r
196          */\r
197         CString MakeShortMessage(const CString& message);\r
198         inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }\r
199 \r
200 \r
201         virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r
202         static int __cdecl      SortCompare(const void * pElem1, const void * pElem2);  ///< sort callback function\r
203 \r
204         void ResizeAllListCtrlCols();\r
205 \r
206         void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point);\r
207         void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point);\r
208 public:\r
209         CWnd *                          m_pNotifyWindow;\r
210         ProjectProperties       m_ProjectProperties;\r
211         WORD                            m_wParam;\r
212 private:\r
213         HFONT                           m_boldFont;\r
214         CString                         m_sRelativeRoot;\r
215         CString                         m_sRepositoryRoot;\r
216         CString                         m_sSelfRelativeURL;\r
217         CString                         m_sURL;\r
218         CString                         m_sUUID;    ///< empty if the log cache is not used\r
219         CHintListCtrl           m_LogList;\r
220         CListCtrl                       m_ChangedFileListCtrl;\r
221         CFilterEdit                     m_cFilter;\r
222         CProgressCtrl           m_LogProgress;\r
223         CMenuButton                     m_btnShow;\r
224         CTGitPath                       m_path;\r
225         CTGitPath                       m_mergePath;\r
226         GitRev                          m_pegrev;\r
227         GitRev                          m_startrev;\r
228         GitRev                          m_LogRevision;\r
229         GitRev                          m_endrev;\r
230         GitRev                          m_wcRev;\r
231 //      GitRevRangeArray        m_selectedRevs;\r
232 //      GitRevRangeArray        m_selectedRevsOneRange;\r
233         bool                            m_bSelectionMustBeContinuous;\r
234         long                            m_logcounter;\r
235         bool                            m_bCancelled;\r
236         volatile LONG           m_bThreadRunning;\r
237         BOOL                            m_bStrict;\r
238         bool                            m_bStrictStopped;\r
239         BOOL                            m_bIncludeMerges;\r
240         git_revnum_t            m_lowestRev;\r
241         BOOL                            m_bSaveStrict;\r
242         CTGitPathList   *   m_currentChangedArray;\r
243         LogChangedPathArray m_CurrentFilteredChangedArray;\r
244         CTGitPathList           m_currentChangedPathList;\r
245         CPtrArray                       m_arShownList;\r
246         bool                            m_hasWC;\r
247         int                                     m_nSearchIndex;\r
248         bool                            m_bFilterWithRegex;\r
249         static const UINT       m_FindDialogMessage;\r
250         CFindReplaceDialog *m_pFindDialog;\r
251         CFont                           m_logFont;\r
252         CString                         m_sMessageBuf;\r
253         CSplitterControl        m_wndSplitter1;\r
254         CSplitterControl        m_wndSplitter2;\r
255         CRect                           m_DlgOrigRect;\r
256         CRect                           m_MsgViewOrigRect;\r
257         CRect                           m_LogListOrigRect;\r
258         CRect                           m_ChgOrigRect;\r
259         CString                         m_sFilterText;\r
260         int                                     m_nSelectedFilter;\r
261         volatile LONG           m_bNoDispUpdates;\r
262         CDateTimeCtrl           m_DateFrom;\r
263         CDateTimeCtrl           m_DateTo;\r
264         DWORD                           m_tFrom;\r
265         DWORD                           m_tTo;\r
266         int                                     m_limit;\r
267         int                                     m_limitcounter;\r
268         int                 m_nSortColumn;\r
269         bool                m_bAscending;\r
270         static int                      m_nSortColumnPathList;\r
271         static bool                     m_bAscendingPathList;\r
272         CRegDWORD                       m_regLastStrict;\r
273         CRegDWORD                       m_regMaxBugIDColWidth;\r
274         CButton                         m_cHidePaths;\r
275         bool                            m_bShowedAll;\r
276         CString                         m_sTitle;\r
277         bool                            m_bSelect;\r
278         bool                            m_bShowBugtraqColumn;\r
279         CString                         m_sLogInfo;\r
280         std::set<git_revnum_t> m_mergedRevs;\r
281 \r
282         CToolTips                       m_tooltips;\r
283 \r
284         CTime                           m_timFrom;\r
285         CTime                           m_timTo;\r
286         CColors                         m_Colors;\r
287         CImageList                      m_imgList;\r
288         HICON                           m_hModifiedIcon;\r
289         HICON                           m_hReplacedIcon;\r
290         HICON                           m_hAddedIcon;\r
291         HICON                           m_hDeletedIcon;\r
292 \r
293         DWORD                           m_childCounter;\r
294         DWORD                           m_maxChild;\r
295         HACCEL                          m_hAccel;\r
296 \r
297         CStoreSelection*        m_pStoreSelection;\r
298     CLogDataVector              m_logEntries;\r
299         \r
300         CXPTheme                        theme;\r
301         bool                            m_bVista;\r
302 };\r
303 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));\r
304 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));\r
305 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));\r