SyncDlg: Do not double load out lists when remote branch is changed
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.h
blob111b07782edb5172579ae5d36ad9964f0a7d3031
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2012 - 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 "afxcmn.h"
22 #include "afxwin.h"
24 #include "StandAloneDlg.h"
25 #include "HistoryCombo.h"
26 #include "MenuButton.h"
27 #include "registry.h"
28 #include "BranchCombox.h"
29 #include "GitLoglist.h"
30 #include "Win7.h"
32 // CSyncDlg dialog
33 #define IDC_SYNC_TAB 0x1000000
35 #define IDC_CMD_LOG 0x1
36 #define IDC_IN_LOGLIST 0x2
37 #define IDC_IN_CHANGELIST 0x3
38 #define IDC_IN_CONFLICT 0x4
39 #define IDC_OUT_LOGLIST 0x5
40 #define IDC_OUT_CHANGELIST 0x6
42 #define IDT_INPUT 108
44 class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox
46 DECLARE_DYNAMIC(CSyncDlg)
48 public:
49 CSyncDlg(CWnd* pParent = NULL); // standard constructor
50 virtual ~CSyncDlg();
52 // Dialog Data
53 enum { IDD = IDD_SYNC };
55 enum { GIT_COMMAND_PUSH,
56 GIT_COMMAND_PULL,
57 GIT_COMMAND_FETCH,
58 GIT_COMMAND_FETCHANDREBASE,
59 GIT_COMMAND_SUBMODULE,
60 GIT_COMMAND_REMOTE
62 protected:
63 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
64 BRANCH_COMBOX_EVENT_HANDLE();
66 virtual BOOL OnInitDialog();
67 afx_msg void OnBnClickedButtonManage();
68 virtual BOOL PreTranslateMessage(MSG* pMsg);
69 afx_msg void OnCbnEditchangeComboboxex();
70 afx_msg void OnBnClickedButtonPull();
71 afx_msg void OnBnClickedButtonPush();
72 afx_msg void OnBnClickedButtonApply();
73 afx_msg void OnBnClickedButtonEmail();
74 afx_msg void OnTimer(UINT_PTR nIDEvent);
76 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
77 CComPtr<ITaskbarList3> m_pTaskbarList;
79 int m_CurrentCmd;
81 CRegDWORD m_regPullButton;
82 CRegDWORD m_regPushButton;
83 CRegDWORD m_regSubmoduleButton;
84 CRegDWORD m_regAutoLoadPutty;
86 CMFCTabCtrl m_ctrlTabCtrl;
88 CToolTips m_tooltips;
90 BOOL m_bInited;
92 CGitLogList m_OutLogList;
93 CGitLogList m_InLogList;
95 CGitStatusListCtrl m_OutChangeFileList;
96 CGitStatusListCtrl m_InChangeFileList;
97 CGitStatusListCtrl m_ConflictFileList;
99 CRichEditCtrl m_ctrlCmdOut;
101 CTGitPathList m_arOutChangeList;
102 CTGitPathList m_arInChangeList;
104 int m_CmdOutCurrentPos;
106 CWinThread* m_pThread;
108 volatile LONG m_bBlock;
110 void ParserCmdOutput(char ch);
112 virtual void LocalBranchChange(){FetchOutList();};
113 virtual void RemoteBranchChange(){};
115 void ShowTab(int windowid)
117 this->m_ctrlTabCtrl.ShowTab(windowid-1);
118 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);
121 void FetchOutList(bool force=false);
123 bool IsURL();
125 void SetRemote(CString remote)
127 if(!remote.IsEmpty())
129 int index=this->m_ctrlURL.FindStringExact(0,remote);
130 if(index>=0)
132 m_ctrlURL.SetCurSel(index);
133 return;
135 this->m_ctrlURL.AddString(remote);
139 std::vector<CString> m_GitCmdList;
141 bool m_bAbort;
143 int m_GitCmdStatus;
145 CStringA m_LogText;
146 CString m_OutLocalBranch;
147 CString m_OutRemoteBranch;
149 CGitHash m_oldHash;
151 void ShowProgressCtrl(bool bShow=true);
152 void ShowInputCtrl(bool bShow=true);
153 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
154 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
156 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
158 void UpdateCombox()
160 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
161 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
162 this->m_ctrlURL.GetWindowText(this->m_strURL);
163 m_strRemoteBranch=m_strRemoteBranch.Trim();
166 void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,
167 CString &rev1,CString &rev2)
169 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);
170 pCtrlList->m_Rev1=rev1;
171 pCtrlList->m_Rev2=rev2;
172 pCtrlList->Show(0,*pGitList);
173 pCtrlList->SetEmptyString(CString(_T("No changed file")));
174 return;
177 void PullComplete();
178 void FetchComplete();
180 DECLARE_MESSAGE_MAP()
182 public:
183 BOOL m_bAutoLoadPuttyKey;
184 BOOL m_bForce;
185 CString m_strURL;
187 protected:
188 int m_Gitverion;
190 static UINT ProgressThreadEntry(LPVOID pVoid){ return ((CSyncDlg*)pVoid) ->ProgressThread(); };
191 UINT ProgressThread();
193 CHistoryCombo m_ctrlURL;
194 CButton m_ctrlDumyButton;
195 CMenuButton m_ctrlPull;
196 CMenuButton m_ctrlPush;
197 CStatic m_ctrlStatus;
198 CMenuButton m_ctrlSubmodule;
199 CProgressCtrl m_ctrlProgress;
200 CAnimateCtrl m_ctrlAnimate;
202 void EnableControlButton(bool bEnabled=true);
203 afx_msg void OnBnClickedButtonCommit();
205 virtual void OnOK();
206 void Refresh();
208 afx_msg void OnBnClickedButtonSubmodule();
209 afx_msg void OnLvnInLogListColumnClick(NMHDR *pNMHDR, LRESULT *pResult);