From aa70ed2244700dbcc93c1fadb22edc1c1caede37 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 1 Feb 2015 11:44:47 +0100 Subject: SCRATCH move icons over to Env, instance proxy model to gui --- gui/InstanceProxyModel.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 gui/InstanceProxyModel.cpp (limited to 'gui/InstanceProxyModel.cpp') diff --git a/gui/InstanceProxyModel.cpp b/gui/InstanceProxyModel.cpp new file mode 100644 index 00000000..09d6fd85 --- /dev/null +++ b/gui/InstanceProxyModel.cpp @@ -0,0 +1,23 @@ +#include "InstanceProxyModel.h" +#include "MultiMC.h" +#include + +InstanceProxyModel::InstanceProxyModel(QObject *parent) : GroupedProxyModel(parent) +{ +} + +bool InstanceProxyModel::subSortLessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + BaseInstance *pdataLeft = static_cast(left.internalPointer()); + BaseInstance *pdataRight = static_cast(right.internalPointer()); + QString sortMode = MMC->settings()->get("InstSortMode").toString(); + if (sortMode == "LastLaunch") + { + return pdataLeft->lastLaunch() > pdataRight->lastLaunch(); + } + else + { + return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0; + } +} -- cgit