Fixed issue #354: What about revert range of revisions from Log window?
[TortoiseGit.git] / src / TortoiseProc / FileDiffDlg.h
blob817996f3f8a310c3b14dee47ad231cefcf5f112a
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include "afxcmn.h"
21 #include "StandAloneDlg.h"
22 #include "Git.h"
23 #include "TGitPath.h"
24 //#include "Blame.h"
25 #include "Git.h"
26 #include "HintListCtrl.h"
27 #include "Colors.h"
28 #include "XPImageButton.h"
29 #include "FilterEdit.h"
30 #include "Tooltip.h"
31 #include "ProgressDlg.h"
32 #include "MenuButton.h"
33 #include "ACEdit.h"
34 #define IDT_FILTER 101
35 #define IDT_INPUT 102
37 /**
38 * \ingroup TortoiseProc
39 * Dialog which fetches and shows the difference between two urls in the
40 * repository. It shows a list of files/folders which were changed in those
41 * two revisions.
43 #define MSG_REF_LOADED (WM_USER+120)
45 class CFileDiffDlg : public CResizableStandAloneDialog
47 DECLARE_DYNAMIC(CFileDiffDlg)
48 public:
49 // class FileDiff
50 // {
51 // public:
52 // CTGitPath path;
53 // svn_client_diff_summarize_kind_t kind;
54 bool propchanged;
55 // svn_node_kind_t node;
56 // };
58 public:
59 CFileDiffDlg(CWnd* pParent = NULL);
60 virtual ~CFileDiffDlg();
62 // void SetDiff(const CTGitPath& path1, GitRev rev1, const CTGitPath& path2, GitRev rev2, svn_depth_t depth, bool ignoreancestry);
63 // void SetDiff(const CTGitPath& path, GitRev peg, GitRev rev1, GitRev rev2, svn_depth_t depth, bool ignoreancestry);
65 void SetDiff(CTGitPath * path, GitRev rev1,GitRev rev2);
66 void SetDiff(CTGitPath * path, GitRev rev1);
67 void SetDiff(CTGitPath * path, CString &hash1, CString &hash2);
69 void DoBlame(bool blame = true) {m_bBlame = blame;}
71 enum { IDD = IDD_DIFFFILES };
73 protected:
74 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
75 virtual void OnCancel();
76 virtual BOOL OnInitDialog();
77 virtual BOOL PreTranslateMessage(MSG* pMsg);
78 afx_msg LRESULT OnRefLoad(WPARAM wParam, LPARAM lParam);
79 afx_msg void OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult);
80 afx_msg void OnLvnGetInfoTipFilelist(NMHDR *pNMHDR, LRESULT *pResult);
81 afx_msg void OnNMCustomdrawFilelist(NMHDR *pNMHDR, LRESULT *pResult);
82 afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
83 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
84 afx_msg void OnEnSetfocusSecondurl();
85 afx_msg void OnEnSetfocusFirsturl();
86 afx_msg void OnBnClickedSwitchleftright();
87 afx_msg void OnHdnItemclickFilelist(NMHDR *pNMHDR, LRESULT *pResult);
88 afx_msg void OnBnClickedRev1btn();
89 afx_msg void OnBnClickedRev2btn();
90 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
91 afx_msg LRESULT OnEnUpdate(WPARAM wParam, LPARAM lParam);
92 afx_msg void OnEnChangeFilter();
93 afx_msg void OnTimer(UINT_PTR nIDEvent);
95 DECLARE_MESSAGE_MAP()
97 // virtual svn_error_t* DiffSummarizeCallback(const CTGitPath& path,
98 // svn_client_diff_summarize_kind_t kind,
99 // bool propchanged,
100 // svn_node_kind_t node);
102 int AddEntry(const CTGitPath * fd);
103 void DoDiff(int selIndex, bool blame);
104 void DiffProps(int selIndex);
105 void SetURLLabels(int mask=0x3);
106 void ClearURLabels(int mask);
107 void Filter(CString sFilterText);
108 void CopySelectionToClipboard();
110 void ClickRevButton(CMenuButton *button,GitRev *rev, CACEdit *edit);
112 void EnableInputControl(bool b=true);
114 int FillRevFromString(GitRev *rev, CString str)
116 GitRev gitrev;
117 if(gitrev.GetCommit(str))
119 CString msg;
120 msg.Format(_T("Reference %s is wrong"),str);
121 CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
122 return -1;
124 *rev=gitrev;
125 return 0;
128 private:
129 static UINT DiffThreadEntry(LPVOID pVoid);
130 UINT DiffThread();
131 static UINT ExportThreadEntry(LPVOID pVoid);
132 UINT ExportThread();
134 static UINT LoadRefThreadEntry(LPVOID pVoid)
136 return ((CFileDiffDlg *)pVoid)->LoadRefThread();
139 UINT LoadRefThread();
141 STRING_VECTOR m_Reflist;
143 virtual BOOL Cancel() {return m_bCancelled;}
145 CToolTips m_tooltips;
147 CMenuButton m_cRev1Btn;
148 CMenuButton m_cRev2Btn;
149 CFilterEdit m_cFilter;
151 CXPImageButton m_SwitchButton;
152 HICON m_hSwitchIcon;
153 CColors m_colors;
154 CHintListCtrl m_cFileList;
155 bool m_bBlame;
156 // CBlame m_blamer;
157 CTGitPathList m_arFileList;
158 std::vector<CTGitPath*> m_arFilteredList;
159 CArray<CTGitPath*, CTGitPath*> m_arSelectedFileList;
161 CString m_strExportDir;
162 CProgressDlg * m_pProgDlg;
164 int m_nIconFolder;
166 CTGitPath m_path1;
167 GitRev m_peg;
168 GitRev m_rev1;
169 CTGitPath m_path2;
170 GitRev m_rev2;
172 bool m_bIgnoreancestry;
173 bool m_bDoPegDiff;
174 volatile LONG m_bThreadRunning;
176 volatile LONG m_bLoadingRef;
178 bool m_bCancelled;
180 void Sort();
181 // static bool SortCompare(const FileDiff& Data1, const FileDiff& Data2);
183 static BOOL m_bAscending;
184 static int m_nSortedColumn;
186 CACEdit m_ctrRev1Edit;
187 CACEdit m_ctrRev2Edit;
189 CString m_FileListText;
190 public:
191 CString m_strRev1;
192 CString m_strRev2;
194 public:
195 afx_msg void OnEnChangeRev1edit();
196 afx_msg void OnEnChangeRev2edit();
197 virtual BOOL DestroyWindow();
198 void OnTextUpdate(CACEdit *pEdit);