cleanup not found favorites

This commit is contained in:
Marco Martin 2020-07-23 16:44:25 +02:00
parent 13500ee9e2
commit daebf5ae60
2 changed files with 16 additions and 2 deletions

View file

@ -121,6 +121,7 @@ void ApplicationListModel::loadApplications()
QMap<int, ApplicationData> orderedList;
QList<ApplicationData> unorderedList;
QSet<QString> foundFavorites;
// Iterate over all entries in the group
while (!subGroupList.isEmpty()) {
@ -159,6 +160,7 @@ void ApplicationListModel::loadApplications()
if (m_favorites.contains(data.storageId)) {
data.location = Favorites;
foundFavorites.insert(data.storageId);
} else if (m_desktopItems.contains(data.storageId)) {
data.location = Desktop;
}
@ -186,6 +188,18 @@ void ApplicationListModel::loadApplications()
endResetModel();
emit countChanged();
bool favChanged = false;
for (const auto &item : m_favorites) {
if (!foundFavorites.contains(item)) {
favChanged = true;
m_favorites.removeAll(item);
}
}
if (favChanged) {
m_homeScreen->config().writeEntry("Favorites", m_favorites);
emit favoriteCountChanged();
}
}
QVariant ApplicationListModel::data(const QModelIndex &index, int role) const

View file

@ -1,5 +1,5 @@
applet.wallpaperPlugin = 'org.kde.image'
applet.writeConfig("AppOrder", ["org.kde.phone.dialer.desktop", "org.kde.mobile.angelfish.desktop", "org.kde.phone.calindori.desktop", "org.kde.mobile.camera.desktop"])
applet.writeConfig("Favorites", ["org.kde.phone.dialer.desktop", "org.kde.mobile.angelfish.desktop", "org.kde.phone.calindori.desktop", "org.kde.mobile.camera.desktop"])
applet.writeConfig("AppOrder", ["org.kde.phone.dialer.desktop", "org.kde.phonebook.desktop", "org.kde.mobile.angelfish.desktop", "org.kde.mobile.camera.desktop"])
applet.writeConfig("Favorites", ["org.kde.phone.dialer.desktop", "org.kde.phonebook.desktop", "org.kde.mobile.angelfish.desktop", "org.kde.mobile.camera.desktop"])
applet.reloadConfig()