Skip to content

Commit 4fd7325

Browse files
committed
fix: Change the app order in Privacy and Security
Change the app order in Privacy and Security Log: Change the app order in Privacy and Security pms: BUG-303417
1 parent 5621880 commit 4fd7325

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/plugin-privacy/operation/applicationitem.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,24 @@ void ApplicationItem::onNameChanged(const QString &name)
100100
return;
101101
m_name = name;
102102
// 不区分大小写,中文按拼音排序排后面
103-
m_sortField = DTK_CORE_NAMESPACE::Chinese2Pinyin(m_name.toUpper());
103+
QString upperName = m_name.toUpper();
104+
105+
int category = 2;
106+
for (const QChar &ch : upperName) {
107+
if (ch.isSpace())
108+
continue;
109+
if (ch.isDigit()) {
110+
category = 0;
111+
} else if (ch.isLetter() && ch.unicode() < 128) {
112+
category = 1;
113+
} else {
114+
category = 2;
115+
}
116+
break;
117+
}
118+
119+
QString pinyin = DTK_CORE_NAMESPACE::Chinese2Pinyin(upperName);
120+
m_sortField = QString::number(category) + pinyin;
104121
emitDataChanged();
105122
}
106123

src/plugin-privacy/operation/privacysecuritymodel.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,16 @@ void AppsModel::reset(ApplicationItemListPtr appList)
9090

9191
void AppsModel::appendItem(ApplicationItem *appItem)
9292
{
93-
beginInsertRows(QModelIndex(), rowCount(), rowCount());
94-
m_appItems.append(appItem);
93+
int insertPos = m_appItems.size();
94+
for (int i = 0; i < m_appItems.size(); ++i) {
95+
if (appItem->sortField() < m_appItems.at(i)->sortField()) {
96+
insertPos = i;
97+
break;
98+
}
99+
}
100+
101+
beginInsertRows(QModelIndex(), insertPos, insertPos);
102+
m_appItems.insert(insertPos, appItem);
95103
endInsertRows();
96104
}
97105

0 commit comments

Comments
 (0)