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
25 #include "XPTheme.h"
\r
26 #include "CommonResource.h"
\r
28 #define SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN (-1)
\r
30 // these defines must be in the order the columns are inserted!
\r
31 #define SVNSLC_COLFILENAME 0x000000002
\r
32 #define SVNSLC_COLEXT 0x000000004
\r
33 #define SVNSLC_COLSTATUS 0x000000008
\r
34 #define SVNSLC_COLTEXTSTATUS 0x000000010
\r
35 #define SVNSLC_COLPROPSTATUS 0x000000020
\r
36 #define SVNSLC_COLAUTHOR 0x000000040
\r
37 #define SVNSLC_COLREVISION 0x000000080
\r
38 #define SVNSLC_COLDATE 0x000000100
\r
39 #define SVNSLC_COLMODIFICATIONDATE 0x000000200
\r
40 #define SVNSLC_COLADD 0x000000400
\r
41 #define SVNSLC_COLDEL 0x000000800
\r
42 #define SVNSLC_NUMCOLUMNS 12
\r
44 //#define SVNSLC_COLREMOTESTATUS 0x000000010
\r
45 //#define SVNSLC_COLREMOTETEXT 0x000000080
\r
46 //#define SVNSLC_COLREMOTEPROP 0x000000100
\r
47 //#define SVNSLC_COLURL 0x000000200
\r
48 //#define SVNSLC_COLLOCK 0x000000400
\r
49 //#define SVNSLC_COLLOCKCOMMENT 0x000000800
\r
51 //#define SVNSLC_COLREMOTEREVISION 0x000004000
\r
53 //#define SVNSLC_COLSVNNEEDSLOCK 0x000010000
\r
54 //#define SVNSLC_COLCOPYFROM 0x000020000
\r
57 #define SVNSLC_SHOWUNVERSIONED CTGitPath::LOGACTIONS_UNVER
\r
58 #define SVNSLC_SHOWNORMAL 0x000000000
\r
59 #define SVNSLC_SHOWMODIFIED (CTGitPath::LOGACTIONS_MODIFIED)
\r
60 #define SVNSLC_SHOWADDED (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY)
\r
61 #define SVNSLC_SHOWREMOVED CTGitPath::LOGACTIONS_DELETED
\r
62 #define SVNSLC_SHOWCONFLICTED CTGitPath::LOGACTIONS_UNMERGED
\r
63 #define SVNSLC_SHOWMISSING 0x00000000
\r
64 #define SVNSLC_SHOWREPLACED CTGitPath::LOGACTIONS_REPLACED
\r
65 #define SVNSLC_SHOWMERGED CTGitPath::LOGACTIONS_MERGED
\r
66 #define SVNSLC_SHOWIGNORED CTGitPath::LOGACTIONS_IGNORE
\r
67 #define SVNSLC_SHOWOBSTRUCTED 0x00000000
\r
68 #define SVNSLC_SHOWEXTERNAL 0x00000000
\r
69 #define SVNSLC_SHOWINCOMPLETE 0x00000000
\r
70 #define SVNSLC_SHOWINEXTERNALS 0x00000000
\r
71 #define SVNSLC_SHOWREMOVEDANDPRESENT 0x00000000
\r
72 #define SVNSLC_SHOWLOCKS 0x00000000
\r
73 #define SVNSLC_SHOWDIRECTFILES 0x00000000
\r
74 #define SVNSLC_SHOWDIRECTFOLDER 0x00000000
\r
75 #define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x00000000
\r
76 #define SVNSLC_SHOWSWITCHED 0x00000000
\r
77 #define SVNSLC_SHOWINCHANGELIST 0x00000000
\r
79 #define SVNSLC_SHOWDIRECTS (SVNSLC_SHOWDIRECTFILES | SVNSLC_SHOWDIRECTFOLDER)
\r
82 #define SVNSLC_SHOWVERSIONED (CTGitPath::LOGACTIONS_FORWORD|SVNSLC_SHOWNORMAL|SVNSLC_SHOWMODIFIED|\
\r
83 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
84 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
85 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
\r
86 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
\r
88 #define SVNSLC_SHOWVERSIONEDBUTNORMAL (SVNSLC_SHOWMODIFIED|SVNSLC_SHOWADDED|\
\r
89 SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
90 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
91 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
\r
92 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
\r
94 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS (SVNSLC_SHOWMODIFIED|\
\r
95 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
96 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
97 SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINEXTERNALS)
\r
99 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS (SVNSLC_SHOWMODIFIED|\
\r
100 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
\r
101 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
\r
102 SVNSLC_SHOWINCOMPLETE)
\r
104 #define SVNSLC_SHOWALL (SVNSLC_SHOWVERSIONED|SVNSLC_SHOWUNVERSIONED)
\r
106 #define SVNSLC_POPALL 0xFFFFFFFFFFFFFFFF
\r
107 #define SVNSLC_POPCOMPAREWITHBASE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMPARE)
\r
108 #define SVNSLC_POPCOMPARE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMPAREWC)
\r
109 #define SVNSLC_POPGNUDIFF CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_GNUDIFF1)
\r
110 #define SVNSLC_POPREVERT CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_REVERT)
\r
111 #define SVNSLC_POPUPDATE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_UPDATE)
\r
112 #define SVNSLC_POPSHOWLOG CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_LOG)
\r
113 #define SVNSLC_POPOPEN CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_OPEN)
\r
114 #define SVNSLC_POPDELETE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_DELETE)
\r
115 #define SVNSLC_POPADD CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_ADD)
\r
116 #define SVNSLC_POPIGNORE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_IGNORE)
\r
117 #define SVNSLC_POPCONFLICT CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_EDITCONFLICT)
\r
118 #define SVNSLC_POPRESOLVE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_RESOLVECONFLICT)
\r
119 #define SVNSLC_POPLOCK CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_LOCK)
\r
120 #define SVNSLC_POPUNLOCK CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_UNLOCK)
\r
121 #define SVNSLC_POPUNLOCKFORCE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_UNLOCKFORCE)
\r
122 #define SVNSLC_POPEXPLORE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_EXPLORE)
\r
123 #define SVNSLC_POPCOMMIT CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMMIT)
\r
124 #define SVNSLC_POPPROPERTIES CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_PROPERTIES)
\r
125 #define SVNSLC_POPREPAIRMOVE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_REPAIRMOVE)
\r
126 #define SVNSLC_POPCHANGELISTS CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_CHECKGROUP)
\r
127 #define SVNSLC_POPBLAME CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_BLAME)
\r
129 #define SVNSLC_IGNORECHANGELIST _T("ignore-on-commit")
\r
131 // This gives up to 64 standard properties and menu entries
\r
132 // plus 192 user-defined properties (should be plenty).
\r
133 // User-defined properties will start at column SVNSLC_NUMCOLUMNS+1
\r
134 // but in the registry, we will record them starting at SVNSLC_USERPROPCOLOFFSET.
\r
136 #define SVNSLC_USERPROPCOLOFFSET 0x40
\r
137 #define SVNSLC_USERPROPCOLLIMIT 0xff
\r
138 #define SVNSLC_MAXCOLUMNCOUNT 0xff
\r
140 // Supporting extreamly long user props makes no sense here --
\r
141 // especially for binary properties. CString uses a pool allocator
\r
142 // that works for up to 256 chars. Make sure we are well below that.
\r
144 #define SVNSLC_MAXUSERPROPLENGTH 0x70
\r
146 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
\r
147 typedef CComCritSecLock<CComCriticalSection> Locker;
\r
149 class CGitStatusListCtrlDropTarget;
\r
152 * A List control, based on the MFC CListCtrl which shows a list of
\r
153 * files with their Subversion status. The control also provides a context
\r
154 * menu to do some Subversion tasks on the selected files.
\r
156 * This is the main control used in many dialogs to show a list of files to
\r
159 class CGitStatusListCtrl :
\r
165 IDSVNLC_REVERT = 1,
\r
173 IDSVNLC_EDITCONFLICT ,
\r
174 IDSVNLC_IGNOREMASK ,
\r
176 IDSVNLC_RESOLVECONFLICT ,
\r
178 IDSVNLC_LOCKFORCE ,
\r
180 IDSVNLC_UNLOCKFORCE ,
\r
183 IDSVNLC_RESOLVETHEIRS ,
\r
184 IDSVNLC_RESOLVEMINE ,
\r
187 IDSVNLC_PROPERTIES ,
\r
190 IDSVNLC_REPAIRMOVE ,
\r
191 IDSVNLC_REMOVEFROMCS ,
\r
193 IDSVNLC_CREATEIGNORECS ,
\r
194 IDSVNLC_CHECKGROUP ,
\r
195 IDSVNLC_UNCHECKGROUP ,
\r
196 IDSVNLC_ADD_RECURSIVE ,
\r
197 IDSVNLC_COMPAREWC ,
\r
200 IDSVNLC_REVERTTOREV ,
\r
202 IDSVNLC_FINDENTRY ,
\r
203 IDSVNLC_COMPARETWO ,
\r
205 // the IDSVNLC_MOVETOCS *must* be the last index, because it contains a dynamic submenu where
\r
206 // the submenu items get command ID's sequent to this number
\r
209 int GetColumnIndex(int colmask);
\r
210 static inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<<i ;}
\r
212 * Sent to the parent window (using ::SendMessage) after a context menu
\r
213 * command has finished if the item count has changed.
\r
215 static const UINT SVNSLNM_ITEMCOUNTCHANGED;
\r
217 * Sent to the parent window (using ::SendMessage) when the control needs
\r
218 * to be refreshed. Since this is done usually in the parent window using
\r
219 * a thread, this message is used to tell the parent to do exactly that.
\r
221 static const UINT SVNSLNM_NEEDSREFRESH;
\r
224 * Sent to the parent window (using ::SendMessage) when the user drops
\r
225 * files on the control. The LPARAM is a pointer to a TCHAR string
\r
226 * containing the dropped path.
\r
228 static const UINT SVNSLNM_ADDFILE;
\r
231 * Sent to the parent window (using ::SendMessage) when the user checks/unchecks
\r
232 * one or more items in the control. The WPARAM contains the number of
\r
233 * checked items in the control.
\r
235 static const UINT SVNSLNM_CHECKCHANGED;
\r
237 CGitStatusListCtrl(void);
\r
238 ~CGitStatusListCtrl(void);
\r
244 * \ingroup TortoiseProc
\r
245 * Helper class for CGitStatusListCtrl which represents
\r
246 * the data for each file shown.
\r
252 FileEntry() : status(git_wc_status_unversioned)
\r
253 // , copyfrom_rev(GIT_REV_ZERO)
\r
254 , last_commit_date(0)
\r
255 , last_commit_rev(GIT_REV_ZERO)
\r
256 // , remoterev(GIT_REV_ZERO)
\r
257 , textstatus(git_wc_status_unversioned)
\r
258 , propstatus(git_wc_status_unversioned)
\r
259 // , remotestatus(git_wc_status_unversioned)
\r
260 // , remotetextstatus(git_wc_status_unversioned)
\r
261 // , remotepropstatus(git_wc_status_unversioned)
\r
265 , inunversionedfolder(false)
\r
266 , inexternal(false)
\r
267 , differentrepo(false)
\r
271 , Revision(GIT_REV_ZERO)
\r
272 , isConflicted(false)
\r
273 // , present_props()
\r
275 /// , working_size(SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN)
\r
277 // , depth(git_depth_unknown)
\r
280 const CTGitPath& GetPath() const
\r
284 const bool IsChecked() const
\r
288 CString GetRelativeGitPath() const
\r
290 if (path.IsEquivalentTo(basepath))
\r
291 return path.GetGitPathString();
\r
292 return path.GetGitPathString().Mid(basepath.GetGitPathString().GetLength()+1);
\r
294 // const bool IsLocked() const
\r
296 // return !(lock_token.IsEmpty() && lock_remotetoken.IsEmpty());
\r
298 // const bool HasNeedsLock() const
\r
300 // return needslock;
\r
302 const bool IsFolder() const
\r
306 const bool IsInExternal() const
\r
310 const bool IsNested() const
\r
314 const bool IsFromDifferentRepository() const
\r
316 return differentrepo;
\r
318 CString GetDisplayName() const
\r
320 CString const& chopped = path.GetDisplayString(&basepath);
\r
321 if (!chopped.IsEmpty())
\r
327 // "Display name" must not be empty.
\r
328 return path.GetFileOrDirectoryName();
\r
331 CString GetChangeList() const
\r
335 // CString GetURL() const
\r
340 git_wc_status_kind status; ///< local status
\r
341 git_wc_status_kind textstatus; ///< local text status
\r
342 git_wc_status_kind propstatus; ///< local property status
\r
345 CTGitPath path; ///< full path of the file
\r
346 CTGitPath basepath; ///< common ancestor path of all files
\r
348 CString changelist; ///< the name of the changelist the item belongs to
\r
350 CString last_commit_author; ///< the author which last committed this item
\r
351 CTime last_commit_date; ///< the date when this item was last committed
\r
352 git_revnum_t last_commit_rev; ///< the revision where this item was last committed
\r
354 git_revnum_t remoterev; ///< the revision in HEAD of the repository
\r
355 bool copied; ///< if the file/folder is added-with-history
\r
356 bool switched; ///< if the file/folder is switched to another url
\r
357 bool checked; ///< if the file is checked in the list control
\r
358 bool inunversionedfolder; ///< if the file is inside an unversioned folder
\r
359 bool inexternal; ///< if the item is in an external folder
\r
360 bool differentrepo; ///< if the item is from a different repository than the rest
\r
361 bool direct; ///< directly included (TRUE) or just a child of a folder
\r
362 bool isfolder; ///< TRUE if entry refers to a folder
\r
363 bool isNested; ///< TRUE if the folder from a different repository and/or path
\r
364 bool isConflicted; ///< TRUE if a file entry is conflicted, i.e. if it has the conflicted paths set
\r
365 bool needslock; ///< TRUE if the Git:needs-lock property is set
\r
366 git_revnum_t Revision; ///< the base revision
\r
367 // PropertyList present_props; ///< cacheable properties present in BASE
\r
368 bool keeplocal; ///< Whether a local copy of this entry should be kept in the working copy after a deletion has been committed
\r
369 git_depth_t depth; ///< the depth of this entry
\r
370 friend class CGitStatusListCtrl;
\r
371 friend class CGitStatusListCtrlDropTarget;
\r
372 friend class CSorter;
\r
376 * \ingroup TortoiseProc
\r
377 * Helper class for CGitStatusListCtrl that represents
\r
378 * the columns visible and their order as well as
\r
379 * persisting that data in the registry.
\r
381 * It assigns logical index values to the (potential) columns:
\r
382 * 0 .. GitSLC_NUMCOLUMNS-1 contain the standard attributes
\r
383 * GitSLC_USERPROPCOLOFFSET .. GitSLC_MAXCOLUMNCOUNT are user props.
\r
385 * The column vector contains the columns that are actually
\r
386 * available in the control.
\r
388 * Since the set of userprops may change from one WC to another,
\r
389 * we also store the settings (width and order) for those
\r
390 * userprops that are not used in this WC.
\r
392 * A userprop is considered "in use", if the respective column
\r
393 * is not hidden or if at least one item has this property set.
\r
395 class ColumnManager
\r
399 /// construction / destruction
\r
401 ColumnManager (CListCtrl* control) : control (control) {};
\r
402 ~ColumnManager() {};
\r
404 /// registry access
\r
406 void ReadSettings (DWORD defaultColumns, const CString& containerName);
\r
407 void WriteSettings() const;
\r
409 /// read column definitions
\r
411 int GetColumnCount() const; ///< total number of columns
\r
412 bool IsVisible (int column) const;
\r
413 int GetInvisibleCount() const;
\r
414 bool IsRelevant (int column) const;
\r
415 bool IsUserProp (int column) const;
\r
416 CString GetName (int column) const;
\r
417 int GetWidth (int column, bool useDefaults = false) const;
\r
418 int GetVisibleWidth (int column, bool useDefaults) const;
\r
420 /// switch columns on and off
\r
422 void SetVisible (int column, bool visible);
\r
424 /// tracking column modifications
\r
426 void ColumnMoved (int column, int position);
\r
427 void ColumnResized (int column);
\r
429 /// call these to update the user-prop list
\r
430 /// (will also auto-insert /-remove new list columns)
\r
432 //void UpdateUserPropList (const std::vector<FileEntry*>& files);
\r
433 //void UpdateRelevance ( const std::vector<FileEntry*>& files
\r
434 // , const std::vector<size_t>& visibleFiles);
\r
436 /// don't clutter the context menu with irrelevant prop info
\r
438 bool AnyUnusedProperties() const;
\r
439 void RemoveUnusedProps();
\r
441 /// bring everything back to its "natural" order
\r
443 void ResetColumns (DWORD defaultColumns);
\r
447 /// initialization utilities
\r
449 void ParseUserPropSettings ( const CString& userPropList
\r
450 , const CString& shownUserProps);
\r
451 void ParseWidths (const CString& widths);
\r
452 void SetStandardColumnVisibility (DWORD visibility);
\r
453 void ParseColumnOrder (const CString& widths);
\r
455 /// map internal column order onto visible column order
\r
456 /// (all invisibles in front)
\r
458 std::vector<int> GetGridColumnOrder();
\r
459 void ApplyColumnOrder();
\r
461 /// utilities used when writing data to the registry
\r
463 DWORD GetSelectedStandardColumns() const;
\r
464 CString GetUserPropList() const;
\r
465 CString GetShownUserProps() const;
\r
466 CString GetWidthString() const;
\r
467 CString GetColumnOrderString() const;
\r
469 /// our parent control and its data
\r
471 CListCtrl* control;
\r
473 /// where to store in the registry
\r
475 CString registryPrefix;
\r
477 /// all columns in their "natural" order
\r
481 int index; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
\r
484 bool relevant; ///< set to @a visible, if no *shown* item has that property
\r
487 std::vector<ColumnInfo> columns;
\r
489 /// user-defined properties
\r
493 CString name; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
\r
497 std::vector<UserProp> userProps;
\r
499 /// stored result from last UpdateUserPropList() call
\r
501 std::set<CString> itemProps;
\r
503 /// global column ordering including unused user props
\r
505 std::vector<int> columnOrder;
\r
508 * \ingroup TortoiseProc
\r
509 * Simple utility class that defines the sort column order.
\r
515 CSorter ( ColumnManager* columnManager
\r
519 bool operator() ( const CTGitPath* entry1
\r
520 , const CTGitPath* entry2) const;
\r
524 ColumnManager* columnManager;
\r
530 * Initializes the control, sets up the columns.
\r
531 * \param dwColumns mask of columns to show. Use the GitSLC_COLxxx defines.
\r
532 * \param sColumnInfoContainer Name of a registry key
\r
533 * where the position and visibility of each column
\r
534 * is saved and used from. If the registry key
\r
535 * doesn't exist, the default order is used
\r
536 * and dwColumns tells which columns are visible.
\r
537 * \param dwContextMenus mask of context menus to be active, not all make sense for every use of this control.
\r
538 * Use the GitSLC_POPxxx defines.
\r
539 * \param bHasCheckboxes TRUE if the control should show check boxes on the left of each file entry.
\r
541 void Init(DWORD dwColumns, const CString& sColumnInfoContainer, unsigned __int64 dwContextMenus = (SVNSLC_POPALL ^ SVNSLC_POPCOMMIT), bool bHasCheckboxes = true);
\r
543 * Sets a background image for the list control.
\r
544 * The image is shown in the right bottom corner.
\r
545 * \param nID the resource ID of the bitmap to use as the background
\r
547 bool SetBackgroundImage(UINT nID);
\r
549 * Makes the 'ignore' context menu only ignore the files and not add the
\r
550 * folder which gets the Git:ignore property changed to the list.
\r
551 * This is needed e.g. for the Add-dialog, where the modified folder
\r
552 * showing up would break the resulting "add" command.
\r
554 void SetIgnoreRemoveOnly(bool bRemoveOnly = true) {m_bIgnoreRemoveOnly = bRemoveOnly;}
\r
556 * The unversioned items are by default shown after all other files in the list.
\r
557 * If that behavior should be changed, set this value to false.
\r
559 void PutUnversionedLast(bool bLast) {m_bUnversionedLast = bLast;}
\r
561 * Fetches the Subversion status of all files and stores the information
\r
562 * about them in an internal array.
\r
563 * \param sFilePath path to a file which contains a list of files and/or folders for which to
\r
564 * fetch the status, separated by newlines.
\r
565 * \param bUpdate TRUE if the remote status is requested too.
\r
566 * \return TRUE on success.
\r
568 BOOL GetStatus ( const CTGitPathList* pathList=NULL
\r
569 , bool bUpdate = false
\r
570 , bool bShowIgnores = false
\r
571 , bool bShowUnRev=false
\r
572 , bool bShowUserProps = false);
\r
575 * Populates the list control with the previously (with GetStatus) gathered status information.
\r
576 * \param dwShow mask of file types to show. Use the GitSLC_SHOWxxx defines.
\r
577 * \param dwCheck mask of file types to check. Use GitLC_SHOWxxx defines. Default (0) means 'use the entry's stored check status'
\r
579 void Show(DWORD dwShow, DWORD dwCheck = 0, bool bShowFolders = true,BOOL updateStatusList=FALSE);
\r
580 void Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders = true);
\r
583 * Copies the selected entries in the control to the clipboard. The entries
\r
584 * are separated by newlines.
\r
585 * \param dwCols the columns to copy. Each column is separated by a tab.
\r
587 bool CopySelectedEntriesToClipboard(DWORD dwCols);
\r
590 * If during the call to GetStatus() some Git:externals are found from different
\r
591 * repositories than the first one checked, then this method returns TRUE.
\r
593 BOOL HasExternalsFromDifferentRepos() const {return m_bHasExternalsFromDifferentRepos;}
\r
596 * If during the call to GetStatus() some Git:externals are found then this method returns TRUE.
\r
598 BOOL HasExternals() const {return m_bHasExternals;}
\r
601 * If unversioned files are found (but not necessarily shown) TRUE is returned.
\r
603 BOOL HasUnversionedItems() {return m_bHasUnversionedItems;}
\r
606 * If there are any locks in the working copy, TRUE is returned
\r
608 BOOL HasLocks() const {return m_bHasLocks;}
\r
611 * If there are any change lists defined in the working copy, TRUE is returned
\r
613 BOOL HasChangeLists() const {return m_bHasChangeLists;}
\r
616 * Returns the file entry data for the list control index.
\r
618 //CGitStatusListCtrl::FileEntry * GetListEntry(UINT_PTR index);
\r
621 * Returns the file entry data for the specified path.
\r
622 * \note The entry might not be shown in the list control.
\r
624 //CGitStatusListCtrl::FileEntry * GetListEntry(const CTGitPath& path);
\r
627 * Returns the index of the list control entry with the specified path,
\r
628 * or -1 if the path is not in the list control.
\r
630 int GetIndex(const CTGitPath& path);
\r
633 * Returns the file entry data for the specified path in the list control.
\r
635 //CGitStatusListCtrl::FileEntry * GetVisibleListEntry(const CTGitPath& path);
\r
638 * Returns a String containing some statistics like number of modified, normal, deleted,...
\r
641 CString GetStatisticsString();
\r
644 * Set a static control which will be updated automatically with
\r
645 * the number of selected and total files shown in the list control.
\r
647 void SetStatLabel(CWnd * pStatLabel){m_pStatLabel = pStatLabel;};
\r
650 * Set a tri-state checkbox which is updated automatically if the
\r
651 * user checks/unchecks file entries in the list control to indicate
\r
652 * if all files are checked, none are checked or some are checked.
\r
654 void SetSelectButton(CButton * pButton) {m_pSelectButton = pButton;}
\r
657 * Set a button which is de-/activated automatically. The button is
\r
658 * only set active if at least one item is selected.
\r
660 void SetConfirmButton(CButton * pButton) {m_pConfirmButton = pButton;}
\r
663 * Select/unselect all entries in the list control.
\r
664 * \param bSelect TRUE to check, FALSE to uncheck.
\r
666 void SelectAll(bool bSelect, bool bIncludeNoCommits = false);
\r
668 /** Set a checkbox on an entry in the listbox
\r
669 * Keeps the listctrl checked state and the FileEntry's checked flag in sync
\r
671 void SetEntryCheck(CTGitPath* pEntry, int listboxIndex, bool bCheck);
\r
673 /** Write a list of the checked items' paths into a path list
\r
675 void WriteCheckedNamesToPathList(CTGitPathList& pathList);
\r
677 /** fills in \a lMin and \a lMax with the lowest/highest revision of all
\r
678 * files/folders in the working copy.
\r
679 * \param bShownOnly if true, the min/max revisions are calculated only for shown items
\r
680 * \param bCheckedOnly if true, the min/max revisions are calculated only for items
\r
681 * which are checked.
\r
682 * \remark Since an item can only be checked if it is visible/shown in the list control
\r
683 * bShownOnly is automatically set to true if bCheckedOnly is true
\r
685 void GetMinMaxRevisions(git_revnum_t& rMin, git_revnum_t& rMax, bool bShownOnly, bool bCheckedOnly);
\r
688 * Returns the parent directory of all entries in the control.
\r
689 * if \a bStrict is set to false, then the paths passed to the control
\r
690 * to fetch the status (in GetStatus()) are used if possible.
\r
692 CString GetCommonDirectory(bool bStrict);
\r
695 * Returns the parent url of all entries in the control.
\r
696 * if \a bStrict is set to false, then the paths passed to the control
\r
697 * to fetch the status (in GetStatus()) are used if possible.
\r
699 CTGitPath GetCommonURL(bool bStrict);
\r
702 * Sets a pointer to a boolean variable which is checked periodically
\r
703 * during the status fetching. As soon as the variable changes to true,
\r
704 * the operations stops.
\r
706 void SetCancelBool(bool * pbCanceled) {m_pbCanceled = pbCanceled;}
\r
709 * Sets the string shown in the control while the status is fetched.
\r
710 * If not set, it defaults to "please wait..."
\r
712 void SetBusyString(const CString& str) {m_sBusy = str;}
\r
713 void SetBusyString(UINT id) {m_sBusy.LoadString(id);}
\r
716 * Sets the string shown in the control if no items are shown. This
\r
717 * can happen for example if there's nothing modified and the unversioned
\r
718 * files aren't shown either, so there's nothing to commit.
\r
719 * If not set, it defaults to "file list is empty".
\r
721 void SetEmptyString(const CString& str) {m_sEmpty = str;}
\r
722 void SetEmptyString(UINT id) {m_sEmpty.LoadString(id);}
\r
725 * Determines if the control should recurse into unversioned folders
\r
726 * when fetching the status. The default behavior is defined by the
\r
727 * registry key HKCU\Software\TortoiseGit\UnversionedRecurse, which
\r
728 * is read in the Init() method.
\r
729 * If you want to change the behavior, call this method *after*
\r
732 void SetUnversionedRecurse(bool bUnversionedRecurse) {m_bUnversionedRecurse = bUnversionedRecurse;}
\r
735 * Returns the number of selected items
\r
737 LONG GetSelected(){return m_nSelected;};
\r
740 * Enables dropping of files on the control.
\r
742 bool EnableFileDrop();
\r
745 * Checks if the path already exists in the list.
\r
747 bool HasPath(const CTGitPath& path);
\r
749 * Checks if the path is shown/visible in the list control.
\r
751 bool IsPathShown(const CTGitPath& path);
\r
753 * Forces the children to be checked when the parent folder is checked,
\r
754 * and the parent folder to be unchecked if one of its children is unchecked.
\r
756 void CheckChildrenWithParent(bool bCheck) {m_bCheckChildrenWithParent = bCheck;}
\r
759 * Allows checking the items if change lists are present. If set to false,
\r
760 * items are not checked if at least one changelist is available.
\r
762 void CheckIfChangelistsArePresent(bool bCheck) {m_bCheckIfGroupsExist = bCheck;}
\r
764 * Returns the currently used show flags passed to the Show() method.
\r
766 DWORD GetShowFlags() {return m_dwShow;}
\r
768 CString GetLastErrorMessage() {return m_sLastError;}
\r
770 void Block(BOOL block, BOOL blockUI) {m_bBlock = block; m_bBlockUI = blockUI;}
\r
772 LONG m_nTargetCount; ///< number of targets in the file passed to GetStatus()
\r
774 CString m_sURL; ///< the URL of the target or "(multiple targets)"
\r
776 GitRev m_HeadRev; ///< the HEAD revision of the repository if bUpdate was TRUE
\r
778 CString m_sUUID; ///< the UUID of the associated repository
\r
780 DECLARE_MESSAGE_MAP()
\r
783 void SaveColumnWidths(bool bSaveToRegistry = false);
\r
784 void Sort(); ///< Sorts the control by columns
\r
785 //void AddEntry(FileEntry * entry, WORD langID, int listIndex); ///< add an entry to the control
\r
786 void RemoveListEntry(int index); ///< removes an entry from the listcontrol and both arrays
\r
787 bool BuildStatistics(); ///< build the statistics and correct the case of files/folders
\r
788 void StartDiff(int fileindex); ///< start the external diff program
\r
789 void StartDiffWC(int fileindex); ///< start the external diff program
\r
790 void StartDiffTwo(int fileindex);
\r
798 void OpenFile(CTGitPath *path,int mode);
\r
800 /// fetch all user properties for all items
\r
801 void FetchUserProperties();
\r
803 /// Process one line of the command file supplied to GetStatus
\r
804 bool FetchStatusForSingleTarget(GitConfig& config, GitStatus& status, const CTGitPath& target,
\r
805 bool bFetchStatusFromRepository, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths,
\r
806 bool bAllDirect, git_depth_t depth = git_depth_infinity, bool bShowIgnores = false);
\r
808 /// Create 'status' data for each item in an unversioned folder
\r
809 void AddUnversionedFolder(const CTGitPath& strFolderName, const CTGitPath& strBasePath, GitConfig * config);
\r
811 /// Read the all the other status items which result from a single GetFirstStatus call
\r
812 void ReadRemainingItemsStatus(GitStatus& status, const CTGitPath& strBasePath, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths, GitConfig * config, bool bAllDirect);
\r
814 /// Clear the status vector (contains custodial pointers)
\r
815 void ClearStatusArray();
\r
817 /// Sort predicate function - Compare the paths of two entries without regard to case
\r
818 //static bool EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2);
\r
820 /// Predicate used to build a list of only the versioned entries of the FileEntry array
\r
821 //static bool IsEntryVersioned(const FileEntry* pEntry1);
\r
823 /// Look up the relevant show flags for a particular Git status value
\r
824 DWORD GetShowFlagsFromGitStatus(git_wc_status_kind status);
\r
826 /// Build a FileEntry item and add it to the FileEntry array
\r
827 //const FileEntry* AddNewFileEntry(
\r
828 // const git_wc_status2_t* pGitStatus, // The return from the Git GetStatus functions
\r
829 // const CTGitPath& path, // The path of the item we're adding
\r
830 // const CTGitPath& basePath, // The base directory for this status build
\r
831 // bool bDirectItem, // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call
\r
832 // bool bInExternal, // Are we in an 'external' folder
\r
833 // bool bEntryfromDifferentRepo // if the entry is from a different repository
\r
836 /// Adjust the checkbox-state on all descendants of a specific item
\r
837 //void SetCheckOnAllDescendentsOf(const FileEntry* parentEntry, bool bCheck);
\r
839 /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)
\r
840 void FillListOfSelectedItemPaths(CTGitPathList& pathList, bool bNoIgnored = false);
\r
842 /// Enables/Disables group view and adds all groups to the list control.
\r
843 /// If bForce is true, then group view is enabled and the 'null' group is added.
\r
844 bool PrepareGroups(bool bForce = false);
\r
845 /// Returns the group number to which the group header belongs
\r
846 /// If the point is not over a group header, -1 is returned
\r
847 int GetGroupFromPoint(POINT * ppt);
\r
848 /// Returns the number of change lists the selection has
\r
849 size_t GetNumberOfChangelistsInSelection();
\r
851 /// Puts the item to the corresponding group
\r
852 bool SetItemGroup(int item, int groupindex);
\r
854 void CheckEntry(int index, int nListItems);
\r
855 void UncheckEntry(int index, int nListItems);
\r
857 /// sends an GitSLNM_CHECKCHANGED notification to the parent
\r
858 void NotifyCheck();
\r
860 int CellRectFromPoint(CPoint& point, RECT *cellrect, int *col) const;
\r
862 void OnContextMenuList(CWnd * pWnd, CPoint point);
\r
863 void OnContextMenuGroup(CWnd * pWnd, CPoint point);
\r
864 void OnContextMenuHeader(CWnd * pWnd, CPoint point);
\r
866 virtual void PreSubclassWindow();
\r
867 virtual BOOL PreTranslateMessage(MSG* pMsg);
\r
868 virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
\r
869 afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
\r
870 afx_msg BOOL OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult);
\r
871 afx_msg void OnHdnItemclick(NMHDR *pNMHDR, LRESULT *pResult);
\r
872 afx_msg void OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
\r
873 afx_msg BOOL OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult);
\r
874 afx_msg void OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult);
\r
875 afx_msg void OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult);
\r
876 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
\r
878 void CreateChangeList(const CString& name);
\r
880 afx_msg void OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult);
\r
881 afx_msg void OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult);
\r
882 afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
\r
883 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
\r
884 afx_msg UINT OnGetDlgCode();
\r
885 afx_msg void OnNMReturn(NMHDR *pNMHDR, LRESULT *pResult);
\r
886 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
\r
887 afx_msg void OnPaint();
\r
888 afx_msg void OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult);
\r
889 afx_msg void OnHdnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
\r
890 afx_msg void OnDestroy();
\r
893 void FileSaveAs(CTGitPath *path);
\r
894 int RevertSelectedItemToVersion();
\r
897 bool * m_pbCanceled;
\r
898 bool m_bAscending; ///< sort direction
\r
899 int m_nSortedColumn; ///< which column to sort
\r
900 bool m_bHasCheckboxes;
\r
901 bool m_bUnversionedLast;
\r
902 bool m_bHasExternalsFromDifferentRepos;
\r
903 bool m_bHasExternals;
\r
904 BOOL m_bHasUnversionedItems;
\r
906 bool m_bHasChangeLists;
\r
907 //typedef std::vector<FileEntry*> FileEntryVector;
\r
908 //FileEntryVector m_arStatusArray;
\r
909 std::vector<CTGitPath*> m_arStatusArray;
\r
910 std::vector<size_t> m_arListArray;
\r
911 std::map<CString, int> m_changelists;
\r
912 bool m_bHasIgnoreGroup;
\r
913 //CTGitPathList m_ConflictFileList;
\r
914 CTGitPathList m_StatusFileList;
\r
915 CTGitPathList m_UnRevFileList;
\r
916 CTGitPathList m_IgnoreFileList;
\r
917 //CTGitPathList m_StatusUrlList;
\r
918 CString m_sLastError;
\r
920 LONG m_nUnversioned;
\r
925 LONG m_nConflicted;
\r
929 DWORD m_dwDefaultColumns;
\r
931 bool m_bShowFolders;
\r
932 bool m_bShowIgnores;
\r
934 unsigned __int64 m_dwContextMenus;
\r
939 bool m_bIgnoreRemoveOnly;
\r
940 bool m_bCheckIfGroupsExist;
\r
941 bool m_bFileDropsEnabled;
\r
946 CWnd * m_pStatLabel;
\r
947 CButton * m_pSelectButton;
\r
948 CButton * m_pConfirmButton;
\r
953 CString m_sNoPropValueText;
\r
955 bool m_bUnversionedRecurse;
\r
957 bool m_bCheckChildrenWithParent;
\r
958 CGitStatusListCtrlDropTarget * m_pDropTarget;
\r
960 ColumnManager m_ColumnManager;
\r
962 std::map<CString,bool> m_mapFilenameToChecked; ///< Remember manually de-/selected items
\r
963 CComCriticalSection m_critSec;
\r
965 friend class CGitStatusListCtrlDropTarget;
\r
969 FILELIST_MODIFY= 0x1,
\r
970 FILELIST_UNVER = 0x2,
\r
971 FILELIST_IGNORE =0x4
\r
974 int UpdateFileList(git_revnum_t hash,CTGitPathList *List=NULL);
\r
975 int UpdateFileList(int mask, bool once=true,CTGitPathList *List=NULL);
\r
976 int UpdateUnRevFileList(CTGitPathList *List=NULL);
\r
977 int UpdateIgnoreFileList(CTGitPathList *List=NULL);
\r
979 int UpdateWithGitPathList(CTGitPathList &list);
\r
981 void AddEntry(CTGitPath* path, WORD langID, int ListIndex);
\r
984 git_revnum_t m_CurrentVersion;
\r
990 class CGitStatusListCtrlDropTarget : public CIDropTarget
\r
993 CGitStatusListCtrlDropTarget(CGitStatusListCtrl * pGitStatusListCtrl):CIDropTarget(pGitStatusListCtrl->m_hWnd){m_pGitStatusListCtrl = pGitStatusListCtrl;}
\r
995 virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD * /*pdwEffect*/, POINTL pt);
\r
996 virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect);
\r
998 CGitStatusListCtrl * m_pGitStatusListCtrl;
\r