• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.5 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 
23 KCompositeJobPrivate::KCompositeJobPrivate()
24 {
25 }
26 
27 KCompositeJobPrivate::~KCompositeJobPrivate()
28 {
29  qDeleteAll(subjobs);
30 }
31 
32 KCompositeJob::KCompositeJob( QObject *parent )
33  : KJob( *new KCompositeJobPrivate, parent )
34 {
35 }
36 
37 KCompositeJob::KCompositeJob( KCompositeJobPrivate &dd, QObject *parent )
38  : KJob( dd, parent)
39 {
40 }
41 
42 KCompositeJob::~KCompositeJob()
43 {
44 }
45 
46 bool KCompositeJob::addSubjob( KJob *job )
47 {
48  Q_D(KCompositeJob);
49  if ( job == 0 || d->subjobs.contains( job ) )
50  {
51  return false;
52  }
53 
54  d->subjobs.append(job);
55 
56  connect( job, SIGNAL(result(KJob*)),
57  SLOT(slotResult(KJob*)) );
58 
59  // Forward information from that subjob.
60  connect( job, SIGNAL(infoMessage(KJob*,QString,QString)),
61  SLOT(slotInfoMessage(KJob*,QString,QString)) );
62 
63  return true;
64 }
65 
66 bool KCompositeJob::removeSubjob( KJob *job )
67 {
68  Q_D(KCompositeJob);
69  if ( job == 0 )
70  {
71  return false;
72  }
73 
74  d->subjobs.removeAll( job );
75 
76  return true;
77 }
78 
79 // KDE5: Make this method const
80 bool KCompositeJob::hasSubjobs()
81 {
82  return !d_func()->subjobs.isEmpty();
83 }
84 
85 const QList<KJob*> &KCompositeJob::subjobs() const
86 {
87  return d_func()->subjobs;
88 }
89 
90 void KCompositeJob::clearSubjobs()
91 {
92  Q_D(KCompositeJob);
93  d->subjobs.clear();
94 }
95 
96 void KCompositeJob::slotResult( KJob *job )
97 {
98  // Did job have an error ?
99  if ( job->error() && !error() )
100  {
101  // Store it in the parent only if first error
102  setError( job->error() );
103  setErrorText( job->errorText() );
104  emitResult();
105  }
106 
107  removeSubjob(job);
108 }
109 
110 void KCompositeJob::slotInfoMessage( KJob *job, const QString &plain, const QString &rich )
111 {
112  emit infoMessage( job, plain, rich );
113 }
114 
115 #include "kcompositejob.moc"
KCompositeJob::addSubjob
virtual bool addSubjob(KJob *job)
Add a job that has to be finished before a result is emitted.
Definition: kcompositejob.cpp:46
KCompositeJob::~KCompositeJob
virtual ~KCompositeJob()
Destroys a KCompositeJob object.
Definition: kcompositejob.cpp:42
KCompositeJobPrivate
Definition: kcompositejob_p.h:30
KJob::emitResult
void emitResult()
Utility function to emit the result signal, and suicide this job.
Definition: kjob.cpp:306
KJob::setError
void setError(int errorCode)
Sets the error code.
Definition: kjob.cpp:250
KCompositeJobPrivate::KCompositeJobPrivate
KCompositeJobPrivate()
Definition: kcompositejob.cpp:23
KCompositeJob::slotInfoMessage
virtual void slotInfoMessage(KJob *job, const QString &plain, const QString &rich)
Forward signal from subjob.
Definition: kcompositejob.cpp:110
QString
QObject
kcompositejob_p.h
KJob::setErrorText
void setErrorText(const QString &errorText)
Sets the error text.
Definition: kjob.cpp:256
KCompositeJobPrivate::~KCompositeJobPrivate
~KCompositeJobPrivate()
Definition: kcompositejob.cpp:27
kcompositejob.h
KCompositeJob::slotResult
virtual void slotResult(KJob *job)
Called whenever a subjob finishes.
Definition: kcompositejob.cpp:96
KCompositeJob::KCompositeJob
KCompositeJob(QObject *parent=0)
Creates a new KCompositeJob object.
Definition: kcompositejob.cpp:32
KCompositeJob::clearSubjobs
void clearSubjobs()
Clears the list of subjobs.
Definition: kcompositejob.cpp:90
KCompositeJobPrivate::subjobs
QList< KJob * > subjobs
Definition: kcompositejob_p.h:36
KCompositeJob::subjobs
const QList< KJob * > & subjobs() const
Retrieves the list of the subjobs.
Definition: kcompositejob.cpp:85
KCompositeJob::hasSubjobs
bool hasSubjobs()
Checks if this job has subjobs running.
Definition: kcompositejob.cpp:80
KJob::result
void result(KJob *job)
Emitted when the job is finished (except when killed with KJob::Quietly).
KCompositeJob
The base class for all jobs able to be composed of one or more subjobs.
Definition: kcompositejob.h:33
KJob::infoMessage
void infoMessage(KJob *job, const QString &plain, const QString &rich=QString())
Emitted to display state information about this job.
KJob
The base class for all jobs.
Definition: kjob.h:84
KJob::errorText
QString errorText() const
Returns the error text if there has been an error.
Definition: kjob.cpp:225
QList< KJob * >
KJob::error
int error() const
Returns the error code, if there has been an error.
Definition: kjob.cpp:220
KCompositeJob::removeSubjob
virtual bool removeSubjob(KJob *job)
Mark a sub job as being done.
Definition: kcompositejob.cpp:66
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Sat May 31 2014 00:20:54 by doxygen 1.8.5 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.10.5 API Reference

Skip menu "kdelibs-4.10.5 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