RepoBrowser: Show overlay for submodules
[TortoiseGit.git] / src / TortoiseProc / RepositoryBrowser.h
blob0153fefbef9127434ad7a0cc1d47a3106ffef868
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"
26 #define REPOBROWSER_CTRL_MIN_WIDTH 20
28 class CShadowFilesTree;
30 typedef std::map<CString, CShadowFilesTree> TShadowFilesTreeMap;
32 class CShadowFilesTree
34 public:
35 CShadowFilesTree()
36 : m_hTree(NULL)
37 , m_pParent(NULL)
38 , m_bFolder(false)
39 , m_bSubmodule(false)
40 , m_iSize(0)
43 CString m_sName;
44 CGitHash m_hash;
45 size_t m_iSize;
46 bool m_bFolder;
47 bool m_bSubmodule;
49 HTREEITEM m_hTree;
51 TShadowFilesTreeMap m_ShadowTree;
52 CShadowFilesTree* m_pParent;
54 CString GetFullName() const
56 if (m_pParent == NULL)
57 return m_sName;
59 CString parentPath = m_pParent->GetFullName();
60 if (parentPath.IsEmpty())
61 return m_sName;
62 else
63 return m_pParent->GetFullName() + _T("/") + m_sName;
66 typedef std::vector<CShadowFilesTree *> TShadowFilesTreeList;
68 class CRepositoryBrowser : public CResizableStandAloneDialog
70 DECLARE_DYNAMIC(CRepositoryBrowser)
72 public:
73 CRepositoryBrowser(CString rev, CWnd* pParent = NULL); // standard constructor
74 virtual ~CRepositoryBrowser();
76 // Dialog Data
77 enum { IDD = IDD_REPOSITORY_BROWSER };
79 static bool s_bSortLogical;
81 enum eCmd
83 eCmd_Open = WM_APP,
84 eCmd_OpenWith,
85 eCmd_OpenWithAlternativeEditor,
86 eCmd_ViewLog,
87 eCmd_Blame,
88 eCmd_CompareWC,
89 eCmd_Revert,
90 eCmd_SaveAs,
91 eCmd_CopyPath,
92 eCmd_CopyHash,
95 enum eCol
97 eCol_Name,
98 eCol_Extension,
99 eCol_FileSize,
102 enum eOpenType
104 ALTERNATIVEEDITOR,
105 OPEN,
106 OPEN_WITH,
109 enum eSelectionType
111 ONLY_FILES,
112 ONLY_FILESSUBMODULES,
113 ONLY_FOLDERS,
114 MIXED_FOLDERS_FILES,
117 private:
118 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
120 DECLARE_MESSAGE_MAP()
122 afx_msg void OnOK();
123 afx_msg void OnCancel();
124 virtual BOOL OnInitDialog();
126 CTreeCtrl m_RepoTree;
127 CListCtrl m_RepoList;
129 afx_msg void OnLvnColumnclickRepoList(NMHDR *pNMHDR, LRESULT *pResult);
130 int m_currSortCol;
131 bool m_currSortDesc;
133 CShadowFilesTree m_TreeRoot;
134 int ReadTreeRecursive(git_repository &repo, git_tree * tree, CShadowFilesTree * treeroot);
135 int ReadTree(CShadowFilesTree * treeroot);
136 int m_nIconFolder;
137 int m_nOpenIconFolder;
138 int m_nExternalOvl;
140 bool m_bHasWC;
142 void Refresh();
143 CString m_sRevision;
144 void FillListCtrlForTreeNode(HTREEITEM treeNode);
145 void FillListCtrlForShadowTree(CShadowFilesTree* pTree);
146 afx_msg void OnTvnSelchangedRepoTree(NMHDR *pNMHDR, LRESULT *pResult);
148 afx_msg void OnNMDblclk_RepoList(NMHDR *pNMHDR, LRESULT *pResult);
149 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
150 void OnContextMenu_RepoList(CPoint point);
151 void OnContextMenu_RepoTree(CPoint point);
152 void ShowContextMenu(CPoint point, TShadowFilesTreeList &selectedLeafs, eSelectionType selType);
154 void FileSaveAs(const CString path);
155 void OpenFile(const CString path, eOpenType mode, bool isSubmodule);
156 bool RevertItemToVersion(const CString &path);
158 afx_msg void OnBnClickedButtonRevision();
160 virtual BOOL PreTranslateMessage(MSG* pMsg);
162 /// resizes the control so that the divider is at position 'point'
163 void HandleDividerMove(CPoint point, bool bDraw);
164 bool bDragMode;
165 void SaveDividerPosition();
166 int oldy, oldx;
167 /// draws the bar when the tree and list control are resized
168 void DrawXorBar(CDC * pDC, int x1, int y1, int width, int height);
169 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
170 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
171 afx_msg void OnCaptureChanged(CWnd *pWnd);
172 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
173 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
174 afx_msg void CopyHashToClipboard(TShadowFilesTreeList &selectedLeafs);