Verified Commit 4f035ce6 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/kicker: unify sort method in appsmodel and rootmodel

parent d1fdf677
Pipeline #193545 passed with stage
in 6 minutes and 25 seconds
......@@ -76,7 +76,7 @@ AppsModel::AppsModel(const QList<AbstractEntry *> &entryList, bool deleteEntries
}
}
sortEntries();
sortEntries(m_entryList);
refreshSectionList();
}
......@@ -552,7 +552,7 @@ void AppsModel::refreshInternal()
}
if (m_sorted) {
sortEntries();
sortEntries(m_entryList);
}
m_changeTimer = new QTimer(this);
......@@ -575,7 +575,7 @@ void AppsModel::refreshInternal()
}
if (m_sorted) {
sortEntries();
sortEntries(m_entryList);
}
if (m_paginate) {
......@@ -723,11 +723,11 @@ void AppsModel::processServiceGroup(KServiceGroup::Ptr group)
}
}
void AppsModel::sortEntries()
void AppsModel::sortEntries(QList<AbstractEntry *> &entryList)
{
QCollator c;
std::sort(m_entryList.begin(), m_entryList.end(), [&c](AbstractEntry *a, AbstractEntry *b) {
std::sort(entryList.begin(), entryList.end(), [&c](AbstractEntry *a, AbstractEntry *b) {
if (a->type() != b->type()) {
return a->type() > b->type();
} else {
......
......@@ -113,6 +113,7 @@ protected Q_SLOTS:
protected:
void refreshInternal();
void sortEntries(QList<AbstractEntry *> &entryList);
bool m_complete;
......@@ -129,7 +130,6 @@ protected:
private:
void processServiceGroup(KServiceGroup::Ptr group);
void sortEntries();
void refreshSectionList();
bool m_autoPopulate;
......
......@@ -314,15 +314,7 @@ void RootModel::refresh()
}
QList<AbstractEntry *> apps(appsHash.values());
QCollator c;
std::sort(apps.begin(), apps.end(), [&c](AbstractEntry *a, AbstractEntry *b) {
if (a->type() != b->type()) {
return a->type() > b->type();
} else {
return c.compare(a->name(), b->name()) < 0;
}
});
sortEntries(apps);
if (!m_showAllAppsCategorized && !m_paginate) { // The app list built above goes into a model.
allModel = new AppsModel(apps, false, this);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment