• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • jobs
kcompositejob.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17
18*/
19
20#include "kcompositejob.h"
21#include "kcompositejob_p.h"
22
23KCompositeJobPrivate::KCompositeJobPrivate()
24{
25}
26
27KCompositeJobPrivate::~KCompositeJobPrivate()
28{
29}
30
31KCompositeJob::KCompositeJob( QObject *parent )
32 : KJob( *new KCompositeJobPrivate, parent )
33{
34}
35
36KCompositeJob::KCompositeJob( KCompositeJobPrivate &dd, QObject *parent )
37 : KJob( dd, parent)
38{
39}
40
41KCompositeJob::~KCompositeJob()
42{
43}
44
45bool KCompositeJob::addSubjob( KJob *job )
46{
47 Q_D(KCompositeJob);
48 if ( job == 0 || d->subjobs.contains( job ) )
49 {
50 return false;
51 }
52
53 job->setParent(this);
54 d->subjobs.append(job);
55 connect( job, SIGNAL(result(KJob*)),
56 SLOT(slotResult(KJob*)) );
57
58 // Forward information from that subjob.
59 connect( job, SIGNAL(infoMessage(KJob*,QString,QString)),
60 SLOT(slotInfoMessage(KJob*,QString,QString)) );
61
62 return true;
63}
64
65bool KCompositeJob::removeSubjob( KJob *job )
66{
67 Q_D(KCompositeJob);
68 if ( job == 0 )
69 {
70 return false;
71 }
72
73 job->setParent(0);
74 d->subjobs.removeAll( job );
75
76 return true;
77}
78
79// KDE5: Make this method const
80bool KCompositeJob::hasSubjobs()
81{
82 return !d_func()->subjobs.isEmpty();
83}
84
85const QList<KJob*> &KCompositeJob::subjobs() const
86{
87 return d_func()->subjobs;
88}
89
90void KCompositeJob::clearSubjobs()
91{
92 Q_D(KCompositeJob);
93 Q_FOREACH(KJob *job, d->subjobs) {
94 job->setParent(0);
95 }
96 d->subjobs.clear();
97}
98
99void KCompositeJob::slotResult( KJob *job )
100{
101 // Did job have an error ?
102 if ( job->error() && !error() )
103 {
104 // Store it in the parent only if first error
105 setError( job->error() );
106 setErrorText( job->errorText() );
107 emitResult();
108 }
109
110 removeSubjob(job);
111}
112
113void KCompositeJob::slotInfoMessage( KJob *job, const QString &plain, const QString &rich )
114{
115 emit infoMessage( job, plain, rich );
116}
117
118#include "kcompositejob.moc"
KCompositeJobPrivate
Definition: kcompositejob_p.h:31
KCompositeJobPrivate::~KCompositeJobPrivate
~KCompositeJobPrivate()
Definition: kcompositejob.cpp:27
KCompositeJobPrivate::KCompositeJobPrivate
KCompositeJobPrivate()
Definition: kcompositejob.cpp:23
KCompositeJob
The base class for all jobs able to be composed of one or more subjobs.
Definition: kcompositejob.h:34
KCompositeJob::KCompositeJob
KCompositeJob(QObject *parent=0)
Creates a new KCompositeJob object.
Definition: kcompositejob.cpp:31
KCompositeJob::addSubjob
virtual bool addSubjob(KJob *job)
Add a job that has to be finished before a result is emitted.
Definition: kcompositejob.cpp:45
KCompositeJob::subjobs
const QList< KJob * > & subjobs() const
Retrieves the list of the subjobs.
Definition: kcompositejob.cpp:85
KCompositeJob::slotInfoMessage
virtual void slotInfoMessage(KJob *job, const QString &plain, const QString &rich)
Forward signal from subjob.
Definition: kcompositejob.cpp:113
KCompositeJob::removeSubjob
virtual bool removeSubjob(KJob *job)
Mark a sub job as being done.
Definition: kcompositejob.cpp:65
KCompositeJob::slotResult
virtual void slotResult(KJob *job)
Called whenever a subjob finishes.
Definition: kcompositejob.cpp:99
KCompositeJob::clearSubjobs
void clearSubjobs()
Clears the list of subjobs.
Definition: kcompositejob.cpp:90
KCompositeJob::~KCompositeJob
virtual ~KCompositeJob()
Destroys a KCompositeJob object.
Definition: kcompositejob.cpp:41
KCompositeJob::hasSubjobs
bool hasSubjobs()
Checks if this job has subjobs running.
Definition: kcompositejob.cpp:80
KJob
The base class for all jobs.
Definition: kjob.h:85
KJob::setErrorText
void setErrorText(const QString &errorText)
Sets the error text.
Definition: kjob.cpp:256
KJob::emitResult
void emitResult()
Utility function to emit the result signal, and suicide this job.
Definition: kjob.cpp:306
KJob::error
int error() const
Returns the error code, if there has been an error.
Definition: kjob.cpp:220
KJob::result
void result(KJob *job)
Emitted when the job is finished (except when killed with KJob::Quietly).
KJob::errorText
QString errorText() const
Returns the error text if there has been an error.
Definition: kjob.cpp:225
KJob::infoMessage
void infoMessage(KJob *job, const QString &plain, const QString &rich=QString())
Emitted to display state information about this job.
QList
Definition: kaboutdata.h:33
QObject
QString
kcompositejob.h
kcompositejob_p.h
setError
static void setError(QAbstractSocket *socket, QAbstractSocket::SocketError error, const QString &errorString)
Definition: ksocketfactory.cpp:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal