summaryrefslogtreecommitdiff
path: root/ui/gridView.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:05:30 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:05:30 +0200
commitc0fce877c478ddbf71a1b651c789e5ea00a00144 (patch)
treede01b0ae8fd296bd24fbca54a80f2f0ba071d461 /ui/gridView.cpp
parent3.3 (diff)
downloadFreeFileSync-c0fce877c478ddbf71a1b651c789e5ea00a00144.tar.gz
FreeFileSync-c0fce877c478ddbf71a1b651c789e5ea00a00144.tar.bz2
FreeFileSync-c0fce877c478ddbf71a1b651c789e5ea00a00144.zip
3.4
Diffstat (limited to 'ui/gridView.cpp')
-rw-r--r--ui/gridView.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/ui/gridView.cpp b/ui/gridView.cpp
index 9b841e56..585296a9 100644
--- a/ui/gridView.cpp
+++ b/ui/gridView.cpp
@@ -1,3 +1,9 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+//
#include "gridView.h"
#include "sorting.h"
#include "../synchronization.h"
@@ -92,11 +98,11 @@ GridView::StatusCmpResult GridView::updateCmpResult(bool hideFiltered, //maps so
}
else
{
- if (!fsObj->isEmpty<LEFT_SIDE>())
- ++output.foldersOnLeftView;
+ if (!fsObj->isEmpty<LEFT_SIDE>())
+ ++output.foldersOnLeftView;
- if (!fsObj->isEmpty<RIGHT_SIDE>())
- ++output.foldersOnRightView;
+ if (!fsObj->isEmpty<RIGHT_SIDE>())
+ ++output.foldersOnRightView;
}
viewRef.push_back(*j);
@@ -206,11 +212,11 @@ GridView::StatusSyncPreview GridView::updateSyncPreview(bool hideFiltered, //map
}
else
{
- if (!fsObj->isEmpty<LEFT_SIDE>())
- ++output.foldersOnLeftView;
+ if (!fsObj->isEmpty<LEFT_SIDE>())
+ ++output.foldersOnLeftView;
- if (!fsObj->isEmpty<RIGHT_SIDE>())
- ++output.foldersOnRightView;
+ if (!fsObj->isEmpty<RIGHT_SIDE>())
+ ++output.foldersOnRightView;
}
viewRef.push_back(*j);
@@ -416,6 +422,28 @@ private:
};
+template <bool ascending, FreeFileSync::SelectedSide side>
+class GridView::SortByExtension : public std::binary_function<RefIndex, RefIndex, bool>
+{
+public:
+ SortByExtension(const GridView& view) : m_view(view) {}
+
+ bool operator()(const RefIndex a, const RefIndex b) const
+ {
+ const FileSystemObject* fsObjA = m_view.getReferencedRow(a);
+ const FileSystemObject* fsObjB = m_view.getReferencedRow(b);
+ if (fsObjA == NULL) //invalid rows shall appear at the end
+ return false;
+ else if (fsObjB == NULL)
+ return true;
+
+ return sortByExtension<ascending, side>(*fsObjA, *fsObjB);
+ }
+private:
+ const GridView& m_view;
+};
+
+
template <bool ascending>
class GridView::SortByCmpResult : public std::binary_function<RefIndex, RefIndex, bool>
{
@@ -490,6 +518,12 @@ void GridView::sortView(const SortType type, const bool onLeft, const bool ascen
else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByDate<false, LEFT_SIDE >(*this));
else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByDate<false, RIGHT_SIDE>(*this));
break;
+ case SORT_BY_EXTENSION:
+ if ( ascending && onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<true, LEFT_SIDE >(*this));
+ else if ( ascending && !onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<true, RIGHT_SIDE>(*this));
+ else if (!ascending && onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<false, LEFT_SIDE >(*this));
+ else if (!ascending && !onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<false, RIGHT_SIDE>(*this));
+ break;
case SORT_BY_CMP_RESULT:
if ( ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByCmpResult<true >(*this));
else if (!ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByCmpResult<false>(*this));
bgstack15