Can edit branch description of nested local branches
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blobc21bd38100656ba6f4c6fa776c2273226aa6005f
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;
50 /**
51 * from = refs/heads, refname = refs/heads/master => true
52 * from = refs/heads, refname = refs/heads => true
53 * from = refs/heads, refname = refs/headsh => false
54 * from = refs/heads/, refname = refs/heads/master => true
55 * from = refs/heads/, refname = refs/heads => false
57 bool IsFrom(const wchar_t* from)const
59 CString name = GetRefName();
60 int len = (int)wcslen(from);
61 if (from[len - 1] != '/' && wcsncmp(name, from, len) == 0)
63 if (len == name.GetLength())
64 return true;
65 if (len < name.GetLength() && name[len] == '/')
66 return true;
67 return false;
70 return wcsncmp(name, from, len) == 0;
73 CString GetRefsHeadsName() const
75 return GetRefName().Mid(11); // len = 11 refs/heads/
78 CShadowTree* FindLeaf(CString partialRefName);
80 CString m_csRefName;
81 CString m_csUpstream;
82 CString m_csRefHash;
83 CTime m_csDate;
84 CString m_csAuthor;
85 CString m_csSubject;
86 CString m_csDescription;
88 HTREEITEM m_hTree;
90 TShadowTreeMap m_ShadowTree;
91 CShadowTree* m_pParent;
93 typedef std::vector<CShadowTree*> VectorPShadowTree;
95 class CBrowseRefsDlg : public CResizableStandAloneDialog
97 DECLARE_DYNAMIC(CBrowseRefsDlg)
99 public:
100 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
101 virtual ~CBrowseRefsDlg();
103 enum eCmd
105 eCmd_ViewLog = WM_APP,
106 eCmd_AddRemote,
107 eCmd_ManageRemotes,
108 eCmd_CreateBranch,
109 eCmd_CreateTag,
110 eCmd_DeleteAllTags,
111 eCmd_DeleteBranch,
112 eCmd_DeleteRemoteBranch,
113 eCmd_DeleteTag,
114 eCmd_ShowReflog,
115 eCmd_Diff,
116 eCmd_Fetch,
117 eCmd_Switch,
118 eCmd_Merge,
119 eCmd_Rename,
120 eCmd_RepoBrowser,
121 eCmd_DeleteRemoteTag,
122 eCmd_EditBranchDescription,
123 eCmd_ViewLogRange,
124 eCmd_ViewLogRangeReachableFromOnlyOne,
125 eCmd_UnifiedDiff,
128 enum eCol
130 eCol_Name,
131 eCol_Upstream,
132 eCol_Date,
133 eCol_Msg,
134 eCol_LastAuthor,
135 eCol_Hash,
136 eCol_Description,
139 // Dialog Data
140 enum { IDD = IDD_DIALOG_BROWSE_REFS };
142 protected:
143 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
145 DECLARE_MESSAGE_MAP()
147 afx_msg void OnBnClickedOk();
148 virtual BOOL OnInitDialog();
150 CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false);
152 void Refresh(CString selectRef = CString());
154 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
156 void FillListCtrlForTreeNode(HTREEITEM treeNode);
158 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
160 bool SelectRef(CString refName, bool bExactMatch);
162 bool ConfirmDeleteRef(VectorPShadowTree& leafs);
163 bool DoDeleteRefs(VectorPShadowTree& leafs);
164 bool DoDeleteRef(CString completeRefName);
166 CString GetFullRefName(CString partialRefName);
168 private:
169 bool m_bHasWC;
171 CString m_cmdPath;
173 STRING_VECTOR remotes;
175 CShadowTree m_TreeRoot;
176 CShadowTree* m_pListCtrlRoot;
177 CTreeCtrl m_RefTreeCtrl;
178 CListCtrl m_ListRefLeafs;
179 ColumnManager m_ColumnManager;
181 CFilterEdit m_ctrlFilter;
182 afx_msg void OnEnChangeEditFilter();
183 afx_msg void OnTimer(UINT_PTR nIDEvent);
184 DWORD m_SelectedFilters;
185 void SetFilterCueText();
186 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
187 afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);
188 bool IsMatchFilter(const CShadowTree* pTree, const CString &ref, const CString &filter, bool positive);
190 int m_currSortCol;
191 bool m_currSortDesc;
192 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
194 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
196 void GetSelectedLeaves(VectorPShadowTree& selectedLeafs);
197 void OnContextMenu_ListRefLeafs(CPoint point);
198 void OnContextMenu_RefTreeCtrl(CPoint point);
199 static CString GetTwoSelectedRefs(VectorPShadowTree& selectedLeafs, const CString &lastSelected, const CString &separator);
201 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
202 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
203 virtual BOOL PreTranslateMessage(MSG* pMsg);
204 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
205 afx_msg void OnDestroy();
206 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
207 afx_msg void OnItemChangedListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
208 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
209 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
210 afx_msg void OnBnClickedCurrentbranch();
211 afx_msg void OnBnClickedCheck1();
212 BOOL m_bIncludeNestedRefs;
213 CRegDWORD m_regIncludeNestedRefs;
214 void UpdateInfoLabel();
216 CString m_sLastSelected;
217 CString m_initialRef;
218 int m_pickRef_Kind;
219 CString m_pickedRef;
220 bool m_bPickOne;
221 bool m_bPickedRefSet;
223 DWORD m_DateFormat; // DATE_SHORTDATE or DATE_LONGDATE
224 bool m_bRelativeTimes; // Show relative times
226 public:
227 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All, bool pickMultipleRefsOrRange = false);
228 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);