Plasma5Support

servicejob.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Aaron Seigo <aseigo@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "servicejob.h"
8
9#include <QDebug>
10
11#include "private/servicejob_p.h"
12
13namespace Plasma5Support
14{
15ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest, const QString &op, const QVariantMap &params)
16 : q(owner)
17 , destination(dest)
18 , operation(op)
19 , parameters(params)
20 , m_allowAutoStart(true)
21{
22}
23
24void ServiceJobPrivate::preventAutoStart()
25{
26 m_allowAutoStart = false;
27}
28
29void ServiceJobPrivate::autoStart()
30{
31 if (m_allowAutoStart) {
32 m_allowAutoStart = false;
33
34 if (q->isAutoDelete()) {
35 // by checking for isAutoDelete, we prevent autostarting when
36 // exec() is called or when the job owner has "taken control"
37 // of the job by requesting it not be autodeleted
38 q->start();
39 }
40 }
41}
42
43ServiceJob::ServiceJob(const QString &destination, const QString &operation, const QVariantMap &parameters, QObject *parent)
44 : KJob(parent)
45 , d(new ServiceJobPrivate(this, destination, operation, parameters))
46{
47 connect(this, SIGNAL(finished(KJob *)), this, SLOT(preventAutoStart()));
48}
49
51{
52 delete d;
53}
54
55QString ServiceJob::destination() const
56{
57 return d->destination;
58}
59
60QString ServiceJob::operationName() const
61{
62 return d->operation;
63}
64
65QVariantMap ServiceJob::parameters() const
66{
67 return d->parameters;
68}
69
70QVariant ServiceJob::result() const
71{
72 return d->result;
73}
74
76{
77 d->result = result;
78 emitResult();
79}
80
82{
83 setResult(false);
84}
85
86} // namespace Plasma5Support
87
88#include "moc_servicejob.cpp"
void emitResult()
void finished(KJob *job)
QVariantMap parameters() const
Q_INVOKABLE void start() override
Default implementation of start, which simply sets the results to false.
~ServiceJob() override
Destructor.
void setResult(const QVariant &result)
Sets the result for an operation.
Namespace for everything in libplasma.
Definition datamodel.cpp:15
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.