kuiserver: announce destination URL changes to job clients

to fix the plasma job notification actions (see the previous commit), also
changing the destination URL type to QString because it is such (see
kdelibs/kio/kio/copyjob.cpp and kdelibs/kio/kio/job.cpp) and the
QVariant/QDBusVariant conversion is redundant

requires changes to the job tracker interface in kdelibs aswell.. see
kdelibs/kdeui/jobs/kuiserverjobtracker.cpp

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-27 03:19:51 +03:00
parent aa57bf2832
commit 42bd88d0d2
6 changed files with 27 additions and 18 deletions

View file

@ -289,13 +289,16 @@ QDBusObjectPath JobView::objectPath() const
return m_objectPath;
}
void JobView::setDestUrl(const QDBusVariant &destUrl)
void JobView::setDestUrl(const QString &destUrl)
{
m_destUrl = destUrl.variant();
foreach(const iFacePair &pair, m_objectPaths) {
pair.second->asyncCall(QLatin1String("setDestUrl"), destUrl);
}
m_destUrl = destUrl;
emit destUrlSet();
}
QVariant JobView::destUrl() const
QString JobView::destUrl() const
{
return m_destUrl;
}
@ -354,6 +357,10 @@ void JobView::addJobContact(const QString& objectPath, const QString& address)
if (m_totalAmount > 0) {
client->asyncCall(QLatin1String("setTotalAmount"), m_totalAmount, m_totalUnit);
}
if (!m_destUrl.isEmpty()) {
client->asyncCall(QLatin1String("setDestUrl"), m_destUrl);
}
}
QStringList JobView::jobContacts()

View file

@ -105,14 +105,14 @@ public:
/**
* Set the dest Url of the job...
* sent from the jobtracker (once upon construction)
* @param destUrl will be a QVariant, likely to have 1
* @param destUrl will be a QString, likely to have 1
* dest Url...OR it can be non-existent (only srcUrl would
* be there), in that case it is a delete a directory job
* etc..
*/
void setDestUrl(const QDBusVariant& destUrl);
void setDestUrl(const QString& destUrl);
QVariant destUrl() const;
QString destUrl() const;
/**
* The below methods force an emission of the respective signal.
@ -194,7 +194,7 @@ private:
QHash<uint, QPair<QString, QString> > m_descFields;
QVariant m_destUrl;
QString m_destUrl;
QDBusObjectPath m_objectPath;

View file

@ -216,7 +216,7 @@ QStringList ProgressListModel::gatherJobUrls()
QStringList jobUrls;
foreach(JobView* jobView, m_jobViews) {
jobUrls.append(jobView->destUrl().toString());
jobUrls.append(jobView->destUrl());
}
return jobUrls;
}

View file

@ -52,8 +52,7 @@ Column {
message,
0,
0,
// TODO: [{"id": message, "text": i18n("Open")}]
[])
runningJobs[source]["destUrl"] ? [{"id": message, "text": i18n("Open")}] : [])
delete runningJobs[source]
}
Component.onCompleted: {

View file

@ -22,10 +22,10 @@
#include "jobcontrol.h"
#include <QDBusConnection>
#include <QtCore/qcoreevent.h>
#include <QTimerEvent>
#include <QDebug>
#include <KJob>
#include <Plasma/DataEngine>
@ -199,9 +199,12 @@ void JobView::setProcessedAmount(qlonglong amount, const QString &unit)
}
}
void JobView::setDestUrl(const QDBusVariant & destUrl)
void JobView::setDestUrl(const QString &destUrl)
{
Q_UNUSED(destUrl);
if (m_destUrl != destUrl) {
setData("destUrl", destUrl);
scheduleUpdate();
}
}
void JobView::setPercent(uint percent)
@ -363,9 +366,8 @@ Plasma::Service* KuiserverEngine::serviceForSource(const QString& source)
JobView *jobView = qobject_cast<JobView *>(containerForSource(source));
if (jobView) {
return new JobControl(this, jobView);
} else {
return DataEngine::serviceForSource(source);
}
return DataEngine::serviceForSource(source);
}
void KuiserverEngine::init()

View file

@ -96,8 +96,8 @@ public:
void setPercent(uint percent);
void setSuspended(bool suspended);
//vestigal, required to implement this dbus interface
void setDestUrl(const QDBusVariant &destUrl);
// vestigal, required to implement this dbus interface
void setDestUrl(const QString &destUrl);
void terminate(const QString &errorMessage);
@ -135,6 +135,7 @@ private:
State m_state;
QString m_destUrl;
QMap<QString, int> m_unitMap;
int m_bytesUnitId;
int m_unitId;