From 6dac5a3fc2687dc0118a7fb8c1f5921efd1a189c Mon Sep 17 00:00:00 2001 From: qiqi49 Date: Wed, 30 Oct 2024 16:05:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(appdata):=E8=B0=83=E6=95=B4=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=90=8C=E4=B8=80=E7=BB=84=E7=9A=84=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libappdata/app-category-model.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/libappdata/app-category-model.cpp b/src/libappdata/app-category-model.cpp index 85b936d..ba90504 100644 --- a/src/libappdata/app-category-model.cpp +++ b/src/libappdata/app-category-model.cpp @@ -87,23 +87,20 @@ bool AppCategoryModel::filterAcceptsRow(int source_row, const QModelIndex &sourc bool AppCategoryModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const { int result = 0; - if (m_mode == FirstLatter) { - QString leftKey = AppCategoryModel::getFirstLatterUpper(source_left.data(DataEntity::FirstLetter).toString()); - QString rightKey = AppCategoryModel::getFirstLatterUpper(source_right.data(DataEntity::FirstLetter).toString()); - - result = leftKey.compare(rightKey); - - } else { - // 按分类进行排序 + if (m_mode == Category) { + // 按功能分类进行排序 int leftIndex = getCategoryIndex(source_left.data(DataEntity::Category).toString()); int rightIndex = getCategoryIndex(source_right.data(DataEntity::Category).toString()); result = (leftIndex < rightIndex) ? -1 : (leftIndex > rightIndex) ? 1 : 0; } - if (result == 0) { - // 分类相同时,按打开次数排序; model使用的升序排序,为了保持使用次数多的在前,所以此处使用 > 比较符, - return source_left.data(DataEntity::LaunchTimes).toInt() > source_right.data(DataEntity::LaunchTimes).toInt(); + // 功能分类相同时,也按字母排序 + if ((result == 0) || (m_mode == FirstLatter)) { + QString leftKey = source_left.data(DataEntity::FirstLetter).toString(); + QString rightKey = source_right.data(DataEntity::FirstLetter).toString(); + + result = leftKey.compare(rightKey, Qt::CaseInsensitive); } return result < 0;