Fixed some unused variables warnings
[TortoiseGit.git] / src / TortoiseProc / GitStatusListCtrlHelpers.cpp
blob5db046405ba625289ceaca851ea008020ed1c2bf
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include ".\resource.h"
22 #include "GitStatusListCtrl.h"
23 #include <iterator>
25 // registry version number of column-settings of GitLogListBase
26 #define BLAME_COLUMN_VERSION 4
28 #ifndef assert
29 #define assert(x) ATLASSERT(x)
30 #endif
31 // assign property list
32 #if 0
33 PropertyList&
34 PropertyList::operator= (const char* rhs)
36 // do you really want to replace the property list?
38 assert (properties.empty());
39 properties.clear();
41 // add all properties in the list
43 while ((rhs != NULL) && (*rhs != 0))
45 const char* next = strchr (rhs, ' ');
47 CString name (rhs, static_cast<int>(next == NULL ? strlen (rhs) : next - rhs));
48 properties.insert (std::make_pair (name, CString()));
50 rhs = next == NULL ? NULL : next+1;
53 // done
55 return *this;
58 // collect property names in a set
60 void PropertyList::GetPropertyNames (std::set<CString>& names)
62 for ( CIT iter = properties.begin(), end = properties.end()
63 ; iter != end
64 ; ++iter)
66 names.insert (iter->first);
70 // get a property value.
72 CString PropertyList::operator[](const CString& name) const
74 CIT iter = properties.find (name);
76 return iter == properties.end()
77 ? CString()
78 : iter->second;
81 // set a property value.
83 CString& PropertyList::operator[](const CString& name)
85 return properties[name];
88 /// check whether that property has been set on this item.
90 bool PropertyList::HasProperty (const CString& name) const
92 return properties.find (name) != properties.end();
95 // due to frequent use: special check for svn:needs-lock
97 bool PropertyList::IsNeedsLockSet() const
99 static const CString svnNeedsLock = _T("svn:needs-lock");
100 return HasProperty (svnNeedsLock);
103 #endif
104 // registry access
106 void ColumnManager::ReadSettings
107 ( DWORD defaultColumns
108 , DWORD hideColumns
109 , const CString& containerName
110 , int maxsize
111 , int * widthlist)
113 // defaults
114 DWORD selectedStandardColumns = defaultColumns & ~hideColumns;
115 m_dwDefaultColumns = defaultColumns & ~hideColumns;
117 columns.resize (maxsize);
118 int power = 1;
119 for (size_t i = 0; i < maxsize; ++i)
121 columns[i].index = static_cast<int>(i);
122 if(widthlist==NULL)
123 columns[i].width = 0;
124 else
125 columns[i].width = widthlist[i];
126 columns[i].visible = true;
127 columns[i].relevant = !(hideColumns & power);
128 power *= 2;
131 // userProps.clear();
133 // where the settings are stored within the registry
135 registryPrefix = _T("Software\\TortoiseGit\\StatusColumns\\") + containerName;
137 // we accept settings of current version only
138 bool valid = (DWORD)CRegDWORD (registryPrefix + _T("Version"), 0xff) == BLAME_COLUMN_VERSION;
139 if (valid)
141 // read (possibly different) column selection
143 selectedStandardColumns = CRegDWORD (registryPrefix, selectedStandardColumns) & ~hideColumns;
145 // read user-prop lists
147 CString userPropList = CRegString (registryPrefix + _T("UserProps"));
148 CString shownUserProps = CRegString (registryPrefix + _T("ShownUserProps"));
150 ParseUserPropSettings (userPropList, shownUserProps);
152 // read column widths
154 CString colWidths = CRegString (registryPrefix + _T("_Width"));
156 ParseWidths (colWidths);
159 // process old-style visibility setting
161 SetStandardColumnVisibility (selectedStandardColumns);
163 // clear all previously set header columns
165 int c = ((CHeaderCtrl*)(control->GetDlgItem(0)))->GetItemCount()-1;
166 while (c>=0)
167 control->DeleteColumn(c--);
169 // create columns
171 for (int i = 0, count = GetColumnCount(); i < count; ++i)
172 control->InsertColumn (i, GetName(i), LVCFMT_LEFT, IsVisible(i)&&IsRelevant(i) ? -1 : GetVisibleWidth(i, false));
174 // restore column ordering
176 if (valid)
177 ParseColumnOrder (CRegString (registryPrefix + _T("_Order")));
178 else
179 ParseColumnOrder (CString());
181 ApplyColumnOrder();
183 // auto-size the columns so we can see them while fetching status
184 // (seems the same values will not take affect in InsertColumn)
186 for (int i = 0, count = GetColumnCount(); i < count; ++i)
187 if (IsVisible(i))
188 control->SetColumnWidth (i, GetVisibleWidth (i, true));
191 void ColumnManager::WriteSettings() const
193 CRegDWORD regVersion (registryPrefix + _T("Version"), 0, TRUE);
194 regVersion = BLAME_COLUMN_VERSION;
196 // write (possibly different) column selection
198 CRegDWORD regStandardColumns (registryPrefix, 0, TRUE);
199 regStandardColumns = GetSelectedStandardColumns();
201 // write user-prop lists
203 CRegString regUserProps (registryPrefix + _T("UserProps"), CString(), TRUE);
204 regUserProps = GetUserPropList();
206 CRegString regShownUserProps (registryPrefix + _T("ShownUserProps"), CString(), TRUE);
207 regShownUserProps = GetShownUserProps();
209 // write column widths
211 CRegString regWidths (registryPrefix + _T("_Width"), CString(), TRUE);
212 regWidths = GetWidthString();
214 // write column ordering
216 CRegString regColumnOrder (registryPrefix + _T("_Order"), CString(), TRUE);
217 regColumnOrder = GetColumnOrderString();
220 // read column definitions
222 int ColumnManager::GetColumnCount() const
224 return static_cast<int>(columns.size());
227 bool ColumnManager::IsVisible (int column) const
229 size_t index = static_cast<size_t>(column);
230 assert (columns.size() > index);
232 return columns[index].visible;
235 int ColumnManager::GetInvisibleCount() const
237 int invisibleCount = 0;
238 for (std::vector<ColumnInfo>::const_iterator it = columns.begin(); it != columns.end(); ++it)
240 if (!it->visible)
241 invisibleCount++;
243 return invisibleCount;
246 bool ColumnManager::IsRelevant (int column) const
248 size_t index = static_cast<size_t>(column);
249 assert (columns.size() > index);
251 return columns[index].relevant;
254 bool ColumnManager::IsUserProp (int column) const
256 size_t index = static_cast<size_t>(column);
257 assert (columns.size() > index);
259 return columns[index].index >= SVNSLC_USERPROPCOLOFFSET;
262 int ColumnManager::SetNames(UINT* buffer, int size)
264 itemName.clear();
265 for(int i=0;i<size;i++)
266 itemName.push_back(*buffer++);
267 return 0;
270 CString ColumnManager::GetName (int column) const
272 // standard columns
273 size_t index = static_cast<size_t>(column);
274 if (index < itemName.size())
276 CString result;
277 result.LoadString (itemName[index]);
278 return result;
281 // user-prop columns
283 // if (index < columns.size())
284 // return userProps[columns[index].index - SVNSLC_USERPROPCOLOFFSET].name;
286 // default: empty
288 return CString();
291 int ColumnManager::GetWidth (int column, bool useDefaults) const
293 size_t index = static_cast<size_t>(column);
294 assert (columns.size() > index);
296 int width = columns[index].width;
297 if ((width == 0) && useDefaults)
298 width = LVSCW_AUTOSIZE_USEHEADER;
300 return width;
303 int ColumnManager::GetVisibleWidth (int column, bool useDefaults) const
305 return IsVisible (column)
306 ? GetWidth (column, useDefaults)
307 : 0;
310 // switch columns on and off
312 void ColumnManager::SetVisible
313 ( int column
314 , bool visible)
316 size_t index = static_cast<size_t>(column);
317 assert (index < columns.size());
319 if (columns[index].visible != visible)
321 columns[index].visible = visible;
322 columns[index].relevant |= visible;
323 if (!visible)
324 columns[index].width = 0;
326 control->SetColumnWidth (column, GetVisibleWidth (column, true));
327 ApplyColumnOrder();
329 control->Invalidate (FALSE);
333 // tracking column modifications
335 void ColumnManager::ColumnMoved (int column, int position)
337 // in front of what column has it been inserted?
339 int index = columns[column].index;
341 std::vector<int> gridColumnOrder = GetGridColumnOrder();
343 size_t visiblePosition = static_cast<size_t>(position);
344 size_t columnCount = gridColumnOrder.size();
346 for (; (visiblePosition < columnCount)
347 && !columns[gridColumnOrder[visiblePosition]].visible
348 ; ++visiblePosition )
352 int next = -1;
353 if (visiblePosition != columnCount)
355 next = gridColumnOrder[visiblePosition];
358 // move logical column index just in front of that "next" column
360 columnOrder.erase (std::find ( columnOrder.begin(), columnOrder.end(), index));
361 columnOrder.insert ( std::find ( columnOrder.begin(), columnOrder.end(), next), index);
363 // make sure, invisible columns are still put in front of all others
365 ApplyColumnOrder();
368 void ColumnManager::ColumnResized (int column)
370 size_t index = static_cast<size_t>(column);
371 assert (index < columns.size());
372 assert (columns[index].visible);
374 int width = control->GetColumnWidth (column);
375 columns[index].width = width;
377 int propertyIndex = columns[index].index;
378 if (propertyIndex >= SVNSLC_USERPROPCOLOFFSET)
379 userProps[propertyIndex - SVNSLC_USERPROPCOLOFFSET].width = width;
381 control->Invalidate (FALSE);
384 // call these to update the user-prop list
385 // (will also auto-insert /-remove new list columns)
386 #if 0
387 void ColumnManager::UpdateUserPropList
388 (const std::vector<FileEntry*>& files)
390 // collect all user-defined props
392 std::set<CString> aggregatedProps;
393 for (size_t i = 0, count = files.size(); i < count; ++i)
394 files[i]->present_props.GetPropertyNames (aggregatedProps);
396 aggregatedProps.erase (_T("svn:needs-lock"));
397 itemProps = aggregatedProps;
399 // add new ones to the internal list
401 std::set<CString> newProps = aggregatedProps;
402 for (size_t i = 0, count = userProps.size(); i < count; ++i)
403 newProps.erase (userProps[i].name);
405 while (newProps.size() + userProps.size()
406 > SVNSLC_MAXCOLUMNCOUNT - SVNSLC_USERPROPCOLOFFSET)
407 newProps.erase (--newProps.end());
409 typedef std::set<CString>::const_iterator CIT;
410 for ( CIT iter = newProps.begin(), end = newProps.end()
411 ; iter != end
412 ; ++iter)
414 int index = static_cast<int>(userProps.size())
415 + SVNSLC_USERPROPCOLOFFSET;
416 columnOrder.push_back (index);
418 UserProp userProp;
419 userProp.name = *iter;
420 userProp.width = 0;
422 userProps.push_back (userProp);
425 // remove unused columns from control.
426 // remove used ones from the set of aggregatedProps.
428 for (size_t i = columns.size(); i > 0; --i)
429 if ((columns[i-1].index >= SVNSLC_USERPROPCOLOFFSET)
430 && (aggregatedProps.erase (GetName ((int)i-1)) == 0))
432 // this user-prop has not been set on any item
434 if (!columns[i-1].visible)
436 control->DeleteColumn (static_cast<int>(i-1));
437 columns.erase (columns.begin() + i-1);
441 // aggregatedProps now contains new columns only.
442 // we can't use newProps here because some props may have been used
443 // earlier but were not in the recent list of used props.
444 // -> they are neither in columns[] nor in newProps.
446 for ( CIT iter = aggregatedProps.begin(), end = aggregatedProps.end()
447 ; iter != end
448 ; ++iter)
450 // get the logical column index / ID
452 int index = -1;
453 int width = 0;
454 for (size_t i = 0, count = userProps.size(); i < count; ++i)
455 if (userProps[i].name == *iter)
457 index = static_cast<int>(i) + SVNSLC_USERPROPCOLOFFSET;
458 width = userProps[i].width;
459 break;
462 assert (index != -1);
464 // find insertion position
466 std::vector<ColumnInfo>::iterator columnIter = columns.begin();
467 std::vector<ColumnInfo>::iterator end = columns.end();
468 for (; (columnIter != end) && columnIter->index < index; ++columnIter);
469 int pos = static_cast<int>(columnIter - columns.begin());
471 ColumnInfo column;
472 column.index = index;
473 column.width = width;
474 column.visible = false;
476 columns.insert (columnIter, column);
478 // update control
480 int result = control->InsertColumn (pos, *iter, LVCFMT_LEFT, GetVisibleWidth(pos, false));
481 assert (result != -1);
482 UNREFERENCED_PARAMETER(result);
485 // update column order
487 ApplyColumnOrder();
489 #endif
490 #if 0
491 void ColumnManager::UpdateRelevance
492 ( const std::vector<FileEntry*>& files
493 , const std::vector<size_t>& visibleFiles)
495 // collect all user-defined props that belong to shown files
497 std::set<CString> aggregatedProps;
498 for (size_t i = 0, count = visibleFiles.size(); i < count; ++i)
499 files[visibleFiles[i]]->present_props.GetPropertyNames (aggregatedProps);
501 aggregatedProps.erase (_T("svn:needs-lock"));
502 itemProps = aggregatedProps;
504 // invisible columns for unused props are not relevant
506 for (int i = 0, count = GetColumnCount(); i < count; ++i)
507 if (IsUserProp(i) && !IsVisible(i))
509 columns[i].relevant
510 = aggregatedProps.find (GetName(i)) != aggregatedProps.end();
514 #endif
515 // don't clutter the context menu with irrelevant prop info
517 bool ColumnManager::AnyUnusedProperties() const
519 return columns.size() < userProps.size() + itemName.size();
522 void ColumnManager::RemoveUnusedProps()
524 // determine what column indexes / IDs to keep.
525 // map them onto new IDs (we may delete some IDs in between)
527 std::map<int, int> validIndices;
528 int userPropID = SVNSLC_USERPROPCOLOFFSET;
530 for (size_t i = 0, count = columns.size(); i < count; ++i)
532 int index = columns[i].index;
534 if (itemProps.find (GetName((int)i)) != itemProps.end()
535 || columns[i].visible
536 || index < SVNSLC_USERPROPCOLOFFSET)
538 validIndices[index] = index < SVNSLC_USERPROPCOLOFFSET
539 ? index
540 : userPropID++;
544 // remove everything else:
546 // remove from columns and control.
547 // also update index values in columns
549 for (size_t i = columns.size(); i > 0; --i)
551 std::map<int, int>::const_iterator iter
552 = validIndices.find (columns[i-1].index);
554 if (iter == validIndices.end())
556 control->DeleteColumn (static_cast<int>(i-1));
557 columns.erase (columns.begin() + i-1);
559 else
561 columns[i-1].index = iter->second;
565 // remove from user props
567 for (size_t i = userProps.size(); i > 0; --i)
569 int index = static_cast<int>(i)-1 + SVNSLC_USERPROPCOLOFFSET;
570 if (validIndices.find (index) == validIndices.end())
571 userProps.erase (userProps.begin() + i-1);
574 // remove from and update column order
576 for (size_t i = columnOrder.size(); i > 0; --i)
578 std::map<int, int>::const_iterator iter
579 = validIndices.find (columnOrder[i-1]);
581 if (iter == validIndices.end())
582 columnOrder.erase (columnOrder.begin() + i-1);
583 else
584 columnOrder[i-1] = iter->second;
588 // bring everything back to its "natural" order
590 void ColumnManager::ResetColumns (DWORD defaultColumns)
592 // update internal data
594 std::sort (columnOrder.begin(), columnOrder.end());
596 for (size_t i = 0, count = columns.size(); i < count; ++i)
598 columns[i].width = 0;
599 columns[i].visible = (i < 32) && (((defaultColumns >> i) & 1) != 0);
602 for (size_t i = 0, count = userProps.size(); i < count; ++i)
603 userProps[i].width = 0;
605 // update UI
607 for (int i = 0, count = GetColumnCount(); i < count; ++i)
608 control->SetColumnWidth (i, GetVisibleWidth (i, true));
610 ApplyColumnOrder();
612 control->Invalidate (FALSE);
615 // initialization utilities
617 void ColumnManager::ParseUserPropSettings(const CString& userPropList, const CString& shownUserProps)
619 assert (userProps.empty());
621 static CString delimiters (_T(" "));
623 // parse list of visible user-props
625 std::set<CString> visibles;
627 int pos = 0;
628 CString name = shownUserProps.Tokenize (delimiters, pos);
629 while (!name.IsEmpty())
631 visibles.insert (name);
632 name = shownUserProps.Tokenize (delimiters, pos);
635 // create list of all user-props
637 pos = 0;
638 name = userPropList.Tokenize (delimiters, pos);
639 while (!name.IsEmpty())
641 bool visible = visibles.find (name) != visibles.end();
643 UserProp newEntry;
644 newEntry.name = name;
645 newEntry.width = 0;
647 userProps.push_back (newEntry);
649 // auto-create columns for visible user-props
650 // (others may be added later)
652 if (visible)
654 ColumnInfo newColumn;
655 newColumn.width = 0;
656 newColumn.visible = true;
657 newColumn.relevant = true;
658 newColumn.index = static_cast<int>(userProps.size())
659 + SVNSLC_USERPROPCOLOFFSET - 1;
661 columns.push_back (newColumn);
664 name = userPropList.Tokenize (delimiters, pos);
668 void ColumnManager::ParseWidths (const CString& widths)
670 for (int i = 0, count = widths.GetLength() / 8; i < count; ++i)
672 long width = _tcstol (widths.Mid (i*8, 8), NULL, 16);
673 if (i < itemName.size())
675 // a standard column
677 columns[i].width = width;
679 else if (i >= SVNSLC_USERPROPCOLOFFSET)
681 // a user-prop column
683 size_t index = static_cast<size_t>(i - SVNSLC_USERPROPCOLOFFSET);
684 assert (index < userProps.size());
685 userProps[index].width = width;
687 for (size_t k = 0, count = columns.size(); k < count; ++k)
688 if (columns[k].index == i)
689 columns[k].width = width;
691 else
693 // there is no such column
695 assert (width == 0);
700 void ColumnManager::SetStandardColumnVisibility
701 (DWORD visibility)
703 for (size_t i = 0; i < itemName.size(); ++i)
705 columns[i].visible = (visibility & 1) > 0;
706 visibility /= 2;
710 void ColumnManager::ParseColumnOrder
711 (const CString& widths)
713 std::set<int> alreadyPlaced;
714 columnOrder.clear();
716 // place columns according to valid entries in orderString
718 int limit = static_cast<int>(SVNSLC_USERPROPCOLOFFSET + userProps.size());
719 for (int i = 0, count = widths.GetLength() / 2; i < count; ++i)
721 int index = _tcstol (widths.Mid (i*2, 2), NULL, 16);
722 if ((index < itemName.size())
723 || ((index >= SVNSLC_USERPROPCOLOFFSET) && (index < limit)))
725 alreadyPlaced.insert (index);
726 columnOrder.push_back (index);
730 // place the remaining colums behind it
732 for (int i = 0; i < itemName.size(); ++i)
733 if (alreadyPlaced.find (i) == alreadyPlaced.end())
734 columnOrder.push_back (i);
736 for (int i = SVNSLC_USERPROPCOLOFFSET; i < limit; ++i)
737 if (alreadyPlaced.find (i) == alreadyPlaced.end())
738 columnOrder.push_back (i);
741 // map internal column order onto visible column order
742 // (all invisibles in front)
744 std::vector<int> ColumnManager::GetGridColumnOrder()
746 // extract order of used columns from order of all columns
748 std::vector<int> result;
749 result.reserve (SVNSLC_MAXCOLUMNCOUNT+1);
751 size_t colCount = columns.size();
752 bool visible = false;
756 // put invisible cols in front
758 for (size_t i = 0, count = columnOrder.size(); i < count; ++i)
760 int index = columnOrder[i];
761 for (size_t k = 0; k < colCount; ++k)
763 const ColumnInfo& column = columns[k];
764 if ((column.index == index) && (column.visible == visible))
765 result.push_back (static_cast<int>(k));
769 visible = !visible;
771 while (visible);
773 return result;
776 void ColumnManager::ApplyColumnOrder()
778 // extract order of used columns from order of all columns
780 int order[SVNSLC_MAXCOLUMNCOUNT+1];
781 SecureZeroMemory (order, sizeof (order));
783 std::vector<int> gridColumnOrder = GetGridColumnOrder();
784 std::copy (gridColumnOrder.begin(), gridColumnOrder.end(), stdext::checked_array_iterator<int*>(&order[0], sizeof(order)));
786 // we must have placed all columns or something is really fishy ..
788 assert (gridColumnOrder.size() == columns.size());
789 assert (GetColumnCount() == ((CHeaderCtrl*)(control->GetDlgItem(0)))->GetItemCount());
791 // o.k., apply our column ordering
793 control->SetColumnOrderArray (GetColumnCount(), order);
796 // utilities used when writing data to the registry
798 DWORD ColumnManager::GetSelectedStandardColumns() const
800 DWORD result = 0;
801 for (size_t i = itemName.size(); i > 0; --i)
802 result = result * 2 + (columns[i-1].visible ? 1 : 0);
804 return result;
807 CString ColumnManager::GetUserPropList() const
809 CString result;
811 for (size_t i = 0, count = userProps.size(); i < count; ++i)
812 result += userProps[i].name + _T(' ');
814 return result;
817 CString ColumnManager::GetShownUserProps() const
819 CString result;
821 for (size_t i = 0, count = columns.size(); i < count; ++i)
823 size_t index = static_cast<size_t>(columns[i].index);
824 if (columns[i].visible && (index >= SVNSLC_USERPROPCOLOFFSET))
825 result += userProps[index - SVNSLC_USERPROPCOLOFFSET].name
826 + _T(' ');
829 return result;
832 CString ColumnManager::GetWidthString() const
834 CString result;
836 // regular columns
838 TCHAR buf[10];
839 for (size_t i = 0; i < itemName.size(); ++i)
841 _stprintf_s (buf, 10, _T("%08X"), columns[i].width);
842 result += buf;
845 // range with no column IDs
847 result += CString ('0', 8 * (SVNSLC_USERPROPCOLOFFSET - itemName.size()));
849 // user-prop columns
851 for (size_t i = 0, count = userProps.size(); i < count; ++i)
853 _stprintf_s (buf, 10, _T("%08X"), userProps[i].width);
854 result += buf;
857 return result;
860 CString ColumnManager::GetColumnOrderString() const
862 CString result;
864 TCHAR buf[3];
865 for (size_t i = 0, count = columnOrder.size(); i < count; ++i)
867 _stprintf_s (buf, 3, _T("%02X"), columnOrder[i]);
868 result += buf;
871 return result;
874 // sorter utility class
876 CSorter::CSorter ( ColumnManager* columnManager
877 , int sortedColumn
878 , bool ascending)
879 : columnManager (columnManager)
880 , sortedColumn (sortedColumn)
881 , ascending (ascending)
885 bool CSorter::operator() (const CTGitPath* entry1 , const CTGitPath* entry2) const
887 #define SGN(x) ((x)==0?0:((x)>0?1:-1))
889 int result = 0;
890 switch (sortedColumn)
892 case 18:
894 if (result == 0)
896 __int64 writetime1 = entry1->GetLastWriteTime();
897 __int64 writetime2 = entry2->GetLastWriteTime();
899 FILETIME* filetime1 = (FILETIME*)(__int64*)&writetime1;
900 FILETIME* filetime2 = (FILETIME*)(__int64*)&writetime2;
902 result = CompareFileTime(filetime1,filetime2);
905 case 17:
907 if (result == 0)
909 // result = entry1->copyfrom_url.CompareNoCase(entry2->copyfrom_url);
912 case 16:
914 if (result == 0)
916 // result = SGN(entry1->needslock - entry2->needslock);
919 case 15:
921 if (result == 0)
923 // result = SGN(entry1->last_commit_date - entry2->last_commit_date);
926 case 14:
928 if (result == 0)
930 // result = entry1->remoterev - entry2->remoterev;
933 case 13:
935 if (result == 0)
937 // result = entry1->last_commit_rev - entry2->last_commit_rev;
940 case 12:
942 if (result == 0)
944 // result = entry1->last_commit_author.CompareNoCase(entry2->last_commit_author);
947 case 11: //Del Number
949 if (result == 0)
951 // result = entry1->lock_comment.CompareNoCase(entry2->lock_comment);
952 result = A2L(entry1->m_StatDel)-A2L(entry2->m_StatDel);
955 case 10: //Add Number
957 if (result == 0)
959 //result = entry1->lock_owner.CompareNoCase(entry2->lock_owner);
960 result = A2L(entry1->m_StatAdd)-A2L(entry2->m_StatAdd);
963 case 9: //Modification Data
965 if (result == 0)
967 // result = entry1->url.CompareNoCase(entry2->url);
970 case 8: //Data
972 if (result == 0)
974 // result = entry1->remotepropstatus - entry2->remotepropstatus;
977 case 7: // Version
979 if (result == 0)
981 // result = entry1->remotetextstatus - entry2->remotetextstatus;
984 case 6: // Author
986 if (result == 0)
988 // result = entry1->propstatus - entry2->propstatus;
991 case 5: //Prop Status
993 if (result == 0)
995 // result = entry1->textstatus - entry2->textstatus;
998 case 4: //Text Status
1000 if (result == 0)
1002 // result = entry1->remotestatus - entry2->remotestatus;
1005 case 3: // Status
1007 if (result == 0)
1009 result = entry1->GetActionName(entry1->m_Action).CompareNoCase(entry2->GetActionName(entry2->m_Action));
1012 case 2: //Ext file
1014 if (result == 0)
1016 result = entry1->GetFileExtension().CompareNoCase(entry2->GetFileExtension());
1019 case 1: // File name
1021 if (result == 0)
1023 result = entry1->GetFileOrDirectoryName().CompareNoCase(entry2->GetFileOrDirectoryName());
1026 case 0: // Full path column
1028 if (result == 0)
1030 result = CTGitPath::Compare(entry1->GetGitPathString(), entry2->GetGitPathString());
1033 default:
1034 if ((result == 0) && (sortedColumn > 0))
1036 // N/A props are "less than" empty props
1038 // const CString& propName = columnManager->GetName (sortedColumn);
1040 // bool entry1HasProp = entry1->present_props.HasProperty (propName);
1041 // bool entry2HasProp = entry2->present_props.HasProperty (propName);
1043 // if (entry1HasProp)
1044 // {
1045 // result = entry2HasProp
1046 // ? entry1->present_props[propName].Compare
1047 // (entry2->present_props[propName])
1048 // : 1;
1049 // }
1050 // else
1051 // {
1052 // result = entry2HasProp ? -1 : 0;
1053 // }
1055 } // switch (m_nSortedColumn)
1056 if (!ascending)
1057 result = -result;
1059 return result < 0;