summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-models/filtermodels.cpp11
-rw-r--r--qt-models/filtermodels.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index b71a660ae..f6ff5ea69 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -102,8 +102,13 @@ void FilterModelBase::changeName(const QString &oldName, const QString &newName)
// Update the the items array.
// The last item is supposed to be the "Show Empty Tags" entry.
-void FilterModelBase::updateList(const QStringList &newList)
+// All other items will be sorted alphabetically. Attention: the passed-in list is modified!
+void FilterModelBase::updateList(QStringList &newList)
{
+ // Sort list, but leave out last element by using std::prev()
+ if (!newList.empty())
+ std::sort(newList.begin(), std::prev(newList.end()));
+
beginResetModel();
// Keep copy of the old items array to reimport the checked state later.
@@ -264,7 +269,6 @@ void SuitsFilterModel::repopulate()
list.append(suit);
}
}
- qSort(list);
list << tr("No suit set");
updateList(list);
}
@@ -289,7 +293,6 @@ void TagFilterModel::repopulate()
list.append(QString(current_tag_entry->tag->name));
current_tag_entry = current_tag_entry->next;
}
- qSort(list);
list << tr("Empty tags");
updateList(list);
}
@@ -368,7 +371,6 @@ void BuddyFilterModel::repopulate()
}
}
}
- qSort(list);
list << tr("No buddies");
updateList(list);
}
@@ -415,7 +417,6 @@ void LocationFilterModel::repopulate()
list.append(location);
}
}
- qSort(list);
list << tr("No location set");
updateList(list);
}
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 7e5aae727..5c54a135b 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -36,7 +36,7 @@ slots:
void changeName(const QString &oldName, const QString &newName);
protected:
explicit FilterModelBase(QObject *parent = 0);
- void updateList(const QStringList &new_list);
+ void updateList(QStringList &new_list);
virtual int countDives(const char *) const = 0;
private:
Qt::ItemFlags flags(const QModelIndex &index) const;