1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 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.
23 #include "StandAloneDlg.h"
26 const int gPickRef_Head
= 1;
27 const int gPickRef_Tag
= 2;
28 const int gPickRef_Remote
= 4;
29 const int gPickRef_All
= gPickRef_Head
| gPickRef_Tag
| gPickRef_Remote
;
30 const int gPickRef_NoTag
= gPickRef_All
& ~gPickRef_Tag
;
35 typedef std::map
<CString
,CShadowTree
> TShadowTreeMap
;
37 CShadowTree():m_hTree(NULL
),m_pParent(NULL
){}
39 CShadowTree
* GetNextSub(CString
& nameLeft
, bool bCreateIfNotExist
);
41 bool IsLeaf()const {return m_ShadowTree
.empty();}
42 CString
GetRefName()const
46 return m_pParent
->GetRefName()+"/"+m_csRefName
;
48 bool IsFrom(const wchar_t* from
)const
50 return wcsncmp(GetRefName(),from
,wcslen(from
))==0;
53 CShadowTree
* FindLeaf(CString partialRefName
);
58 CString m_csDate_Iso8601
;
64 TShadowTreeMap m_ShadowTree
;
65 CShadowTree
* m_pParent
;
67 typedef std::vector
<CShadowTree
*> VectorPShadowTree
;
69 class CBrowseRefsDlg
: public CResizableStandAloneDialog
71 DECLARE_DYNAMIC(CBrowseRefsDlg
)
74 CBrowseRefsDlg(CString cmdPath
, CWnd
* pParent
= NULL
); // standard constructor
75 virtual ~CBrowseRefsDlg();
79 eCmd_ViewLog
= WM_APP
,
85 eCmd_DeleteRemoteBranch
,
104 enum { IDD
= IDD_DIALOG_BROWSE_REFS
};
107 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
109 DECLARE_MESSAGE_MAP()
111 afx_msg
void OnBnClickedOk();
112 virtual BOOL
OnInitDialog();
114 CString
GetSelectedRef(bool onlyIfLeaf
, bool pickFirstSelIfMultiSel
= false);
116 void Refresh(CString selectRef
= CString());
118 CShadowTree
& GetTreeNode(CString refName
, CShadowTree
* pTreePos
=NULL
, bool bCreateIfNotExist
=false);
120 void FillListCtrlForTreeNode(HTREEITEM treeNode
);
122 void FillListCtrlForShadowTree(CShadowTree
* pTree
, CString refNamePrefix
, bool isFirstLevel
);
124 bool SelectRef(CString refName
, bool bExactMatch
);
126 bool ConfirmDeleteRef(VectorPShadowTree
& leafs
);
127 bool DoDeleteRefs(VectorPShadowTree
& leafs
, bool bForce
);
128 bool DoDeleteRef(CString completeRefName
, bool bForce
);
130 CString
GetFullRefName(CString partialRefName
);
137 CShadowTree m_TreeRoot
;
138 CShadowTree
* m_pListCtrlRoot
;
139 CTreeCtrl m_RefTreeCtrl
;
140 CListCtrl m_ListRefLeafs
;
143 afx_msg
void OnEnChangeEditFilter();
144 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
148 afx_msg
void OnTvnSelchangedTreeRef(NMHDR
*pNMHDR
, LRESULT
*pResult
);
150 afx_msg
void OnContextMenu(CWnd
* pWndFrom
, CPoint point
);
152 void OnContextMenu_ListRefLeafs(CPoint point
);
153 void OnContextMenu_RefTreeCtrl(CPoint point
);
155 bool AreAllFrom(VectorPShadowTree
& leafs
, const wchar_t* from
);
156 void ShowContextMenu(CPoint point
, HTREEITEM hTreePos
, VectorPShadowTree
& selectedLeafs
);
157 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
158 afx_msg
void OnLvnColumnclickListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
159 afx_msg
void OnDestroy();
160 afx_msg
void OnNMDblclkListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
161 afx_msg
void OnLvnEndlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
162 afx_msg
void OnLvnBeginlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
164 CString m_initialRef
;
169 static CString
PickRef(bool returnAsHash
= false, CString initialRef
= CString(), int pickRef_Kind
= gPickRef_All
);
170 static bool PickRefForCombo(CComboBoxEx
* pComboBox
, int pickRef_Kind
= gPickRef_All
);