Pick Ref: Implemented ref picking for push dialog
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blob16391be7c0b4be173afa363163fc41c95d8a9c91
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_DeleteTag
71 enum eCol
73 eCol_Name,
74 eCol_Date,
75 eCol_Msg,
76 eCol_Hash
79 // Dialog Data
80 enum { IDD = IDD_DIALOG_BROWSE_REFS };
82 protected:
83 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
85 DECLARE_MESSAGE_MAP()
86 public:
87 afx_msg void OnBnClickedOk();
88 virtual BOOL OnInitDialog();
90 CString GetSelectedRef(bool onlyIfLeaf);
92 void Refresh(CString selectRef = CString());
94 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
96 void FillListCtrlForTreeNode(HTREEITEM treeNode);
98 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
100 bool SelectRef(CString refName, bool bExactMatch);
102 bool ConfirmDeleteRef(CString completeRefName);
103 bool DoDeleteRef(CString completeRefName, bool bForce);
105 CString GetFullRefName(CString partialRefName);
107 private:
108 CString m_cmdPath;
110 CShadowTree m_TreeRoot;
111 CTreeCtrl m_RefTreeCtrl;
112 CListCtrl m_ListRefLeafs;
114 int m_currSortCol;
115 bool m_currSortDesc;
116 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
117 public:
119 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
121 void OnContextMenu_ListRefLeafs(CPoint point);
122 void OnContextMenu_RefTreeCtrl(CPoint point);
124 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
125 virtual BOOL PreTranslateMessage(MSG* pMsg);
126 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
127 afx_msg void OnDestroy();
128 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
131 public:
132 CString m_initialRef;
133 int m_pickRef_Kind;
134 CString m_pickedRef;
136 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All);
137 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);