OSDN Git Service

Fixed issue #150: When pushing, 'remote' should default to the tracked branch, or...
[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 #include "HyperLink.h"\r
39 \r
40 using namespace std;\r
41 \r
42 \r
43 #define MERGE_REVSELECTSTART     1\r
44 #define MERGE_REVSELECTEND       2\r
45 #define MERGE_REVSELECTSTARTEND  3              ///< both\r
46 #define MERGE_REVSELECTMINUSONE  4              ///< first with N-1\r
47 \r
48 \r
49 #define LOGFILTER_TIMER         101\r
50 \r
51 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);\r
52 \r
53 /**\r
54  * \ingroup TortoiseProc\r
55  * Shows log messages of a single file or folder in a listbox. \r
56  */\r
57 class CLogDlg : public CResizableStandAloneDialog, IFilterEditValidator\r
58 {\r
59         DECLARE_DYNAMIC(CLogDlg)\r
60         \r
61         friend class CStoreSelection;\r
62 \r
63 public:\r
64         CLogDlg(CWnd* pParent = NULL);   // standard constructor\r
65         virtual ~CLogDlg();\r
66 #if 0\r
67         enum\r
68         {\r
69                 LOGLIST_GRAPH,\r
70                 LOGLIST_ACTION,\r
71                 LOGLIST_MESSAGE,\r
72                 LOGLIST_AUTHOR,\r
73                 LOGLIST_DATE,\r
74                 LOGLIST_BUG,\r
75                 LOGLIST_MESSAGE_MAX=250\r
76         };\r
77 #endif\r
78         enum\r
79         {\r
80                 FILELIST_ACTION,\r
81                 FILELIST_ADD,\r
82                 FILELIST_DEL,\r
83                 FILELIST_PATH\r
84         };\r
85 \r
86         void SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit);\r
87         void SetIncludeMerge(bool bInclude = true) {m_bIncludeMerges = bInclude;}\r
88         void SetProjectPropertiesPath(const CTGitPath& path) {m_ProjectProperties.ReadProps(path);}\r
89         bool IsThreadRunning() {return !!m_LogList.m_bThreadRunning;}\r
90         void SetDialogTitle(const CString& sTitle) {m_sTitle = sTitle;}\r
91         void SetSelect(bool bSelect) {m_bSelect = bSelect;}\r
92         void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;}\r
93         void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;}\r
94         void SetMergePath(const CTGitPath& mergepath) {m_mergePath = mergepath;}\r
95         void SetStartRef(const CString& StartRef);\r
96         void ShowStartRef();\r
97         /**\r
98          * Provides selected commit hash if available, call after OK return from here\r
99          * Empty if none\r
100         **/\r
101         CString GetSelectedHash(){ return m_sSelectedHash; }\r
102 \r
103 //      const GitRevRangeArray& GetSelectedRevRanges() {return m_selectedRevs;}\r
104 \r
105 // Dialog Data\r
106         enum { IDD = IDD_LOGMESSAGE };\r
107 \r
108 protected:\r
109         //implement the virtual methods from Git base class\r
110         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
111         virtual BOOL Cancel();\r
112         virtual bool Validate(LPCTSTR string);\r
113 \r
114         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
115 \r
116         afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);\r
117         afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);\r
118         afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);\r
119         afx_msg LRESULT OnLogListLoading(WPARAM wParam, LPARAM lParam);\r
120 \r
121         afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);\r
122         afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);\r
123         afx_msg void OnBnClickedGetall();\r
124         afx_msg void OnNMDblclkChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);\r
125         afx_msg void OnNMDblclkLoglist(NMHDR *pNMHDR, LRESULT *pResult);\r
126         afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);\r
127         afx_msg void OnBnClickedHelp();\r
128         afx_msg void OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult);\r
129         afx_msg void OnBnClickedStatbutton();\r
130 \r
131         afx_msg void OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);\r
132         afx_msg void OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);\r
133         afx_msg void OnEnChangeSearchedit();\r
134         afx_msg void OnTimer(UINT_PTR nIDEvent);\r
135         afx_msg void OnDtnDatetimechangeDateto(NMHDR *pNMHDR, LRESULT *pResult);\r
136         afx_msg void OnDtnDatetimechangeDatefrom(NMHDR *pNMHDR, LRESULT *pResult);\r
137         afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);\r
138         afx_msg void OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult);\r
139         afx_msg void OnBnClickShowWholeProject();\r
140         afx_msg void OnBnClickedHidepaths();\r
141         afx_msg void OnBnClickedAllBranch();\r
142         afx_msg void OnBnClickedBrowseRef();\r
143         afx_msg void OnBnClickedCheckStoponcopy();\r
144         \r
145         afx_msg void OnDtnDropdownDatefrom(NMHDR *pNMHDR, LRESULT *pResult);\r
146         afx_msg void OnDtnDropdownDateto(NMHDR *pNMHDR, LRESULT *pResult);\r
147         afx_msg void OnSize(UINT nType, int cx, int cy);\r
148         afx_msg void OnBnClickedFirstParent();\r
149         afx_msg void OnBnClickedRefresh();\r
150         afx_msg void OnRefresh();\r
151         afx_msg void OnFind();\r
152         afx_msg void OnFocusFilter();\r
153         afx_msg void OnEditCopy();\r
154 \r
155         virtual void OnCancel();\r
156         virtual void OnOK();\r
157         virtual BOOL OnInitDialog();\r
158         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
159 \r
160         void    FillLogMessageCtrl(bool bShow = true);\r
161         void    DoDiffFromLog(INT_PTR selIndex, GitRev *rev1, GitRev *rev2, bool blame, bool unified);\r
162 \r
163         static  void LogCallBack(void *data, int cur){((CLogDlg*)data)->LogRunStatus(cur);}\r
164         void    LogRunStatus(int cur);\r
165 \r
166         DECLARE_MESSAGE_MAP()\r
167 \r
168 private:\r
169         \r
170 \r
171         void Refresh (bool autoGoOnline = false);\r
172         BOOL IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev);\r
173         BOOL Open(bool bOpenWith, CString changedpath, git_revnum_t rev);\r
174         void EditAuthor(const CLogDataVector& logs);\r
175         void EditLogMessage(int index);\r
176         void DoSizeV1(int delta);\r
177         void DoSizeV2(int delta);\r
178         void AdjustMinSize();\r
179         void SetSplitterRange();\r
180         void SetFilterCueText();\r
181         \r
182         void CopySelectionToClipBoard();\r
183         void CopyChangedSelectionToClipBoard();\r
184         CTGitPathList GetChangedPathsFromSelectedRevisions(bool bRelativePaths = false, bool bUseFilter = true);\r
185     void SortShownListArray();\r
186         \r
187     void SetSortArrow(CListCtrl * control, int nColumn, bool bAscending);\r
188         void SortByColumn(int nSortColumn, bool bAscending);\r
189         \r
190         void EnableOKButton();\r
191         void GetAll(bool bIsShowProjectOrBranch = false);\r
192         void UpdateLogInfoLabel();\r
193         void SaveSplitterPos();\r
194         bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase);\r
195         void CheckRegexpTooltip();\r
196         void GetChangedPaths(std::vector<CString>& changedpaths, std::vector<LogChangedPath*>& changedlogpaths);\r
197         void DiffSelectedFile();\r
198         void DiffSelectedRevWithPrevious();\r
199         void SetDlgTitle(bool bOffline);\r
200         CString GetAbsoluteUrlFromRelativeUrl(const CString& url);\r
201 \r
202         /**\r
203          * Extracts part of commit message suitable for displaying in revision list.\r
204          */\r
205         CString MakeShortMessage(const CString& message);\r
206 //      inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }\r
207 \r
208 \r
209         virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r
210         static int __cdecl      SortCompare(const void * pElem1, const void * pElem2);  ///< sort callback function\r
211 \r
212         void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point);\r
213         void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point);\r
214 public:\r
215         CWnd *                          m_pNotifyWindow;\r
216         ProjectProperties       m_ProjectProperties;\r
217         WORD                            m_wParam;\r
218 private:\r
219         //HFONT                         m_boldFont;\r
220         CString                         m_sRelativeRoot;\r
221         CString                         m_sRepositoryRoot;\r
222         CString                         m_sSelfRelativeURL;\r
223         CString                         m_sURL;\r
224         CString                         m_sUUID;    ///< empty if the log cache is not used\r
225         CGitLogList                     m_LogList;\r
226         CGitStatusListCtrl  m_ChangedFileListCtrl;\r
227         CFilterEdit                     m_cFilter;\r
228         CHyperLink                      m_staticRef;\r
229         CProgressCtrl           m_LogProgress;\r
230         CMenuButton                     m_btnShow;\r
231         CMenuButton                     m_btnShowWholeProject;\r
232         CTGitPath                       m_path;\r
233         CTGitPath                       m_mergePath;\r
234         GitRev                          m_pegrev;\r
235         GitRev                          m_startrev;\r
236         GitRev                          m_LogRevision;\r
237         GitRev                          m_endrev;\r
238         //GitRev                                m_wcRev;\r
239 //      GitRevRangeArray        m_selectedRevs;\r
240 //      GitRevRangeArray        m_selectedRevsOneRange;\r
241         CString                         m_sSelectedHash;        // set to selected commit hash on OK if appropriate\r
242         bool                            m_bSelectionMustBeContinuous;\r
243         bool                            m_bSelectionMustBeSingle;\r
244         long                            m_logcounter;\r
245         bool                            m_bCancelled;\r
246         \r
247         BOOL                            m_bIncludeMerges;\r
248         BOOL                            m_bFirstParent;\r
249         BOOL                            m_bAllBranch;\r
250         BOOL                            m_bWholeProject;\r
251 \r
252         git_revnum_t            m_lowestRev;\r
253         CTGitPathList   *   m_currentChangedArray;\r
254         LogChangedPathArray m_CurrentFilteredChangedArray;\r
255         CTGitPathList           m_currentChangedPathList;\r
256         //CPtrArray                     m_arShownList;\r
257         bool                            m_hasWC;\r
258         int                                     m_nSearchIndex;\r
259         bool                            m_bFilterWithRegex;\r
260         static const UINT       m_FindDialogMessage;\r
261         CFindReplaceDialog *m_pFindDialog;\r
262         CFont                           m_logFont;\r
263         CString                         m_sMessageBuf;\r
264         CSplitterControl        m_wndSplitter1;\r
265         CSplitterControl        m_wndSplitter2;\r
266         CRect                           m_DlgOrigRect;\r
267         CRect                           m_MsgViewOrigRect;\r
268         CRect                           m_LogListOrigRect;\r
269         CRect                           m_ChgOrigRect;\r
270 //      CString                         m_sFilterText;\r
271         \r
272         //volatile LONG         m_bNoDispUpdates;\r
273         CDateTimeCtrl           m_DateFrom;\r
274         CDateTimeCtrl           m_DateTo;\r
275         int                                     m_limit;\r
276         int                                     m_limitcounter;\r
277         int                 m_nSortColumn;\r
278         bool                m_bAscending;\r
279         static int                      m_nSortColumnPathList;\r
280         static bool                     m_bAscendingPathList;\r
281         //CRegDWORD                     m_regMaxBugIDColWidth;\r
282         CButton                         m_cHidePaths;\r
283         bool                            m_bShowedAll;\r
284         CString                         m_sTitle;\r
285         bool                            m_bSelect;\r
286         bool                            m_bShowBugtraqColumn;\r
287         CString                         m_sLogInfo;\r
288         std::set<git_revnum_t> m_mergedRevs;\r
289 \r
290         CToolTips                       m_tooltips;\r
291 \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