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;