BrowseRefs: Rename option also in the reflist context menu.
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
bloba249647562681d531b0f9e44f2b3737460e7f55d
1 #pragma once
3 #include "Git.h"
4 #include <map>
5 #include "afxcmn.h"
6 #include "StandAloneDlg.h"
9 const int gPickRef_Head = 1;
10 const int gPickRef_Tag = 2;
11 const int gPickRef_Remote = 4;
12 const int gPickRef_All = gPickRef_Head | gPickRef_Tag | gPickRef_Remote;
13 const int gPickRef_NoTag = gPickRef_All & ~gPickRef_Tag;
15 class CShadowTree
17 public:
18 typedef std::map<CString,CShadowTree> TShadowTreeMap;
20 CShadowTree():m_hTree(NULL),m_pParent(NULL){}
22 CShadowTree* GetNextSub(CString& nameLeft, bool bCreateIfNotExist);
24 bool IsLeaf()const {return m_ShadowTree.empty();}
25 CString GetRefName()const
27 if(m_pParent==NULL)
28 return m_csRefName;
29 return m_pParent->GetRefName()+"/"+m_csRefName;
31 bool IsFrom(const wchar_t* from)const
33 return wcsncmp(GetRefName(),from,wcslen(from))==0;
36 CShadowTree* FindLeaf(CString partialRefName);
38 CString m_csRefName;
39 CString m_csRefHash;
40 CString m_csDate;
41 CString m_csDate_Iso8601;
42 CString m_csAuthor;
43 CString m_csSubject;
45 HTREEITEM m_hTree;
47 TShadowTreeMap m_ShadowTree;
48 CShadowTree* m_pParent;
50 typedef std::vector<CShadowTree*> VectorPShadowTree;
52 class CBrowseRefsDlg : public CResizableStandAloneDialog
54 DECLARE_DYNAMIC(CBrowseRefsDlg)
56 public:
57 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
58 virtual ~CBrowseRefsDlg();
60 enum eCmd
62 eCmd_ViewLog = WM_APP,
63 eCmd_AddRemote,
64 eCmd_ManageRemotes,
65 eCmd_CreateBranch,
66 eCmd_CreateTag,
67 eCmd_DeleteBranch,
68 eCmd_DeleteRemoteBranch,
69 eCmd_DeleteTag,
70 eCmd_ShowReflog,
71 eCmd_Diff,
72 eCmd_Fetch,
73 eCmd_Switch,
74 eCmd_Rename
77 enum eCol
79 eCol_Name,
80 eCol_Date,
81 eCol_Msg,
82 eCol_Hash
85 // Dialog Data
86 enum { IDD = IDD_DIALOG_BROWSE_REFS };
88 protected:
89 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
91 DECLARE_MESSAGE_MAP()
92 public:
93 afx_msg void OnBnClickedOk();
94 virtual BOOL OnInitDialog();
96 CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false);
98 void Refresh(CString selectRef = CString());
100 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
102 void FillListCtrlForTreeNode(HTREEITEM treeNode);
104 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
106 bool SelectRef(CString refName, bool bExactMatch);
108 bool ConfirmDeleteRef(VectorPShadowTree& leafs);
109 bool DoDeleteRefs(VectorPShadowTree& leafs, bool bForce);
110 bool DoDeleteRef(CString completeRefName, bool bForce);
112 CString GetFullRefName(CString partialRefName);
114 private:
115 CString m_cmdPath;
117 CShadowTree m_TreeRoot;
118 CShadowTree* m_pListCtrlRoot;
119 CTreeCtrl m_RefTreeCtrl;
120 CListCtrl m_ListRefLeafs;
122 int m_currSortCol;
123 bool m_currSortDesc;
124 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
125 public:
127 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
129 void OnContextMenu_ListRefLeafs(CPoint point);
130 void OnContextMenu_RefTreeCtrl(CPoint point);
132 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
133 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
134 virtual BOOL PreTranslateMessage(MSG* pMsg);
135 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
136 afx_msg void OnDestroy();
137 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
138 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
139 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
142 public:
143 CString m_initialRef;
144 int m_pickRef_Kind;
145 CString m_pickedRef;
147 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All);
148 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);