summaryrefslogtreecommitdiffstats
path: root/logic/ModList.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-02-06 09:32:44 +0100
committerPetr Mrázek <peterix@gmail.com>2014-02-06 09:32:44 +0100
commitf8df07c3272c0e02f31f46fda8a429292c7a446a (patch)
tree31af739dd416f521787ed970af05fb1de8b01222 /logic/ModList.cpp
parentb4b6091372310f4a811180cffde3ea5611881e6c (diff)
downloadMultiMC-f8df07c3272c0e02f31f46fda8a429292c7a446a.tar
MultiMC-f8df07c3272c0e02f31f46fda8a429292c7a446a.tar.gz
MultiMC-f8df07c3272c0e02f31f46fda8a429292c7a446a.tar.lz
MultiMC-f8df07c3272c0e02f31f46fda8a429292c7a446a.tar.xz
MultiMC-f8df07c3272c0e02f31f46fda8a429292c7a446a.zip
Small tweaks to make things better.
Diffstat (limited to 'logic/ModList.cpp')
-rw-r--r--logic/ModList.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/logic/ModList.cpp b/logic/ModList.cpp
index 499623bf..79b56986 100644
--- a/logic/ModList.cpp
+++ b/logic/ModList.cpp
@@ -62,6 +62,19 @@ void ModList::stopWatching()
}
}
+void ModList::internalSort(QList<Mod> &what)
+{
+ auto predicate = [](const Mod & left, const Mod & right)
+ {
+ if (left.name() == right.name())
+ {
+ return left.mmc_id().localeAwareCompare(right.mmc_id()) <= 0;
+ }
+ return left.name().localeAwareCompare(right.name()) <= 0;
+ };
+ std::sort(what.begin(), what.end(), predicate);
+}
+
bool ModList::update()
{
if (!isValid())
@@ -98,7 +111,7 @@ bool ModList::update()
isEnabled = idxEnabled >= 0;
}
int idx = isEnabled ? idxEnabled : idxDisabled;
- QFileInfo & info = isEnabled ? infoEnabled : infoDisabled;
+ QFileInfo &info = isEnabled ? infoEnabled : infoDisabled;
// if the file from the index file exists
if (idx != -1)
{
@@ -122,8 +135,7 @@ bool ModList::update()
{
newMods.append(Mod(entry));
}
- std::sort(newMods.begin(), newMods.end(), [](const Mod & left, const Mod & right)
- { return left.name().localeAwareCompare(right.name()) <= 0; });
+ internalSort(newMods);
orderedMods.append(newMods);
orderOrStateChanged = true;
}
@@ -236,8 +248,8 @@ bool ModList::installMod(const QFileInfo &filename, int index)
int idx = mods.indexOf(m);
if (idx != -1)
{
- int idx2 = mods.indexOf(m,idx+1);
- if(idx2 != -1)
+ int idx2 = mods.indexOf(m, idx + 1);
+ if (idx2 != -1)
return false;
if (mods[idx].replace(m))
{
@@ -416,7 +428,7 @@ QVariant ModList::data(const QModelIndex &index, int role) const
switch (index.column())
{
case ActiveColumn:
- return mods[row].enabled() ? Qt::Checked: Qt::Unchecked;
+ return mods[row].enabled() ? Qt::Checked : Qt::Unchecked;
default:
return QVariant();
}
@@ -567,8 +579,7 @@ bool ModList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row
if (m_list_file.isEmpty())
{
beginResetModel();
- std::sort(mods.begin(), mods.end(), [](const Mod & left, const Mod & right)
- { return left.name().localeAwareCompare(right.name()) <= 0; });
+ internalSort(mods);
endResetModel();
}
}