• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kcompositejob.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License version 2 as published by the Free Software Foundation.
00007 
00008     This library is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011     Library General Public License for more details.
00012 
00013     You should have received a copy of the GNU Library General Public License
00014     along with this library; see the file COPYING.LIB.  If not, write to
00015     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, USA.
00017 
00018 */
00019 
00020 #include "kcompositejob.h"
00021 #include "kcompositejob_p.h"
00022 
00023 KCompositeJobPrivate::KCompositeJobPrivate()
00024 {
00025 }
00026 
00027 KCompositeJobPrivate::~KCompositeJobPrivate()
00028 {
00029     qDeleteAll(subjobs);
00030 }
00031 
00032 KCompositeJob::KCompositeJob( QObject *parent )
00033     : KJob( *new KCompositeJobPrivate, parent )
00034 {
00035 }
00036 
00037 KCompositeJob::KCompositeJob( KCompositeJobPrivate &dd, QObject *parent )
00038     : KJob( dd, parent)
00039 {
00040 }
00041 
00042 KCompositeJob::~KCompositeJob()
00043 {
00044 }
00045 
00046 bool KCompositeJob::addSubjob( KJob *job )
00047 {
00048     Q_D(KCompositeJob);
00049     if ( job == 0 || d->subjobs.contains( job ) )
00050     {
00051         return false;
00052     }
00053 
00054     d->subjobs.append(job);
00055 
00056     connect( job, SIGNAL( result( KJob* ) ),
00057              SLOT( slotResult( KJob* ) ) );
00058 
00059     // Forward information from that subjob.
00060     connect( job, SIGNAL(infoMessage( KJob*, const QString &, const QString & )),
00061              SLOT(slotInfoMessage( KJob*, const QString &, const QString & ) ) );
00062 
00063     return true;
00064 }
00065 
00066 bool KCompositeJob::removeSubjob( KJob *job )
00067 {
00068     Q_D(KCompositeJob);
00069     if ( job == 0 )
00070     {
00071         return false;
00072     }
00073 
00074     d->subjobs.removeAll( job );
00075 
00076     return true;
00077 }
00078 
00079 bool KCompositeJob::hasSubjobs()
00080 {
00081     return !d_func()->subjobs.isEmpty();
00082 }
00083 
00084 const QList<KJob*> &KCompositeJob::subjobs() const
00085 {
00086     return d_func()->subjobs;
00087 }
00088 
00089 void KCompositeJob::clearSubjobs()
00090 {
00091     Q_D(KCompositeJob);
00092     d->subjobs.clear();
00093 }
00094 
00095 void KCompositeJob::slotResult( KJob *job )
00096 {
00097     // Did job have an error ?
00098     if ( job->error() && !error() )
00099     {
00100         // Store it in the parent only if first error
00101         setError( job->error() );
00102         setErrorText( job->errorText() );
00103         emitResult();
00104     }
00105 
00106     removeSubjob(job);
00107 }
00108 
00109 void KCompositeJob::slotInfoMessage( KJob *job, const QString &plain, const QString &rich )
00110 {
00111     emit infoMessage( job, plain, rich );
00112 }
00113 
00114 #include "kcompositejob.moc"

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal