Commit d7a2055f authored by Méven Car's avatar Méven Car Committed by Méven Car
Browse files

recentlyused: Add SlaveBase::special impl to handle forgetting resources

Allows recentlyused:/ users (aka dolphin) to forget resources, while staying loosely tied to KActivitiesStats.

Bump KF5_MIN_VERSION to 5.94
parent aa2b37c0
Pipeline #176571 failed with stage
in 1 minute and 36 seconds
......@@ -8,7 +8,7 @@ set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE
project(kio-extras VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.90.0")
set(KF5_MIN_VERSION "5.94.0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......@@ -72,7 +72,7 @@ set_package_properties(Qt${QT_MAJOR_VERSION}Sql PROPERTIES
TYPE OPTIONAL
)
find_package(KF5ActivitiesStats 5.62 QUIET)
find_package(KF5ActivitiesStats ${KF5_MIN_VERSION} QUIET)
set_package_properties(KF5ActivitiesStats PROPERTIES
PURPOSE "Provides the recentlyused:/ kioslave."
TYPE OPTIONAL
......
......@@ -10,6 +10,7 @@
#include <QCoreApplication>
#include <QUrl>
#include <QUrlQuery>
#include <QDataStream>
#include <KIO/Job>
#include <KLocalizedString>
......@@ -271,5 +272,41 @@ void RecentlyUsed::mimetype(const QUrl &url)
}
}
void RecentlyUsed::special(const QByteArray &data) {
int id;
QDataStream stream(data);
stream >> id;
switch (id) {
case 1: { // Forget
QList<QUrl> urls;
stream >> urls;
QList<QString> paths;
for (const auto &url: qAsConst(urls)) {
if (url.isLocalFile() || url.scheme().isEmpty()) {
paths.append(url.path());
} else {
paths.append(url.toString());
}
}
Query query = UsedResources
| Limit(paths.size());
query.setUrlFilters(Url(paths));
query.setAgents(Agent::any());
query.setActivities(Activity::any());
ResultModel model(query);
model.forgetResources(paths);
break;
}
default:
break;
}
}
// needed for JSON file embedding
#include "recentlyused.moc"
......@@ -90,6 +90,21 @@ protected:
void stat(const QUrl &url) override;
void mimetype(const QUrl &url) override;
/**
* Implemention of the forget action
*
* Use it like so:
*
* QByteArray packedArgs;
* QDataStream stream(&packedArgs, QIODevice::WriteOnly);
* stream << int(1); // Forget
* stream << urls;
*
* auto job = KIO::special(QUrl("recentlyused:/"), packedArgs);
* job->exec();
*/
void special(const QByteArray &data) override;
private:
KIO::UDSEntry udsEntryFromResource(const QString &resource, const QString &mimeType);
KIO::UDSEntry udsEntryForRoot(const QString &dirName, const QString &iconName);
......
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