OSDN Git Service

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