CommitDlg: Update empty file list message
[TortoiseGit.git] / src / TortoiseProc / RepositoryBrowser.h
blob9c40fa435fb7bb85e19cf31de38bfb889fe1d61d
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2014 - 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 "GitHash.h"
24 #include "GitStatusListCtrl.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_bLoaded(true)
40 , m_bSubmodule(false)
41 , m_bExecutable(false)
42 , m_bSymlink(false)
43 , m_iSize(0)
46 CString m_sName;
47 CGitHash m_hash;
48 git_off_t m_iSize;
49 bool m_bFolder;
50 bool m_bLoaded;
51 bool m_bSubmodule;
52 bool m_bExecutable;
53 bool m_bSymlink;
55 HTREEITEM m_hTree;
57 TShadowFilesTreeMap m_ShadowTree;
58 CShadowFilesTree* m_pParent;
60 CString GetFullName() const
62 if (m_pParent == NULL)
63 return m_sName;
65 CString parentPath = m_pParent->GetFullName();
66 if (parentPath.IsEmpty())
67 return m_sName;
68 else
69 return m_pParent->GetFullName() + _T("/") + m_sName;
72 typedef std::vector<CShadowFilesTree *> TShadowFilesTreeList;
74 class CRepositoryBrowser : public CResizableStandAloneDialog
76 DECLARE_DYNAMIC(CRepositoryBrowser)
78 public:
79 CRepositoryBrowser(CString rev, CWnd* pParent = NULL); // standard constructor
80 virtual ~CRepositoryBrowser();
82 // Dialog Data
83 enum { IDD = IDD_REPOSITORY_BROWSER };
85 static bool s_bSortLogical;
87 enum eCmd
89 eCmd_Open = WM_APP,
90 eCmd_OpenWith,
91 eCmd_OpenWithAlternativeEditor,
92 eCmd_ViewLog,
93 eCmd_Blame,
94 eCmd_CompareWC,
95 eCmd_Revert,
96 eCmd_SaveAs,
97 eCmd_CopyPath,
98 eCmd_CopyHash,
99 eCmd_ViewLogSubmodule,
100 eCmd_PrepareDiff,
101 eCmd_PrepareDiff_Compare,
104 enum eCol
106 eCol_Name,
107 eCol_Extension,
108 eCol_FileSize,
111 enum eOpenType
113 ALTERNATIVEEDITOR,
114 OPEN,
115 OPEN_WITH,
118 enum eSelectionType
120 ONLY_FILES,
121 ONLY_FILESSUBMODULES,
122 ONLY_FOLDERS,
123 MIXED_FOLDERS_FILES,
126 private:
127 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
129 DECLARE_MESSAGE_MAP()
131 afx_msg void OnOK();
132 afx_msg void OnCancel();
133 afx_msg void OnDestroy();
134 virtual BOOL OnInitDialog();
136 CTreeCtrl m_RepoTree;
137 CListCtrl m_RepoList;
138 ColumnManager m_ColumnManager;
140 afx_msg void OnLvnColumnclickRepoList(NMHDR *pNMHDR, LRESULT *pResult);
141 int m_currSortCol;
142 bool m_currSortDesc;
144 CShadowFilesTree m_TreeRoot;
145 int ReadTreeRecursive(git_repository &repo, const git_tree * tree, CShadowFilesTree * treeroot);
146 int ReadTree(CShadowFilesTree * treeroot, const CString& root = L"");
147 int m_nIconFolder;
148 int m_nOpenIconFolder;
149 int m_nExternalOvl;
150 int m_nExecutableOvl;
151 int m_nSymlinkOvl;
153 bool m_bHasWC;
155 void Refresh();
156 CString m_sRevision;
157 void FillListCtrlForTreeNode(HTREEITEM treeNode);
158 void FillListCtrlForShadowTree(CShadowFilesTree* pTree);
159 void UpdateInfoLabel();
160 afx_msg void OnTvnSelchangedRepoTree(NMHDR *pNMHDR, LRESULT *pResult);
161 afx_msg void OnTvnItemExpandingRepoTree(NMHDR *pNMHDR, LRESULT *pResult);
162 afx_msg void OnLvnItemchangedRepolist(NMHDR *pNMHDR, LRESULT *pResult);
164 afx_msg void OnNMDblclk_RepoList(NMHDR *pNMHDR, LRESULT *pResult);
165 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
166 void OnContextMenu_RepoList(CPoint point);
167 void OnContextMenu_RepoTree(CPoint point);
168 void ShowContextMenu(CPoint point, TShadowFilesTreeList &selectedLeafs, eSelectionType selType);
170 void FileSaveAs(const CString path);
171 void OpenFile(const CString path, eOpenType mode, bool isSubmodule, CGitHash itemHash);
172 bool RevertItemToVersion(const CString &path);
174 afx_msg void OnBnClickedButtonRevision();
176 virtual BOOL PreTranslateMessage(MSG* pMsg);
178 CString m_sMarkForDiffFilename;
179 CGitHash m_sMarkForDiffVersion;
181 /// resizes the control so that the divider is at position 'point'
182 void HandleDividerMove(CPoint point, bool bDraw);
183 bool bDragMode;
184 void SaveDividerPosition();
185 int oldy, oldx;
186 /// draws the bar when the tree and list control are resized
187 void DrawXorBar(CDC * pDC, int x1, int y1, int width, int height);
188 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
189 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
190 afx_msg void OnCaptureChanged(CWnd *pWnd);
191 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
192 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
193 afx_msg void CopyHashToClipboard(TShadowFilesTreeList &selectedLeafs);