From 6d9742c5f738d87939bfa5cf902df9acc292dcd1 Mon Sep 17 00:00:00 2001 From: youdiansaodongxi Date: Fri, 28 Apr 2023 10:13:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=A8=E9=83=A8=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E7=95=8C=E9=9D=A2=E5=BA=94=E7=94=A8=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdata/plugin/all-app-data-provider.cpp | 17 +++++++++++++++-- src/appdata/plugin/all-app-data-provider.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/appdata/plugin/all-app-data-provider.cpp b/src/appdata/plugin/all-app-data-provider.cpp index 9ba77c9..32e0961 100644 --- a/src/appdata/plugin/all-app-data-provider.cpp +++ b/src/appdata/plugin/all-app-data-provider.cpp @@ -158,8 +158,13 @@ bool AllAppDataProvider::appDataSort(const DataEntity &a, const DataEntity &b) } else if ((a.top() == 0) && (b.top() == 0)) { if (a.isRecentInstall()) { if (b.isRecentInstall()) { - return QDateTime::fromString(a.insertTime(), "yyyy-MM-dd hh:mm:ss") - > QDateTime::fromString(b.insertTime(), "yyyy-MM-dd hh:mm:ss"); + if (QDateTime::fromString(a.insertTime(), "yyyy-MM-dd hh:mm:ss") + != QDateTime::fromString(b.insertTime(), "yyyy-MM-dd hh:mm:ss")) { + return QDateTime::fromString(a.insertTime(), "yyyy-MM-dd hh:mm:ss") + > QDateTime::fromString(b.insertTime(), "yyyy-MM-dd hh:mm:ss"); + } else { + return letterSort(a.firstLetter(), b.firstLetter()); + } } else { return true; } @@ -188,6 +193,14 @@ void AllAppDataProvider::setRecentState(DataEntity &app) app.setRecentInstall(false); } +bool AllAppDataProvider::letterSort(const QString &a, const QString &b) +{ + if (QString::compare(a, b, Qt::CaseInsensitive) == 0) { + return false; + } + return QString::compare(a, b, Qt::CaseInsensitive) > 0 ? false : true; +} + void AllAppDataProvider::sendData() { QVector data; diff --git a/src/appdata/plugin/all-app-data-provider.h b/src/appdata/plugin/all-app-data-provider.h index 8b5f190..90ef01a 100644 --- a/src/appdata/plugin/all-app-data-provider.h +++ b/src/appdata/plugin/all-app-data-provider.h @@ -55,6 +55,7 @@ private: void updateData(const QList& apps); static bool appDataSort(const DataEntity &a, const DataEntity &b); static void setRecentState(DataEntity &app); + static bool letterSort(const QString &a, const QString &b); private: QMutex m_mutex;