RefBrowser: Added basic filter
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blob245cce21c6ef166a9218e6f3bd2194077121e571
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2012 - 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"
24 #include "afxwin.h"
26 const int gPickRef_Head = 1;
27 const int gPickRef_Tag = 2;
28 const int gPickRef_Remote = 4;
29 const int gPickRef_All = gPickRef_Head | gPickRef_Tag | gPickRef_Remote;
30 const int gPickRef_NoTag = gPickRef_All & ~gPickRef_Tag;
32 class CShadowTree
34 public:
35 typedef std::map<CString,CShadowTree> TShadowTreeMap;
37 CShadowTree():m_hTree(NULL),m_pParent(NULL){}
39 CShadowTree* GetNextSub(CString& nameLeft, bool bCreateIfNotExist);
41 bool IsLeaf()const {return m_ShadowTree.empty();}
42 CString GetRefName()const
44 if(m_pParent==NULL)
45 return m_csRefName;
46 return m_pParent->GetRefName()+"/"+m_csRefName;
48 bool IsFrom(const wchar_t* from)const
50 return wcsncmp(GetRefName(),from,wcslen(from))==0;
53 CShadowTree* FindLeaf(CString partialRefName);
55 CString m_csRefName;
56 CString m_csRefHash;
57 CString m_csDate;
58 CString m_csDate_Iso8601;
59 CString m_csAuthor;
60 CString m_csSubject;
62 HTREEITEM m_hTree;
64 TShadowTreeMap m_ShadowTree;
65 CShadowTree* m_pParent;
67 typedef std::vector<CShadowTree*> VectorPShadowTree;
69 class CBrowseRefsDlg : public CResizableStandAloneDialog
71 DECLARE_DYNAMIC(CBrowseRefsDlg)
73 public:
74 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
75 virtual ~CBrowseRefsDlg();
77 enum eCmd
79 eCmd_ViewLog = WM_APP,
80 eCmd_AddRemote,
81 eCmd_ManageRemotes,
82 eCmd_CreateBranch,
83 eCmd_CreateTag,
84 eCmd_DeleteBranch,
85 eCmd_DeleteRemoteBranch,
86 eCmd_DeleteTag,
87 eCmd_ShowReflog,
88 eCmd_Diff,
89 eCmd_Fetch,
90 eCmd_Switch,
91 eCmd_Rename,
92 eCmd_RepoBrowser,
95 enum eCol
97 eCol_Name,
98 eCol_Date,
99 eCol_Msg,
100 eCol_Hash
103 // Dialog Data
104 enum { IDD = IDD_DIALOG_BROWSE_REFS };
106 protected:
107 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
109 DECLARE_MESSAGE_MAP()
111 afx_msg void OnBnClickedOk();
112 virtual BOOL OnInitDialog();
114 CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false);
116 void Refresh(CString selectRef = CString());
118 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
120 void FillListCtrlForTreeNode(HTREEITEM treeNode);
122 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
124 bool SelectRef(CString refName, bool bExactMatch);
126 bool ConfirmDeleteRef(VectorPShadowTree& leafs);
127 bool DoDeleteRefs(VectorPShadowTree& leafs, bool bForce);
128 bool DoDeleteRef(CString completeRefName, bool bForce);
130 CString GetFullRefName(CString partialRefName);
132 private:
133 bool m_bHasWC;
135 CString m_cmdPath;
137 CShadowTree m_TreeRoot;
138 CShadowTree* m_pListCtrlRoot;
139 CTreeCtrl m_RefTreeCtrl;
140 CListCtrl m_ListRefLeafs;
142 CEdit m_ctrlFilter;
143 afx_msg void OnEnChangeEditFilter();
144 afx_msg void OnTimer(UINT_PTR nIDEvent);
146 int m_currSortCol;
147 bool m_currSortDesc;
148 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
150 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
152 void OnContextMenu_ListRefLeafs(CPoint point);
153 void OnContextMenu_RefTreeCtrl(CPoint point);
155 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
156 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
157 virtual BOOL PreTranslateMessage(MSG* pMsg);
158 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
159 afx_msg void OnDestroy();
160 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
161 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
162 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
164 CString m_initialRef;
165 int m_pickRef_Kind;
166 CString m_pickedRef;
168 public:
169 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All);
170 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);