Includes cleanup
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blob388571ec5caf490d5dfd73eb26c2c7e13410a8c0
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2015 - 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 <map>
22 #include "StandAloneDlg.h"
23 #include "FilterEdit.h"
24 #include "GitStatusListCtrl.h"
25 #include "gittype.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_csUpstream;
58 CString m_csRefHash;
59 CString m_csDate;
60 CString m_csDate_Iso8601;
61 CString m_csAuthor;
62 CString m_csSubject;
63 CString m_csDescription;
65 HTREEITEM m_hTree;
67 TShadowTreeMap m_ShadowTree;
68 CShadowTree* m_pParent;
70 typedef std::vector<CShadowTree*> VectorPShadowTree;
72 class CBrowseRefsDlg : public CResizableStandAloneDialog
74 DECLARE_DYNAMIC(CBrowseRefsDlg)
76 public:
77 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
78 virtual ~CBrowseRefsDlg();
80 enum eCmd
82 eCmd_ViewLog = WM_APP,
83 eCmd_AddRemote,
84 eCmd_ManageRemotes,
85 eCmd_CreateBranch,
86 eCmd_CreateTag,
87 eCmd_DeleteAllTags,
88 eCmd_DeleteBranch,
89 eCmd_DeleteRemoteBranch,
90 eCmd_DeleteTag,
91 eCmd_ShowReflog,
92 eCmd_Diff,
93 eCmd_Fetch,
94 eCmd_Switch,
95 eCmd_Merge,
96 eCmd_Rename,
97 eCmd_RepoBrowser,
98 eCmd_DeleteRemoteTag,
99 eCmd_EditBranchDescription,
100 eCmd_ViewLogRange,
101 eCmd_ViewLogRangeReachableFromOnlyOne,
102 eCmd_UnifiedDiff,
105 enum eCol
107 eCol_Name,
108 eCol_Upstream,
109 eCol_Date,
110 eCol_Msg,
111 eCol_LastAuthor,
112 eCol_Hash,
113 eCol_Description,
116 // Dialog Data
117 enum { IDD = IDD_DIALOG_BROWSE_REFS };
119 protected:
120 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
122 DECLARE_MESSAGE_MAP()
124 afx_msg void OnBnClickedOk();
125 virtual BOOL OnInitDialog();
127 CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false);
129 void Refresh(CString selectRef = CString());
131 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
133 void FillListCtrlForTreeNode(HTREEITEM treeNode);
135 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
137 bool SelectRef(CString refName, bool bExactMatch);
139 bool ConfirmDeleteRef(VectorPShadowTree& leafs);
140 bool DoDeleteRefs(VectorPShadowTree& leafs);
141 bool DoDeleteRef(CString completeRefName);
143 CString GetFullRefName(CString partialRefName);
145 private:
146 bool m_bHasWC;
148 CString m_cmdPath;
150 STRING_VECTOR remotes;
152 CShadowTree m_TreeRoot;
153 CShadowTree* m_pListCtrlRoot;
154 CTreeCtrl m_RefTreeCtrl;
155 CListCtrl m_ListRefLeafs;
156 ColumnManager m_ColumnManager;
158 CFilterEdit m_ctrlFilter;
159 afx_msg void OnEnChangeEditFilter();
160 afx_msg void OnTimer(UINT_PTR nIDEvent);
161 DWORD m_SelectedFilters;
162 void SetFilterCueText();
163 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
164 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
165 bool IsMatchFilter(const CShadowTree* pTree, const CString &ref, const CString &filter, bool positive);
167 int m_currSortCol;
168 bool m_currSortDesc;
169 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
171 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
173 void GetSelectedLeaves(VectorPShadowTree& selectedLeafs);
174 void OnContextMenu_ListRefLeafs(CPoint point);
175 void OnContextMenu_RefTreeCtrl(CPoint point);
176 static CString GetTwoSelectedRefs(VectorPShadowTree& selectedLeafs, const CString &lastSelected, const CString &separator);
178 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
179 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
180 virtual BOOL PreTranslateMessage(MSG* pMsg);
181 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
182 afx_msg void OnDestroy();
183 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
184 afx_msg void OnItemChangedListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
185 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
186 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
187 afx_msg void OnBnClickedCurrentbranch();
188 void UpdateInfoLabel();
190 CString m_sLastSelected;
191 CString m_initialRef;
192 int m_pickRef_Kind;
193 CString m_pickedRef;
194 bool m_bPickOne;
195 bool m_bPickedRefSet;
197 public:
198 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All, bool pickMultipleRefsOrRange = false);
199 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);