Don't import ogdf namespace
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.h
blob723c6824f14b735701ef8e9e28f5c67b3d7c0d11
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009, 2012-2017 - 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.
20 #pragma once
21 #include "StandAloneDlg.h"
22 #include "HistoryCombo.h"
23 #include "MenuButton.h"
24 #include "registry.h"
25 #include "BranchCombox.h"
26 #include "GitLoglist.h"
27 #include "GitProgressList.h"
28 #include "GitRefCompareList.h"
29 #include "GitTagCompareList.h"
30 #include "SyncTabCtrl.h"
31 #include "GestureEnabledControl.h"
33 // CSyncDlg dialog
34 #define IDC_SYNC_TAB 0x1000000
36 #define IDC_CMD_LOG 0x1
37 #define IDC_IN_LOGLIST 0x2
38 #define IDC_IN_CHANGELIST 0x3
39 #define IDC_IN_CONFLICT 0x4
40 #define IDC_OUT_LOGLIST 0x5
41 #define IDC_OUT_CHANGELIST 0x6
42 #define IDC_CMD_GIT_PROG 0x7
43 #define IDC_REFLIST 0x8
44 #define IDC_TAGCOMPARELIST 0x9
46 #define IDT_INPUT 108
48 class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox
50 DECLARE_DYNAMIC(CSyncDlg)
52 public:
53 CSyncDlg(CWnd* pParent = nullptr); // standard constructor
54 virtual ~CSyncDlg();
56 // Dialog Data
57 enum { IDD = IDD_SYNC };
59 enum { GIT_COMMAND_PUSH,
60 GIT_COMMAND_PULL,
61 GIT_COMMAND_FETCH,
62 GIT_COMMAND_FETCHANDREBASE,
63 GIT_COMMAND_SUBMODULE,
64 GIT_COMMAND_REMOTE,
65 GIT_COMMAND_STASH
67 protected:
68 virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
69 BRANCH_COMBOX_EVENT_HANDLE();
71 virtual BOOL OnInitDialog() override;
72 afx_msg void OnBnClickedButtonManage();
73 virtual BOOL PreTranslateMessage(MSG* pMsg) override;
74 afx_msg void OnCbnEditchangeComboboxex();
75 afx_msg void OnBnClickedButtonPull();
76 afx_msg void OnBnClickedButtonPush();
77 afx_msg void OnBnClickedButtonApply();
78 afx_msg void OnBnClickedButtonEmail();
79 afx_msg void OnTimer(UINT_PTR nIDEvent);
80 afx_msg void OnDestroy();
81 afx_msg LRESULT OnThemeChanged();
83 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
84 CComPtr<ITaskbarList3> m_pTaskbarList;
86 int m_CurrentCmd;
88 CRegDWORD m_regPullButton;
89 CRegDWORD m_regPushButton;
90 CRegDWORD m_regSubmoduleButton;
91 CRegDWORD m_regAutoLoadPutty;
93 CSyncTabCtrl m_ctrlTabCtrl;
95 BOOL m_bInited;
97 CGitLogList m_OutLogList;
98 CGitLogList m_InLogList;
99 CGitProgressList m_GitProgressList;
100 std::unique_ptr<ProgressCommand> progressCommand;
102 CGitStatusListCtrl m_OutChangeFileList;
103 CGitStatusListCtrl m_InChangeFileList;
104 CGitStatusListCtrl m_ConflictFileList;
106 CGestureEnabledControlTmpl<CRichEditCtrl> m_ctrlCmdOut;
107 CGitRefCompareList m_refList;
108 CGitTagCompareList m_tagCompareList;
110 CTGitPathList m_arOutChangeList;
111 CTGitPathList m_arInChangeList;
113 int m_CmdOutCurrentPos;
115 CWinThread* m_pThread;
117 volatile LONG m_bBlock;
118 CGitGuardedByteArray m_Databuf;
119 int m_BufStart;
121 void ParserCmdOutput(char ch);
123 virtual void LocalBranchChange() override { FetchOutList(); };
124 virtual void RemoteBranchChange() override {};
126 void ShowTab(int windowid)
128 this->m_ctrlTabCtrl.ShowTab(windowid-1);
129 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);
132 void FetchOutList(bool force=false);
134 bool IsURL();
136 virtual void SetRemote(CString remote) override
138 if(!remote.IsEmpty())
140 int index=this->m_ctrlURL.FindStringExact(0,remote);
141 if(index>=0)
143 m_ctrlURL.SetCurSel(index);
144 return;
146 this->m_ctrlURL.AddString(remote);
150 std::vector<CString> m_GitCmdList;
151 STRING_VECTOR m_remotelist;
153 volatile bool m_bAbort;
154 bool m_bDone;
155 ULONGLONG m_startTick;
156 bool m_bWantToExit;
158 int m_GitCmdStatus;
160 CStringA m_LogText;
161 CString m_OutLocalBranch;
162 CString m_OutRemoteBranch;
164 CGitHash m_oldHash;
165 CGitHash m_oldRemoteHash;
166 MAP_HASH_NAME m_oldHashMap;
167 MAP_HASH_NAME m_newHashMap;
169 void ShowProgressCtrl(bool bShow=true);
170 void ShowInputCtrl(bool bShow=true);
171 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
172 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
174 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
175 LRESULT OnProgCmdFinish(WPARAM wParam, LPARAM lParam);
176 void FillNewRefMap();
177 void RunPostAction();
178 void UpdateCombox()
180 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
181 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
182 this->m_ctrlURL.GetWindowText(this->m_strURL);
183 m_strRemoteBranch=m_strRemoteBranch.Trim();
186 void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,
187 CString rev1, CString rev2)
189 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);
190 pCtrlList->m_Rev1=rev1;
191 pCtrlList->m_Rev2=rev2;
192 pCtrlList->SetEmptyString(CString(MAKEINTRESOURCE(IDS_COMPAREREV_NODIFF)));
193 pCtrlList->UpdateWithGitPathList(*pGitList);
194 pCtrlList->Show(GITSLC_SHOWALL);
195 return;
198 void ShowInCommits(const CString& friendname);
199 void PullComplete();
200 void FetchComplete();
201 void StashComplete();
203 DECLARE_MESSAGE_MAP()
205 public:
206 BOOL m_bAutoLoadPuttyKey;
207 BOOL m_bForce;
208 CString m_strURL;
209 int m_seq;
211 protected:
212 static UINT ProgressThreadEntry(LPVOID pVoid) { return reinterpret_cast<CSyncDlg*>(pVoid)->ProgressThread(); };
213 UINT ProgressThread();
215 CHistoryCombo m_ctrlURL;
216 CButton m_ctrlDumyButton;
217 CMenuButton m_ctrlPull;
218 CMenuButton m_ctrlPush;
219 CStatic m_ctrlStatus;
220 CMenuButton m_ctrlSubmodule;
221 CMenuButton m_ctrlStash;
222 CProgressCtrl m_ctrlProgress;
223 CAnimateCtrl m_ctrlAnimate;
224 CStatic m_ctrlProgLabel;
225 int m_iPullRebase;
227 void EnableControlButton(bool bEnabled=true);
228 afx_msg void OnBnClickedButtonCommit();
230 virtual void OnOK() override;
231 virtual void OnCancel() override;
232 void Refresh();
233 bool AskSetTrackedBranch();
235 afx_msg void OnBnClickedButtonSubmodule();
236 afx_msg void OnBnClickedButtonStash();
237 afx_msg void OnBnClickedCheckForce();
238 afx_msg void OnBnClickedLog();
239 afx_msg void OnEnscrollLog();
240 afx_msg void OnEnLinkLog(NMHDR* pNMHDR, LRESULT* pResult);
242 friend class CSyncTabCtrl;