fix(appdata):调整应用列表排序相同时,同一组的排序方式
This commit is contained in:
parent
df9a2c1820
commit
6dac5a3fc2
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue