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_COLTEXTSTATUS 0x000000010
\r
33 #define SVNSLC_COLPROPSTATUS 0x000000020
\r
34 #define SVNSLC_COLAUTHOR 0x000000040
\r
35 #define SVNSLC_COLREVISION 0x000000080
\r
36 #define SVNSLC_COLDATE 0x000000100
\r
37 #define SVNSLC_COLMODIFICATIONDATE 0x000000200
\r
38 #define SVNSLC_NUMCOLUMNS 10
\r
40 //#define SVNSLC_COLREMOTESTATUS 0x000000010
\r
41 //#define SVNSLC_COLREMOTETEXT 0x000000080
\r
42 //#define SVNSLC_COLREMOTEPROP 0x000000100
\r
43 //#define SVNSLC_COLURL 0x000000200
\r
44 //#define SVNSLC_COLLOCK 0x000000400
\r
45 //#define SVNSLC_COLLOCKCOMMENT 0x000000800
\r
47 //#define SVNSLC_COLREMOTEREVISION 0x000004000
\r
49 //#define SVNSLC_COLSVNNEEDSLOCK 0x000010000
\r
50 //#define SVNSLC_COLCOPYFROM 0x000020000
\r
53 #define SVNSLC_SHOWUNVERSIONED 0x000000001
\r
54 #define SVNSLC_SHOWNORMAL 0x000000002
\r
55 #define SVNSLC_SHOWMODIFIED 0x000000004
\r
56 #define SVNSLC_SHOWADDED 0x000000008
\r
57 #define SVNSLC_SHOWREMOVED 0x000000010
\r
58 #define SVNSLC_SHOWCONFLICTED 0x000000020
\r
59 #define SVNSLC_SHOWMISSING 0x000000040
\r
60 #define SVNSLC_SHOWREPLACED 0x000000080
\r
61 #define SVNSLC_SHOWMERGED 0x000000100
\r
62 #define SVNSLC_SHOWIGNORED 0x000000200
\r
63 #define SVNSLC_SHOWOBSTRUCTED 0x000000400
\r
64 #define SVNSLC_SHOWEXTERNAL 0x000000800
\r
65 #define SVNSLC_SHOWINCOMPLETE 0x000001000
\r
66 #define SVNSLC_SHOWINEXTERNALS 0x000002000
\r
67 #define SVNSLC_SHOWREMOVEDANDPRESENT 0x000004000
\r
68 #define SVNSLC_SHOWLOCKS 0x000008000
\r
69 #define SVNSLC_SHOWDIRECTFILES 0x000010000
\r
70 #define SVNSLC_SHOWDIRECTFOLDER 0x000020000
\r
71 #define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x000040000
\r
72 #define SVNSLC_SHOWSWITCHED 0x000080000
\r
73 #define SVNSLC_SHOWINCHANGELIST 0x000100000
\r
75 #define SVNSLC_SHOWDIRECTS (SVNSLC_SHOWDIRECTFILES | SVNSLC_SHOWDIRECTFOLDER)
\r
78 #define SVNSLC_SHOWVERSIONED (SVNSLC_SHOWNORMAL|SVNSLC_SHOWMODIFIED|\
\r
79 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
80 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
81 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
\r
82 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
\r
84 #define SVNSLC_SHOWVERSIONEDBUTNORMAL (SVNSLC_SHOWMODIFIED|SVNSLC_SHOWADDED|\
\r
85 SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
86 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
87 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
\r
88 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
\r
90 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS (SVNSLC_SHOWMODIFIED|\
\r
91 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
92 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
93 SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINEXTERNALS)
\r
95 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS (SVNSLC_SHOWMODIFIED|\
\r
96 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
97 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
98 SVNSLC_SHOWINCOMPLETE)
\r
100 #define SVNSLC_SHOWALL (SVNSLC_SHOWVERSIONED|SVNSLC_SHOWUNVERSIONED)
\r
102 #define SVNSLC_POPALL 0xFFFFFFFF
\r
103 #define SVNSLC_POPCOMPAREWITHBASE 0x00000001
\r
104 #define SVNSLC_POPCOMPARE 0x00000002
\r
105 #define SVNSLC_POPGNUDIFF 0x00000004
\r
106 #define SVNSLC_POPREVERT 0x00000008
\r
107 #define SVNSLC_POPUPDATE 0x00000010
\r
108 #define SVNSLC_POPSHOWLOG 0x00000020
\r
109 #define SVNSLC_POPOPEN 0x00000040
\r
110 #define SVNSLC_POPDELETE 0x00000080
\r
111 #define SVNSLC_POPADD 0x00000100
\r
112 #define SVNSLC_POPIGNORE 0x00000200
\r
113 #define SVNSLC_POPCONFLICT 0x00000400
\r
114 #define SVNSLC_POPRESOLVE 0x00000800
\r
115 #define SVNSLC_POPLOCK 0x00001000
\r
116 #define SVNSLC_POPUNLOCK 0x00002000
\r
117 #define SVNSLC_POPUNLOCKFORCE 0x00004000
\r
118 #define SVNSLC_POPEXPLORE 0x00008000
\r
119 #define SVNSLC_POPCOMMIT 0x00010000
\r
120 #define SVNSLC_POPPROPERTIES 0x00020000
\r
121 #define SVNSLC_POPREPAIRMOVE 0x00040000
\r
122 #define SVNSLC_POPCHANGELISTS 0x00080000
\r
123 #define SVNSLC_POPBLAME 0x00100000
\r
125 #define SVNSLC_IGNORECHANGELIST _T("ignore-on-commit")
\r
127 // This gives up to 64 standard properties and menu entries
\r
128 // plus 192 user-defined properties (should be plenty).
\r
129 // User-defined properties will start at column SVNSLC_NUMCOLUMNS+1
\r
130 // but in the registry, we will record them starting at SVNSLC_USERPROPCOLOFFSET.
\r
132 #define SVNSLC_USERPROPCOLOFFSET 0x40
\r
133 #define SVNSLC_USERPROPCOLLIMIT 0xff
\r
134 #define SVNSLC_MAXCOLUMNCOUNT 0xff
\r
136 // Supporting extreamly long user props makes no sense here --
\r
137 // especially for binary properties. CString uses a pool allocator
\r
138 // that works for up to 256 chars. Make sure we are well below that.
\r
140 #define SVNSLC_MAXUSERPROPLENGTH 0x70
\r
142 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
\r
143 typedef CComCritSecLock<CComCriticalSection> Locker;
\r
147 * A List control, based on the MFC CListCtrl which shows a list of
\r
148 * files with their Subversion status. The control also provides a context
\r
149 * menu to do some Subversion tasks on the selected files.
\r
151 * This is the main control used in many dialogs to show a list of files to
\r
154 class CGitStatusListCtrl :
\r
159 * Sent to the parent window (using ::SendMessage) after a context menu
\r
160 * command has finished if the item count has changed.
\r
162 static const UINT SVNSLNM_ITEMCOUNTCHANGED;
\r
164 * Sent to the parent window (using ::SendMessage) when the control needs
\r
165 * to be refreshed. Since this is done usually in the parent window using
\r
166 * a thread, this message is used to tell the parent to do exactly that.
\r
168 static const UINT SVNSLNM_NEEDSREFRESH;
\r
171 * Sent to the parent window (using ::SendMessage) when the user drops
\r
172 * files on the control. The LPARAM is a pointer to a TCHAR string
\r
173 * containing the dropped path.
\r
175 static const UINT SVNSLNM_ADDFILE;
\r
178 * Sent to the parent window (using ::SendMessage) when the user checks/unchecks
\r
179 * one or more items in the control. The WPARAM contains the number of
\r
180 * checked items in the control.
\r
182 static const UINT SVNSLNM_CHECKCHANGED;
\r
184 CGitStatusListCtrl(void);
\r
185 ~CGitStatusListCtrl(void);
\r
188 * \ingroup TortoiseProc
\r
189 * Helper class for CGitStatusListCtrl which represents
\r
190 * the data for each file shown.
\r
195 FileEntry() : status(git_wc_status_unversioned)
\r
196 // , copyfrom_rev(GIT_REV_ZERO)
\r
197 , last_commit_date(0)
\r
198 , last_commit_rev(GIT_REV_ZERO)
\r
199 // , remoterev(GIT_REV_ZERO)
\r
200 , textstatus(git_wc_status_unversioned)
\r
201 , propstatus(git_wc_status_unversioned)
\r
202 // , remotestatus(git_wc_status_unversioned)
\r
203 // , remotetextstatus(git_wc_status_unversioned)
\r
204 // , remotepropstatus(git_wc_status_unversioned)
\r
208 , inunversionedfolder(false)
\r
209 , inexternal(false)
\r
210 , differentrepo(false)
\r
214 , Revision(GIT_REV_ZERO)
\r
215 , isConflicted(false)
\r
216 // , present_props()
\r
218 /// , working_size(SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN)
\r
220 // , depth(git_depth_unknown)
\r
223 const CTGitPath& GetPath() const
\r
227 const bool IsChecked() const
\r
231 CString GetRelativeGitPath() const
\r
233 if (path.IsEquivalentTo(basepath))
\r
234 return path.GetGitPathString();
\r
235 return path.GetGitPathString().Mid(basepath.GetGitPathString().GetLength()+1);
\r
237 // const bool IsLocked() const
\r
239 // return !(lock_token.IsEmpty() && lock_remotetoken.IsEmpty());
\r
241 // const bool HasNeedsLock() const
\r
243 // return needslock;
\r
245 const bool IsFolder() const
\r
249 const bool IsInExternal() const
\r
253 const bool IsNested() const
\r
257 const bool IsFromDifferentRepository() const
\r
259 return differentrepo;
\r
261 CString GetDisplayName() const
\r
263 CString const& chopped = path.GetDisplayString(&basepath);
\r
264 if (!chopped.IsEmpty())
\r
270 // "Display name" must not be empty.
\r
271 return path.GetFileOrDirectoryName();
\r
274 CString GetChangeList() const
\r
278 // CString GetURL() const
\r
283 git_wc_status_kind status; ///< local status
\r
284 git_wc_status_kind textstatus; ///< local text status
\r
285 git_wc_status_kind propstatus; ///< local property status
\r
288 CTGitPath path; ///< full path of the file
\r
289 CTGitPath basepath; ///< common ancestor path of all files
\r
291 CString changelist; ///< the name of the changelist the item belongs to
\r
293 CString last_commit_author; ///< the author which last committed this item
\r
294 CTime last_commit_date; ///< the date when this item was last committed
\r
295 git_revnum_t last_commit_rev; ///< the revision where this item was last committed
\r
297 git_revnum_t remoterev; ///< the revision in HEAD of the repository
\r
298 bool copied; ///< if the file/folder is added-with-history
\r
299 bool switched; ///< if the file/folder is switched to another url
\r
300 bool checked; ///< if the file is checked in the list control
\r
301 bool inunversionedfolder; ///< if the file is inside an unversioned folder
\r
302 bool inexternal; ///< if the item is in an external folder
\r
303 bool differentrepo; ///< if the item is from a different repository than the rest
\r
304 bool direct; ///< directly included (TRUE) or just a child of a folder
\r
305 bool isfolder; ///< TRUE if entry refers to a folder
\r
306 bool isNested; ///< TRUE if the folder from a different repository and/or path
\r
307 bool isConflicted; ///< TRUE if a file entry is conflicted, i.e. if it has the conflicted paths set
\r
308 bool needslock; ///< TRUE if the Git:needs-lock property is set
\r
309 git_revnum_t Revision; ///< the base revision
\r
310 // PropertyList present_props; ///< cacheable properties present in BASE
\r
311 bool keeplocal; ///< Whether a local copy of this entry should be kept in the working copy after a deletion has been committed
\r
312 git_depth_t depth; ///< the depth of this entry
\r
313 friend class CGitStatusListCtrl;
\r
314 friend class CGitStatusListCtrlDropTarget;
\r
315 friend class CSorter;
\r
318 * \ingroup TortoiseProc
\r
319 * Helper class for CGitStatusListCtrl that represents
\r
320 * the columns visible and their order as well as
\r
321 * persisting that data in the registry.
\r
323 * It assigns logical index values to the (potential) columns:
\r
324 * 0 .. GitSLC_NUMCOLUMNS-1 contain the standard attributes
\r
325 * GitSLC_USERPROPCOLOFFSET .. GitSLC_MAXCOLUMNCOUNT are user props.
\r
327 * The column vector contains the columns that are actually
\r
328 * available in the control.
\r
330 * Since the set of userprops may change from one WC to another,
\r
331 * we also store the settings (width and order) for those
\r
332 * userprops that are not used in this WC.
\r
334 * A userprop is considered "in use", if the respective column
\r
335 * is not hidden or if at least one item has this property set.
\r
337 class ColumnManager
\r
341 /// construction / destruction
\r
343 ColumnManager (CListCtrl* control) : control (control) {};
\r
344 ~ColumnManager() {};
\r
346 /// registry access
\r
348 void ReadSettings (DWORD defaultColumns, const CString& containerName);
\r
349 void WriteSettings() const;
\r
351 /// read column definitions
\r
353 int GetColumnCount() const; ///< total number of columns
\r
354 bool IsVisible (int column) const;
\r
355 int GetInvisibleCount() const;
\r
356 bool IsRelevant (int column) const;
\r
357 bool IsUserProp (int column) const;
\r
358 CString GetName (int column) const;
\r
359 int GetWidth (int column, bool useDefaults = false) const;
\r
360 int GetVisibleWidth (int column, bool useDefaults) const;
\r
362 /// switch columns on and off
\r
364 void SetVisible (int column, bool visible);
\r
366 /// tracking column modifications
\r
368 void ColumnMoved (int column, int position);
\r
369 void ColumnResized (int column);
\r
371 /// call these to update the user-prop list
\r
372 /// (will also auto-insert /-remove new list columns)
\r
374 void UpdateUserPropList (const std::vector<FileEntry*>& files);
\r
375 void UpdateRelevance ( const std::vector<FileEntry*>& files
\r
376 , const std::vector<size_t>& visibleFiles);
\r
378 /// don't clutter the context menu with irrelevant prop info
\r
380 bool AnyUnusedProperties() const;
\r
381 void RemoveUnusedProps();
\r
383 /// bring everything back to its "natural" order
\r
385 void ResetColumns (DWORD defaultColumns);
\r
389 /// initialization utilities
\r
391 void ParseUserPropSettings ( const CString& userPropList
\r
392 , const CString& shownUserProps);
\r
393 void ParseWidths (const CString& widths);
\r
394 void SetStandardColumnVisibility (DWORD visibility);
\r
395 void ParseColumnOrder (const CString& widths);
\r
397 /// map internal column order onto visible column order
\r
398 /// (all invisibles in front)
\r
400 std::vector<int> GetGridColumnOrder();
\r
401 void ApplyColumnOrder();
\r
403 /// utilities used when writing data to the registry
\r
405 DWORD GetSelectedStandardColumns() const;
\r
406 CString GetUserPropList() const;
\r
407 CString GetShownUserProps() const;
\r
408 CString GetWidthString() const;
\r
409 CString GetColumnOrderString() const;
\r
411 /// our parent control and its data
\r
413 CListCtrl* control;
\r
415 /// where to store in the registry
\r
417 CString registryPrefix;
\r
419 /// all columns in their "natural" order
\r
423 int index; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
\r
426 bool relevant; ///< set to @a visible, if no *shown* item has that property
\r
429 std::vector<ColumnInfo> columns;
\r
431 /// user-defined properties
\r
435 CString name; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
\r
439 std::vector<UserProp> userProps;
\r
441 /// stored result from last UpdateUserPropList() call
\r
443 std::set<CString> itemProps;
\r
445 /// global column ordering including unused user props
\r
447 std::vector<int> columnOrder;
\r
450 * \ingroup TortoiseProc
\r
451 * Simple utility class that defines the sort column order.
\r
457 CSorter ( ColumnManager* columnManager
\r
461 bool operator() ( const CTGitPath* entry1
\r
462 , const CTGitPath* entry2) const;
\r
466 ColumnManager* columnManager;
\r
472 * Initializes the control, sets up the columns.
\r
473 * \param dwColumns mask of columns to show. Use the GitSLC_COLxxx defines.
\r
474 * \param sColumnInfoContainer Name of a registry key
\r
475 * where the position and visibility of each column
\r
476 * is saved and used from. If the registry key
\r
477 * doesn't exist, the default order is used
\r
478 * and dwColumns tells which columns are visible.
\r
479 * \param dwContextMenus mask of context menus to be active, not all make sense for every use of this control.
\r
480 * Use the GitSLC_POPxxx defines.
\r
481 * \param bHasCheckboxes TRUE if the control should show check boxes on the left of each file entry.
\r
483 void Init(DWORD dwColumns, const CString& sColumnInfoContainer, DWORD dwContextMenus = (SVNSLC_POPALL ^ SVNSLC_POPCOMMIT), bool bHasCheckboxes = true);
\r
485 * Sets a background image for the list control.
\r
486 * The image is shown in the right bottom corner.
\r
487 * \param nID the resource ID of the bitmap to use as the background
\r
489 bool SetBackgroundImage(UINT nID);
\r
491 * Makes the 'ignore' context menu only ignore the files and not add the
\r
492 * folder which gets the Git:ignore property changed to the list.
\r
493 * This is needed e.g. for the Add-dialog, where the modified folder
\r
494 * showing up would break the resulting "add" command.
\r
496 void SetIgnoreRemoveOnly(bool bRemoveOnly = true) {m_bIgnoreRemoveOnly = bRemoveOnly;}
\r
498 * The unversioned items are by default shown after all other files in the list.
\r
499 * If that behavior should be changed, set this value to false.
\r
501 void PutUnversionedLast(bool bLast) {m_bUnversionedLast = bLast;}
\r
503 * Fetches the Subversion status of all files and stores the information
\r
504 * about them in an internal array.
\r
505 * \param sFilePath path to a file which contains a list of files and/or folders for which to
\r
506 * fetch the status, separated by newlines.
\r
507 * \param bUpdate TRUE if the remote status is requested too.
\r
508 * \return TRUE on success.
\r
510 BOOL GetStatus ( const CTGitPathList& pathList
\r
511 , bool bUpdate = false
\r
512 , bool bShowIgnores = false
\r
513 , bool bShowUnRev=false
\r
514 , bool bShowUserProps = false);
\r
517 * Populates the list control with the previously (with GetStatus) gathered status information.
\r
518 * \param dwShow mask of file types to show. Use the GitSLC_SHOWxxx defines.
\r
519 * \param dwCheck mask of file types to check. Use GitLC_SHOWxxx defines. Default (0) means 'use the entry's stored check status'
\r
521 void Show(DWORD dwShow, DWORD dwCheck = 0, bool bShowFolders = true);
\r
522 void Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders = true);
\r
525 * Copies the selected entries in the control to the clipboard. The entries
\r
526 * are separated by newlines.
\r
527 * \param dwCols the columns to copy. Each column is separated by a tab.
\r
529 bool CopySelectedEntriesToClipboard(DWORD dwCols);
\r
532 * If during the call to GetStatus() some Git:externals are found from different
\r
533 * repositories than the first one checked, then this method returns TRUE.
\r
535 BOOL HasExternalsFromDifferentRepos() const {return m_bHasExternalsFromDifferentRepos;}
\r
538 * If during the call to GetStatus() some Git:externals are found then this method returns TRUE.
\r
540 BOOL HasExternals() const {return m_bHasExternals;}
\r
543 * If unversioned files are found (but not necessarily shown) TRUE is returned.
\r
545 BOOL HasUnversionedItems() {return m_bHasUnversionedItems;}
\r
548 * If there are any locks in the working copy, TRUE is returned
\r
550 BOOL HasLocks() const {return m_bHasLocks;}
\r
553 * If there are any change lists defined in the working copy, TRUE is returned
\r
555 BOOL HasChangeLists() const {return m_bHasChangeLists;}
\r
558 * Returns the file entry data for the list control index.
\r
560 CGitStatusListCtrl::FileEntry * GetListEntry(UINT_PTR index);
\r
563 * Returns the file entry data for the specified path.
\r
564 * \note The entry might not be shown in the list control.
\r
566 CGitStatusListCtrl::FileEntry * GetListEntry(const CTGitPath& path);
\r
569 * Returns the index of the list control entry with the specified path,
\r
570 * or -1 if the path is not in the list control.
\r
572 int GetIndex(const CTGitPath& path);
\r
575 * Returns the file entry data for the specified path in the list control.
\r
577 CGitStatusListCtrl::FileEntry * GetVisibleListEntry(const CTGitPath& path);
\r
580 * Returns a String containing some statistics like number of modified, normal, deleted,...
\r
583 CString GetStatisticsString();
\r
586 * Set a static control which will be updated automatically with
\r
587 * the number of selected and total files shown in the list control.
\r
589 void SetStatLabel(CWnd * pStatLabel){m_pStatLabel = pStatLabel;};
\r
592 * Set a tri-state checkbox which is updated automatically if the
\r
593 * user checks/unchecks file entries in the list control to indicate
\r
594 * if all files are checked, none are checked or some are checked.
\r
596 void SetSelectButton(CButton * pButton) {m_pSelectButton = pButton;}
\r
599 * Set a button which is de-/activated automatically. The button is
\r
600 * only set active if at least one item is selected.
\r
602 void SetConfirmButton(CButton * pButton) {m_pConfirmButton = pButton;}
\r
605 * Select/unselect all entries in the list control.
\r
606 * \param bSelect TRUE to check, FALSE to uncheck.
\r
608 void SelectAll(bool bSelect, bool bIncludeNoCommits = false);
\r
610 /** Set a checkbox on an entry in the listbox
\r
611 * Keeps the listctrl checked state and the FileEntry's checked flag in sync
\r
613 void SetEntryCheck(CTGitPath* pEntry, int listboxIndex, bool bCheck);
\r
615 /** Write a list of the checked items' paths into a path list
\r
617 void WriteCheckedNamesToPathList(CTGitPathList& pathList);
\r
619 /** fills in \a lMin and \a lMax with the lowest/highest revision of all
\r
620 * files/folders in the working copy.
\r
621 * \param bShownOnly if true, the min/max revisions are calculated only for shown items
\r
622 * \param bCheckedOnly if true, the min/max revisions are calculated only for items
\r
623 * which are checked.
\r
624 * \remark Since an item can only be checked if it is visible/shown in the list control
\r
625 * bShownOnly is automatically set to true if bCheckedOnly is true
\r
627 void GetMinMaxRevisions(git_revnum_t& rMin, git_revnum_t& rMax, bool bShownOnly, bool bCheckedOnly);
\r
630 * Returns the parent directory of all entries in the control.
\r
631 * if \a bStrict is set to false, then the paths passed to the control
\r
632 * to fetch the status (in GetStatus()) are used if possible.
\r
634 CTGitPath GetCommonDirectory(bool bStrict);
\r
637 * Returns the parent url of all entries in the control.
\r
638 * if \a bStrict is set to false, then the paths passed to the control
\r
639 * to fetch the status (in GetStatus()) are used if possible.
\r
641 CTGitPath GetCommonURL(bool bStrict);
\r
644 * Sets a pointer to a boolean variable which is checked periodically
\r
645 * during the status fetching. As soon as the variable changes to true,
\r
646 * the operations stops.
\r
648 void SetCancelBool(bool * pbCanceled) {m_pbCanceled = pbCanceled;}
\r
651 * Sets the string shown in the control while the status is fetched.
\r
652 * If not set, it defaults to "please wait..."
\r
654 void SetBusyString(const CString& str) {m_sBusy = str;}
\r
655 void SetBusyString(UINT id) {m_sBusy.LoadString(id);}
\r
658 * Sets the string shown in the control if no items are shown. This
\r
659 * can happen for example if there's nothing modified and the unversioned
\r
660 * files aren't shown either, so there's nothing to commit.
\r
661 * If not set, it defaults to "file list is empty".
\r
663 void SetEmptyString(const CString& str) {m_sEmpty = str;}
\r
664 void SetEmptyString(UINT id) {m_sEmpty.LoadString(id);}
\r
667 * Determines if the control should recurse into unversioned folders
\r
668 * when fetching the status. The default behavior is defined by the
\r
669 * registry key HKCU\Software\TortoiseGit\UnversionedRecurse, which
\r
670 * is read in the Init() method.
\r
671 * If you want to change the behavior, call this method *after*
\r
674 void SetUnversionedRecurse(bool bUnversionedRecurse) {m_bUnversionedRecurse = bUnversionedRecurse;}
\r
677 * Returns the number of selected items
\r
679 LONG GetSelected(){return m_nSelected;};
\r
682 * Enables dropping of files on the control.
\r
684 bool EnableFileDrop();
\r
687 * Checks if the path already exists in the list.
\r
689 bool HasPath(const CTGitPath& path);
\r
691 * Checks if the path is shown/visible in the list control.
\r
693 bool IsPathShown(const CTGitPath& path);
\r
695 * Forces the children to be checked when the parent folder is checked,
\r
696 * and the parent folder to be unchecked if one of its children is unchecked.
\r
698 void CheckChildrenWithParent(bool bCheck) {m_bCheckChildrenWithParent = bCheck;}
\r
701 * Allows checking the items if change lists are present. If set to false,
\r
702 * items are not checked if at least one changelist is available.
\r
704 void CheckIfChangelistsArePresent(bool bCheck) {m_bCheckIfGroupsExist = bCheck;}
\r
706 * Returns the currently used show flags passed to the Show() method.
\r
708 DWORD GetShowFlags() {return m_dwShow;}
\r
710 CString GetLastErrorMessage() {return m_sLastError;}
\r
712 void Block(BOOL block, BOOL blockUI) {m_bBlock = block; m_bBlockUI = blockUI;}
\r
714 LONG m_nTargetCount; ///< number of targets in the file passed to GetStatus()
\r
716 CString m_sURL; ///< the URL of the target or "(multiple targets)"
\r
718 GitRev m_HeadRev; ///< the HEAD revision of the repository if bUpdate was TRUE
\r
720 CString m_sUUID; ///< the UUID of the associated repository
\r
722 DECLARE_MESSAGE_MAP()
\r
725 void SaveColumnWidths(bool bSaveToRegistry = false);
\r
726 void Sort(); ///< Sorts the control by columns
\r
727 void AddEntry(FileEntry * entry, WORD langID, int listIndex); ///< add an entry to the control
\r
728 void RemoveListEntry(int index); ///< removes an entry from the listcontrol and both arrays
\r
729 bool BuildStatistics(); ///< build the statistics and correct the case of files/folders
\r
730 void StartDiff(int fileindex); ///< start the external diff program
\r
732 /// fetch all user properties for all items
\r
733 void FetchUserProperties();
\r
735 /// Process one line of the command file supplied to GetStatus
\r
736 bool FetchStatusForSingleTarget(GitConfig& config, GitStatus& status, const CTGitPath& target,
\r
737 bool bFetchStatusFromRepository, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths,
\r
738 bool bAllDirect, git_depth_t depth = git_depth_infinity, bool bShowIgnores = false);
\r
740 /// Create 'status' data for each item in an unversioned folder
\r
741 void AddUnversionedFolder(const CTGitPath& strFolderName, const CTGitPath& strBasePath, GitConfig * config);
\r
743 /// Read the all the other status items which result from a single GetFirstStatus call
\r
744 void ReadRemainingItemsStatus(GitStatus& status, const CTGitPath& strBasePath, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths, GitConfig * config, bool bAllDirect);
\r
746 /// Clear the status vector (contains custodial pointers)
\r
747 void ClearStatusArray();
\r
749 /// Sort predicate function - Compare the paths of two entries without regard to case
\r
750 static bool EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2);
\r
752 /// Predicate used to build a list of only the versioned entries of the FileEntry array
\r
753 static bool IsEntryVersioned(const FileEntry* pEntry1);
\r
755 /// Look up the relevant show flags for a particular Git status value
\r
756 DWORD GetShowFlagsFromGitStatus(git_wc_status_kind status);
\r
758 /// Build a FileEntry item and add it to the FileEntry array
\r
759 const FileEntry* AddNewFileEntry(
\r
760 const git_wc_status2_t* pGitStatus, // The return from the Git GetStatus functions
\r
761 const CTGitPath& path, // The path of the item we're adding
\r
762 const CTGitPath& basePath, // The base directory for this status build
\r
763 bool bDirectItem, // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call
\r
764 bool bInExternal, // Are we in an 'external' folder
\r
765 bool bEntryfromDifferentRepo // if the entry is from a different repository
\r
768 /// Adjust the checkbox-state on all descendants of a specific item
\r
769 void SetCheckOnAllDescendentsOf(const FileEntry* parentEntry, bool bCheck);
\r
771 /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)
\r
772 void FillListOfSelectedItemPaths(CTGitPathList& pathList, bool bNoIgnored = false);
\r
774 /// Enables/Disables group view and adds all groups to the list control.
\r
775 /// If bForce is true, then group view is enabled and the 'null' group is added.
\r
776 bool PrepareGroups(bool bForce = false);
\r
777 /// Returns the group number to which the group header belongs
\r
778 /// If the point is not over a group header, -1 is returned
\r
779 int GetGroupFromPoint(POINT * ppt);
\r
780 /// Returns the number of change lists the selection has
\r
781 size_t GetNumberOfChangelistsInSelection();
\r
783 /// Puts the item to the corresponding group
\r
784 bool SetItemGroup(int item, int groupindex);
\r
786 void CheckEntry(int index, int nListItems);
\r
787 void UncheckEntry(int index, int nListItems);
\r
789 /// sends an GitSLNM_CHECKCHANGED notification to the parent
\r
790 void NotifyCheck();
\r
792 int CellRectFromPoint(CPoint& point, RECT *cellrect, int *col) const;
\r
794 void OnContextMenuList(CWnd * pWnd, CPoint point);
\r
795 void OnContextMenuGroup(CWnd * pWnd, CPoint point);
\r
796 void OnContextMenuHeader(CWnd * pWnd, CPoint point);
\r
798 virtual void PreSubclassWindow();
\r
799 virtual BOOL PreTranslateMessage(MSG* pMsg);
\r
800 virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
\r
801 afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
\r
802 afx_msg BOOL OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult);
\r
803 afx_msg void OnHdnItemclick(NMHDR *pNMHDR, LRESULT *pResult);
\r
804 afx_msg void OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
\r
805 afx_msg BOOL OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult);
\r
806 afx_msg void OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult);
\r
807 afx_msg void OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult);
\r
808 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
\r
810 void CreateChangeList(const CString& name);
\r
812 afx_msg void OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult);
\r
813 afx_msg void OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult);
\r
814 afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
\r
815 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
\r
816 afx_msg UINT OnGetDlgCode();
\r
817 afx_msg void OnNMReturn(NMHDR *pNMHDR, LRESULT *pResult);
\r
818 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
\r
819 afx_msg void OnPaint();
\r
820 afx_msg void OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult);
\r
821 afx_msg void OnHdnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
\r
822 afx_msg void OnDestroy();
\r
825 bool * m_pbCanceled;
\r
826 bool m_bAscending; ///< sort direction
\r
827 int m_nSortedColumn; ///< which column to sort
\r
828 bool m_bHasCheckboxes;
\r
829 bool m_bUnversionedLast;
\r
830 bool m_bHasExternalsFromDifferentRepos;
\r
831 bool m_bHasExternals;
\r
832 BOOL m_bHasUnversionedItems;
\r
834 bool m_bHasChangeLists;
\r
835 //typedef std::vector<FileEntry*> FileEntryVector;
\r
836 //FileEntryVector m_arStatusArray;
\r
837 std::vector<CTGitPath*> m_arStatusArray;
\r
838 std::vector<size_t> m_arListArray;
\r
839 std::map<CString, int> m_changelists;
\r
840 bool m_bHasIgnoreGroup;
\r
841 //CTGitPathList m_ConflictFileList;
\r
842 CTGitPathList m_StatusFileList;
\r
843 CTGitPathList m_UnRevFileList;
\r
844 CTGitPathList m_IgnoreFileList;
\r
845 //CTGitPathList m_StatusUrlList;
\r
846 CString m_sLastError;
\r
848 LONG m_nUnversioned;
\r
853 LONG m_nConflicted;
\r
857 DWORD m_dwDefaultColumns;
\r
859 bool m_bShowFolders;
\r
860 bool m_bShowIgnores;
\r
862 DWORD m_dwContextMenus;
\r
867 bool m_bIgnoreRemoveOnly;
\r
868 bool m_bCheckIfGroupsExist;
\r
869 bool m_bFileDropsEnabled;
\r
874 CWnd * m_pStatLabel;
\r
875 CButton * m_pSelectButton;
\r
876 CButton * m_pConfirmButton;
\r
881 CString m_sNoPropValueText;
\r
883 bool m_bUnversionedRecurse;
\r
885 bool m_bCheckChildrenWithParent;
\r
886 CGitStatusListCtrlDropTarget * m_pDropTarget;
\r
888 ColumnManager m_ColumnManager;
\r
890 std::map<CString,bool> m_mapFilenameToChecked; ///< Remember manually de-/selected items
\r
891 CComCriticalSection m_critSec;
\r
893 friend class CGitStatusListCtrlDropTarget;
\r
897 FILELIST_MODIFY= 0x1,
\r
898 FILELIST_UNVER = 0x2,
\r
899 FILELIST_IGNORE =0x4
\r
902 int UpdateFileList(git_revnum_t hash,CTGitPathList *List=NULL);
\r
903 int UpdateFileList(int mask, bool once=true,CTGitPathList *List=NULL);
\r
904 int UpdateUnRevFileList(CTGitPathList *List=NULL);
\r
905 int UpdateIgnoreFileList(CTGitPathList *List=NULL);
\r
906 void AddEntry(CTGitPath* path, WORD langID, int ListIndex);
\r
911 class CGitStatusListCtrlDropTarget : public CIDropTarget
\r
914 CGitStatusListCtrlDropTarget(CGitStatusListCtrl * pGitStatusListCtrl):CIDropTarget(pGitStatusListCtrl->m_hWnd){m_pGitStatusListCtrl = pGitStatusListCtrl;}
\r
916 virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD * /*pdwEffect*/, POINTL pt);
\r
917 virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect);
\r
919 CGitStatusListCtrl * m_pGitStatusListCtrl;
\r