Add support for "project" config level
[TortoiseGit.git] / src / TortoiseProc / RepositoryBrowser.h
blob8b126a2752f12ebee3cef61f6aceb9e898ecdb97
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2013 - TortoiseGit
4 // Copyright (C) 2012-2013 - Sven Strickroth <email@cs-ware.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include <map>
23 #include "StandAloneDlg.h"
24 #include "GitHash.h"
25 #include "GitStatusListCtrl.h"
27 #define REPOBROWSER_CTRL_MIN_WIDTH 20
29 class CShadowFilesTree;
31 typedef std::map<CString, CShadowFilesTree> TShadowFilesTreeMap;
33 class CShadowFilesTree
35 public:
36 CShadowFilesTree()
37 : m_hTree(NULL)
38 , m_pParent(NULL)
39 , m_bFolder(false)
40 , m_bSubmodule(false)
41 , m_iSize(0)
44 CString m_sName;
45 CGitHash m_hash;
46 size_t m_iSize;
47 bool m_bFolder;
48 bool m_bSubmodule;
50 HTREEITEM m_hTree;
52 TShadowFilesTreeMap m_ShadowTree;
53 CShadowFilesTree* m_pParent;
55 CString GetFullName() const
57 if (m_pParent == NULL)
58 return m_sName;
60 CString parentPath = m_pParent->GetFullName();
61 if (parentPath.IsEmpty())
62 return m_sName;
63 else
64 return m_pParent->GetFullName() + _T("/") + m_sName;
67 typedef std::vector<CShadowFilesTree *> TShadowFilesTreeList;
69 class CRepositoryBrowser : public CResizableStandAloneDialog
71 DECLARE_DYNAMIC(CRepositoryBrowser)
73 public:
74 CRepositoryBrowser(CString rev, CWnd* pParent = NULL); // standard constructor
75 virtual ~CRepositoryBrowser();
77 // Dialog Data
78 enum { IDD = IDD_REPOSITORY_BROWSER };
80 static bool s_bSortLogical;
82 enum eCmd
84 eCmd_Open = WM_APP,
85 eCmd_OpenWith,
86 eCmd_OpenWithAlternativeEditor,
87 eCmd_ViewLog,
88 eCmd_Blame,
89 eCmd_CompareWC,
90 eCmd_Revert,
91 eCmd_SaveAs,
92 eCmd_CopyPath,
93 eCmd_CopyHash,
96 enum eCol
98 eCol_Name,
99 eCol_Extension,
100 eCol_FileSize,
103 enum eOpenType
105 ALTERNATIVEEDITOR,
106 OPEN,
107 OPEN_WITH,
110 enum eSelectionType
112 ONLY_FILES,
113 ONLY_FILESSUBMODULES,
114 ONLY_FOLDERS,
115 MIXED_FOLDERS_FILES,
118 private:
119 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
121 DECLARE_MESSAGE_MAP()
123 afx_msg void OnOK();
124 afx_msg void OnCancel();
125 afx_msg void OnDestroy();
126 virtual BOOL OnInitDialog();
128 CTreeCtrl m_RepoTree;
129 CListCtrl m_RepoList;
130 ColumnManager m_ColumnManager;
132 afx_msg void OnLvnColumnclickRepoList(NMHDR *pNMHDR, LRESULT *pResult);
133 int m_currSortCol;
134 bool m_currSortDesc;
136 CShadowFilesTree m_TreeRoot;
137 int ReadTreeRecursive(git_repository &repo, git_tree * tree, CShadowFilesTree * treeroot);
138 int ReadTree(CShadowFilesTree * treeroot);
139 int m_nIconFolder;
140 int m_nOpenIconFolder;
141 int m_nExternalOvl;
143 bool m_bHasWC;
145 void Refresh();
146 CString m_sRevision;
147 void FillListCtrlForTreeNode(HTREEITEM treeNode);
148 void FillListCtrlForShadowTree(CShadowFilesTree* pTree);
149 void UpdateInfoLabel();
150 afx_msg void OnTvnSelchangedRepoTree(NMHDR *pNMHDR, LRESULT *pResult);
151 afx_msg void OnLvnItemchangedRepolist(NMHDR *pNMHDR, LRESULT *pResult);
153 afx_msg void OnNMDblclk_RepoList(NMHDR *pNMHDR, LRESULT *pResult);
154 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
155 void OnContextMenu_RepoList(CPoint point);
156 void OnContextMenu_RepoTree(CPoint point);
157 void ShowContextMenu(CPoint point, TShadowFilesTreeList &selectedLeafs, eSelectionType selType);
159 void FileSaveAs(const CString path);
160 void OpenFile(const CString path, eOpenType mode, bool isSubmodule, CGitHash itemHash);
161 bool RevertItemToVersion(const CString &path);
163 afx_msg void OnBnClickedButtonRevision();
165 virtual BOOL PreTranslateMessage(MSG* pMsg);
167 /// resizes the control so that the divider is at position 'point'
168 void HandleDividerMove(CPoint point, bool bDraw);
169 bool bDragMode;
170 void SaveDividerPosition();
171 int oldy, oldx;
172 /// draws the bar when the tree and list control are resized
173 void DrawXorBar(CDC * pDC, int x1, int y1, int width, int height);
174 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
175 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
176 afx_msg void OnCaptureChanged(CWnd *pWnd);
177 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
178 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
179 afx_msg void CopyHashToClipboard(TShadowFilesTreeList &selectedLeafs);