OSDN Git Service

Fix Email patch body show subject problem
[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 \r
39 using namespace std;\r
40 \r
41 \r
42 #define MERGE_REVSELECTSTART     1\r
43 #define MERGE_REVSELECTEND       2\r
44 #define MERGE_REVSELECTSTARTEND  3              ///< both\r
45 #define MERGE_REVSELECTMINUSONE  4              ///< first with N-1\r
46 \r
47 \r
48 #define LOGFILTER_TIMER         101\r
49 \r
50 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);\r
51 \r
52 /**\r
53  * \ingroup TortoiseProc\r
54  * Shows log messages of a single file or folder in a listbox. \r
55  */\r
56 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator\r
57 {\r
58         DECLARE_DYNAMIC(CLogDlg)\r
59         \r
60         friend class CStoreSelection;\r
61 \r
62 public:\r
63         CLogDlg(CWnd* pParent = NULL);   // standard constructor\r
64         virtual ~CLogDlg();\r
65 #if 0\r
66         enum\r
67         {\r
68                 LOGLIST_GRAPH,\r
69                 LOGLIST_ACTION,\r
70                 LOGLIST_MESSAGE,\r
71                 LOGLIST_AUTHOR,\r
72                 LOGLIST_DATE,\r
73                 LOGLIST_BUG,\r
74                 LOGLIST_MESSAGE_MAX=250\r
75         };\r
76 #endif\r
77         enum\r
78         {\r
79                 FILELIST_ACTION,\r
80                 FILELIST_ADD,\r
81                 FILELIST_DEL,\r
82                 FILELIST_PATH\r
83         };\r
84 \r
85         void SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit);\r
86         void SetIncludeMerge(bool bInclude = true) {m_bIncludeMerges = bInclude;}\r
87         void SetProjectPropertiesPath(const CTGitPath& path) {m_ProjectProperties.ReadProps(path);}\r
88         bool IsThreadRunning() {return !!m_LogList.m_bThreadRunning;}\r
89         void SetDialogTitle(const CString& sTitle) {m_sTitle = sTitle;}\r
90         void SetSelect(bool bSelect) {m_bSelect = bSelect;}\r
91         void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}\r
92         void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}\r
93         void SetMergePath(const CTGitPath& mergepath) {m_mergePath = mergepath;}\r
94         /**\r
95          * Provides selected commit hash if available, call after OK return from here\r
96          * Empty if none\r
97         **/\r
98         CString GetSelectedHash(){ return m_sSelectedHash; }\r
99 \r
100 //      const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}\r
101 \r
102 // Dialog Data\r
103         enum { IDD = IDD_LOGMESSAGE };\r
104 \r
105 protected:\r
106         //implement the virtual methods from Git base class\r
107         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
108         virtual BOOL Cancel();\r
109         virtual bool Validate(LPCTSTR string);\r
110 \r
111         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
112 \r
113         afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);\r
114         afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);\r
115         afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);\r
116         afx_msg LRESULT OnLogListLoading(WPARAM wParam, LPARAM lParam);\r
117 \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 OnBnClickShowWholeProject();\r
137         afx_msg void OnBnClickedHidepaths();\r
138         afx_msg void OnBnClickedAllBranch();\r
139         afx_msg void OnBnClickedCheckStoponcopy();\r
140         \r
141         afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);\r
142         afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);\r
143         afx_msg void OnSize(UINT nType, int cx, int cy);\r
144         afx_msg void OnBnClickedFirstParent();\r
145         afx_msg void OnBnClickedRefresh();\r
146         afx_msg void OnRefresh();\r
147         afx_msg void OnFind();\r
148         afx_msg void OnFocusFilter();\r
149         afx_msg void OnEditCopy();\r
150 \r
151         virtual void OnCancel();\r
152         virtual void OnOK();\r
153         virtual BOOL OnInitDialog();\r
154         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
155 \r
156         void    FillLogMessageCtrl(bool bShow = true);\r
157         void    DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);\r
158 \r
159         static  void LogCallBack(void *data, int cur){((CLogDlg*)data)->LogRunStatus(cur);}\r
160         void    LogRunStatus(int cur);\r
161 \r
162         DECLARE_MESSAGE_MAP()\r
163 \r
164 private:\r
165         \r
166 \r
167         void Refresh (bool autoGoOnline = false);\r
168         BOOL IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev);\r
169         BOOL Open(bool bOpenWith, CString changedpath, git_revnum_t rev);\r
170         void EditAuthor(const CLogDataVector& logs);\r
171         void EditLogMessage(int index);\r
172         void DoSizeV1(int delta);\r
173         void DoSizeV2(int delta);\r
174         void AdjustMinSize();\r
175         void SetSplitterRange();\r
176         void SetFilterCueText();\r
177         \r
178         void CopySelectionToClipBoard();\r
179         void CopyChangedSelectionToClipBoard();\r
180         CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);\r
181     void SortShownListArray();\r
182         \r
183     void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);\r
184         void SortByColumn(int nSortColumn, bool bAscending);\r
185         \r
186         void EnableOKButton();\r
187         void GetAll(bool bIsShowProjectOrBranch = false);\r
188         void UpdateLogInfoLabel();\r
189         void SaveSplitterPos();\r
190         bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase);\r
191         void CheckRegexpTooltip();\r
192         void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);\r
193         void DiffSelectedFile();\r
194         void DiffSelectedRevWithPrevious();\r
195         void SetDlgTitle(bool bOffline);\r
196         CString GetAbsoluteUrlFromRelativeUrl(const CString& url);\r
197 \r
198         /**\r
199          * Extracts part of commit message suitable for displaying in revision list.\r
200          */\r
201         CString MakeShortMessage(const CString& message);\r
202 //      inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }\r
203 \r
204 \r
205         virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r
206         static int __cdecl      SortCompare(const void * pElem1, const void * pElem2);  ///< sort callback function\r
207 \r
208         void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point);\r
209         void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point);\r
210 public:\r
211         CWnd *                          m_pNotifyWindow;\r
212         ProjectProperties       m_ProjectProperties;\r
213         WORD                            m_wParam;\r
214 private:\r
215         //HFONT                         m_boldFont;\r
216         CString                         m_sRelativeRoot;\r
217         CString                         m_sRepositoryRoot;\r
218         CString                         m_sSelfRelativeURL;\r
219         CString                         m_sURL;\r
220         CString                         m_sUUID;    ///< empty if the log cache is not used\r
221         CGitLogList                     m_LogList;\r
222         CGitStatusListCtrl  m_ChangedFileListCtrl;\r
223         CFilterEdit                     m_cFilter;\r
224         CProgressCtrl           m_LogProgress;\r
225         CMenuButton                     m_btnShow;\r
226         CMenuButton                     m_btnShowWholeProject;\r
227         CTGitPath                       m_path;\r
228         CTGitPath                       m_mergePath;\r
229         GitRev                          m_pegrev;\r
230         GitRev                          m_startrev;\r
231         GitRev                          m_LogRevision;\r
232         GitRev                          m_endrev;\r
233         //GitRev                                m_wcRev;\r
234 //      GitRevRangeArray        m_selectedRevs;\r
235 //      GitRevRangeArray        m_selectedRevsOneRange;\r
236         CString                         m_sSelectedHash;        // set to selected commit hash on OK if appropriate\r
237         bool                            m_bSelectionMustBeContinuous;\r
238         bool                            m_bSelectionMustBeSingle;\r
239         long                            m_logcounter;\r
240         bool                            m_bCancelled;\r
241         \r
242         BOOL                            m_bIncludeMerges;\r
243         BOOL                            m_bFirstParent;\r
244         BOOL                            m_bAllBranch;\r
245         BOOL                            m_bWholeProject;\r
246 \r
247         git_revnum_t            m_lowestRev;\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         \r
267         //volatile LONG         m_bNoDispUpdates;\r
268         CDateTimeCtrl           m_DateFrom;\r
269         CDateTimeCtrl           m_DateTo;\r
270         int                                     m_limit;\r
271         int                                     m_limitcounter;\r
272         int                 m_nSortColumn;\r
273         bool                m_bAscending;\r
274         static int                      m_nSortColumnPathList;\r
275         static bool                     m_bAscendingPathList;\r
276         //CRegDWORD                     m_regMaxBugIDColWidth;\r
277         CButton                         m_cHidePaths;\r
278         bool                            m_bShowedAll;\r
279         CString                         m_sTitle;\r
280         bool                            m_bSelect;\r
281         bool                            m_bShowBugtraqColumn;\r
282         CString                         m_sLogInfo;\r
283         std::set<git_revnum_t> m_mergedRevs;\r
284 \r
285         CToolTips                       m_tooltips;\r
286 \r
287         CColors                         m_Colors;\r
288         CImageList                      m_imgList;\r
289 #if 0\r
290         HICON                           m_hModifiedIcon;\r
291         HICON                           m_hReplacedIcon;\r
292         HICON                           m_hAddedIcon;\r
293         HICON                           m_hDeletedIcon;\r
294 #endif\r
295 \r
296         DWORD                           m_childCounter;\r
297         DWORD                           m_maxChild;\r
298         HACCEL                          m_hAccel;\r
299 \r
300 \r
301     \r
302         \r
303         //CXPTheme                      theme;\r
304         bool                            m_bVista;\r
305 };\r
306 static UINT WM_REVSELECTED = RegisterWindowMessage(_T("TORTOISEGit_REVSELECTED_MSG"));\r
307 static UINT WM_REVLIST = RegisterWindowMessage(_T("TORTOISEGit_REVLIST_MSG"));\r
308 static UINT WM_REVLISTONERANGE = RegisterWindowMessage(_T("TORTOISEGit_REVLISTONERANGE_MSG"));\r