1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2015 - 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.
22 #include "StandAloneDlg.h"
23 #include "FilterEdit.h"
24 #include "GitStatusListCtrl.h"
27 const int gPickRef_Head
= 1;
28 const int gPickRef_Tag
= 2;
29 const int gPickRef_Remote
= 4;
30 const int gPickRef_All
= gPickRef_Head
| gPickRef_Tag
| gPickRef_Remote
;
31 const int gPickRef_NoTag
= gPickRef_All
& ~gPickRef_Tag
;
36 typedef std::map
<CString
,CShadowTree
> TShadowTreeMap
;
38 CShadowTree():m_hTree(NULL
),m_pParent(NULL
){}
40 CShadowTree
* GetNextSub(CString
& nameLeft
, bool bCreateIfNotExist
);
42 bool IsLeaf()const {return m_ShadowTree
.empty();}
43 CString
GetRefName()const
47 return m_pParent
->GetRefName()+"/"+m_csRefName
;
51 * from = refs/heads, refname = refs/heads/master => true
52 * from = refs/heads, refname = refs/heads => true
53 * from = refs/heads, refname = refs/headsh => false
54 * from = refs/heads/, refname = refs/heads/master => true
55 * from = refs/heads/, refname = refs/heads => false
57 bool IsFrom(const wchar_t* from
)const
59 CString name
= GetRefName();
60 int len
= (int)wcslen(from
);
61 if (from
[len
- 1] != '/' && wcsncmp(name
, from
, len
) == 0)
63 if (len
== name
.GetLength())
65 if (len
< name
.GetLength() && name
[len
] == '/')
70 return wcsncmp(name
, from
, len
) == 0;
73 CString
GetRefsHeadsName() const
75 return GetRefName().Mid(11); // len = 11 refs/heads/
78 CShadowTree
* FindLeaf(CString partialRefName
);
86 CString m_csDescription
;
90 TShadowTreeMap m_ShadowTree
;
91 CShadowTree
* m_pParent
;
93 typedef std::vector
<CShadowTree
*> VectorPShadowTree
;
95 class CBrowseRefsDlg
: public CResizableStandAloneDialog
97 DECLARE_DYNAMIC(CBrowseRefsDlg
)
100 CBrowseRefsDlg(CString cmdPath
, CWnd
* pParent
= NULL
); // standard constructor
101 virtual ~CBrowseRefsDlg();
105 eCmd_ViewLog
= WM_APP
,
112 eCmd_DeleteRemoteBranch
,
121 eCmd_DeleteRemoteTag
,
122 eCmd_EditBranchDescription
,
124 eCmd_ViewLogRangeReachableFromOnlyOne
,
142 enum { IDD
= IDD_DIALOG_BROWSE_REFS
};
145 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
147 DECLARE_MESSAGE_MAP()
149 afx_msg
void OnBnClickedOk();
150 virtual BOOL
OnInitDialog();
152 CString
GetSelectedRef(bool onlyIfLeaf
, bool pickFirstSelIfMultiSel
= false);
154 void Refresh(CString selectRef
= CString());
156 CShadowTree
& GetTreeNode(CString refName
, CShadowTree
* pTreePos
=NULL
, bool bCreateIfNotExist
=false);
158 void FillListCtrlForTreeNode(HTREEITEM treeNode
);
160 void FillListCtrlForShadowTree(CShadowTree
* pTree
, CString refNamePrefix
, bool isFirstLevel
);
162 bool SelectRef(CString refName
, bool bExactMatch
);
164 bool ConfirmDeleteRef(VectorPShadowTree
& leafs
);
165 bool DoDeleteRefs(VectorPShadowTree
& leafs
);
166 bool DoDeleteRef(CString completeRefName
);
168 CString
GetFullRefName(CString partialRefName
);
175 STRING_VECTOR remotes
;
177 CShadowTree m_TreeRoot
;
178 CShadowTree
* m_pListCtrlRoot
;
179 CTreeCtrl m_RefTreeCtrl
;
180 CListCtrl m_ListRefLeafs
;
181 ColumnManager m_ColumnManager
;
183 CFilterEdit m_ctrlFilter
;
184 afx_msg
void OnEnChangeEditFilter();
185 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
186 DWORD m_SelectedFilters
;
187 void SetFilterCueText();
188 afx_msg LRESULT
OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
);
189 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
190 bool IsMatchFilter(const CShadowTree
* pTree
, const CString
&ref
, const CString
&filter
, bool positive
);
194 afx_msg
void OnTvnSelchangedTreeRef(NMHDR
*pNMHDR
, LRESULT
*pResult
);
196 afx_msg
void OnContextMenu(CWnd
* pWndFrom
, CPoint point
);
198 void GetSelectedLeaves(VectorPShadowTree
& selectedLeafs
);
199 void OnContextMenu_ListRefLeafs(CPoint point
);
200 void OnContextMenu_RefTreeCtrl(CPoint point
);
201 static CString
GetTwoSelectedRefs(VectorPShadowTree
& selectedLeafs
, const CString
&lastSelected
, const CString
&separator
);
203 bool AreAllFrom(VectorPShadowTree
& leafs
, const wchar_t* from
);
204 void ShowContextMenu(CPoint point
, HTREEITEM hTreePos
, VectorPShadowTree
& selectedLeafs
);
205 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
206 afx_msg
void OnLvnColumnclickListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
207 afx_msg
void OnDestroy();
208 afx_msg
void OnNMDblclkListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
209 afx_msg
void OnItemChangedListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
210 afx_msg
void OnLvnEndlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
211 afx_msg
void OnLvnBeginlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
212 afx_msg
void OnBnClickedCurrentbranch();
213 afx_msg
void OnBnClickedIncludeNestedRefs();
214 BOOL m_bIncludeNestedRefs
;
215 CRegDWORD m_regIncludeNestedRefs
;
216 void UpdateInfoLabel();
218 CString m_sLastSelected
;
219 CString m_initialRef
;
223 bool m_bPickedRefSet
;
225 DWORD m_DateFormat
; // DATE_SHORTDATE or DATE_LONGDATE
226 bool m_bRelativeTimes
; // Show relative times
229 static CString
PickRef(bool returnAsHash
= false, CString initialRef
= CString(), int pickRef_Kind
= gPickRef_All
, bool pickMultipleRefsOrRange
= false);
230 static bool PickRefForCombo(CComboBoxEx
* pComboBox
, int pickRef_Kind
= gPickRef_All
);