From daebf5ae603d5080ad38f7a9e1315b63cdaa4592 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 23 Jul 2020 16:44:25 +0200 Subject: [PATCH] cleanup not found favorites --- containments/homescreen/applicationlistmodel.cpp | 14 ++++++++++++++ .../org.kde.phone.homescreen.js | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/containments/homescreen/applicationlistmodel.cpp b/containments/homescreen/applicationlistmodel.cpp index 433e2d3b..ecb46acb 100644 --- a/containments/homescreen/applicationlistmodel.cpp +++ b/containments/homescreen/applicationlistmodel.cpp @@ -121,6 +121,7 @@ void ApplicationListModel::loadApplications() QMap orderedList; QList unorderedList; + QSet 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 diff --git a/look-and-feel/contents/plasmoidsetupscripts/org.kde.phone.homescreen.js b/look-and-feel/contents/plasmoidsetupscripts/org.kde.phone.homescreen.js index 5955db9d..aa5eb6f5 100644 --- a/look-and-feel/contents/plasmoidsetupscripts/org.kde.phone.homescreen.js +++ b/look-and-feel/contents/plasmoidsetupscripts/org.kde.phone.homescreen.js @@ -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()