libgit2: Enable fetch function
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blob4a05cfeb7526bee2fcf393c21def906fdc6ff055
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2013 - 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"
25 #include "FilterEdit.h"
27 const int gPickRef_Head = 1;
28 const int gPickRef_Tag = 2;
29 const int gPickRef_Remote = 4;
30 const int gPickRef_All = gPickRef_Head | gPickRef_Tag | gPickRef_Remote;
31 const int gPickRef_NoTag = gPickRef_All & ~gPickRef_Tag;
33 class CShadowTree
35 public:
36 typedef std::map<CString,CShadowTree> TShadowTreeMap;
38 CShadowTree():m_hTree(NULL),m_pParent(NULL){}
40 CShadowTree* GetNextSub(CString& nameLeft, bool bCreateIfNotExist);
42 bool IsLeaf()const {return m_ShadowTree.empty();}
43 CString GetRefName()const
45 if(m_pParent==NULL)
46 return m_csRefName;
47 return m_pParent->GetRefName()+"/"+m_csRefName;
49 bool IsFrom(const wchar_t* from)const
51 return wcsncmp(GetRefName(),from,wcslen(from))==0;
54 CShadowTree* FindLeaf(CString partialRefName);
56 CString m_csRefName;
57 CString m_csRefHash;
58 CString m_csDate;
59 CString m_csDate_Iso8601;
60 CString m_csAuthor;
61 CString m_csSubject;
62 CString m_csDescription;
64 HTREEITEM m_hTree;
66 TShadowTreeMap m_ShadowTree;
67 CShadowTree* m_pParent;
69 typedef std::vector<CShadowTree*> VectorPShadowTree;
71 class CBrowseRefsDlg : public CResizableStandAloneDialog
73 DECLARE_DYNAMIC(CBrowseRefsDlg)
75 public:
76 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
77 virtual ~CBrowseRefsDlg();
79 enum eCmd
81 eCmd_ViewLog = WM_APP,
82 eCmd_AddRemote,
83 eCmd_ManageRemotes,
84 eCmd_CreateBranch,
85 eCmd_CreateTag,
86 eCmd_DeleteAllTags,
87 eCmd_DeleteBranch,
88 eCmd_DeleteRemoteBranch,
89 eCmd_DeleteTag,
90 eCmd_ShowReflog,
91 eCmd_Diff,
92 eCmd_Fetch,
93 eCmd_Switch,
94 eCmd_Rename,
95 eCmd_RepoBrowser,
96 eCmd_DeleteRemoteTag,
97 eCmd_EditBranchDescription,
100 enum eCol
102 eCol_Name,
103 eCol_Date,
104 eCol_Msg,
105 eCol_LastAuthor,
106 eCol_Hash,
107 eCol_Description,
110 // Dialog Data
111 enum { IDD = IDD_DIALOG_BROWSE_REFS };
113 protected:
114 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
116 DECLARE_MESSAGE_MAP()
118 afx_msg void OnBnClickedOk();
119 virtual BOOL OnInitDialog();
121 CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false);
123 void Refresh(CString selectRef = CString());
125 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
127 void FillListCtrlForTreeNode(HTREEITEM treeNode);
129 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
131 bool SelectRef(CString refName, bool bExactMatch);
133 bool ConfirmDeleteRef(VectorPShadowTree& leafs);
134 bool DoDeleteRefs(VectorPShadowTree& leafs, bool bForce);
135 bool DoDeleteRef(CString completeRefName, bool bForce);
137 CString GetFullRefName(CString partialRefName);
139 private:
140 bool m_bHasWC;
142 CString m_cmdPath;
144 CShadowTree m_TreeRoot;
145 CShadowTree* m_pListCtrlRoot;
146 CTreeCtrl m_RefTreeCtrl;
147 CListCtrl m_ListRefLeafs;
149 CFilterEdit m_ctrlFilter;
150 afx_msg void OnEnChangeEditFilter();
151 afx_msg void OnTimer(UINT_PTR nIDEvent);
152 DWORD m_SelectedFilters;
153 void SetFilterCueText();
154 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
155 bool IsMatchFilter(const CShadowTree* pTree, const CString &ref, const CString &filter);
157 int m_currSortCol;
158 bool m_currSortDesc;
159 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
161 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
163 void OnContextMenu_ListRefLeafs(CPoint point);
164 void OnContextMenu_RefTreeCtrl(CPoint point);
166 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
167 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
168 virtual BOOL PreTranslateMessage(MSG* pMsg);
169 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
170 afx_msg void OnDestroy();
171 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
172 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
173 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
175 CString m_initialRef;
176 int m_pickRef_Kind;
177 CString m_pickedRef;
178 bool m_bPickOne;
180 public:
181 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All);
182 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);