1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2016 - 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"
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
;
42 CShadowTree
* GetNextSub(CString
& nameLeft
, bool bCreateIfNotExist
);
44 bool IsLeaf()const {return m_ShadowTree
.empty();}
45 CString
GetRefName()const
49 return m_pParent
->GetRefName()+"/"+m_csRefName
;
53 * from = refs/heads, refname = refs/heads/master => true
54 * from = refs/heads, refname = refs/heads => true
55 * from = refs/heads, refname = refs/headsh => false
56 * from = refs/heads/, refname = refs/heads/master => true
57 * from = refs/heads/, refname = refs/heads => false
59 bool IsFrom(const wchar_t* from
)const
61 CString name
= GetRefName();
62 int len
= (int)wcslen(from
);
63 if (from
[len
- 1] != '/' && wcsncmp(name
, from
, len
) == 0)
65 if (len
== name
.GetLength())
67 if (len
< name
.GetLength() && name
[len
] == '/')
72 return wcsncmp(name
, from
, len
) == 0;
75 CString
GetRefsHeadsName() const
77 return GetRefName().Mid(11); // len = 11 refs/heads/
80 CShadowTree
* FindLeaf(CString partialRefName
);
88 CString m_csDescription
;
92 TShadowTreeMap m_ShadowTree
;
93 CShadowTree
* m_pParent
;
95 typedef std::vector
<CShadowTree
*> VectorPShadowTree
;
97 class CBrowseRefsDlg
: public CResizableStandAloneDialog
99 DECLARE_DYNAMIC(CBrowseRefsDlg
)
102 CBrowseRefsDlg(CString cmdPath
, CWnd
* pParent
= nullptr); // standard constructor
103 virtual ~CBrowseRefsDlg();
107 eCmd_ViewLog
= WM_APP
,
114 eCmd_DeleteRemoteBranch
,
123 eCmd_DeleteRemoteTag
,
124 eCmd_EditBranchDescription
,
126 eCmd_ViewLogRangeReachableFromOnlyOne
,
144 enum { IDD
= IDD_DIALOG_BROWSE_REFS
};
147 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
149 DECLARE_MESSAGE_MAP()
151 afx_msg
void OnBnClickedOk();
152 virtual BOOL
OnInitDialog();
154 CString
GetSelectedRef(bool onlyIfLeaf
, bool pickFirstSelIfMultiSel
= false);
156 void Refresh(CString selectRef
= CString());
158 CShadowTree
& GetTreeNode(CString refName
, CShadowTree
* pTreePos
= nullptr, bool bCreateIfNotExist
= false);
160 void FillListCtrlForTreeNode(HTREEITEM treeNode
);
162 void FillListCtrlForShadowTree(CShadowTree
* pTree
, CString refNamePrefix
, bool isFirstLevel
);
164 bool SelectRef(CString refName
, bool bExactMatch
);
166 bool ConfirmDeleteRef(VectorPShadowTree
& leafs
);
167 bool DoDeleteRefs(VectorPShadowTree
& leafs
);
168 bool DoDeleteRef(CString completeRefName
);
170 CString
GetFullRefName(CString partialRefName
);
177 STRING_VECTOR remotes
;
179 CShadowTree m_TreeRoot
;
180 CShadowTree
* m_pListCtrlRoot
;
181 CTreeCtrl m_RefTreeCtrl
;
182 CResizableColumnsListCtrl
<CListCtrl
> m_ListRefLeafs
;
184 CFilterEdit m_ctrlFilter
;
185 afx_msg
void OnEnChangeEditFilter();
186 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
187 DWORD m_SelectedFilters
;
188 void SetFilterCueText();
189 afx_msg LRESULT
OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
);
190 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
191 bool IsMatchFilter(const CShadowTree
* pTree
, const CString
&ref
, const CString
&filter
, bool positive
);
195 CRegDWORD m_regCurrSortCol
;
196 CRegDWORD m_regCurrSortDesc
;
197 afx_msg
void OnTvnSelchangedTreeRef(NMHDR
*pNMHDR
, LRESULT
*pResult
);
199 afx_msg
void OnContextMenu(CWnd
* pWndFrom
, CPoint point
);
201 void GetSelectedLeaves(VectorPShadowTree
& selectedLeafs
);
202 void OnContextMenu_ListRefLeafs(CPoint point
);
203 void OnContextMenu_RefTreeCtrl(CPoint point
);
204 static CString
GetTwoSelectedRefs(VectorPShadowTree
& selectedLeafs
, const CString
&lastSelected
, const CString
&separator
);
206 bool AreAllFrom(VectorPShadowTree
& leafs
, const wchar_t* from
);
207 void ShowContextMenu(CPoint point
, HTREEITEM hTreePos
, VectorPShadowTree
& selectedLeafs
);
208 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
209 afx_msg
void OnLvnColumnclickListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
210 afx_msg
void OnDestroy();
211 afx_msg
void OnNMDblclkListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
212 afx_msg
void OnItemChangedListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
213 afx_msg
void OnLvnEndlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
214 afx_msg
void OnLvnBeginlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
215 afx_msg
void OnBnClickedCurrentbranch();
216 afx_msg
void OnBnClickedIncludeNestedRefs();
217 BOOL m_bIncludeNestedRefs
;
218 CRegDWORD m_regIncludeNestedRefs
;
219 void UpdateInfoLabel();
221 CString m_sLastSelected
;
222 CString m_initialRef
;
226 bool m_bPickedRefSet
;
228 DWORD m_DateFormat
; // DATE_SHORTDATE or DATE_LONGDATE
229 bool m_bRelativeTimes
; // Show relative times
232 static CString
PickRef(bool returnAsHash
= false, CString initialRef
= CString(), int pickRef_Kind
= gPickRef_All
, bool pickMultipleRefsOrRange
= false);
233 static bool PickRefForCombo(CComboBoxEx
* pComboBox
, int pickRef_Kind
= gPickRef_All
);