OSDN Git Service

Merge Git book to Help document
[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_DeleteRemoteBranch,\r
69                 eCmd_DeleteTag,\r
70                 eCmd_ShowReflog\r
71         };\r
72 \r
73         enum eCol\r
74         {\r
75                 eCol_Name,\r
76                 eCol_Date,\r
77                 eCol_Msg,\r
78                 eCol_Hash\r
79         };\r
80 \r
81 // Dialog Data\r
82         enum { IDD = IDD_DIALOG_BROWSE_REFS };\r
83 \r
84 protected:\r
85         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
86 \r
87         DECLARE_MESSAGE_MAP()\r
88 public:\r
89         afx_msg void OnBnClickedOk();\r
90         virtual BOOL OnInitDialog();\r
91 \r
92         CString                 GetSelectedRef(bool onlyIfLeaf);\r
93 \r
94         void                    Refresh(CString selectRef = CString());\r
95 \r
96         CShadowTree&    GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);\r
97 \r
98         void                    FillListCtrlForTreeNode(HTREEITEM treeNode);\r
99 \r
100         void                    FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);\r
101 \r
102         bool                    SelectRef(CString refName, bool bExactMatch);\r
103 \r
104         bool                    ConfirmDeleteRef(CString completeRefName);\r
105         bool                    DoDeleteRef(CString completeRefName, bool bForce);\r
106 \r
107         CString                 GetFullRefName(CString partialRefName);\r
108 \r
109 private:\r
110         CString                 m_cmdPath;\r
111 \r
112         CShadowTree             m_TreeRoot;\r
113         CTreeCtrl               m_RefTreeCtrl;\r
114         CListCtrl               m_ListRefLeafs;\r
115 \r
116         int                             m_currSortCol;\r
117         bool                    m_currSortDesc;\r
118         afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);\r
119 public:\r
120 \r
121         afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);\r
122 \r
123         void            OnContextMenu_ListRefLeafs(CPoint point);\r
124         void            OnContextMenu_RefTreeCtrl(CPoint point);\r
125 \r
126         void            ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);\r
127         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
128         afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);\r
129         afx_msg void OnDestroy();\r
130         afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);\r
131 \r
132 \r
133 public:\r
134         CString m_initialRef;\r
135         int             m_pickRef_Kind;\r
136         CString m_pickedRef;\r
137 \r
138         static CString  PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All); \r
139         static bool             PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All); \r
140 };\r