OSDN Git Service

Pick Ref: Implemented ref picking for push dialog
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / BrowseRefsDlg.h
1 #pragma once\r
2 \r
3 #include "Git.h"\r
4 #include <map>\r
5 #include "afxcmn.h"\r
6 #include "StandAloneDlg.h"\r
7 \r
8 \r
9 const int gPickRef_Head         = 1;\r
10 const int gPickRef_Tag          = 2;\r
11 const int gPickRef_Remote       = 4;\r
12 const int gPickRef_All          = gPickRef_Head | gPickRef_Tag | gPickRef_Remote;\r
13 const int gPickRef_NoTag        = gPickRef_All & ~gPickRef_Tag;\r
14 \r
15 class CShadowTree\r
16 {\r
17 public:\r
18         typedef std::map<CString,CShadowTree> TShadowTreeMap;\r
19 \r
20         CShadowTree():m_hTree(NULL),m_pParent(NULL){}\r
21         \r
22         CShadowTree*    GetNextSub(CString& nameLeft, bool bCreateIfNotExist);\r
23 \r
24         bool                    IsLeaf()const {return m_ShadowTree.empty();}\r
25         CString                 GetRefName()const\r
26         {\r
27                 if(m_pParent==NULL)\r
28                         return m_csRefName;\r
29                 return m_pParent->GetRefName()+"/"+m_csRefName;\r
30         }\r
31         bool                    IsFrom(const wchar_t* from)const\r
32         {\r
33                 return wcsncmp(GetRefName(),from,wcslen(from))==0;\r
34         }\r
35 \r
36         CShadowTree*    FindLeaf(CString partialRefName);\r
37 \r
38         CString                 m_csRefName;\r
39         CString                 m_csRefHash;\r
40         CString                 m_csDate;\r
41         CString                 m_csDate_Iso8601;\r
42         CString                 m_csAuthor;\r
43         CString                 m_csSubject;\r
44 \r
45         HTREEITEM               m_hTree;\r
46 \r
47         TShadowTreeMap  m_ShadowTree;\r
48         CShadowTree*    m_pParent;\r
49 };\r
50 typedef std::vector<CShadowTree*> VectorPShadowTree;\r
51 \r
52 class CBrowseRefsDlg : public CResizableStandAloneDialog\r
53 {\r
54         DECLARE_DYNAMIC(CBrowseRefsDlg)\r
55 \r
56 public:\r
57         CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL);   // standard constructor\r
58         virtual ~CBrowseRefsDlg();\r
59 \r
60         enum eCmd\r
61         {\r
62                 eCmd_ViewLog = WM_APP,\r
63                 eCmd_AddRemote,\r
64                 eCmd_ManageRemotes,\r
65                 eCmd_CreateBranch,\r
66                 eCmd_CreateTag,\r
67                 eCmd_DeleteBranch,\r
68                 eCmd_DeleteTag\r
69         };\r
70 \r
71         enum eCol\r
72         {\r
73                 eCol_Name,\r
74                 eCol_Date,\r
75                 eCol_Msg,\r
76                 eCol_Hash\r
77         };\r
78 \r
79 // Dialog Data\r
80         enum { IDD = IDD_DIALOG_BROWSE_REFS };\r
81 \r
82 protected:\r
83         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
84 \r
85         DECLARE_MESSAGE_MAP()\r
86 public:\r
87         afx_msg void OnBnClickedOk();\r
88         virtual BOOL OnInitDialog();\r
89 \r
90         CString                 GetSelectedRef(bool onlyIfLeaf);\r
91 \r
92         void                    Refresh(CString selectRef = CString());\r
93 \r
94         CShadowTree&    GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);\r
95 \r
96         void                    FillListCtrlForTreeNode(HTREEITEM treeNode);\r
97 \r
98         void                    FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);\r
99 \r
100         bool                    SelectRef(CString refName, bool bExactMatch);\r
101 \r
102         bool                    ConfirmDeleteRef(CString completeRefName);\r
103         bool                    DoDeleteRef(CString completeRefName, bool bForce);\r
104 \r
105         CString                 GetFullRefName(CString partialRefName);\r
106 \r
107 private:\r
108         CString                 m_cmdPath;\r
109 \r
110         CShadowTree             m_TreeRoot;\r
111         CTreeCtrl               m_RefTreeCtrl;\r
112         CListCtrl               m_ListRefLeafs;\r
113 \r
114         int                             m_currSortCol;\r
115         bool                    m_currSortDesc;\r
116         afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);\r
117 public:\r
118 \r
119         afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);\r
120 \r
121         void            OnContextMenu_ListRefLeafs(CPoint point);\r
122         void            OnContextMenu_RefTreeCtrl(CPoint point);\r
123 \r
124         void            ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);\r
125         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
126         afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);\r
127         afx_msg void OnDestroy();\r
128         afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);\r
129 \r
130 \r
131 public:\r
132         CString m_initialRef;\r
133         int             m_pickRef_Kind;\r
134         CString m_pickedRef;\r
135 \r
136         static CString  PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All); \r
137         static bool             PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All); \r
138 };\r