Do not pass big read-only parameters per value
[TortoiseGit.git] / src / TortoiseProc / FileDiffDlg.h
blobf6517648d522ed9d5adf3fac029a8624e06a8d24
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011,2013 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
21 #include "afxcmn.h"
22 #include "StandAloneDlg.h"
23 #include "Git.h"
24 #include "TGitPath.h"
25 #include "Git.h"
26 #include "HintListCtrl.h"
27 #include "Colors.h"
28 #include "FilterEdit.h"
29 #include "MessageBox.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 CFileDiffDlg(CWnd* pParent = NULL);
50 virtual ~CFileDiffDlg();
52 void SetDiff(const CTGitPath * path, const GitRev &rev1, const GitRev &rev2);
53 void SetDiff(const CTGitPath * path, const GitRev &rev1);
54 void SetDiff(const CTGitPath * path, const CString &hash1, const CString &hash2);
56 void DoBlame(bool blame = true) {m_bBlame = blame;}
58 enum { IDD = IDD_DIFFFILES };
60 protected:
61 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
62 virtual void OnCancel();
63 virtual BOOL OnInitDialog();
64 virtual BOOL PreTranslateMessage(MSG* pMsg);
65 afx_msg LRESULT OnRefLoad(WPARAM wParam, LPARAM lParam);
66 afx_msg void OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult);
67 afx_msg void OnLvnGetInfoTipFilelist(NMHDR *pNMHDR, LRESULT *pResult);
68 afx_msg void OnNMCustomdrawFilelist(NMHDR *pNMHDR, LRESULT *pResult);
69 afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
70 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
71 afx_msg void OnEnSetfocusSecondurl();
72 afx_msg void OnEnSetfocusFirsturl();
73 afx_msg void OnBnClickedSwitchleftright();
74 afx_msg void OnHdnItemclickFilelist(NMHDR *pNMHDR, LRESULT *pResult);
75 afx_msg void OnBnClickedRev1btn();
76 afx_msg void OnBnClickedRev2btn();
77 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
78 afx_msg LRESULT OnEnUpdate(WPARAM wParam, LPARAM lParam);
79 afx_msg void OnEnChangeFilter();
80 afx_msg void OnTimer(UINT_PTR nIDEvent);
81 afx_msg void OnBnClickedLog();
82 afx_msg LRESULT OnDisableButtons(WPARAM, LPARAM);
83 afx_msg LRESULT OnDiffFinished(WPARAM, LPARAM);
85 DECLARE_MESSAGE_MAP()
87 int AddEntry(const CTGitPath * fd);
88 void DoDiff(int selIndex, bool blame);
89 void DiffProps(int selIndex);
90 void SetURLLabels(int mask=0x3);
91 void ClearURLabels(int mask);
92 void Filter(CString sFilterText);
93 void CopySelectionToClipboard(BOOL isFull=FALSE);
95 void ClickRevButton(CMenuButton *button,GitRev *rev, CACEdit *edit);
97 void EnableInputControl(bool b=true);
99 int RevertSelectedItemToVersion(CString rev);
101 int FillRevFromString(GitRev *rev, CString str)
103 GitRev gitrev;
104 bool revfail = false;
107 revfail = !!gitrev.GetCommit(str);
109 catch (const char *msg)
111 CMessageBox::Show(m_hWnd, _T("Could not get commit ") + str + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
112 return -1;
115 if (revfail)
117 CString msg;
118 msg.Format(_T("Reference %s is wrong"), str);
119 CMessageBox::Show(NULL, msg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
120 return -1;
122 *rev=gitrev;
123 return 0;
126 private:
127 static UINT WM_DISABLEBUTTONS;
128 static UINT WM_DIFFFINISHED;
130 static UINT DiffThreadEntry(LPVOID pVoid);
131 UINT DiffThread();
133 static UINT LoadRefThreadEntry(LPVOID pVoid)
135 return ((CFileDiffDlg *)pVoid)->LoadRefThread();
138 UINT LoadRefThread();
140 STRING_VECTOR m_Reflist;
142 virtual BOOL Cancel() {return m_bCancelled;}
143 virtual BOOL DestroyWindow();
144 void OnTextUpdate(CACEdit *pEdit);
146 CToolTips m_tooltips;
148 CMenuButton m_cRev1Btn;
149 CMenuButton m_cRev2Btn;
150 CFilterEdit m_cFilter;
152 CMFCButton m_SwitchButton;
153 CColors m_colors;
154 CHintListCtrl m_cFileList;
155 bool m_bBlame;
156 CTGitPathList m_arFileList;
157 std::vector<CTGitPath*> m_arFilteredList;
159 CString m_strExportDir;
160 CProgressDlg * m_pProgDlg;
162 int m_nIconFolder;
164 CTGitPath m_path1;
165 GitRev m_peg;
166 GitRev m_rev1;
167 CTGitPath m_path2;
168 GitRev m_rev2;
170 volatile LONG m_bThreadRunning;
172 volatile LONG m_bLoadingRef;
174 bool m_bCancelled;
176 void Sort();
177 static bool SortCompare(const CTGitPath& Data1, const CTGitPath& Data2);
179 static BOOL m_bAscending;
180 static int m_nSortedColumn;
182 CACEdit m_ctrRev1Edit;
183 CACEdit m_ctrRev2Edit;
185 CString m_FileListText;
187 public:
188 CString m_strRev1;
189 CString m_strRev2;
190 CString m_sFilter;