1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2018 - 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.
21 #include "StandAloneDlg.h"
22 #include "FilterEdit.h"
23 #include "ResizableColumnsListCtrl.h"
25 #include "HistoryCombo.h"
26 #include "GestureEnabledControl.h"
28 const int gPickRef_Head
= 1;
29 const int gPickRef_Tag
= 2;
30 const int gPickRef_Remote
= 4;
31 const int gPickRef_All
= gPickRef_Head
| gPickRef_Tag
| gPickRef_Remote
;
32 const int gPickRef_NoTag
= gPickRef_All
& ~gPickRef_Tag
;
37 typedef std::map
<CString
,CShadowTree
> TShadowTreeMap
;
44 CShadowTree
* GetNextSub(CString
& nameLeft
, bool bCreateIfNotExist
);
46 bool IsLeaf()const {return m_ShadowTree
.empty();}
47 CString
GetRefName()const
51 return m_pParent
->GetRefName()+"/"+m_csRefName
;
55 * from = refs/heads, refname = refs/heads/master => true
56 * from = refs/heads, refname = refs/heads => true
57 * from = refs/heads, refname = refs/headsh => false
58 * from = refs/heads/, refname = refs/heads/master => true
59 * from = refs/heads/, refname = refs/heads => false
61 bool IsFrom(const wchar_t* from
)const
63 CString name
= GetRefName();
64 int len
= (int)wcslen(from
);
65 if (from
[len
- 1] != '/' && wcsncmp(name
, from
, len
) == 0)
67 if (len
== name
.GetLength())
69 if (len
< name
.GetLength() && name
[len
] == '/')
74 return wcsncmp(name
, from
, len
) == 0;
77 CString
GetRefsHeadsName() const
79 return GetRefName().Mid((int)wcslen(L
"refs/heads/"));
82 CShadowTree
* FindLeaf(CString partialRefName
);
90 CString m_csDescription
;
94 TShadowTreeMap m_ShadowTree
;
95 CShadowTree
* m_pParent
;
97 typedef std::vector
<CShadowTree
*> VectorPShadowTree
;
99 class CBrowseRefsDlg
: public CResizableStandAloneDialog
101 DECLARE_DYNAMIC(CBrowseRefsDlg
)
104 CBrowseRefsDlg(CString cmdPath
, CWnd
* pParent
= nullptr); // standard constructor
105 virtual ~CBrowseRefsDlg();
109 eCmd_ViewLog
= WM_APP
,
116 eCmd_DeleteRemoteBranch
,
125 eCmd_DeleteRemoteTag
,
126 eCmd_EditBranchDescription
,
128 eCmd_ViewLogRangeReachableFromOnlyOne
,
149 enum { IDD
= IDD_BROWSE_REFS
};
152 virtual void DoDataExchange(CDataExchange
* pDX
) override
; // DDX/DDV support
154 DECLARE_MESSAGE_MAP()
156 afx_msg
void OnBnClickedOk();
157 virtual BOOL
OnInitDialog() override
;
159 CString
GetSelectedRef(bool onlyIfLeaf
, bool pickFirstSelIfMultiSel
= false);
161 void Refresh(CString selectRef
= CString());
163 CShadowTree
& GetTreeNode(CString refName
, CShadowTree
* pTreePos
= nullptr, bool bCreateIfNotExist
= false);
165 void FillListCtrlForTreeNode(HTREEITEM treeNode
);
167 void FillListCtrlForShadowTree(CShadowTree
* pTree
, CString refNamePrefix
, bool isFirstLevel
);
169 bool SelectRef(CString refName
, bool bExactMatch
);
171 bool ConfirmDeleteRef(VectorPShadowTree
& leafs
);
172 bool DoDeleteRefs(VectorPShadowTree
& leafs
);
173 bool DoDeleteRef(CString completeRefName
);
175 CString
GetFullRefName(CString partialRefName
);
177 CShadowTree
* GetListEntry(int index
);
178 CShadowTree
* GetTreeEntry(HTREEITEM treeItem
);
185 STRING_VECTOR remotes
;
187 CShadowTree m_TreeRoot
;
188 CShadowTree
* m_pListCtrlRoot
;
189 CGestureEnabledControlTmpl
<CTreeCtrl
> m_RefTreeCtrl
;
190 CGestureEnabledControlTmpl
<CResizableColumnsListCtrl
<CListCtrl
>> m_ListRefLeafs
;
192 CFilterEdit m_ctrlFilter
;
193 afx_msg
void OnEnChangeEditFilter();
194 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
195 DWORD m_SelectedFilters
;
196 void SetFilterCueText();
197 afx_msg LRESULT
OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
);
198 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
199 bool IsMatchFilter(const CShadowTree
* pTree
, const CString
&ref
, const CString
&filter
, bool positive
);
200 CComboBox m_cBranchFilter
;
204 CRegDWORD m_regCurrSortCol
;
205 CRegDWORD m_regCurrSortDesc
;
206 afx_msg
void OnTvnSelchangedTreeRef(NMHDR
*pNMHDR
, LRESULT
*pResult
);
208 afx_msg
void OnContextMenu(CWnd
* pWndFrom
, CPoint point
);
210 void GetSelectedLeaves(VectorPShadowTree
& selectedLeafs
);
211 void OnContextMenu_ListRefLeafs(CPoint point
);
212 void OnContextMenu_RefTreeCtrl(CPoint point
);
213 static CString
GetTwoSelectedRefs(VectorPShadowTree
& selectedLeafs
, const CString
&lastSelected
, const CString
&separator
);
215 bool AreAllFrom(VectorPShadowTree
& leafs
, const wchar_t* from
);
216 void ShowContextMenu(CPoint point
, HTREEITEM hTreePos
, VectorPShadowTree
& selectedLeafs
);
217 virtual BOOL
PreTranslateMessage(MSG
* pMsg
) override
;
218 afx_msg
void OnLvnColumnclickListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
219 afx_msg
void OnDestroy();
220 afx_msg
void OnNMDblclkListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
221 afx_msg
void OnItemChangedListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
222 afx_msg
void OnLvnEndlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
223 afx_msg
void OnLvnBeginlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
224 afx_msg
void OnBnClickedCurrentbranch();
225 afx_msg
void OnBnClickedIncludeNestedRefs();
226 afx_msg
void OnCbnSelchangeBrowseRefsBranchfilter();
227 BOOL m_bIncludeNestedRefs
;
228 CRegDWORD m_regIncludeNestedRefs
;
229 void UpdateInfoLabel();
231 CString m_sLastSelected
;
232 CString m_initialRef
;
237 bool m_bPickedRefSet
;
239 DWORD m_DateFormat
; // DATE_SHORTDATE or DATE_LONGDATE
240 bool m_bRelativeTimes
; // Show relative times
243 static CString
PickRef(bool returnAsHash
= false, CString initialRef
= CString(), int pickRef_Kind
= gPickRef_All
, bool pickMultipleRefsOrRange
= false);
244 static bool PickRefForCombo(CHistoryCombo
& refComboBox
, int pickRef_Kind
= gPickRef_All
, int useShortName
= gPickRef_Head
);