• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

util

executecompositejob.cpp

00001 /* This file is part of KDevelop
00002 Copyright 2007-2008 Hamish Rodda <rodda@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 as published by the Free Software Foundation; either
00007 version 2 of the License, or (at your option) any later version.
00008 
00009 This library is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 Library General Public License for more details.
00013 
00014 You should have received a copy of the GNU Library General Public License
00015 along with this library; see the file COPYING.LIB.  If not, write to
00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017 Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "executecompositejob.h"
00021 
00022 #include <kdebug.h>
00023 
00024 namespace KDevelop
00025 {
00026 class ExecuteCompositeJobPrivate
00027 {
00028 public:
00029     bool m_killing;
00030 };
00031 
00032 ExecuteCompositeJob::ExecuteCompositeJob(QObject* parent, const QList<KJob*>& jobs)
00033 : KCompositeJob(parent), d(new ExecuteCompositeJobPrivate)
00034 {
00035     d->m_killing = false;
00036     setCapabilities(Killable);
00037 
00038     qDebug() << "execute composite" << jobs;
00039     foreach(KJob* job, jobs) {
00040         addSubjob(job);
00041     }
00042 }
00043 
00044 ExecuteCompositeJob::~ExecuteCompositeJob()
00045 {
00046     delete d;
00047 }
00048 
00049 void ExecuteCompositeJob::start()
00050 {
00051     if(hasSubjobs())
00052         subjobs().first()->start();
00053     else
00054         emitResult();
00055 }
00056 
00057 void ExecuteCompositeJob::slotResult(KJob* job)
00058 {
00059     kDebug() << "finished: "<< job << job->error() << error();
00060     KCompositeJob::slotResult(job);
00061 
00062     if(hasSubjobs() && !error() && !d->m_killing)
00063     {
00064         kDebug() << "remaining: " << subjobs().count() << subjobs();
00065         KJob* nextJob=subjobs().first();
00066         nextJob->start();
00067     } else {
00068         emitResult();
00069     }
00070 }
00071 
00072 bool ExecuteCompositeJob::doKill()
00073 {
00074     d->m_killing = true;
00075     while(hasSubjobs()) {
00076         KJob* j = subjobs().first();
00077         if( !j ) {
00078             removeSubjob(j);
00079             continue;
00080         }
00081         if (j->kill()) {
00082             removeSubjob(j);
00083         } else {
00084             return false;
00085         }
00086     }
00087     return true;
00088 }
00089 
00090 }
00091 
00092 #include "executecompositejob.moc"

util

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

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
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