RefBrowser: Display tracked branch
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blobc8aa1d5f6e63ca5438bcb283ad8f843bb82d0f39
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.
19 #pragma once
21 #include "Git.h"
22 #include <map>
23 #include "StandAloneDlg.h"
24 #include "afxwin.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;
34 class CShadowTree
36 public:
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
46 if(m_pParent==NULL)
47 return m_csRefName;
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);
57 CString m_csRefName;
58 CString m_csUpstream;
59 CString m_csRefHash;
60 CString m_csDate;
61 CString m_csDate_Iso8601;
62 CString m_csAuthor;
63 CString m_csSubject;
64 CString m_csDescription;
66 HTREEITEM m_hTree;
68 TShadowTreeMap m_ShadowTree;
69 CShadowTree* m_pParent;
71 typedef std::vector<CShadowTree*> VectorPShadowTree;
73 class CBrowseRefsDlg : public CResizableStandAloneDialog
75 DECLARE_DYNAMIC(CBrowseRefsDlg)
77 public:
78 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
79 virtual ~CBrowseRefsDlg();
81 enum eCmd
83 eCmd_ViewLog = WM_APP,
84 eCmd_AddRemote,
85 eCmd_ManageRemotes,
86 eCmd_CreateBranch,
87 eCmd_CreateTag,
88 eCmd_DeleteAllTags,
89 eCmd_DeleteBranch,
90 eCmd_DeleteRemoteBranch,
91 eCmd_DeleteTag,
92 eCmd_ShowReflog,
93 eCmd_Diff,
94 eCmd_Fetch,
95 eCmd_Switch,
96 eCmd_Merge,
97 eCmd_Rename,
98 eCmd_RepoBrowser,
99 eCmd_DeleteRemoteTag,
100 eCmd_EditBranchDescription,
101 eCmd_ViewLogRange,
102 eCmd_ViewLogRangeReachableFromOnlyOne,
103 eCmd_UnifiedDiff,
106 enum eCol
108 eCol_Name,
109 eCol_Upstream,
110 eCol_Date,
111 eCol_Msg,
112 eCol_LastAuthor,
113 eCol_Hash,
114 eCol_Description,
117 // Dialog Data
118 enum { IDD = IDD_DIALOG_BROWSE_REFS };
120 protected:
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, bool bForce);
142 bool DoDeleteRef(CString completeRefName, bool bForce);
144 CString GetFullRefName(CString partialRefName);
146 private:
147 bool m_bHasWC;
149 CString m_cmdPath;
151 CShadowTree m_TreeRoot;
152 CShadowTree* m_pListCtrlRoot;
153 CTreeCtrl m_RefTreeCtrl;
154 CListCtrl m_ListRefLeafs;
155 ColumnManager m_ColumnManager;
157 CFilterEdit m_ctrlFilter;
158 afx_msg void OnEnChangeEditFilter();
159 afx_msg void OnTimer(UINT_PTR nIDEvent);
160 DWORD m_SelectedFilters;
161 void SetFilterCueText();
162 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
163 bool IsMatchFilter(const CShadowTree* pTree, const CString &ref, const CString &filter);
165 int m_currSortCol;
166 bool m_currSortDesc;
167 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
169 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
171 void GetSelectedLeaves(VectorPShadowTree& selectedLeafs);
172 void OnContextMenu_ListRefLeafs(CPoint point);
173 void OnContextMenu_RefTreeCtrl(CPoint point);
174 static CString GetTwoSelectedRefs(VectorPShadowTree& selectedLeafs, const CString &lastSelected, const CString &separator);
176 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
177 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
178 virtual BOOL PreTranslateMessage(MSG* pMsg);
179 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
180 afx_msg void OnDestroy();
181 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
182 afx_msg void OnItemChangedListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
183 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
184 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
185 afx_msg void OnBnClickedCurrentbranch();
186 void UpdateInfoLabel();
188 CString m_sLastSelected;
189 CString m_initialRef;
190 int m_pickRef_Kind;
191 CString m_pickedRef;
192 bool m_bPickOne;
193 bool m_bPickedRefSet;
195 public:
196 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All, bool pickMultipleRefsOrRange = false);
197 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);