1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "TGitPath.h"
\r
21 #include "GitStatus.h"
\r
23 #include "GitConfig.h"
\r
26 #define SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN (-1)
\r
28 // these defines must be in the order the columns are inserted!
\r
29 #define SVNSLC_COLFILENAME 0x000000002
\r
30 #define SVNSLC_COLEXT 0x000000004
\r
31 #define SVNSLC_COLSTATUS 0x000000008
\r
32 #define SVNSLC_COLREMOTESTATUS 0x000000010
\r
33 #define SVNSLC_COLTEXTSTATUS 0x000000020
\r
34 #define SVNSLC_COLPROPSTATUS 0x000000040
\r
35 #define SVNSLC_COLREMOTETEXT 0x000000080
\r
36 #define SVNSLC_COLREMOTEPROP 0x000000100
\r
37 #define SVNSLC_COLURL 0x000000200
\r
38 #define SVNSLC_COLLOCK 0x000000400
\r
39 #define SVNSLC_COLLOCKCOMMENT 0x000000800
\r
40 #define SVNSLC_COLAUTHOR 0x000001000
\r
41 #define SVNSLC_COLREVISION 0x000002000
\r
42 #define SVNSLC_COLREMOTEREVISION 0x000004000
\r
43 #define SVNSLC_COLDATE 0x000009000
\r
44 #define SVNSLC_COLSVNNEEDSLOCK 0x000010000
\r
45 #define SVNSLC_COLCOPYFROM 0x000020000
\r
46 #define SVNSLC_COLMODIFICATIONDATE 0x000040000
\r
47 #define SVNSLC_NUMCOLUMNS 19
\r
49 #define SVNSLC_SHOWUNVERSIONED 0x000000001
\r
50 #define SVNSLC_SHOWNORMAL 0x000000002
\r
51 #define SVNSLC_SHOWMODIFIED 0x000000004
\r
52 #define SVNSLC_SHOWADDED 0x000000008
\r
53 #define SVNSLC_SHOWREMOVED 0x000000010
\r
54 #define SVNSLC_SHOWCONFLICTED 0x000000020
\r
55 #define SVNSLC_SHOWMISSING 0x000000040
\r
56 #define SVNSLC_SHOWREPLACED 0x000000080
\r
57 #define SVNSLC_SHOWMERGED 0x000000100
\r
58 #define SVNSLC_SHOWIGNORED 0x000000200
\r
59 #define SVNSLC_SHOWOBSTRUCTED 0x000000400
\r
60 #define SVNSLC_SHOWEXTERNAL 0x000000800
\r
61 #define SVNSLC_SHOWINCOMPLETE 0x000001000
\r
62 #define SVNSLC_SHOWINEXTERNALS 0x000002000
\r
63 #define SVNSLC_SHOWREMOVEDANDPRESENT 0x000004000
\r
64 #define SVNSLC_SHOWLOCKS 0x000008000
\r
65 #define SVNSLC_SHOWDIRECTFILES 0x000010000
\r
66 #define SVNSLC_SHOWDIRECTFOLDER 0x000020000
\r
67 #define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x000040000
\r
68 #define SVNSLC_SHOWSWITCHED 0x000080000
\r
69 #define SVNSLC_SHOWINCHANGELIST 0x000100000
\r
71 #define SVNSLC_SHOWDIRECTS (SVNSLC_SHOWDIRECTFILES | SVNSLC_SHOWDIRECTFOLDER)
\r
74 #define SVNSLC_SHOWVERSIONED (SVNSLC_SHOWNORMAL|SVNSLC_SHOWMODIFIED|\
\r
75 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
76 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
77 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
\r
78 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
\r
80 #define SVNSLC_SHOWVERSIONEDBUTNORMAL (SVNSLC_SHOWMODIFIED|SVNSLC_SHOWADDED|\
\r
81 SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
82 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
83 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
\r
84 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
\r
86 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS (SVNSLC_SHOWMODIFIED|\
\r
87 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
88 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
89 SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINEXTERNALS)
\r
91 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS (SVNSLC_SHOWMODIFIED|\
\r
92 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
93 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
94 SVNSLC_SHOWINCOMPLETE)
\r
96 #define SVNSLC_SHOWALL (SVNSLC_SHOWVERSIONED|SVNSLC_SHOWUNVERSIONED)
\r
98 #define SVNSLC_POPALL 0xFFFFFFFF
\r
99 #define SVNSLC_POPCOMPAREWITHBASE 0x00000001
\r
100 #define SVNSLC_POPCOMPARE 0x00000002
\r
101 #define SVNSLC_POPGNUDIFF 0x00000004
\r
102 #define SVNSLC_POPREVERT 0x00000008
\r
103 #define SVNSLC_POPUPDATE 0x00000010
\r
104 #define SVNSLC_POPSHOWLOG 0x00000020
\r
105 #define SVNSLC_POPOPEN 0x00000040
\r
106 #define SVNSLC_POPDELETE 0x00000080
\r
107 #define SVNSLC_POPADD 0x00000100
\r
108 #define SVNSLC_POPIGNORE 0x00000200
\r
109 #define SVNSLC_POPCONFLICT 0x00000400
\r
110 #define SVNSLC_POPRESOLVE 0x00000800
\r
111 #define SVNSLC_POPLOCK 0x00001000
\r
112 #define SVNSLC_POPUNLOCK 0x00002000
\r
113 #define SVNSLC_POPUNLOCKFORCE 0x00004000
\r
114 #define SVNSLC_POPEXPLORE 0x00008000
\r
115 #define SVNSLC_POPCOMMIT 0x00010000
\r
116 #define SVNSLC_POPPROPERTIES 0x00020000
\r
117 #define SVNSLC_POPREPAIRMOVE 0x00040000
\r
118 #define SVNSLC_POPCHANGELISTS 0x00080000
\r
119 #define SVNSLC_POPBLAME 0x00100000
\r
121 #define SVNSLC_IGNORECHANGELIST _T("ignore-on-commit")
\r
123 // This gives up to 64 standard properties and menu entries
\r
124 // plus 192 user-defined properties (should be plenty).
\r
125 // User-defined properties will start at column SVNSLC_NUMCOLUMNS+1
\r
126 // but in the registry, we will record them starting at SVNSLC_USERPROPCOLOFFSET.
\r
128 #define SVNSLC_USERPROPCOLOFFSET 0x40
\r
129 #define SVNSLC_USERPROPCOLLIMIT 0xff
\r
130 #define SVNSLC_MAXCOLUMNCOUNT 0xff
\r
132 // Supporting extreamly long user props makes no sense here --
\r
133 // especially for binary properties. CString uses a pool allocator
\r
134 // that works for up to 256 chars. Make sure we are well below that.
\r
136 #define SVNSLC_MAXUSERPROPLENGTH 0x70
\r
138 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
\r
139 typedef CComCritSecLock<CComCriticalSection> Locker;
\r
143 * A List control, based on the MFC CListCtrl which shows a list of
\r
144 * files with their Subversion status. The control also provides a context
\r
145 * menu to do some Subversion tasks on the selected files.
\r
147 * This is the main control used in many dialogs to show a list of files to
\r
150 class CGitStatusListCtrl :
\r
155 * Sent to the parent window (using ::SendMessage) after a context menu
\r
156 * command has finished if the item count has changed.
\r
158 static const UINT SVNSLNM_ITEMCOUNTCHANGED;
\r
160 * Sent to the parent window (using ::SendMessage) when the control needs
\r
161 * to be refreshed. Since this is done usually in the parent window using
\r
162 * a thread, this message is used to tell the parent to do exactly that.
\r
164 static const UINT SVNSLNM_NEEDSREFRESH;
\r
167 * Sent to the parent window (using ::SendMessage) when the user drops
\r
168 * files on the control. The LPARAM is a pointer to a TCHAR string
\r
169 * containing the dropped path.
\r
171 static const UINT SVNSLNM_ADDFILE;
\r
174 * Sent to the parent window (using ::SendMessage) when the user checks/unchecks
\r
175 * one or more items in the control. The WPARAM contains the number of
\r
176 * checked items in the control.
\r
178 static const UINT SVNSLNM_CHECKCHANGED;
\r
180 CGitStatusListCtrl(void);
\r
181 ~CGitStatusListCtrl(void);
\r
184 * \ingroup TortoiseProc
\r
185 * Helper class for CGitStatusListCtrl which represents
\r
186 * the data for each file shown.
\r
191 FileEntry() : status(git_wc_status_unversioned)
\r
192 // , copyfrom_rev(GIT_REV_ZERO)
\r
193 , last_commit_date(0)
\r
194 , last_commit_rev(GIT_REV_ZERO)
\r
195 // , remoterev(GIT_REV_ZERO)
\r
196 , textstatus(git_wc_status_unversioned)
\r
197 , propstatus(git_wc_status_unversioned)
\r
198 // , remotestatus(git_wc_status_unversioned)
\r
199 // , remotetextstatus(git_wc_status_unversioned)
\r
200 // , remotepropstatus(git_wc_status_unversioned)
\r
204 , inunversionedfolder(false)
\r
205 , inexternal(false)
\r
206 , differentrepo(false)
\r
210 , Revision(GIT_REV_ZERO)
\r
211 , isConflicted(false)
\r
212 // , present_props()
\r
214 /// , working_size(SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN)
\r
216 // , depth(git_depth_unknown)
\r
219 const CTGitPath& GetPath() const
\r
223 const bool IsChecked() const
\r
227 CString GetRelativeGitPath() const
\r
229 if (path.IsEquivalentTo(basepath))
\r
230 return path.GetGitPathString();
\r
231 return path.GetGitPathString().Mid(basepath.GetGitPathString().GetLength()+1);
\r
233 // const bool IsLocked() const
\r
235 // return !(lock_token.IsEmpty() && lock_remotetoken.IsEmpty());
\r
237 // const bool HasNeedsLock() const
\r
239 // return needslock;
\r
241 const bool IsFolder() const
\r
245 const bool IsInExternal() const
\r
249 const bool IsNested() const
\r
253 const bool IsFromDifferentRepository() const
\r
255 return differentrepo;
\r
257 CString GetDisplayName() const
\r
259 CString const& chopped = path.GetDisplayString(&basepath);
\r
260 if (!chopped.IsEmpty())
\r
266 // "Display name" must not be empty.
\r
267 return path.GetFileOrDirectoryName();
\r
270 CString GetChangeList() const
\r
274 // CString GetURL() const
\r
279 git_wc_status_kind status; ///< local status
\r
280 git_wc_status_kind textstatus; ///< local text status
\r
281 git_wc_status_kind propstatus; ///< local property status
\r
284 CTGitPath path; ///< full path of the file
\r
285 CTGitPath basepath; ///< common ancestor path of all files
\r
287 CString changelist; ///< the name of the changelist the item belongs to
\r
289 CString last_commit_author; ///< the author which last committed this item
\r
290 CTime last_commit_date; ///< the date when this item was last committed
\r
291 git_revnum_t last_commit_rev; ///< the revision where this item was last committed
\r
293 git_revnum_t remoterev; ///< the revision in HEAD of the repository
\r
294 bool copied; ///< if the file/folder is added-with-history
\r
295 bool switched; ///< if the file/folder is switched to another url
\r
296 bool checked; ///< if the file is checked in the list control
\r
297 bool inunversionedfolder; ///< if the file is inside an unversioned folder
\r
298 bool inexternal; ///< if the item is in an external folder
\r
299 bool differentrepo; ///< if the item is from a different repository than the rest
\r
300 bool direct; ///< directly included (TRUE) or just a child of a folder
\r
301 bool isfolder; ///< TRUE if entry refers to a folder
\r
302 bool isNested; ///< TRUE if the folder from a different repository and/or path
\r
303 bool isConflicted; ///< TRUE if a file entry is conflicted, i.e. if it has the conflicted paths set
\r
304 bool needslock; ///< TRUE if the Git:needs-lock property is set
\r
305 git_revnum_t Revision; ///< the base revision
\r
306 // PropertyList present_props; ///< cacheable properties present in BASE
\r
307 bool keeplocal; ///< Whether a local copy of this entry should be kept in the working copy after a deletion has been committed
\r
308 git_depth_t depth; ///< the depth of this entry
\r
309 friend class CGitStatusListCtrl;
\r
310 friend class CGitStatusListCtrlDropTarget;
\r
311 friend class CSorter;
\r
314 * \ingroup TortoiseProc
\r
315 * Helper class for CGitStatusListCtrl that represents
\r
316 * the columns visible and their order as well as
\r
317 * persisting that data in the registry.
\r
319 * It assigns logical index values to the (potential) columns:
\r
320 * 0 .. GitSLC_NUMCOLUMNS-1 contain the standard attributes
\r
321 * GitSLC_USERPROPCOLOFFSET .. GitSLC_MAXCOLUMNCOUNT are user props.
\r
323 * The column vector contains the columns that are actually
\r
324 * available in the control.
\r
326 * Since the set of userprops may change from one WC to another,
\r
327 * we also store the settings (width and order) for those
\r
328 * userprops that are not used in this WC.
\r
330 * A userprop is considered "in use", if the respective column
\r
331 * is not hidden or if at least one item has this property set.
\r
333 class ColumnManager
\r
337 /// construction / destruction
\r
339 ColumnManager (CListCtrl* control) : control (control) {};
\r
340 ~ColumnManager() {};
\r
342 /// registry access
\r
344 void ReadSettings (DWORD defaultColumns, const CString& containerName);
\r
345 void WriteSettings() const;
\r
347 /// read column definitions
\r
349 int GetColumnCount() const; ///< total number of columns
\r
350 bool IsVisible (int column) const;
\r
351 int GetInvisibleCount() const;
\r
352 bool IsRelevant (int column) const;
\r
353 bool IsUserProp (int column) const;
\r
354 CString GetName (int column) const;
\r
355 int GetWidth (int column, bool useDefaults = false) const;
\r
356 int GetVisibleWidth (int column, bool useDefaults) const;
\r
358 /// switch columns on and off
\r
360 void SetVisible (int column, bool visible);
\r
362 /// tracking column modifications
\r
364 void ColumnMoved (int column, int position);
\r
365 void ColumnResized (int column);
\r
367 /// call these to update the user-prop list
\r
368 /// (will also auto-insert /-remove new list columns)
\r
370 void UpdateUserPropList (const std::vector<FileEntry*>& files);
\r
371 void UpdateRelevance ( const std::vector<FileEntry*>& files
\r
372 , const std::vector<size_t>& visibleFiles);
\r
374 /// don't clutter the context menu with irrelevant prop info
\r
376 bool AnyUnusedProperties() const;
\r
377 void RemoveUnusedProps();
\r
379 /// bring everything back to its "natural" order
\r
381 void ResetColumns (DWORD defaultColumns);
\r
385 /// initialization utilities
\r
387 void ParseUserPropSettings ( const CString& userPropList
\r
388 , const CString& shownUserProps);
\r
389 void ParseWidths (const CString& widths);
\r
390 void SetStandardColumnVisibility (DWORD visibility);
\r
391 void ParseColumnOrder (const CString& widths);
\r
393 /// map internal column order onto visible column order
\r
394 /// (all invisibles in front)
\r
396 std::vector<int> GetGridColumnOrder();
\r
397 void ApplyColumnOrder();
\r
399 /// utilities used when writing data to the registry
\r
401 DWORD GetSelectedStandardColumns() const;
\r
402 CString GetUserPropList() const;
\r
403 CString GetShownUserProps() const;
\r
404 CString GetWidthString() const;
\r
405 CString GetColumnOrderString() const;
\r
407 /// our parent control and its data
\r
409 CListCtrl* control;
\r
411 /// where to store in the registry
\r
413 CString registryPrefix;
\r
415 /// all columns in their "natural" order
\r
419 int index; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
\r
422 bool relevant; ///< set to @a visible, if no *shown* item has that property
\r
425 std::vector<ColumnInfo> columns;
\r
427 /// user-defined properties
\r
431 CString name; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
\r
435 std::vector<UserProp> userProps;
\r
437 /// stored result from last UpdateUserPropList() call
\r
439 std::set<CString> itemProps;
\r
441 /// global column ordering including unused user props
\r
443 std::vector<int> columnOrder;
\r
445 * \ingroup TortoiseProc
\r
446 * Simple utility class that defines the sort column order.
\r
452 CSorter ( ColumnManager* columnManager
\r
456 bool operator() ( const FileEntry* entry1
\r
457 , const FileEntry* entry2) const;
\r
461 ColumnManager* columnManager;
\r
467 * Initializes the control, sets up the columns.
\r
468 * \param dwColumns mask of columns to show. Use the GitSLC_COLxxx defines.
\r
469 * \param sColumnInfoContainer Name of a registry key
\r
470 * where the position and visibility of each column
\r
471 * is saved and used from. If the registry key
\r
472 * doesn't exist, the default order is used
\r
473 * and dwColumns tells which columns are visible.
\r
474 * \param dwContextMenus mask of context menus to be active, not all make sense for every use of this control.
\r
475 * Use the GitSLC_POPxxx defines.
\r
476 * \param bHasCheckboxes TRUE if the control should show check boxes on the left of each file entry.
\r
478 void Init(DWORD dwColumns, const CString& sColumnInfoContainer, DWORD dwContextMenus = (SVNSLC_POPALL ^ SVNSLC_POPCOMMIT), bool bHasCheckboxes = true);
\r
480 * Sets a background image for the list control.
\r
481 * The image is shown in the right bottom corner.
\r
482 * \param nID the resource ID of the bitmap to use as the background
\r
484 bool SetBackgroundImage(UINT nID);
\r
486 * Makes the 'ignore' context menu only ignore the files and not add the
\r
487 * folder which gets the Git:ignore property changed to the list.
\r
488 * This is needed e.g. for the Add-dialog, where the modified folder
\r
489 * showing up would break the resulting "add" command.
\r
491 void SetIgnoreRemoveOnly(bool bRemoveOnly = true) {m_bIgnoreRemoveOnly = bRemoveOnly;}
\r
493 * The unversioned items are by default shown after all other files in the list.
\r
494 * If that behavior should be changed, set this value to false.
\r
496 void PutUnversionedLast(bool bLast) {m_bUnversionedLast = bLast;}
\r
498 * Fetches the Subversion status of all files and stores the information
\r
499 * about them in an internal array.
\r
500 * \param sFilePath path to a file which contains a list of files and/or folders for which to
\r
501 * fetch the status, separated by newlines.
\r
502 * \param bUpdate TRUE if the remote status is requested too.
\r
503 * \return TRUE on success.
\r
505 BOOL GetStatus ( const CTGitPathList& pathList
\r
506 , bool bUpdate = false
\r
507 , bool bShowIgnores = false
\r
508 , bool bShowUserProps = false);
\r
511 * Populates the list control with the previously (with GetStatus) gathered status information.
\r
512 * \param dwShow mask of file types to show. Use the GitSLC_SHOWxxx defines.
\r
513 * \param dwCheck mask of file types to check. Use GitLC_SHOWxxx defines. Default (0) means 'use the entry's stored check status'
\r
515 void Show(DWORD dwShow, DWORD dwCheck = 0, bool bShowFolders = true);
\r
516 void Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders = true);
\r
519 * Copies the selected entries in the control to the clipboard. The entries
\r
520 * are separated by newlines.
\r
521 * \param dwCols the columns to copy. Each column is separated by a tab.
\r
523 bool CopySelectedEntriesToClipboard(DWORD dwCols);
\r
526 * If during the call to GetStatus() some Git:externals are found from different
\r
527 * repositories than the first one checked, then this method returns TRUE.
\r
529 BOOL HasExternalsFromDifferentRepos() const {return m_bHasExternalsFromDifferentRepos;}
\r
532 * If during the call to GetStatus() some Git:externals are found then this method returns TRUE.
\r
534 BOOL HasExternals() const {return m_bHasExternals;}
\r
537 * If unversioned files are found (but not necessarily shown) TRUE is returned.
\r
539 BOOL HasUnversionedItems() {return m_bHasUnversionedItems;}
\r
542 * If there are any locks in the working copy, TRUE is returned
\r
544 BOOL HasLocks() const {return m_bHasLocks;}
\r
547 * If there are any change lists defined in the working copy, TRUE is returned
\r
549 BOOL HasChangeLists() const {return m_bHasChangeLists;}
\r
552 * Returns the file entry data for the list control index.
\r
554 CGitStatusListCtrl::FileEntry * GetListEntry(UINT_PTR index);
\r
557 * Returns the file entry data for the specified path.
\r
558 * \note The entry might not be shown in the list control.
\r
560 CGitStatusListCtrl::FileEntry * GetListEntry(const CTGitPath& path);
\r
563 * Returns the index of the list control entry with the specified path,
\r
564 * or -1 if the path is not in the list control.
\r
566 int GetIndex(const CTGitPath& path);
\r
569 * Returns the file entry data for the specified path in the list control.
\r
571 CGitStatusListCtrl::FileEntry * GetVisibleListEntry(const CTGitPath& path);
\r
574 * Returns a String containing some statistics like number of modified, normal, deleted,...
\r
577 CString GetStatisticsString();
\r
580 * Set a static control which will be updated automatically with
\r
581 * the number of selected and total files shown in the list control.
\r
583 void SetStatLabel(CWnd * pStatLabel){m_pStatLabel = pStatLabel;};
\r
586 * Set a tri-state checkbox which is updated automatically if the
\r
587 * user checks/unchecks file entries in the list control to indicate
\r
588 * if all files are checked, none are checked or some are checked.
\r
590 void SetSelectButton(CButton * pButton) {m_pSelectButton = pButton;}
\r
593 * Set a button which is de-/activated automatically. The button is
\r
594 * only set active if at least one item is selected.
\r
596 void SetConfirmButton(CButton * pButton) {m_pConfirmButton = pButton;}
\r
599 * Select/unselect all entries in the list control.
\r
600 * \param bSelect TRUE to check, FALSE to uncheck.
\r
602 void SelectAll(bool bSelect, bool bIncludeNoCommits = false);
\r
604 /** Set a checkbox on an entry in the listbox
\r
605 * Keeps the listctrl checked state and the FileEntry's checked flag in sync
\r
607 void SetEntryCheck(FileEntry* pEntry, int listboxIndex, bool bCheck);
\r
609 /** Write a list of the checked items' paths into a path list
\r
611 void WriteCheckedNamesToPathList(CTGitPathList& pathList);
\r
613 /** fills in \a lMin and \a lMax with the lowest/highest revision of all
\r
614 * files/folders in the working copy.
\r
615 * \param bShownOnly if true, the min/max revisions are calculated only for shown items
\r
616 * \param bCheckedOnly if true, the min/max revisions are calculated only for items
\r
617 * which are checked.
\r
618 * \remark Since an item can only be checked if it is visible/shown in the list control
\r
619 * bShownOnly is automatically set to true if bCheckedOnly is true
\r
621 void GetMinMaxRevisions(git_revnum_t& rMin, git_revnum_t& rMax, bool bShownOnly, bool bCheckedOnly);
\r
624 * Returns the parent directory of all entries in the control.
\r
625 * if \a bStrict is set to false, then the paths passed to the control
\r
626 * to fetch the status (in GetStatus()) are used if possible.
\r
628 CTGitPath GetCommonDirectory(bool bStrict);
\r
631 * Returns the parent url of all entries in the control.
\r
632 * if \a bStrict is set to false, then the paths passed to the control
\r
633 * to fetch the status (in GetStatus()) are used if possible.
\r
635 CTGitPath GetCommonURL(bool bStrict);
\r
638 * Sets a pointer to a boolean variable which is checked periodically
\r
639 * during the status fetching. As soon as the variable changes to true,
\r
640 * the operations stops.
\r
642 void SetCancelBool(bool * pbCanceled) {m_pbCanceled = pbCanceled;}
\r
645 * Sets the string shown in the control while the status is fetched.
\r
646 * If not set, it defaults to "please wait..."
\r
648 void SetBusyString(const CString& str) {m_sBusy = str;}
\r
649 void SetBusyString(UINT id) {m_sBusy.LoadString(id);}
\r
652 * Sets the string shown in the control if no items are shown. This
\r
653 * can happen for example if there's nothing modified and the unversioned
\r
654 * files aren't shown either, so there's nothing to commit.
\r
655 * If not set, it defaults to "file list is empty".
\r
657 void SetEmptyString(const CString& str) {m_sEmpty = str;}
\r
658 void SetEmptyString(UINT id) {m_sEmpty.LoadString(id);}
\r
661 * Determines if the control should recurse into unversioned folders
\r
662 * when fetching the status. The default behavior is defined by the
\r
663 * registry key HKCU\Software\TortoiseGit\UnversionedRecurse, which
\r
664 * is read in the Init() method.
\r
665 * If you want to change the behavior, call this method *after*
\r
668 void SetUnversionedRecurse(bool bUnversionedRecurse) {m_bUnversionedRecurse = bUnversionedRecurse;}
\r
671 * Returns the number of selected items
\r
673 LONG GetSelected(){return m_nSelected;};
\r
676 * Enables dropping of files on the control.
\r
678 bool EnableFileDrop();
\r
681 * Checks if the path already exists in the list.
\r
683 bool HasPath(const CTGitPath& path);
\r
685 * Checks if the path is shown/visible in the list control.
\r
687 bool IsPathShown(const CTGitPath& path);
\r
689 * Forces the children to be checked when the parent folder is checked,
\r
690 * and the parent folder to be unchecked if one of its children is unchecked.
\r
692 void CheckChildrenWithParent(bool bCheck) {m_bCheckChildrenWithParent = bCheck;}
\r
695 * Allows checking the items if change lists are present. If set to false,
\r
696 * items are not checked if at least one changelist is available.
\r
698 void CheckIfChangelistsArePresent(bool bCheck) {m_bCheckIfGroupsExist = bCheck;}
\r
700 * Returns the currently used show flags passed to the Show() method.
\r
702 DWORD GetShowFlags() {return m_dwShow;}
\r
704 CString GetLastErrorMessage() {return m_sLastError;}
\r
706 void Block(BOOL block, BOOL blockUI) {m_bBlock = block; m_bBlockUI = blockUI;}
\r
708 LONG m_nTargetCount; ///< number of targets in the file passed to GetStatus()
\r
710 CString m_sURL; ///< the URL of the target or "(multiple targets)"
\r
712 GitRev m_HeadRev; ///< the HEAD revision of the repository if bUpdate was TRUE
\r
714 CString m_sUUID; ///< the UUID of the associated repository
\r
716 DECLARE_MESSAGE_MAP()
\r
719 void SaveColumnWidths(bool bSaveToRegistry = false);
\r
720 void Sort(); ///< Sorts the control by columns
\r
721 void AddEntry(FileEntry * entry, WORD langID, int listIndex); ///< add an entry to the control
\r
722 void RemoveListEntry(int index); ///< removes an entry from the listcontrol and both arrays
\r
723 bool BuildStatistics(); ///< build the statistics and correct the case of files/folders
\r
724 void StartDiff(int fileindex); ///< start the external diff program
\r
726 /// fetch all user properties for all items
\r
727 void FetchUserProperties();
\r
729 /// Process one line of the command file supplied to GetStatus
\r
730 bool FetchStatusForSingleTarget(GitConfig& config, GitStatus& status, const CTGitPath& target,
\r
731 bool bFetchStatusFromRepository, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths,
\r
732 bool bAllDirect, git_depth_t depth = git_depth_infinity, bool bShowIgnores = false);
\r
734 /// Create 'status' data for each item in an unversioned folder
\r
735 void AddUnversionedFolder(const CTGitPath& strFolderName, const CTGitPath& strBasePath, GitConfig * config);
\r
737 /// Read the all the other status items which result from a single GetFirstStatus call
\r
738 void ReadRemainingItemsStatus(GitStatus& status, const CTGitPath& strBasePath, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths, GitConfig * config, bool bAllDirect);
\r
740 /// Clear the status vector (contains custodial pointers)
\r
741 void ClearStatusArray();
\r
743 /// Sort predicate function - Compare the paths of two entries without regard to case
\r
744 static bool EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2);
\r
746 /// Predicate used to build a list of only the versioned entries of the FileEntry array
\r
747 static bool IsEntryVersioned(const FileEntry* pEntry1);
\r
749 /// Look up the relevant show flags for a particular Git status value
\r
750 DWORD GetShowFlagsFromGitStatus(git_wc_status_kind status);
\r
752 /// Build a FileEntry item and add it to the FileEntry array
\r
753 const FileEntry* AddNewFileEntry(
\r
754 const git_wc_status2_t* pGitStatus, // The return from the Git GetStatus functions
\r
755 const CTGitPath& path, // The path of the item we're adding
\r
756 const CTGitPath& basePath, // The base directory for this status build
\r
757 bool bDirectItem, // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call
\r
758 bool bInExternal, // Are we in an 'external' folder
\r
759 bool bEntryfromDifferentRepo // if the entry is from a different repository
\r
762 /// Adjust the checkbox-state on all descendants of a specific item
\r
763 void SetCheckOnAllDescendentsOf(const FileEntry* parentEntry, bool bCheck);
\r
765 /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)
\r
766 void FillListOfSelectedItemPaths(CTGitPathList& pathList, bool bNoIgnored = false);
\r
768 /// Enables/Disables group view and adds all groups to the list control.
\r
769 /// If bForce is true, then group view is enabled and the 'null' group is added.
\r
770 bool PrepareGroups(bool bForce = false);
\r
771 /// Returns the group number to which the group header belongs
\r
772 /// If the point is not over a group header, -1 is returned
\r
773 int GetGroupFromPoint(POINT * ppt);
\r
774 /// Returns the number of change lists the selection has
\r
775 size_t GetNumberOfChangelistsInSelection();
\r
777 /// Puts the item to the corresponding group
\r
778 bool SetItemGroup(int item, int groupindex);
\r
780 void CheckEntry(int index, int nListItems);
\r
781 void UncheckEntry(int index, int nListItems);
\r
783 /// sends an GitSLNM_CHECKCHANGED notification to the parent
\r
784 void NotifyCheck();
\r
786 int CellRectFromPoint(CPoint& point, RECT *cellrect, int *col) const;
\r
788 void OnContextMenuList(CWnd * pWnd, CPoint point);
\r
789 void OnContextMenuGroup(CWnd * pWnd, CPoint point);
\r
790 void OnContextMenuHeader(CWnd * pWnd, CPoint point);
\r
792 virtual void PreSubclassWindow();
\r
793 virtual BOOL PreTranslateMessage(MSG* pMsg);
\r
794 virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
\r
795 afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
\r
796 afx_msg BOOL OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult);
\r
797 afx_msg void OnHdnItemclick(NMHDR *pNMHDR, LRESULT *pResult);
\r
798 afx_msg void OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
\r
799 afx_msg BOOL OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult);
\r
800 afx_msg void OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult);
\r
801 afx_msg void OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult);
\r
802 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
\r
804 void CreateChangeList(const CString& name);
\r
806 afx_msg void OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult);
\r
807 afx_msg void OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult);
\r
808 afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
\r
809 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
\r
810 afx_msg UINT OnGetDlgCode();
\r
811 afx_msg void OnNMReturn(NMHDR *pNMHDR, LRESULT *pResult);
\r
812 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
\r
813 afx_msg void OnPaint();
\r
814 afx_msg void OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult);
\r
815 afx_msg void OnHdnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
\r
816 afx_msg void OnDestroy();
\r
819 bool * m_pbCanceled;
\r
820 bool m_bAscending; ///< sort direction
\r
821 int m_nSortedColumn; ///< which column to sort
\r
822 bool m_bHasCheckboxes;
\r
823 bool m_bUnversionedLast;
\r
824 bool m_bHasExternalsFromDifferentRepos;
\r
825 bool m_bHasExternals;
\r
826 BOOL m_bHasUnversionedItems;
\r
828 bool m_bHasChangeLists;
\r
829 typedef std::vector<FileEntry*> FileEntryVector;
\r
830 FileEntryVector m_arStatusArray;
\r
831 std::vector<size_t> m_arListArray;
\r
832 std::map<CString, int> m_changelists;
\r
833 bool m_bHasIgnoreGroup;
\r
834 CTGitPathList m_ConflictFileList;
\r
835 CTGitPathList m_StatusFileList;
\r
836 CTGitPathList m_StatusUrlList;
\r
837 CString m_sLastError;
\r
839 LONG m_nUnversioned;
\r
844 LONG m_nConflicted;
\r
848 DWORD m_dwDefaultColumns;
\r
850 bool m_bShowFolders;
\r
851 bool m_bShowIgnores;
\r
853 DWORD m_dwContextMenus;
\r
858 bool m_bIgnoreRemoveOnly;
\r
859 bool m_bCheckIfGroupsExist;
\r
860 bool m_bFileDropsEnabled;
\r
865 CWnd * m_pStatLabel;
\r
866 CButton * m_pSelectButton;
\r
867 CButton * m_pConfirmButton;
\r
872 CString m_sNoPropValueText;
\r
874 bool m_bUnversionedRecurse;
\r
876 bool m_bCheckChildrenWithParent;
\r
877 CGitStatusListCtrlDropTarget * m_pDropTarget;
\r
879 ColumnManager m_ColumnManager;
\r
881 std::map<CString,bool> m_mapFilenameToChecked; ///< Remember manually de-/selected items
\r
882 CComCriticalSection m_critSec;
\r
884 friend class CGitStatusListCtrlDropTarget;
\r
888 class CGitStatusListCtrlDropTarget : public CIDropTarget
\r
891 CGitStatusListCtrlDropTarget(CGitStatusListCtrl * pGitStatusListCtrl):CIDropTarget(pGitStatusListCtrl->m_hWnd){m_pGitStatusListCtrl = pGitStatusListCtrl;}
\r
893 virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD * /*pdwEffect*/, POINTL pt);
\r
894 virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect);
\r
896 CGitStatusListCtrl * m_pGitStatusListCtrl;
\r