Commit 06602886 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


(cherry picked from commit ff446e23)
parent 0b938e5f
Pipeline #169502 passed with stage
in 7 minutes and 39 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;
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;
}
......@@ -312,6 +324,8 @@ public:
}
endRemoveRows();
saveOrdering();
}
int rowCount(const QModelIndex &parent = QModelIndex()) const override
......@@ -593,7 +607,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;
......
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