Commit ff446e23 authored by Méven Car's avatar Méven Car Committed by Nate Graham
Browse files

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
parent 359d397b
Pipeline #169501 passed with stage
in 6 minutes and 31 seconds
......@@ -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;
// 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));
......@@ -306,6 +318,8 @@ public:
std::remove(m_itemEntries.begin(), m_itemEntries.end(), entry);
int rowCount(const QModelIndex &parent = QModelIndex()) const override
......@@ -587,7 +601,7 @@ void KAStatsFavoritesModel::removeFavoriteFrom(const QString &id, const Activity
qCDebug(KICKER_DEBUG) << "addFavoriteTo" << id << activity << url << " (actual)";
qCDebug(KICKER_DEBUG) << "removeFavoriteFrom" << id << activity << url << " (actual)";
if (url.isEmpty())
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