prevent autostarting

This commit is contained in:
Aaron Seigo 2011-04-28 22:45:19 +02:00 committed by Marco Martin
parent 88956b1539
commit fbfc9e91e9
3 changed files with 17 additions and 2 deletions

View File

@ -37,6 +37,7 @@ public:
const QString &op,
const QMap<QString, QVariant> &params);
void preventAutoStart();
void autoStart();
ServiceJob *q;
@ -45,6 +46,7 @@ public:
QMap<QString, QVariant> parameters;
QVariant result;
Credentials identity;
bool m_allowAutoStart;
};
}

View File

@ -18,6 +18,9 @@
*/
#include "servicejob.h"
#include <kdebug.h>
#include <plasma/private/servicejob_p.h>
namespace Plasma
@ -28,13 +31,21 @@ ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest,
: q(owner),
destination(dest),
operation(op),
parameters(params)
parameters(params),
m_allowAutoStart(true)
{
}
void ServiceJobPrivate::preventAutoStart()
{
m_allowAutoStart = false;
}
void ServiceJobPrivate::autoStart()
{
q->start();
if (m_allowAutoStart) {
q->start();
}
}
ServiceJob::ServiceJob(const QString &destination, const QString &operation,
@ -42,6 +53,7 @@ ServiceJob::ServiceJob(const QString &destination, const QString &operation,
: KJob(parent),
d(new ServiceJobPrivate(this, destination, operation, parameters))
{
connect(this, SIGNAL(finished(KJob*)), this, SLOT(preventAutoStart()));
}
ServiceJob::~ServiceJob()

View File

@ -123,6 +123,7 @@ protected:
private:
Q_PRIVATE_SLOT(d, void autoStart())
Q_PRIVATE_SLOT(d, void preventAutoStart())
ServiceJobPrivate * const d;