Convert old-style Favorites resources in KActivities DB

In the past, application Favorites were stored with their .desktop file path
such as "/usr/share/applications/org.kde.dolphin.desktop". But now those
entries are stored like so: "applications:org.kde.dolphin.desktop".

This commit converts old DB entries to the new style, which solves the issue
of users with old databases being unable to change their Favorite items.

BUG: 385814
FIXED-IN: 5.24.5
wilder-5.25
Méven Car 4 years ago committed by Nate Graham
parent 359d397b75
commit ff446e235e
  1. 18
      applets/kicker/plugin/kastatsfavoritesmodel.cpp

@ -253,7 +253,19 @@ public:
auto entry = entryForResource(resource);
if (!entry || !entry->isValid()) {
qCDebug(KICKER_DEBUG) << "Entry is not valid!";
qCDebug(KICKER_DEBUG) << "Entry is not valid!" << resource;
return;
}
// TODO Remove a few releases after Plasma 5.25 as this should become dead code, once users have run this code at least once
// Converts old-style applications favorites with path (/usrshare/applications/org.kde.dolphin.desktop) or storageId (org.kde.dolphin.desktop)
if ((_resource.startsWith(QLatin1String("/")) || QUrl(_resource).scheme().isEmpty()) && _resource.endsWith(QLatin1String(".desktop"))) {
m_watcher.unlinkFromActivity(QUrl(_resource), QStringLiteral(":any"), agentForUrl(resource));
const auto normalized = normalizedId(resource).value();
qCDebug(KICKER_DEBUG) << "Converting old-style application favorite entry" << _resource << "to" << normalized;
m_watcher.linkToActivity(QUrl(normalized), QStringLiteral(":any"), agentForUrl(resource));
return;
}
@ -306,6 +318,8 @@ public:
std::remove(m_itemEntries.begin(), m_itemEntries.end(), entry);
endRemoveRows();
saveOrdering();
}
int rowCount(const QModelIndex &parent = QModelIndex()) const override
@ -587,7 +601,7 @@ void KAStatsFavoritesModel::removeFavoriteFrom(const QString &id, const Activity
Q_ASSERT(!activity.values.isEmpty());
qCDebug(KICKER_DEBUG) << "addFavoriteTo" << id << activity << url << " (actual)";
qCDebug(KICKER_DEBUG) << "removeFavoriteFrom" << id << activity << url << " (actual)";
if (url.isEmpty())
return;

Loading…
Cancel
Save