cleanup includes
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
bloba0384b41da875881c27fa5b758aae4a4c04b0309
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2011 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 #include "Git.h"
22 #include <map>
23 #include "StandAloneDlg.h"
25 const int gPickRef_Head = 1;
26 const int gPickRef_Tag = 2;
27 const int gPickRef_Remote = 4;
28 const int gPickRef_All = gPickRef_Head | gPickRef_Tag | gPickRef_Remote;
29 const int gPickRef_NoTag = gPickRef_All & ~gPickRef_Tag;
31 class CShadowTree
33 public:
34 typedef std::map<CString,CShadowTree> TShadowTreeMap;
36 CShadowTree():m_hTree(NULL),m_pParent(NULL){}
38 CShadowTree* GetNextSub(CString& nameLeft, bool bCreateIfNotExist);
40 bool IsLeaf()const {return m_ShadowTree.empty();}
41 CString GetRefName()const
43 if(m_pParent==NULL)
44 return m_csRefName;
45 return m_pParent->GetRefName()+"/"+m_csRefName;
47 bool IsFrom(const wchar_t* from)const
49 return wcsncmp(GetRefName(),from,wcslen(from))==0;
52 CShadowTree* FindLeaf(CString partialRefName);
54 CString m_csRefName;
55 CString m_csRefHash;
56 CString m_csDate;
57 CString m_csDate_Iso8601;
58 CString m_csAuthor;
59 CString m_csSubject;
61 HTREEITEM m_hTree;
63 TShadowTreeMap m_ShadowTree;
64 CShadowTree* m_pParent;
66 typedef std::vector<CShadowTree*> VectorPShadowTree;
68 class CBrowseRefsDlg : public CResizableStandAloneDialog
70 DECLARE_DYNAMIC(CBrowseRefsDlg)
72 public:
73 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
74 virtual ~CBrowseRefsDlg();
76 enum eCmd
78 eCmd_ViewLog = WM_APP,
79 eCmd_AddRemote,
80 eCmd_ManageRemotes,
81 eCmd_CreateBranch,
82 eCmd_CreateTag,
83 eCmd_DeleteBranch,
84 eCmd_DeleteRemoteBranch,
85 eCmd_DeleteTag,
86 eCmd_ShowReflog,
87 eCmd_Diff,
88 eCmd_Fetch,
89 eCmd_Switch,
90 eCmd_Rename
93 enum eCol
95 eCol_Name,
96 eCol_Date,
97 eCol_Msg,
98 eCol_Hash
101 // Dialog Data
102 enum { IDD = IDD_DIALOG_BROWSE_REFS };
104 protected:
105 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
107 DECLARE_MESSAGE_MAP()
109 afx_msg void OnBnClickedOk();
110 virtual BOOL OnInitDialog();
112 CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false);
114 void Refresh(CString selectRef = CString());
116 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
118 void FillListCtrlForTreeNode(HTREEITEM treeNode);
120 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
122 bool SelectRef(CString refName, bool bExactMatch);
124 bool ConfirmDeleteRef(VectorPShadowTree& leafs);
125 bool DoDeleteRefs(VectorPShadowTree& leafs, bool bForce);
126 bool DoDeleteRef(CString completeRefName, bool bForce);
128 CString GetFullRefName(CString partialRefName);
130 private:
131 CString m_cmdPath;
133 CShadowTree m_TreeRoot;
134 CShadowTree* m_pListCtrlRoot;
135 CTreeCtrl m_RefTreeCtrl;
136 CListCtrl m_ListRefLeafs;
138 int m_currSortCol;
139 bool m_currSortDesc;
140 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
142 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
144 void OnContextMenu_ListRefLeafs(CPoint point);
145 void OnContextMenu_RefTreeCtrl(CPoint point);
147 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
148 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
149 virtual BOOL PreTranslateMessage(MSG* pMsg);
150 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
151 afx_msg void OnDestroy();
152 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
153 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
154 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
156 CString m_initialRef;
157 int m_pickRef_Kind;
158 CString m_pickedRef;
160 public:
161 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All);
162 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);