1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2014 - 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"
25 #include "FilterEdit.h"
26 #include "GitStatusListCtrl.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
;
39 CShadowTree():m_hTree(NULL
),m_pParent(NULL
){}
41 CShadowTree
* GetNextSub(CString
& nameLeft
, bool bCreateIfNotExist
);
43 bool IsLeaf()const {return m_ShadowTree
.empty();}
44 CString
GetRefName()const
48 return m_pParent
->GetRefName()+"/"+m_csRefName
;
50 bool IsFrom(const wchar_t* from
)const
52 return wcsncmp(GetRefName(),from
,wcslen(from
))==0;
55 CShadowTree
* FindLeaf(CString partialRefName
);
61 CString m_csDate_Iso8601
;
64 CString m_csDescription
;
68 TShadowTreeMap m_ShadowTree
;
69 CShadowTree
* m_pParent
;
71 typedef std::vector
<CShadowTree
*> VectorPShadowTree
;
73 class CBrowseRefsDlg
: public CResizableStandAloneDialog
75 DECLARE_DYNAMIC(CBrowseRefsDlg
)
78 CBrowseRefsDlg(CString cmdPath
, CWnd
* pParent
= NULL
); // standard constructor
79 virtual ~CBrowseRefsDlg();
83 eCmd_ViewLog
= WM_APP
,
90 eCmd_DeleteRemoteBranch
,
100 eCmd_EditBranchDescription
,
102 eCmd_ViewLogRangeReachableFromOnlyOne
,
118 enum { IDD
= IDD_DIALOG_BROWSE_REFS
};
121 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
123 DECLARE_MESSAGE_MAP()
125 afx_msg
void OnBnClickedOk();
126 virtual BOOL
OnInitDialog();
128 CString
GetSelectedRef(bool onlyIfLeaf
, bool pickFirstSelIfMultiSel
= false);
130 void Refresh(CString selectRef
= CString());
132 CShadowTree
& GetTreeNode(CString refName
, CShadowTree
* pTreePos
=NULL
, bool bCreateIfNotExist
=false);
134 void FillListCtrlForTreeNode(HTREEITEM treeNode
);
136 void FillListCtrlForShadowTree(CShadowTree
* pTree
, CString refNamePrefix
, bool isFirstLevel
);
138 bool SelectRef(CString refName
, bool bExactMatch
);
140 bool ConfirmDeleteRef(VectorPShadowTree
& leafs
);
141 bool DoDeleteRefs(VectorPShadowTree
& leafs
);
142 bool DoDeleteRef(CString completeRefName
);
144 CString
GetFullRefName(CString partialRefName
);
151 STRING_VECTOR remotes
;
153 CShadowTree m_TreeRoot
;
154 CShadowTree
* m_pListCtrlRoot
;
155 CTreeCtrl m_RefTreeCtrl
;
156 CListCtrl m_ListRefLeafs
;
157 ColumnManager m_ColumnManager
;
159 CFilterEdit m_ctrlFilter
;
160 afx_msg
void OnEnChangeEditFilter();
161 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
162 DWORD m_SelectedFilters
;
163 void SetFilterCueText();
164 afx_msg LRESULT
OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
);
165 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
166 bool IsMatchFilter(const CShadowTree
* pTree
, const CString
&ref
, const CString
&filter
, bool positive
);
170 afx_msg
void OnTvnSelchangedTreeRef(NMHDR
*pNMHDR
, LRESULT
*pResult
);
172 afx_msg
void OnContextMenu(CWnd
* pWndFrom
, CPoint point
);
174 void GetSelectedLeaves(VectorPShadowTree
& selectedLeafs
);
175 void OnContextMenu_ListRefLeafs(CPoint point
);
176 void OnContextMenu_RefTreeCtrl(CPoint point
);
177 static CString
GetTwoSelectedRefs(VectorPShadowTree
& selectedLeafs
, const CString
&lastSelected
, const CString
&separator
);
179 bool AreAllFrom(VectorPShadowTree
& leafs
, const wchar_t* from
);
180 void ShowContextMenu(CPoint point
, HTREEITEM hTreePos
, VectorPShadowTree
& selectedLeafs
);
181 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
182 afx_msg
void OnLvnColumnclickListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
183 afx_msg
void OnDestroy();
184 afx_msg
void OnNMDblclkListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
185 afx_msg
void OnItemChangedListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
186 afx_msg
void OnLvnEndlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
187 afx_msg
void OnLvnBeginlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
188 afx_msg
void OnBnClickedCurrentbranch();
189 void UpdateInfoLabel();
191 CString m_sLastSelected
;
192 CString m_initialRef
;
196 bool m_bPickedRefSet
;
199 static CString
PickRef(bool returnAsHash
= false, CString initialRef
= CString(), int pickRef_Kind
= gPickRef_All
, bool pickMultipleRefsOrRange
= false);
200 static bool PickRefForCombo(CComboBoxEx
* pComboBox
, int pickRef_Kind
= gPickRef_All
);