From 4cd51895137a1c0a64f56d109277f1f8d32fda5d Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 30 Sep 2009 21:42:05 +0000 Subject: [PATCH] in case of job failure, be sure we don't leave the context menu just hanging around there svn path=/trunk/KDE/kdelibs/; revision=1029846 --- containment.cpp | 12 +++++++++++- containment.h | 1 + private/containment_p.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/containment.cpp b/containment.cpp index 3ecb3d06d..469481505 100644 --- a/containment.cpp +++ b/containment.cpp @@ -1233,6 +1233,7 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS KIO::JobFlags flags = KIO::HideProgressInfo; KIO::TransferJob *job = KIO::get(url, KIO::NoReload, flags); dropPoints[job] = dropEvent->scenePos(); + QObject::connect(job, SIGNAL(result(KJob*)), q, SLOT(dropJobResult(KJob*))); QObject::connect(job, SIGNAL(mimetype(KIO::Job *, const QString&)), q, SLOT(mimeTypeRetrieved(KIO::Job *, const QString&))); @@ -1342,7 +1343,16 @@ void ContainmentPrivate::remoteAppletReady(Plasma::AccessAppletJob *job) q->addApplet(job->applet(), pos); } -void ContainmentPrivate::mimeTypeRetrieved(KIO::Job * job, const QString &mimetype) +void ContainmentPrivate::dropJobResult(KJob *job) +{ + if (job->error()) { + // TODO: error feedback + clearDataForMimeJob(qobject_cast(job)); + kDebug() << "ERROR" << job->error() << ' ' << job->errorString(); + } +} + +void ContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimetype) { kDebug() << "Mimetype Job returns." << mimetype; if (job->error()) { diff --git a/containment.h b/containment.h index 5e4339edc..dfa43f91f 100644 --- a/containment.h +++ b/containment.h @@ -586,6 +586,7 @@ class PLASMA_EXPORT Containment : public Applet * This slot is called when the 'stat' after a job event has finished. */ Q_PRIVATE_SLOT(d, void mimeTypeRetrieved(KIO::Job *, const QString &)) + Q_PRIVATE_SLOT(d, void dropJobResult(KJob *)) friend class Applet; friend class AppletPrivate; diff --git a/private/containment_p.h b/private/containment_p.h index 243ba0b3e..e6d69f927 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -88,6 +88,7 @@ public: void clearDataForMimeJob(KIO::Job *job); void remoteAppletReady(Plasma::AccessAppletJob *job); void mimeTypeRetrieved(KIO::Job *job, const QString &mimetype); + void dropJobResult(KJob *); void containmentActions(KMenu &desktopMenu); void appletActions(KMenu &desktopMenu, Applet *applet, bool includeApplet); bool showContextMenu(const QPointF &point, const QPoint &screenPos, bool includeApplet, bool isMouseEvent);