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.
22 #include "StandAloneDlg.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
41 , m_bExecutable(false)
57 TShadowFilesTreeMap m_ShadowTree
;
58 CShadowFilesTree
* m_pParent
;
60 CString
GetFullName() const
62 if (m_pParent
== NULL
)
65 CString parentPath
= m_pParent
->GetFullName();
66 if (parentPath
.IsEmpty())
69 return m_pParent
->GetFullName() + _T("/") + m_sName
;
72 typedef std::vector
<CShadowFilesTree
*> TShadowFilesTreeList
;
74 class CRepositoryBrowser
: public CResizableStandAloneDialog
76 DECLARE_DYNAMIC(CRepositoryBrowser
)
79 CRepositoryBrowser(CString rev
, CWnd
* pParent
= NULL
); // standard constructor
80 virtual ~CRepositoryBrowser();
83 enum { IDD
= IDD_REPOSITORY_BROWSER
};
85 static bool s_bSortLogical
;
91 eCmd_OpenWithAlternativeEditor
,
99 eCmd_ViewLogSubmodule
,
119 ONLY_FILESSUBMODULES
,
125 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
127 DECLARE_MESSAGE_MAP()
130 afx_msg
void OnCancel();
131 afx_msg
void OnDestroy();
132 virtual BOOL
OnInitDialog();
134 CTreeCtrl m_RepoTree
;
135 CListCtrl m_RepoList
;
136 ColumnManager m_ColumnManager
;
138 afx_msg
void OnLvnColumnclickRepoList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
142 CShadowFilesTree m_TreeRoot
;
143 int ReadTreeRecursive(git_repository
&repo
, const git_tree
* tree
, CShadowFilesTree
* treeroot
);
144 int ReadTree(CShadowFilesTree
* treeroot
, const CString
& root
= L
"");
146 int m_nOpenIconFolder
;
148 int m_nExecutableOvl
;
155 void FillListCtrlForTreeNode(HTREEITEM treeNode
);
156 void FillListCtrlForShadowTree(CShadowFilesTree
* pTree
);
157 void UpdateInfoLabel();
158 afx_msg
void OnTvnSelchangedRepoTree(NMHDR
*pNMHDR
, LRESULT
*pResult
);
159 afx_msg
void OnTvnItemExpandingRepoTree(NMHDR
*pNMHDR
, LRESULT
*pResult
);
160 afx_msg
void OnLvnItemchangedRepolist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
162 afx_msg
void OnNMDblclk_RepoList(NMHDR
*pNMHDR
, LRESULT
*pResult
);
163 afx_msg
void OnContextMenu(CWnd
* pWndFrom
, CPoint point
);
164 void OnContextMenu_RepoList(CPoint point
);
165 void OnContextMenu_RepoTree(CPoint point
);
166 void ShowContextMenu(CPoint point
, TShadowFilesTreeList
&selectedLeafs
, eSelectionType selType
);
168 void FileSaveAs(const CString path
);
169 void OpenFile(const CString path
, eOpenType mode
, bool isSubmodule
, CGitHash itemHash
);
170 bool RevertItemToVersion(const CString
&path
);
172 afx_msg
void OnBnClickedButtonRevision();
174 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
176 /// resizes the control so that the divider is at position 'point'
177 void HandleDividerMove(CPoint point
, bool bDraw
);
179 void SaveDividerPosition();
181 /// draws the bar when the tree and list control are resized
182 void DrawXorBar(CDC
* pDC
, int x1
, int y1
, int width
, int height
);
183 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
184 afx_msg
void OnMouseMove(UINT nFlags
, CPoint point
);
185 afx_msg
void OnCaptureChanged(CWnd
*pWnd
);
186 afx_msg
void OnLButtonDown(UINT nFlags
, CPoint point
);
187 afx_msg
void OnLButtonUp(UINT nFlags
, CPoint point
);
188 afx_msg
void CopyHashToClipboard(TShadowFilesTreeList
&selectedLeafs
);