From 1c60e9b4fcaeae505232aa6287d76a2567d6ea1d Mon Sep 17 00:00:00 2001 From: MrMelon Date: Mon, 6 Jun 2022 18:12:50 +0100 Subject: [PATCH 1/3] Add initial sorting function --- launcher/icons/IconList.cpp | 28 ++++++++++++++++++++++++++++ launcher/icons/IconList.h | 1 + 2 files changed, 29 insertions(+) diff --git a/launcher/icons/IconList.cpp b/launcher/icons/IconList.cpp index 0ddfae55..e0debcb0 100644 --- a/launcher/icons/IconList.cpp +++ b/launcher/icons/IconList.cpp @@ -56,6 +56,32 @@ IconList::IconList(const QStringList &builtinPaths, QString path, QObject *paren emit iconUpdated({}); } +void IconList::sortIconList() +{ + qDebug() << "Sorting icon list..."; + + QVector newIcons = QVector(); + QVectorIterator iconIter(icons); + +iconLoop: + while(iconIter.hasNext()) + { + MMCIcon a = iconIter.next(); + for(int i=0;i Date: Mon, 6 Jun 2022 22:18:19 +0100 Subject: [PATCH 2/3] Simplify sorting logic to a single std::sort call --- launcher/icons/IconList.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/launcher/icons/IconList.cpp b/launcher/icons/IconList.cpp index e0debcb0..522b39a7 100644 --- a/launcher/icons/IconList.cpp +++ b/launcher/icons/IconList.cpp @@ -59,26 +59,9 @@ IconList::IconList(const QStringList &builtinPaths, QString path, QObject *paren void IconList::sortIconList() { qDebug() << "Sorting icon list..."; - - QVector newIcons = QVector(); - QVectorIterator iconIter(icons); - -iconLoop: - while(iconIter.hasNext()) - { - MMCIcon a = iconIter.next(); - for(int i=0;i Date: Tue, 7 Jun 2022 15:27:57 +0100 Subject: [PATCH 3/3] QString::locateAwareCompare() is better for human-like sorting --- launcher/icons/IconList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/icons/IconList.cpp b/launcher/icons/IconList.cpp index 522b39a7..d426aa80 100644 --- a/launcher/icons/IconList.cpp +++ b/launcher/icons/IconList.cpp @@ -60,7 +60,7 @@ void IconList::sortIconList() { qDebug() << "Sorting icon list..."; std::sort(icons.begin(), icons.end(), [](const MMCIcon& a, const MMCIcon& b) { - return a.m_key.compare(b.m_key) < 0; + return a.m_key.localeAwareCompare(b.m_key) < 0; }); reindex(); }