1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2013 - 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"
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
;
49 bool IsFrom(const wchar_t* from
)const
51 return wcsncmp(GetRefName(),from
,wcslen(from
))==0;
54 CShadowTree
* FindLeaf(CString partialRefName
);
59 CString m_csDate_Iso8601
;
62 CString m_csDescription
;
66 TShadowTreeMap m_ShadowTree
;
67 CShadowTree
* m_pParent
;
69 typedef std::vector
<CShadowTree
*> VectorPShadowTree
;
71 class CBrowseRefsDlg
: public CResizableStandAloneDialog
73 DECLARE_DYNAMIC(CBrowseRefsDlg
)
76 CBrowseRefsDlg(CString cmdPath
, CWnd
* pParent
= NULL
); // standard constructor
77 virtual ~CBrowseRefsDlg();
81 eCmd_ViewLog
= WM_APP
,
88 eCmd_DeleteRemoteBranch
,
97 eCmd_EditBranchDescription
,
99 eCmd_ViewLogRangeReachableFromOnlyOne
,
113 enum { IDD
= IDD_DIALOG_BROWSE_REFS
};
116 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
118 DECLARE_MESSAGE_MAP()
120 afx_msg
void OnBnClickedOk();
121 virtual BOOL
OnInitDialog();
123 CString
GetSelectedRef(bool onlyIfLeaf
, bool pickFirstSelIfMultiSel
= false);
125 void Refresh(CString selectRef
= CString());
127 CShadowTree
& GetTreeNode(CString refName
, CShadowTree
* pTreePos
=NULL
, bool bCreateIfNotExist
=false);
129 void FillListCtrlForTreeNode(HTREEITEM treeNode
);
131 void FillListCtrlForShadowTree(CShadowTree
* pTree
, CString refNamePrefix
, bool isFirstLevel
);
133 bool SelectRef(CString refName
, bool bExactMatch
);
135 bool ConfirmDeleteRef(VectorPShadowTree
& leafs
);
136 bool DoDeleteRefs(VectorPShadowTree
& leafs
, bool bForce
);
137 bool DoDeleteRef(CString completeRefName
, bool bForce
);
139 CString
GetFullRefName(CString partialRefName
);
146 CShadowTree m_TreeRoot
;
147 CShadowTree
* m_pListCtrlRoot
;
148 CTreeCtrl m_RefTreeCtrl
;
149 CListCtrl m_ListRefLeafs
;
151 CFilterEdit m_ctrlFilter
;
152 afx_msg
void OnEnChangeEditFilter();
153 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
154 DWORD m_SelectedFilters
;
155 void SetFilterCueText();
156 afx_msg LRESULT
OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
);
157 bool IsMatchFilter(const CShadowTree
* pTree
, const CString
&ref
, const CString
&filter
);
161 afx_msg
void OnTvnSelchangedTreeRef(NMHDR
*pNMHDR
, LRESULT
*pResult
);
163 afx_msg
void OnContextMenu(CWnd
* pWndFrom
, CPoint point
);
165 void OnContextMenu_ListRefLeafs(CPoint point
);
166 void OnContextMenu_RefTreeCtrl(CPoint point
);
168 bool AreAllFrom(VectorPShadowTree
& leafs
, const wchar_t* from
);
169 void ShowContextMenu(CPoint point
, HTREEITEM hTreePos
, VectorPShadowTree
& selectedLeafs
);
170 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
171 afx_msg
void OnLvnColumnclickListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
172 afx_msg
void OnDestroy();
173 afx_msg
void OnNMDblclkListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
174 afx_msg
void OnItemChangedListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
175 afx_msg
void OnLvnEndlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
176 afx_msg
void OnLvnBeginlabeleditListRefLeafs(NMHDR
*pNMHDR
, LRESULT
*pResult
);
178 CString m_sLastSelected
;
179 CString m_initialRef
;
185 static CString
PickRef(bool returnAsHash
= false, CString initialRef
= CString(), int pickRef_Kind
= gPickRef_All
, bool pickMultipleRefs
= false);
186 static bool PickRefForCombo(CComboBoxEx
* pComboBox
, int pickRef_Kind
= gPickRef_All
);