OSDN Git Service

Update Tooltips info at setting dialog of shell overlay type
[tortoisegit/TortoiseGitJp.git] / src / Git / GitStatusListCtrl.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 #include "TGitPath.h"\r
21 #include "GitStatus.h"\r
22 #include "GitRev.h"\r
23 #include "GitConfig.h"\r
24 #include "Colors.h"\r
25 #include "XPTheme.h"\r
26 \r
27 #define SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN (-1)\r
28 \r
29 // these defines must be in the order the columns are inserted!\r
30 #define SVNSLC_COLFILENAME                      0x000000002\r
31 #define SVNSLC_COLEXT                           0x000000004\r
32 #define SVNSLC_COLSTATUS                        0x000000008\r
33 #define SVNSLC_COLTEXTSTATUS            0x000000010\r
34 #define SVNSLC_COLPROPSTATUS            0x000000020\r
35 #define SVNSLC_COLAUTHOR                        0x000000040\r
36 #define SVNSLC_COLREVISION                      0x000000080\r
37 #define SVNSLC_COLDATE                          0x000000100\r
38 #define SVNSLC_COLMODIFICATIONDATE      0x000000200\r
39 #define SVNSLC_COLADD                           0x000000400\r
40 #define SVNSLC_COLDEL                           0x000000800\r
41 #define SVNSLC_NUMCOLUMNS                       12\r
42 \r
43 //#define SVNSLC_COLREMOTESTATUS                0x000000010\r
44 //#define SVNSLC_COLREMOTETEXT          0x000000080\r
45 //#define SVNSLC_COLREMOTEPROP          0x000000100\r
46 //#define SVNSLC_COLURL                         0x000000200\r
47 //#define SVNSLC_COLLOCK                                0x000000400\r
48 //#define SVNSLC_COLLOCKCOMMENT         0x000000800\r
49 \r
50 //#define       SVNSLC_COLREMOTEREVISION        0x000004000\r
51 \r
52 //#define SVNSLC_COLSVNNEEDSLOCK                0x000010000\r
53 //#define SVNSLC_COLCOPYFROM                    0x000020000\r
54 \r
55                 \r
56 #define SVNSLC_SHOWUNVERSIONED  CTGitPath::LOGACTIONS_UNVER\r
57 #define SVNSLC_SHOWNORMAL               0x000000000\r
58 #define SVNSLC_SHOWMODIFIED             (CTGitPath::LOGACTIONS_MODIFIED)\r
59 #define SVNSLC_SHOWADDED                (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY)\r
60 #define SVNSLC_SHOWREMOVED              CTGitPath::LOGACTIONS_DELETED\r
61 #define SVNSLC_SHOWCONFLICTED   CTGitPath::LOGACTIONS_UNMERGED\r
62 #define SVNSLC_SHOWMISSING              0x00000000\r
63 #define SVNSLC_SHOWREPLACED             CTGitPath::LOGACTIONS_REPLACED\r
64 #define SVNSLC_SHOWMERGED               0x00000000\r
65 #define SVNSLC_SHOWIGNORED              CTGitPath::LOGACTIONS_IGNORE\r
66 #define SVNSLC_SHOWOBSTRUCTED   0x00000000\r
67 #define SVNSLC_SHOWEXTERNAL             0x00000000\r
68 #define SVNSLC_SHOWINCOMPLETE   0x00000000\r
69 #define SVNSLC_SHOWINEXTERNALS  0x00000000\r
70 #define SVNSLC_SHOWREMOVEDANDPRESENT 0x00000000\r
71 #define SVNSLC_SHOWLOCKS                0x00000000\r
72 #define SVNSLC_SHOWDIRECTFILES  0x00000000\r
73 #define SVNSLC_SHOWDIRECTFOLDER 0x00000000\r
74 #define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x00000000\r
75 #define SVNSLC_SHOWSWITCHED             0x00000000\r
76 #define SVNSLC_SHOWINCHANGELIST 0x00000000\r
77 \r
78 #define SVNSLC_SHOWDIRECTS              (SVNSLC_SHOWDIRECTFILES | SVNSLC_SHOWDIRECTFOLDER)\r
79 \r
80 \r
81 #define SVNSLC_SHOWVERSIONED (SVNSLC_SHOWNORMAL|SVNSLC_SHOWMODIFIED|\\r
82 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\\r
83 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\\r
84 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\\r
85 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)\r
86 \r
87 #define SVNSLC_SHOWVERSIONEDBUTNORMAL (SVNSLC_SHOWMODIFIED|SVNSLC_SHOWADDED|\\r
88 SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\\r
89 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\\r
90 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\\r
91 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)\r
92 \r
93 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS (SVNSLC_SHOWMODIFIED|\\r
94 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\\r
95 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\\r
96 SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINEXTERNALS)\r
97 \r
98 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS (SVNSLC_SHOWMODIFIED|\\r
99         SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\\r
100         SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\\r
101         SVNSLC_SHOWINCOMPLETE)\r
102 \r
103 #define SVNSLC_SHOWALL (SVNSLC_SHOWVERSIONED|SVNSLC_SHOWUNVERSIONED)\r
104 \r
105 #define SVNSLC_POPALL                                   0xFFFFFFFF\r
106 #define SVNSLC_POPCOMPAREWITHBASE               0x00000001\r
107 #define SVNSLC_POPCOMPARE                               0x00000002\r
108 #define SVNSLC_POPGNUDIFF                               0x00000004\r
109 #define SVNSLC_POPREVERT                                0x00000008\r
110 #define SVNSLC_POPUPDATE                                0x00000010\r
111 #define SVNSLC_POPSHOWLOG                               0x00000020\r
112 #define SVNSLC_POPOPEN                                  0x00000040\r
113 #define SVNSLC_POPDELETE                                0x00000080\r
114 #define SVNSLC_POPADD                                   0x00000100\r
115 #define SVNSLC_POPIGNORE                                0x00000200\r
116 #define SVNSLC_POPCONFLICT                              0x00000400\r
117 #define SVNSLC_POPRESOLVE                               0x00000800\r
118 #define SVNSLC_POPLOCK                                  0x00001000\r
119 #define SVNSLC_POPUNLOCK                                0x00002000\r
120 #define SVNSLC_POPUNLOCKFORCE                   0x00004000\r
121 #define SVNSLC_POPEXPLORE                               0x00008000\r
122 #define SVNSLC_POPCOMMIT                                0x00010000\r
123 #define SVNSLC_POPPROPERTIES                    0x00020000\r
124 #define SVNSLC_POPREPAIRMOVE                    0x00040000\r
125 #define SVNSLC_POPCHANGELISTS                   0x00080000\r
126 #define SVNSLC_POPBLAME                                 0x00100000\r
127 \r
128 #define SVNSLC_IGNORECHANGELIST                 _T("ignore-on-commit")\r
129 \r
130 // This gives up to 64 standard properties and menu entries\r
131 // plus 192 user-defined properties (should be plenty).\r
132 // User-defined properties will start at column SVNSLC_NUMCOLUMNS+1\r
133 // but in the registry, we will record them starting at SVNSLC_USERPROPCOLOFFSET.\r
134 \r
135 #define SVNSLC_USERPROPCOLOFFSET        0x40\r
136 #define SVNSLC_USERPROPCOLLIMIT         0xff\r
137 #define SVNSLC_MAXCOLUMNCOUNT           0xff\r
138 \r
139 // Supporting extreamly long user props makes no sense here --\r
140 // especially for binary properties. CString uses a pool allocator\r
141 // that works for up to 256 chars. Make sure we are well below that.\r
142 \r
143 #define SVNSLC_MAXUSERPROPLENGTH        0x70\r
144 \r
145 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);\r
146 typedef CComCritSecLock<CComCriticalSection> Locker;\r
147 \r
148 class CGitStatusListCtrlDropTarget;\r
149 /**\r
150  * \ingroup SVN\r
151  * A List control, based on the MFC CListCtrl which shows a list of\r
152  * files with their Subversion status. The control also provides a context\r
153  * menu to do some Subversion tasks on the selected files.\r
154  *\r
155  * This is the main control used in many dialogs to show a list of files to\r
156  * work on.\r
157  */\r
158 class CGitStatusListCtrl :\r
159         public CListCtrl\r
160 {\r
161 public:\r
162         int GetColumnIndex(int colmask);\r
163         /**\r
164          * Sent to the parent window (using ::SendMessage) after a context menu\r
165          * command has finished if the item count has changed.\r
166          */\r
167         static const UINT SVNSLNM_ITEMCOUNTCHANGED;\r
168         /**\r
169          * Sent to the parent window (using ::SendMessage) when the control needs\r
170          * to be refreshed. Since this is done usually in the parent window using\r
171          * a thread, this message is used to tell the parent to do exactly that.\r
172          */\r
173         static const UINT SVNSLNM_NEEDSREFRESH;\r
174 \r
175         /**\r
176          * Sent to the parent window (using ::SendMessage) when the user drops\r
177          * files on the control. The LPARAM is a pointer to a TCHAR string\r
178          * containing the dropped path.\r
179          */\r
180         static const UINT SVNSLNM_ADDFILE;\r
181 \r
182         /**\r
183          * Sent to the parent window (using ::SendMessage) when the user checks/unchecks\r
184          * one or more items in the control. The WPARAM contains the number of\r
185          * checked items in the control.\r
186          */\r
187         static const UINT SVNSLNM_CHECKCHANGED;\r
188 \r
189         CGitStatusListCtrl(void);\r
190         ~CGitStatusListCtrl(void);\r
191 \r
192         /**\r
193          * \ingroup TortoiseProc\r
194          * Helper class for CGitStatusListCtrl which represents\r
195          * the data for each file shown.\r
196          */\r
197 #if 0\r
198         class FileEntry\r
199         {\r
200         public:\r
201                 FileEntry() : status(git_wc_status_unversioned)\r
202 //                      , copyfrom_rev(GIT_REV_ZERO)\r
203                         , last_commit_date(0)\r
204                         , last_commit_rev(GIT_REV_ZERO)\r
205 //                      , remoterev(GIT_REV_ZERO)\r
206                         , textstatus(git_wc_status_unversioned)\r
207                         , propstatus(git_wc_status_unversioned)\r
208 //                      , remotestatus(git_wc_status_unversioned)\r
209 //                      , remotetextstatus(git_wc_status_unversioned)\r
210 //                      , remotepropstatus(git_wc_status_unversioned)\r
211                         , copied(false)\r
212                         , switched(false)\r
213                         , checked(false)\r
214                         , inunversionedfolder(false)\r
215                         , inexternal(false)\r
216                         , differentrepo(false)\r
217                         , direct(false)\r
218                         , isfolder(false)\r
219                         , isNested(false)\r
220                         , Revision(GIT_REV_ZERO)\r
221                         , isConflicted(false)\r
222 //                      , present_props()\r
223                         , needslock(false)\r
224 ///                     , working_size(SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN)\r
225                         , keeplocal(false)\r
226 //                      , depth(git_depth_unknown)\r
227                 {\r
228                 }\r
229                 const CTGitPath& GetPath() const\r
230                 {\r
231                         return path;\r
232                 }\r
233                 const bool IsChecked() const\r
234                 {\r
235                         return checked;\r
236                 }\r
237                 CString GetRelativeGitPath() const\r
238                 {\r
239                         if (path.IsEquivalentTo(basepath))\r
240                                 return path.GetGitPathString();\r
241                         return path.GetGitPathString().Mid(basepath.GetGitPathString().GetLength()+1);\r
242                 }\r
243 //              const bool IsLocked() const\r
244 //              {\r
245 //                      return !(lock_token.IsEmpty() && lock_remotetoken.IsEmpty());\r
246 //              }\r
247 //              const bool HasNeedsLock() const\r
248 //              {\r
249 //                      return needslock;\r
250 //              }\r
251                 const bool IsFolder() const\r
252                 {\r
253                         return isfolder;\r
254                 }\r
255                 const bool IsInExternal() const\r
256                 {\r
257                         return inexternal;\r
258                 }\r
259                 const bool IsNested() const\r
260                 {\r
261                         return isNested;\r
262                 }\r
263                 const bool IsFromDifferentRepository() const\r
264                 {\r
265                         return differentrepo;\r
266                 }\r
267                 CString GetDisplayName() const\r
268                 {\r
269                         CString const& chopped = path.GetDisplayString(&basepath);\r
270                         if (!chopped.IsEmpty())\r
271                         {\r
272                                 return chopped;\r
273                         }\r
274                         else\r
275                         {\r
276                                 // "Display name" must not be empty.\r
277                                 return path.GetFileOrDirectoryName();\r
278                         }\r
279                 }\r
280                 CString GetChangeList() const\r
281                 {\r
282                         return changelist;\r
283                 }\r
284 //              CString GetURL() const\r
285 //              {\r
286 //                      return url;\r
287 //              }\r
288         public:\r
289                 git_wc_status_kind              status;                                 ///< local status\r
290                 git_wc_status_kind              textstatus;                             ///< local text status\r
291                 git_wc_status_kind              propstatus;                             ///< local property status\r
292                 \r
293         private:\r
294                 CTGitPath                               path;                                   ///< full path of the file\r
295                 CTGitPath                               basepath;                               ///< common ancestor path of all files\r
296                 \r
297                 CString                                 changelist;                             ///< the name of the changelist the item belongs to\r
298                 \r
299                 CString                                 last_commit_author;             ///< the author which last committed this item\r
300                 CTime                                   last_commit_date;               ///< the date when this item was last committed\r
301                 git_revnum_t                    last_commit_rev;                ///< the revision where this item was last committed\r
302                 \r
303                 git_revnum_t                    remoterev;                              ///< the revision in HEAD of the repository\r
304                 bool                                    copied;                                 ///< if the file/folder is added-with-history\r
305                 bool                                    switched;                               ///< if the file/folder is switched to another url\r
306                 bool                                    checked;                                ///< if the file is checked in the list control\r
307                 bool                                    inunversionedfolder;    ///< if the file is inside an unversioned folder\r
308                 bool                                    inexternal;                             ///< if the item is in an external folder\r
309                 bool                                    differentrepo;                  ///< if the item is from a different repository than the rest\r
310                 bool                                    direct;                                 ///< directly included (TRUE) or just a child of a folder\r
311                 bool                                    isfolder;                               ///< TRUE if entry refers to a folder\r
312                 bool                                    isNested;                               ///< TRUE if the folder from a different repository and/or path\r
313                 bool                                    isConflicted;                   ///< TRUE if a file entry is conflicted, i.e. if it has the conflicted paths set\r
314                 bool                                    needslock;                              ///< TRUE if the Git:needs-lock property is set\r
315                 git_revnum_t                    Revision;                               ///< the base revision\r
316 //              PropertyList                    present_props;                  ///< cacheable properties present in BASE\r
317                 bool                                    keeplocal;                              ///< Whether a local copy of this entry should be kept in the working copy after a deletion has been committed\r
318                 git_depth_t                             depth;                                  ///< the depth of this entry\r
319                 friend class CGitStatusListCtrl;\r
320                 friend class CGitStatusListCtrlDropTarget;\r
321         friend class CSorter;\r
322         };\r
323 #endif\r
324         /**\r
325          * \ingroup TortoiseProc\r
326          * Helper class for CGitStatusListCtrl that represents\r
327          * the columns visible and their order as well as \r
328      * persisting that data in the registry.\r
329      *\r
330      * It assigns logical index values to the (potential) columns:\r
331      * 0 .. GitSLC_NUMCOLUMNS-1 contain the standard attributes\r
332      * GitSLC_USERPROPCOLOFFSET .. GitSLC_MAXCOLUMNCOUNT are user props.\r
333      *\r
334      * The column vector contains the columns that are actually\r
335      * available in the control.\r
336      *\r
337      * Since the set of userprops may change from one WC to another,\r
338      * we also store the settings (width and order) for those\r
339      * userprops that are not used in this WC.\r
340      *\r
341      * A userprop is considered "in use", if the respective column\r
342      * is not hidden or if at least one item has this property set.\r
343          */\r
344         class ColumnManager\r
345         {\r
346     public:\r
347 \r
348         /// construction / destruction\r
349 \r
350         ColumnManager (CListCtrl* control) : control (control) {};\r
351         ~ColumnManager() {};\r
352 \r
353         /// registry access\r
354 \r
355         void ReadSettings (DWORD defaultColumns, const CString& containerName);\r
356         void WriteSettings() const;\r
357 \r
358         /// read column definitions\r
359 \r
360         int GetColumnCount() const;                     ///< total number of columns\r
361         bool IsVisible (int column) const;\r
362                 int GetInvisibleCount() const;\r
363         bool IsRelevant (int column) const;\r
364         bool IsUserProp (int column) const;\r
365         CString GetName (int column) const;\r
366         int GetWidth (int column, bool useDefaults = false) const;\r
367         int GetVisibleWidth (int column, bool useDefaults) const;\r
368 \r
369         /// switch columns on and off\r
370 \r
371         void SetVisible (int column, bool visible);\r
372 \r
373         /// tracking column modifications\r
374 \r
375         void ColumnMoved (int column, int position);\r
376         void ColumnResized (int column);\r
377 \r
378         /// call these to update the user-prop list\r
379         /// (will also auto-insert /-remove new list columns)\r
380 \r
381         //void UpdateUserPropList (const std::vector<FileEntry*>& files);\r
382         //void UpdateRelevance ( const std::vector<FileEntry*>& files\r
383          //                    , const std::vector<size_t>& visibleFiles);\r
384 \r
385         /// don't clutter the context menu with irrelevant prop info\r
386 \r
387         bool AnyUnusedProperties() const;\r
388         void RemoveUnusedProps();\r
389 \r
390         /// bring everything back to its "natural" order\r
391 \r
392         void ResetColumns (DWORD defaultColumns);\r
393 \r
394     private:\r
395 \r
396         /// initialization utilities\r
397 \r
398         void ParseUserPropSettings ( const CString& userPropList\r
399                                    , const CString& shownUserProps);\r
400         void ParseWidths (const CString& widths);\r
401         void SetStandardColumnVisibility (DWORD visibility);\r
402         void ParseColumnOrder (const CString& widths);\r
403         \r
404         /// map internal column order onto visible column order\r
405         /// (all invisibles in front)\r
406 \r
407         std::vector<int> GetGridColumnOrder();\r
408         void ApplyColumnOrder();\r
409 \r
410         /// utilities used when writing data to the registry\r
411 \r
412         DWORD GetSelectedStandardColumns() const;\r
413         CString GetUserPropList() const;\r
414         CString GetShownUserProps() const;\r
415         CString GetWidthString() const;\r
416         CString GetColumnOrderString() const;\r
417 \r
418         /// our parent control and its data\r
419 \r
420         CListCtrl* control;\r
421 \r
422         /// where to store in the registry\r
423 \r
424         CString registryPrefix;\r
425 \r
426         /// all columns in their "natural" order\r
427 \r
428         struct ColumnInfo\r
429         {\r
430             int index;          ///< is a user prop when < GitSLC_USERPROPCOLOFFSET\r
431             int width;\r
432             bool visible;\r
433             bool relevant;      ///< set to @a visible, if no *shown* item has that property\r
434         };\r
435 \r
436         std::vector<ColumnInfo> columns;\r
437 \r
438         /// user-defined properties\r
439 \r
440         struct UserProp\r
441         {\r
442             CString name;       ///< is a user prop when < GitSLC_USERPROPCOLOFFSET\r
443             int width;\r
444         };\r
445 \r
446         std::vector<UserProp> userProps;\r
447 \r
448         /// stored result from last UpdateUserPropList() call\r
449 \r
450         std::set<CString> itemProps;\r
451 \r
452         /// global column ordering including unused user props\r
453 \r
454         std::vector<int> columnOrder;\r
455 \r
456     };/**\r
457          * \ingroup TortoiseProc\r
458          * Simple utility class that defines the sort column order.\r
459          */\r
460     class CSorter\r
461     {\r
462     public:\r
463 \r
464         CSorter ( ColumnManager* columnManager\r
465                 , int sortedColumn\r
466                 , bool ascending);\r
467 \r
468         bool operator() ( const CTGitPath* entry1\r
469                         , const CTGitPath* entry2) const;\r
470 \r
471     private:\r
472 \r
473         ColumnManager* columnManager;\r
474         int sortedColumn;\r
475         bool ascending;\r
476     };\r
477 \r
478         /**\r
479          * Initializes the control, sets up the columns.\r
480          * \param dwColumns mask of columns to show. Use the GitSLC_COLxxx defines.\r
481          * \param sColumnInfoContainer Name of a registry key\r
482          *                             where the position and visibility of each column\r
483          *                             is saved and used from. If the registry key\r
484          *                             doesn't exist, the default order is used\r
485          *                             and dwColumns tells which columns are visible.\r
486          * \param dwContextMenus mask of context menus to be active, not all make sense for every use of this control.\r
487          *                       Use the GitSLC_POPxxx defines.\r
488          * \param bHasCheckboxes TRUE if the control should show check boxes on the left of each file entry.\r
489          */\r
490         void Init(DWORD dwColumns, const CString& sColumnInfoContainer, DWORD dwContextMenus = (SVNSLC_POPALL ^ SVNSLC_POPCOMMIT), bool bHasCheckboxes = true);\r
491         /**\r
492          * Sets a background image for the list control.\r
493          * The image is shown in the right bottom corner.\r
494          * \param nID the resource ID of the bitmap to use as the background\r
495          */\r
496         bool SetBackgroundImage(UINT nID);\r
497         /**\r
498          * Makes the 'ignore' context menu only ignore the files and not add the\r
499          * folder which gets the Git:ignore property changed to the list.\r
500          * This is needed e.g. for the Add-dialog, where the modified folder\r
501          * showing up would break the resulting "add" command.\r
502          */\r
503         void SetIgnoreRemoveOnly(bool bRemoveOnly = true) {m_bIgnoreRemoveOnly = bRemoveOnly;}\r
504         /**\r
505          * The unversioned items are by default shown after all other files in the list.\r
506          * If that behavior should be changed, set this value to false.\r
507          */\r
508         void PutUnversionedLast(bool bLast) {m_bUnversionedLast = bLast;}\r
509         /**\r
510          * Fetches the Subversion status of all files and stores the information\r
511          * about them in an internal array.\r
512          * \param sFilePath path to a file which contains a list of files and/or folders for which to\r
513          *                  fetch the status, separated by newlines.\r
514          * \param bUpdate TRUE if the remote status is requested too.\r
515          * \return TRUE on success.\r
516          */\r
517         BOOL GetStatus ( const CTGitPathList* pathList=NULL\r
518                    , bool bUpdate = false\r
519                    , bool bShowIgnores = false\r
520                                    , bool bShowUnRev=false\r
521                    , bool bShowUserProps = false);\r
522 \r
523         /**\r
524          * Populates the list control with the previously (with GetStatus) gathered status information.\r
525          * \param dwShow mask of file types to show. Use the GitSLC_SHOWxxx defines.\r
526          * \param dwCheck mask of file types to check. Use GitLC_SHOWxxx defines. Default (0) means 'use the entry's stored check status'\r
527          */\r
528         void Show(DWORD dwShow, DWORD dwCheck = 0, bool bShowFolders = true,BOOL updateStatusList=FALSE);\r
529         void Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders = true);\r
530 \r
531         /**\r
532          * Copies the selected entries in the control to the clipboard. The entries\r
533          * are separated by newlines.\r
534          * \param dwCols the columns to copy. Each column is separated by a tab.\r
535          */\r
536         bool CopySelectedEntriesToClipboard(DWORD dwCols);\r
537 \r
538         /**\r
539          * If during the call to GetStatus() some Git:externals are found from different\r
540          * repositories than the first one checked, then this method returns TRUE.\r
541          */\r
542         BOOL HasExternalsFromDifferentRepos() const {return m_bHasExternalsFromDifferentRepos;}\r
543 \r
544         /**\r
545          * If during the call to GetStatus() some Git:externals are found then this method returns TRUE.\r
546          */\r
547         BOOL HasExternals() const {return m_bHasExternals;}\r
548 \r
549         /**\r
550          * If unversioned files are found (but not necessarily shown) TRUE is returned.\r
551          */\r
552         BOOL HasUnversionedItems() {return m_bHasUnversionedItems;}\r
553 \r
554         /**\r
555          * If there are any locks in the working copy, TRUE is returned\r
556          */\r
557         BOOL HasLocks() const {return m_bHasLocks;}\r
558 \r
559         /**\r
560          * If there are any change lists defined in the working copy, TRUE is returned\r
561          */\r
562         BOOL HasChangeLists() const {return m_bHasChangeLists;}\r
563 \r
564         /**\r
565          * Returns the file entry data for the list control index.\r
566          */\r
567         //CGitStatusListCtrl::FileEntry * GetListEntry(UINT_PTR index);\r
568 \r
569         /**\r
570          * Returns the file entry data for the specified path.\r
571          * \note The entry might not be shown in the list control.\r
572          */\r
573         //CGitStatusListCtrl::FileEntry * GetListEntry(const CTGitPath& path);\r
574 \r
575         /**\r
576          * Returns the index of the list control entry with the specified path,\r
577          * or -1 if the path is not in the list control.\r
578          */\r
579         int GetIndex(const CTGitPath& path);\r
580 \r
581         /**\r
582          * Returns the file entry data for the specified path in the list control.\r
583          */\r
584         //CGitStatusListCtrl::FileEntry * GetVisibleListEntry(const CTGitPath& path);\r
585 \r
586         /**\r
587          * Returns a String containing some statistics like number of modified, normal, deleted,...\r
588          * files.\r
589          */\r
590         CString GetStatisticsString();\r
591 \r
592         /**\r
593          * Set a static control which will be updated automatically with\r
594          * the number of selected and total files shown in the list control.\r
595          */\r
596         void SetStatLabel(CWnd * pStatLabel){m_pStatLabel = pStatLabel;};\r
597 \r
598         /**\r
599          * Set a tri-state checkbox which is updated automatically if the\r
600          * user checks/unchecks file entries in the list control to indicate\r
601          * if all files are checked, none are checked or some are checked.\r
602          */\r
603         void SetSelectButton(CButton * pButton) {m_pSelectButton = pButton;}\r
604 \r
605         /**\r
606          * Set a button which is de-/activated automatically. The button is\r
607          * only set active if at least one item is selected.\r
608          */\r
609         void SetConfirmButton(CButton * pButton) {m_pConfirmButton = pButton;}\r
610 \r
611         /**\r
612          * Select/unselect all entries in the list control.\r
613          * \param bSelect TRUE to check, FALSE to uncheck.\r
614          */\r
615         void SelectAll(bool bSelect, bool bIncludeNoCommits = false);\r
616 \r
617         /** Set a checkbox on an entry in the listbox\r
618          * Keeps the listctrl checked state and the FileEntry's checked flag in sync\r
619          */\r
620         void SetEntryCheck(CTGitPath* pEntry, int listboxIndex, bool bCheck);\r
621 \r
622         /** Write a list of the checked items' paths into a path list\r
623          */\r
624         void WriteCheckedNamesToPathList(CTGitPathList& pathList);\r
625 \r
626         /** fills in \a lMin and \a lMax with the lowest/highest revision of all\r
627          * files/folders in the working copy.\r
628          * \param bShownOnly if true, the min/max revisions are calculated only for shown items\r
629          * \param bCheckedOnly if true, the min/max revisions are calculated only for items \r
630          *                   which are checked.\r
631          * \remark Since an item can only be checked if it is visible/shown in the list control\r
632          *         bShownOnly is automatically set to true if bCheckedOnly is true\r
633          */\r
634         void GetMinMaxRevisions(git_revnum_t& rMin, git_revnum_t& rMax, bool bShownOnly, bool bCheckedOnly);\r
635 \r
636         /**\r
637          * Returns the parent directory 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
640          */\r
641         CString GetCommonDirectory(bool bStrict);\r
642 \r
643         /**\r
644          * Returns the parent url of all entries in the control.\r
645          * if \a bStrict is set to false, then the paths passed to the control\r
646          * to fetch the status (in GetStatus()) are used if possible.\r
647          */\r
648         CTGitPath GetCommonURL(bool bStrict);\r
649 \r
650         /**\r
651          * Sets a pointer to a boolean variable which is checked periodically\r
652          * during the status fetching. As soon as the variable changes to true,\r
653          * the operations stops.\r
654          */\r
655         void SetCancelBool(bool * pbCanceled) {m_pbCanceled = pbCanceled;}\r
656 \r
657         /**\r
658          * Sets the string shown in the control while the status is fetched.\r
659          * If not set, it defaults to "please wait..."\r
660          */\r
661         void SetBusyString(const CString& str) {m_sBusy = str;}\r
662         void SetBusyString(UINT id) {m_sBusy.LoadString(id);}\r
663 \r
664         /**\r
665          * Sets the string shown in the control if no items are shown. This\r
666          * can happen for example if there's nothing modified and the unversioned\r
667          * files aren't shown either, so there's nothing to commit.\r
668          * If not set, it defaults to "file list is empty".\r
669          */\r
670         void SetEmptyString(const CString& str) {m_sEmpty = str;}\r
671         void SetEmptyString(UINT id) {m_sEmpty.LoadString(id);}\r
672 \r
673         /**\r
674          * Determines if the control should recurse into unversioned folders\r
675          * when fetching the status. The default behavior is defined by the\r
676          * registry key HKCU\Software\TortoiseGit\UnversionedRecurse, which\r
677          * is read in the Init() method.\r
678          * If you want to change the behavior, call this method *after*\r
679          * calling Init().\r
680          */\r
681         void SetUnversionedRecurse(bool bUnversionedRecurse) {m_bUnversionedRecurse = bUnversionedRecurse;}\r
682 \r
683         /**\r
684          * Returns the number of selected items\r
685          */\r
686         LONG GetSelected(){return m_nSelected;};\r
687 \r
688         /**\r
689          * Enables dropping of files on the control.\r
690          */\r
691         bool EnableFileDrop();\r
692 \r
693         /**\r
694          * Checks if the path already exists in the list.\r
695          */\r
696         bool HasPath(const CTGitPath& path);\r
697         /**\r
698          * Checks if the path is shown/visible in the list control.\r
699          */\r
700         bool IsPathShown(const CTGitPath& path);\r
701         /**\r
702          * Forces the children to be checked when the parent folder is checked,\r
703          * and the parent folder to be unchecked if one of its children is unchecked.\r
704          */\r
705         void CheckChildrenWithParent(bool bCheck) {m_bCheckChildrenWithParent = bCheck;}\r
706 \r
707         /**\r
708          * Allows checking the items if change lists are present. If set to false,\r
709          * items are not checked if at least one changelist is available.\r
710          */\r
711         void CheckIfChangelistsArePresent(bool bCheck) {m_bCheckIfGroupsExist = bCheck;}\r
712         /**\r
713          * Returns the currently used show flags passed to the Show() method.\r
714          */\r
715         DWORD GetShowFlags() {return m_dwShow;}\r
716 public:\r
717         CString GetLastErrorMessage() {return m_sLastError;}\r
718 \r
719         void Block(BOOL block, BOOL blockUI) {m_bBlock = block; m_bBlockUI = blockUI;}\r
720 \r
721         LONG                                            m_nTargetCount;         ///< number of targets in the file passed to GetStatus()\r
722 \r
723         CString                                         m_sURL;                         ///< the URL of the target or "(multiple targets)"\r
724 \r
725         GitRev                                          m_HeadRev;                      ///< the HEAD revision of the repository if bUpdate was TRUE\r
726 \r
727         CString                                         m_sUUID;                        ///< the UUID of the associated repository\r
728 \r
729         DECLARE_MESSAGE_MAP()\r
730 \r
731 private:\r
732         void SaveColumnWidths(bool bSaveToRegistry = false);\r
733         void Sort();    ///< Sorts the control by columns\r
734         //void AddEntry(FileEntry * entry, WORD langID, int listIndex); ///< add an entry to the control\r
735         void RemoveListEntry(int index);        ///< removes an entry from the listcontrol and both arrays\r
736         bool BuildStatistics(); ///< build the statistics and correct the case of files/folders\r
737         void StartDiff(int fileindex);  ///< start the external diff program\r
738 \r
739     /// fetch all user properties for all items\r
740     void FetchUserProperties();\r
741 \r
742         /// Process one line of the command file supplied to GetStatus\r
743         bool FetchStatusForSingleTarget(GitConfig& config, GitStatus& status, const CTGitPath& target, \r
744                 bool bFetchStatusFromRepository, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths, \r
745                 bool bAllDirect, git_depth_t depth = git_depth_infinity, bool bShowIgnores = false);\r
746 \r
747         /// Create 'status' data for each item in an unversioned folder\r
748         void AddUnversionedFolder(const CTGitPath& strFolderName, const CTGitPath& strBasePath, GitConfig * config);\r
749 \r
750         /// Read the all the other status items which result from a single GetFirstStatus call\r
751         void ReadRemainingItemsStatus(GitStatus& status, const CTGitPath& strBasePath, CStringA& strCurrentRepositoryUUID, CTGitPathList& arExtPaths, GitConfig * config, bool bAllDirect);\r
752 \r
753         /// Clear the status vector (contains custodial pointers)\r
754         void ClearStatusArray();\r
755 \r
756         /// Sort predicate function - Compare the paths of two entries without regard to case\r
757         //static bool EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2);\r
758 \r
759         /// Predicate used to build a list of only the versioned entries of the FileEntry array\r
760         //static bool IsEntryVersioned(const FileEntry* pEntry1);\r
761 \r
762         /// Look up the relevant show flags for a particular Git status value\r
763         DWORD GetShowFlagsFromGitStatus(git_wc_status_kind status);\r
764 \r
765         /// Build a FileEntry item and add it to the FileEntry array\r
766         //const FileEntry* AddNewFileEntry(\r
767         //      const git_wc_status2_t* pGitStatus,  // The return from the Git GetStatus functions\r
768         //      const CTGitPath& path,                          // The path of the item we're adding\r
769         //      const CTGitPath& basePath,                      // The base directory for this status build\r
770         //      bool bDirectItem,                                       // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call\r
771         //      bool bInExternal,                                       // Are we in an 'external' folder\r
772         //      bool bEntryfromDifferentRepo            // if the entry is from a different repository\r
773         //      );\r
774 \r
775         /// Adjust the checkbox-state on all descendants of a specific item\r
776         //void SetCheckOnAllDescendentsOf(const FileEntry* parentEntry, bool bCheck);\r
777 \r
778         /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)\r
779         void FillListOfSelectedItemPaths(CTGitPathList& pathList, bool bNoIgnored = false);\r
780 \r
781         /// Enables/Disables group view and adds all groups to the list control.\r
782         /// If bForce is true, then group view is enabled and the 'null' group is added.\r
783         bool PrepareGroups(bool bForce = false);\r
784         /// Returns the group number to which the group header belongs\r
785         /// If the point is not over a group header, -1 is returned\r
786         int GetGroupFromPoint(POINT * ppt);\r
787         /// Returns the number of change lists the selection has\r
788         size_t GetNumberOfChangelistsInSelection();\r
789 \r
790         /// Puts the item to the corresponding group\r
791         bool SetItemGroup(int item, int groupindex);\r
792 \r
793         void CheckEntry(int index, int nListItems);\r
794         void UncheckEntry(int index, int nListItems);\r
795 \r
796         /// sends an GitSLNM_CHECKCHANGED notification to the parent\r
797         void NotifyCheck();\r
798 \r
799         int CellRectFromPoint(CPoint& point, RECT *cellrect, int *col) const;\r
800 \r
801         void OnContextMenuList(CWnd * pWnd, CPoint point);\r
802         void OnContextMenuGroup(CWnd * pWnd, CPoint point);\r
803         void OnContextMenuHeader(CWnd * pWnd, CPoint point);\r
804 \r
805         virtual void PreSubclassWindow();\r
806         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
807         virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;\r
808         afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);\r
809         afx_msg BOOL OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult);\r
810         afx_msg void OnHdnItemclick(NMHDR *pNMHDR, LRESULT *pResult);\r
811         afx_msg void OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);\r
812         afx_msg BOOL OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult);\r
813     afx_msg void OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult);\r
814     afx_msg void OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult);\r
815     afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);\r
816 \r
817         void CreateChangeList(const CString& name);\r
818 \r
819         afx_msg void OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult);\r
820         afx_msg void OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult);\r
821         afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);\r
822         afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);\r
823         afx_msg UINT OnGetDlgCode();\r
824         afx_msg void OnNMReturn(NMHDR *pNMHDR, LRESULT *pResult);\r
825         afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\r
826         afx_msg void OnPaint();\r
827         afx_msg void OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult);\r
828         afx_msg void OnHdnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);\r
829         afx_msg void OnDestroy();\r
830 \r
831 private:\r
832         bool *                                          m_pbCanceled;\r
833         bool                                        m_bAscending;               ///< sort direction\r
834         int                                             m_nSortedColumn;        ///< which column to sort\r
835         bool                                            m_bHasCheckboxes;\r
836         bool                                            m_bUnversionedLast;\r
837         bool                                            m_bHasExternalsFromDifferentRepos;\r
838         bool                                            m_bHasExternals;\r
839         BOOL                                            m_bHasUnversionedItems;\r
840         bool                                            m_bHasLocks;\r
841         bool                                            m_bHasChangeLists;\r
842         //typedef std::vector<FileEntry*> FileEntryVector;\r
843         //FileEntryVector                               m_arStatusArray;\r
844         std::vector<CTGitPath*>         m_arStatusArray;\r
845         std::vector<size_t>                     m_arListArray;\r
846         std::map<CString, int>      m_changelists;\r
847         bool                                            m_bHasIgnoreGroup;\r
848         //CTGitPathList                         m_ConflictFileList;\r
849         CTGitPathList                           m_StatusFileList;\r
850         CTGitPathList                           m_UnRevFileList;\r
851         CTGitPathList                           m_IgnoreFileList;\r
852         //CTGitPathList                         m_StatusUrlList;\r
853         CString                                         m_sLastError;\r
854 \r
855         LONG                                            m_nUnversioned;\r
856         LONG                                            m_nNormal;\r
857         LONG                                            m_nModified;\r
858         LONG                                            m_nAdded;\r
859         LONG                                            m_nDeleted;\r
860         LONG                                            m_nConflicted;\r
861         LONG                                            m_nTotal;\r
862         LONG                                            m_nSelected;\r
863 \r
864         DWORD                                           m_dwDefaultColumns;\r
865         DWORD                                           m_dwShow;\r
866         bool                                            m_bShowFolders;\r
867         bool                                            m_bShowIgnores;\r
868         bool                                            m_bUpdate;\r
869         DWORD                                           m_dwContextMenus;\r
870         BOOL                                            m_bBlock;\r
871         BOOL                                            m_bBlockUI;\r
872         bool                                            m_bBusy;\r
873         bool                                            m_bEmpty;\r
874         bool                                            m_bIgnoreRemoveOnly;\r
875         bool                                            m_bCheckIfGroupsExist;\r
876         bool                                            m_bFileDropsEnabled;\r
877         bool                                            m_bOwnDrag;\r
878 \r
879         int                                                     m_nIconFolder;\r
880 \r
881         CWnd *                                          m_pStatLabel;\r
882         CButton *                                       m_pSelectButton;\r
883         CButton *                                       m_pConfirmButton;\r
884         CColors                                         m_Colors;\r
885 \r
886         CString                                         m_sEmpty;\r
887         CString                                         m_sBusy;\r
888         CString                                         m_sNoPropValueText;\r
889 \r
890         bool                                            m_bUnversionedRecurse;\r
891 \r
892         bool                                            m_bCheckChildrenWithParent;\r
893         CGitStatusListCtrlDropTarget * m_pDropTarget;\r
894 \r
895     ColumnManager               m_ColumnManager;\r
896 \r
897         std::map<CString,bool>          m_mapFilenameToChecked; ///< Remember manually de-/selected items\r
898         CComCriticalSection                     m_critSec;\r
899 \r
900         friend class CGitStatusListCtrlDropTarget;\r
901 public:\r
902         enum\r
903         {\r
904                 FILELIST_MODIFY= 0x1,\r
905                 FILELIST_UNVER = 0x2,\r
906                 FILELIST_IGNORE =0x4\r
907         };\r
908 public:\r
909         int UpdateFileList(git_revnum_t hash,CTGitPathList *List=NULL);\r
910         int UpdateFileList(int mask, bool once=true,CTGitPathList *List=NULL);\r
911         int UpdateUnRevFileList(CTGitPathList *List=NULL);\r
912         int UpdateIgnoreFileList(CTGitPathList *List=NULL);\r
913         \r
914         int UpdateWithGitPathList(CTGitPathList &list);\r
915 \r
916         void AddEntry(CTGitPath* path, WORD langID, int ListIndex);\r
917         void Clear();\r
918         int m_FileLoaded;\r
919         git_revnum_t m_CurrentVersion;\r
920 public:\r
921         CXPTheme        m_Theme;\r
922 };\r
923 \r
924 #if 0\r
925 class CGitStatusListCtrlDropTarget : public CIDropTarget\r
926 {\r
927 public:\r
928         CGitStatusListCtrlDropTarget(CGitStatusListCtrl * pGitStatusListCtrl):CIDropTarget(pGitStatusListCtrl->m_hWnd){m_pGitStatusListCtrl = pGitStatusListCtrl;}\r
929 \r
930         virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD * /*pdwEffect*/, POINTL pt);\r
931         virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect);\r
932 private:\r
933         CGitStatusListCtrl * m_pGitStatusListCtrl;\r
934 };\r
935 #endif