OSDN Git Service

f63c2cba681068cdbaec95e13ca71775a79d3bdb
[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 #include <regex>\r
36 #include "GitLogList.h"\r
37 #include "GitStatusListCtrl.h"\r
38 using namespace std;\r
39 \r
40 \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
45 \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
53 \r
54 \r
55 #define LOGFILTER_TIMER         101\r
56 \r
57 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);\r
58 \r
59 /**\r
60  * \ingroup TortoiseProc\r
61  * Shows log messages of a single file or folder in a listbox. \r
62  */\r
63 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator\r
64 {\r
65         DECLARE_DYNAMIC(CLogDlg)\r
66         \r
67         friend class CStoreSelection;\r
68 \r
69 public:\r
70         CLogDlg(CWnd* pParent = NULL);   // standard constructor\r
71         virtual ~CLogDlg();\r
72 #if 0\r
73         enum\r
74         {\r
75                 LOGLIST_GRAPH,\r
76                 LOGLIST_ACTION,\r
77                 LOGLIST_MESSAGE,\r
78                 LOGLIST_AUTHOR,\r
79                 LOGLIST_DATE,\r
80                 LOGLIST_BUG,\r
81                 LOGLIST_MESSAGE_MAX=250\r
82         };\r
83 #endif\r
84         enum\r
85         {\r
86                 FILELIST_ACTION,\r
87                 FILELIST_ADD,\r
88                 FILELIST_DEL,\r
89                 FILELIST_PATH\r
90         };\r
91 \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
101 \r
102 //      const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}\r
103 \r
104 // Dialog Data\r
105         enum { IDD = IDD_LOGMESSAGE };\r
106 \r
107 protected:\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
112 \r
113         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
114 \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
127 \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
139         \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         static  void LogCallBack(void *data, int cur){((CLogDlg*)data)->LogRunStatus(cur);}\r
159         void    LogRunStatus(int cur);\r
160 \r
161         DECLARE_MESSAGE_MAP()\r
162 \r
163 private:\r
164         \r
165 \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
184         \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
196 \r
197         /**\r
198          * Extracts part of commit message suitable for displaying in revision list.\r
199          */\r
200         CString MakeShortMessage(const CString& message);\r
201 //      inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }\r
202 \r
203 \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
206 \r
207         void ResizeAllListCtrlCols();\r
208 \r
209         void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point);\r
210         void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point);\r
211 public:\r
212         CWnd *                          m_pNotifyWindow;\r
213         ProjectProperties       m_ProjectProperties;\r
214         WORD                            m_wParam;\r
215 private:\r
216         //HFONT                         m_boldFont;\r
217         CString                         m_sRelativeRoot;\r
218         CString                         m_sRepositoryRoot;\r
219         CString                         m_sSelfRelativeURL;\r
220         CString                         m_sURL;\r
221         CString                         m_sUUID;    ///< empty if the log cache is not used\r
222         CGitLogList                     m_LogList;\r
223         //CListCtrl                     m_ChangedFileListCtrl;\r
224         \r
225         CGitStatusListCtrl  m_ChangedFileListCtrl;\r
226 \r
227         CFilterEdit                     m_cFilter;\r
228         CProgressCtrl           m_LogProgress;\r
229         CMenuButton                     m_btnShow;\r
230         CTGitPath                       m_path;\r
231         CTGitPath                       m_mergePath;\r
232         GitRev                          m_pegrev;\r
233         GitRev                          m_startrev;\r
234         GitRev                          m_LogRevision;\r
235         GitRev                          m_endrev;\r
236         //GitRev                                m_wcRev;\r
237 //      GitRevRangeArray        m_selectedRevs;\r
238 //      GitRevRangeArray        m_selectedRevsOneRange;\r
239         bool                            m_bSelectionMustBeContinuous;\r
240         long                            m_logcounter;\r
241         bool                            m_bCancelled;\r
242         \r
243         BOOL                            m_bStrict;\r
244 \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
252         bool                            m_hasWC;\r
253         int                                     m_nSearchIndex;\r
254         bool                            m_bFilterWithRegex;\r
255         static const UINT       m_FindDialogMessage;\r
256         CFindReplaceDialog *m_pFindDialog;\r
257         CFont                           m_logFont;\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
270         DWORD                           m_tFrom;\r
271         DWORD                           m_tTo;\r
272         int                                     m_limit;\r
273         int                                     m_limitcounter;\r
274         int                 m_nSortColumn;\r
275         bool                m_bAscending;\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
281         bool                            m_bShowedAll;\r
282         CString                         m_sTitle;\r
283         bool                            m_bSelect;\r
284         bool                            m_bShowBugtraqColumn;\r
285         CString                         m_sLogInfo;\r
286         std::set<git_revnum_t> m_mergedRevs;\r
287 \r
288         CToolTips                       m_tooltips;\r
289 \r
290         CTime                           m_timFrom;\r
291         CTime                           m_timTo;\r
292         CColors                         m_Colors;\r
293         CImageList                      m_imgList;\r
294 #if 0\r
295         HICON                           m_hModifiedIcon;\r
296         HICON                           m_hReplacedIcon;\r
297         HICON                           m_hAddedIcon;\r
298         HICON                           m_hDeletedIcon;\r
299 #endif\r
300 \r
301         DWORD                           m_childCounter;\r
302         DWORD                           m_maxChild;\r
303         HACCEL                          m_hAccel;\r
304 \r
305 \r
306     \r
307         \r
308         //CXPTheme                      theme;\r
309         bool                            m_bVista;\r
310 };\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