Update diff del rename ignore document.
[TortoiseGit.git] / src / TortoiseProc / RepositoryBrowser.h
blob96534b059a5a1dd69315760042a60a38d99e66c9
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - Stefan Kueng
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 <deque>
24 #include "resource.h"
25 #include "TGitPath.h"
26 #include "RepositoryBar.h"
27 #include "StandAloneDlg.h"
28 #include "ProjectProperties.h"
29 #include "LogDlg.h"
30 #include "HintListCtrl.h"
32 #define REPOBROWSER_CTRL_MIN_WIDTH 20
33 #define REPOBROWSER_FETCHTIMER 101
35 using namespace std;
37 class CInputLogDlg;
38 class CTreeDropTarget;
39 class CListDropTarget;
41 /**
42 * \ingroup TortoiseProc
43 * helper class which holds all the information of an item (file or folder)
44 * in the repository. The information gets filled by the svn_client_list()
45 * callback.
47 class CItem
49 public:
50 CItem() : kind(svn_node_none)
51 , size(0)
52 , has_props(false)
53 , created_rev(0)
54 , time(0)
55 , is_dav_comment(false)
56 , lock_creationdate(0)
57 , lock_expirationdate(0)
60 CItem(const CString& _path,
61 svn_node_kind_t _kind,
62 svn_filesize_t _size,
63 bool _has_props,
64 svn_revnum_t _created_rev,
65 apr_time_t _time,
66 const CString& _author,
67 const CString& _locktoken,
68 const CString& _lockowner,
69 const CString& _lockcomment,
70 bool _is_dav_comment,
71 apr_time_t _lock_creationdate,
72 apr_time_t _lock_expirationdate,
73 const CString& _absolutepath)
75 path = _path;
76 kind = _kind;
77 size = _size;
78 has_props = _has_props;
79 created_rev = _created_rev;
80 time = _time;
81 author = _author;
82 locktoken = _locktoken;
83 lockowner = _lockowner;
84 lockcomment = _lockcomment;
85 is_dav_comment = _is_dav_comment;
86 lock_creationdate = _lock_creationdate;
87 lock_expirationdate = _lock_expirationdate;
88 absolutepath = _absolutepath;
90 public:
91 CString path;
92 svn_node_kind_t kind;
93 svn_filesize_t size;
94 bool has_props;
95 svn_revnum_t created_rev;
96 apr_time_t time;
97 CString author;
98 CString locktoken;
99 CString lockowner;
100 CString lockcomment;
101 bool is_dav_comment;
102 apr_time_t lock_creationdate;
103 apr_time_t lock_expirationdate;
104 CString absolutepath; ///< unescaped url stripped of repository root
108 * \ingroup TortoiseProc
109 * helper class which holds the information for a tree item
110 * in the repository browser.
112 class CTreeItem
114 public:
115 CTreeItem() : children_fetched(false), has_child_folders(false) {}
117 CString unescapedname;
118 CString url; ///< unescaped url
119 bool children_fetched; ///< whether the contents of the folder are known/fetched or not
120 deque<CItem> children;
121 bool has_child_folders;
126 * \ingroup TortoiseProc
127 * Dialog to browse a repository.
129 class CRepositoryBrowser : public CResizableStandAloneDialog, public SVN, public IRepo
131 DECLARE_DYNAMIC(CRepositoryBrowser)
132 friend class CTreeDropTarget;
133 friend class CListDropTarget;
135 public:
136 CRepositoryBrowser(const CString& url, const SVNRev& rev); ///< standalone repository browser
137 CRepositoryBrowser(const CString& url, const SVNRev& rev, CWnd* pParent); ///< dependent repository browser
138 virtual ~CRepositoryBrowser();
140 /// Returns the currently displayed revision only (for convenience)
141 SVNRev GetRevision() const;
142 /// Returns the currently displayed URL's path only (for convenience)
143 CString GetPath() const;
145 /// switches to the \c url at \c rev. If the url is valid and exists,
146 /// the repository browser will show the content of that url.
147 bool ChangeToUrl(CString& url, SVNRev& rev, bool bAlreadyChecked);
149 CString GetRepoRoot() { return m_strReposRoot; }
151 enum { IDD = IDD_REPOSITORY_BROWSER };
153 /// the project properties if the repository browser was started from a working copy
154 ProjectProperties m_ProjectProperties;
155 /// the local path of the working copy
156 CTSVNPath m_path;
157 protected:
158 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
159 virtual BOOL OnInitDialog();
160 virtual void OnOK();
161 virtual void OnCancel();
162 virtual BOOL PreTranslateMessage(MSG* pMsg);
163 virtual BOOL Cancel() {return m_bCancelled;}
165 afx_msg void OnBnClickedHelp();
166 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
167 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
168 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
169 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
170 afx_msg void OnTvnSelchangedRepotree(NMHDR *pNMHDR, LRESULT *pResult);
171 afx_msg void OnTvnItemexpandingRepotree(NMHDR *pNMHDR, LRESULT *pResult);
172 afx_msg void OnNMDblclkRepolist(NMHDR *pNMHDR, LRESULT *pResult);
173 afx_msg void OnHdnItemclickRepolist(NMHDR *pNMHDR, LRESULT *pResult);
174 afx_msg void OnLvnItemchangedRepolist(NMHDR *pNMHDR, LRESULT *pResult);
175 afx_msg void OnLvnBegindragRepolist(NMHDR *pNMHDR, LRESULT *pResult);
176 afx_msg void OnLvnBeginrdragRepolist(NMHDR *pNMHDR, LRESULT *pResult);
177 afx_msg void OnTvnBegindragRepotree(NMHDR *pNMHDR, LRESULT *pResult);
178 afx_msg void OnTvnBeginrdragRepotree(NMHDR *pNMHDR, LRESULT *pResult);
179 afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
180 afx_msg void OnLvnEndlabeleditRepolist(NMHDR *pNMHDR, LRESULT *pResult);
181 afx_msg void OnTvnEndlabeleditRepotree(NMHDR *pNMHDR, LRESULT *pResult);
182 afx_msg void OnTimer(UINT_PTR nIDEvent);
184 afx_msg void OnUrlFocus();
185 afx_msg void OnCopy();
186 afx_msg void OnInlineedit();
187 afx_msg void OnRefresh();
188 afx_msg void OnDelete();
189 afx_msg void OnGoUp();
191 DECLARE_MESSAGE_MAP()
193 /// called after the init thread has finished
194 LRESULT OnAfterInitDialog(WPARAM /*wParam*/, LPARAM /*lParam*/);
195 /// draws the bar when the tree and list control are resized
196 void DrawXorBar(CDC * pDC, int x1, int y1, int width, int height);
197 /// callback from the SVN::List() method which stores all the information
198 virtual BOOL ReportList(const CString& path, svn_node_kind_t kind,
199 svn_filesize_t size, bool has_props, svn_revnum_t created_rev,
200 apr_time_t time, const CString& author, const CString& locktoken,
201 const CString& lockowner, const CString& lockcomment,
202 bool is_dav_comment, apr_time_t lock_creationdate,
203 apr_time_t lock_expirationdate, const CString& absolutepath);
205 /// recursively removes all items from \c hItem on downwards.
206 void RecursiveRemove(HTREEITEM hItem, bool bChildrenOnly = false);
207 /// searches the tree item for the specified \c fullurl.
208 HTREEITEM FindUrl(const CString& fullurl, bool create = true);
209 /// searches the tree item for the specified \c fullurl.
210 HTREEITEM FindUrl(const CString& fullurl, const CString& url, bool create = true, HTREEITEM hItem = TVI_ROOT);
212 * Refetches the information for \c url. If \c force is true, then the list
213 * control is refilled again.
214 * \param recursive if true, the information is fetched recursively.
216 bool RefreshNode(const CString& url, bool force = false, bool recursive = false);
218 * Refetches the information for \c hNode. If \c force is true, then the list
219 * control is refilled again.
220 * \param recursive if true, the information is fetched recursively.
222 bool RefreshNode(HTREEITEM hNode, bool force = false, bool recursive = false);
223 /// Fills the list control with all the items in \c pItems.
224 void FillList(deque<CItem> * pItems);
225 /// Sets the sort arrow in the list view header according to the currently used sorting.
226 void SetSortArrow();
227 /// called when a drag-n-drop operation starts
228 void OnBeginDrag(NMHDR *pNMHDR);
229 void OnBeginDragTree(NMHDR *pNMHDR);
230 /// called when a drag-n-drop operation ends and the user dropped something on us.
231 bool OnDrop(const CTSVNPath& target, const CTSVNPathList& pathlist, const SVNRev& srcRev, DWORD dwEffect, POINTL pt);
233 * Since all urls we store and use are not properly escaped but "UI friendly", this
234 * method converts those urls to a properly escaped url which we can use in
235 * Subversion API calls.
237 CString EscapeUrl(const CTSVNPath& url);
238 /// Initializes the repository browser with a new root url
239 void InitRepo();
240 /// Helper function to show the "File Save" dialog
241 bool AskForSavePath(const CTSVNPathList& urlList, CTSVNPath &tempfile, bool bFolder);
243 /// Saves the column widths
244 void SaveColumnWidths(bool bSaveToRegistry = false);
245 /// converts a string to an array of column widths
246 bool StringToWidthArray(const CString& WidthString, int WidthArray[]);
247 /// converts an array of column widths to a string
248 CString WidthArrayToString(int WidthArray[]);
251 static UINT InitThreadEntry(LPVOID pVoid);
252 UINT InitThread();
254 static int CALLBACK ListSort(LPARAM lParam1, LPARAM lParam2, LPARAM lParam3);
256 protected:
257 bool m_bInitDone;
258 CRepositoryBar m_barRepository;
259 CRepositoryBarCnr m_cnrRepositoryBar;
261 CTreeCtrl m_RepoTree;
262 CHintListCtrl m_RepoList;
264 CString m_strReposRoot;
265 CString m_sUUID;
267 HACCEL m_hAccel;
269 private:
270 bool m_bStandAlone;
271 CString m_InitialUrl;
272 SVNRev m_initialRev;
273 bool m_bThreadRunning;
274 static const UINT m_AfterInitMessage;
276 int m_nIconFolder;
277 int m_nOpenIconFolder;
279 volatile bool m_blockEvents;
281 bool m_bSortAscending;
282 int m_nSortedColumn;
283 int m_arColumnWidths[7];
284 int m_arColumnAutoWidths[7];
286 CTreeDropTarget * m_pTreeDropTarget;
287 CListDropTarget * m_pListDropTarget;
288 bool m_bRightDrag;
290 int oldy, oldx;
291 bool bDragMode;
293 bool m_bCancelled;
295 svn_node_kind_t m_diffKind;
296 CTSVNPath m_diffURL;
298 CString m_origDlgTitle;
301 static UINT WM_AFTERINIT = RegisterWindowMessage(_T("TORTOISESVN_AFTERINIT_MSG"));