Prepare release and bump version numbers to 2.17.0.2
[TortoiseGit.git] / src / TortoiseProc / FileDiffDlg.h
blob48c54e171290bffecdaeff67f87365d6216c62a2
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2017, 2019-2020, 2023-2024 - 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 "GitRev.h"
25 #include "TGitPath.h"
26 #include "HintCtrl.h"
27 #include "Colors.h"
28 #include "FilterEdit.h"
29 #include "ProgressDlg.h"
30 #include "MenuButton.h"
31 #include "ACEdit.h"
32 #include "GestureEnabledControl.h"
33 #include "LogDlgFileFilter.h"
34 #include "PatchViewDlg.h"
35 #include "HyperLink.h"
36 #include "ThemeControls.h"
38 #define IDT_FILTER 101
39 #define IDT_INPUT 102
40 #define IDT_FILLPATCHVTIMER 103
42 /**
43 * \ingroup TortoiseProc
44 * Dialog which fetches and shows the difference between two urls in the
45 * repository. It shows a list of files/folders which were changed in those
46 * two revisions.
48 #define MSG_REF_LOADED (WM_USER+120)
50 class CFileDiffDlg : public CResizableStandAloneDialog, IHasPatchView
52 DECLARE_DYNAMIC(CFileDiffDlg)
53 public:
54 CFileDiffDlg(CWnd* pParent = nullptr);
55 virtual ~CFileDiffDlg();
57 void SetDiff(const CTGitPath* path, const GitRev& baseRev1, const GitRev& rev2);
58 void SetDiff(const CTGitPath* path, const GitRev& baseRev1);
59 void SetDiff(const CTGitPath* path, const CString& baseHash1, const CString& hash2);
61 void DoBlame(bool blame = true) {m_bBlame = blame;}
63 enum { IDD = IDD_DIFFFILES };
65 protected:
66 void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
67 void OnCancel() override;
68 void OnOK() override;
69 BOOL OnInitDialog() override;
70 BOOL PreTranslateMessage(MSG* pMsg) override;
71 afx_msg LRESULT OnRefLoad(WPARAM wParam, LPARAM lParam);
72 afx_msg void OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult);
73 afx_msg void OnLvnGetInfoTipFilelist(NMHDR *pNMHDR, LRESULT *pResult);
74 afx_msg void OnNMCustomdrawFilelist(NMHDR *pNMHDR, LRESULT *pResult);
75 afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
76 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
77 afx_msg void OnEnSetfocusSecondurl();
78 afx_msg void OnEnSetfocusFirsturl();
79 afx_msg void OnBnClickedSwitchleftright();
80 afx_msg void OnHdnItemclickFilelist(NMHDR *pNMHDR, LRESULT *pResult);
81 afx_msg void OnBnClickedRev1btn();
82 afx_msg void OnBnClickedRev2btn();
83 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
84 afx_msg LRESULT OnEnUpdate(WPARAM wParam, LPARAM lParam);
85 afx_msg void OnEnChangeFilter();
86 afx_msg void OnTimer(UINT_PTR nIDEvent);
87 afx_msg void OnBnClickedDiffoption();
88 afx_msg void OnBnClickedLog();
89 afx_msg LRESULT OnDisableButtons(WPARAM, LPARAM);
90 afx_msg LRESULT OnDiffFinished(WPARAM, LPARAM);
91 afx_msg void OnLvnBegindrag(NMHDR* pNMHDR, LRESULT* pResult);
93 DECLARE_MESSAGE_MAP()
95 int AddEntry(const CTGitPath * fd);
96 void DoDiff(int selIndex, bool blame);
97 void SetURLLabels(int mask=0x3);
98 void ClearURLabels(int mask);
99 void Filter(const CString& sFilterText);
100 void CopySelectionToClipboard(BOOL isFull=FALSE);
102 void ClickRevButton(CMenuButton *button,GitRev *rev, CACEdit *edit);
104 void EnableInputControl(bool b=true);
106 int RevertSelectedItemToVersion(const CGitHash& rev, bool isOldVersion);
108 bool CheckMultipleDiffs();
110 int FillRevFromString(GitRev* rev, const CString& str)
112 GitRev gitrev;
113 if (gitrev.GetCommit(str))
115 MessageBox(gitrev.GetLastErr(), L"TortoiseGit", MB_ICONERROR);
116 return -1;
118 gitrev.ApplyMailmap();
119 *rev=gitrev;
120 return 0;
123 private:
124 static UINT WM_DISABLEBUTTONS;
125 static UINT WM_DIFFFINISHED;
127 static UINT DiffThreadEntry(LPVOID pVoid);
128 UINT DiffThread();
130 static UINT LoadRefThreadEntry(LPVOID pVoid)
132 return static_cast<CFileDiffDlg*>(pVoid)->LoadRefThread();
135 UINT LoadRefThread();
137 STRING_VECTOR m_Reflist;
139 BOOL DestroyWindow() override;
140 void OnTextUpdate(CACEdit *pEdit);
142 CMenuButton m_cRev1Btn;
143 CMenuButton m_cRev2Btn;
144 CFilterEdit m_cFilter;
145 std::atomic<std::shared_ptr<CLogDlgFileFilter>> m_filter;
147 CMenuButton m_cDiffOptionsBtn;
149 CThemeMFCButton m_SwitchButton;
150 CColors m_colors;
151 CFont m_font;
152 CGestureEnabledControlTmpl<CHintCtrl<CListCtrl>> m_cFileList;
153 bool m_bBlame = false;
154 CTGitPathList m_arFileList;
155 std::vector<const CTGitPath*> m_arFilteredList;
157 CString m_strExportDir;
159 int m_nIconFolder = 0;
161 bool m_bIsBare = false;
162 CTGitPath m_path;
163 GitRev m_rev1;
164 GitRev m_rev2;
166 volatile LONG m_bThreadRunning = FALSE;
168 volatile LONG m_bLoadingRef = FALSE;
170 void Sort();
171 static bool SortCompare(const CTGitPath& Data1, const CTGitPath& Data2);
173 static BOOL m_bAscending;
174 static int m_nSortedColumn;
176 CACEdit m_ctrRev1Edit;
177 CACEdit m_ctrRev2Edit;
179 bool m_bIgnoreSpaceAtEol = false;
180 bool m_bIgnoreSpaceChange = false;
181 bool m_bIgnoreAllSpace = false;
182 bool m_bIgnoreBlankLines = false;
183 bool m_bCommonAncestorDiff = false;
185 CHyperLink m_ctrlShowPatch;
186 afx_msg void OnStnClickedViewPatch();
187 CPatchViewDlg m_patchViewdlg;
188 void FillPatchView(bool onlySetTimer = false);
189 CWnd* GetPatchViewParentWnd() override { return this; }
190 void TogglePatchView() override;
191 afx_msg void OnFileListItemChanged(NMHDR* pNMHDR, LRESULT* pResult);
192 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
193 afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
195 public:
196 CString m_strRev1;
197 CString m_strRev2;
198 CString m_sFilter;