BrowseRefs: Context menu enhancements
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blobc251a9c3ea81b497b77e8f9d5185ba4ff21574a8
1 #pragma once
3 #include "Git.h"
4 #include <map>
5 #include "afxcmn.h"
6 #include "StandAloneDlg.h"
8 class CShadowTree
10 public:
11 typedef std::map<CString,CShadowTree> TShadowTreeMap;
13 CShadowTree():m_hTree(NULL),m_pParent(NULL){}
15 CShadowTree* GetNextSub(CString& nameLeft, bool bCreateIfNotExist);
17 bool IsLeaf()const {return m_ShadowTree.empty();}
18 CString GetRefName()const
20 if(m_pParent==NULL)
21 return m_csRefName;
22 return m_pParent->GetRefName()+"/"+m_csRefName;
24 bool IsFrom(const wchar_t* from)const
26 return wcsncmp(GetRefName(),from,wcslen(from))==0;
29 CString m_csRefName;
30 CString m_csRefHash;
31 CString m_csDate;
32 CString m_csAuthor;
33 CString m_csSubject;
35 HTREEITEM m_hTree;
37 TShadowTreeMap m_ShadowTree;
38 CShadowTree* m_pParent;
40 typedef std::vector<CShadowTree*> VectorPShadowTree;
42 class CBrowseRefsDlg : public CResizableStandAloneDialog
44 DECLARE_DYNAMIC(CBrowseRefsDlg)
46 public:
47 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
48 virtual ~CBrowseRefsDlg();
50 enum eCmd
52 eCmd_ViewLog = WM_APP,
53 eCmd_AddRemote,
54 eCmd_ManageRemotes,
55 eCmd_CreateBranch,
56 eCmd_CreateTag,
57 eCmd_DeleteBranch,
58 eCmd_DeleteTag
61 // Dialog Data
62 enum { IDD = IDD_DIALOG_BROWSE_REFS };
64 protected:
65 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
67 DECLARE_MESSAGE_MAP()
68 public:
69 afx_msg void OnBnClickedOk();
70 virtual BOOL OnInitDialog();
72 void Refresh(bool bSelectCurHead=false);
74 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
76 void FillListCtrlForTreeNode(HTREEITEM treeNode);
78 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
80 bool SelectRef(CString refName);
82 bool ConfirmDeleteRef(CString completeRefName);
83 bool DoDeleteRef(CString completeRefName, bool bForce);
85 private:
86 CString m_cmdPath;
88 CShadowTree m_TreeRoot;
89 CTreeCtrl m_RefTreeCtrl;
90 CListCtrl m_ListRefLeafs;
91 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
92 public:
94 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
96 void OnContextMenu_ListRefLeafs(CPoint point);
97 void OnContextMenu_RefTreeCtrl(CPoint point);
99 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
100 virtual BOOL PreTranslateMessage(MSG* pMsg);