2
* Copyright (C) 2012 Ivan Cukic <ivan.cukic(at)kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2,
6
* or (at your option) any later version, as published by the Free
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#include "Abstract_p.h"
26
namespace Schedulers {
28
Abstract::Private::Private(Abstract * parent)
33
void Abstract::Private::jobFinished(KJob * job)
35
kDebug() << "Job has finished with this result" << job->error();
36
q->jobFinished(job->error());
39
bool Abstract::startJob(int index)
41
d->lastJobStarted = index;
43
// If the index is not valid
44
if (index < 0 || d->jobs.size() <= index) {
49
JobFactory * factory = d->jobs[index];
51
// If the job factory is null, exit
58
KJob * job = d->jobs[index]->create(this);
60
connect(job, SIGNAL(finished(KJob *)),
61
d, SLOT(jobFinished(KJob *)));
68
Abstract::Abstract(QObject * parent)
69
: Job(parent), d(new Private(this))
71
d->lastJobStarted = -1;
75
this, SIGNAL(finished(KJob *)),
76
this, SLOT(deleteLater()),
88
void Abstract::addJob(Job * other)
90
d->jobs << JobFactory::wrap(other);
93
void Abstract::addJob(JobFactory * other)
98
void Abstract::start()
100
if (d->jobs.size() == 0) {
108
int Abstract::lastJobStarted() const
110
return d->lastJobStarted;
113
int Abstract::jobCount() const
115
return d->jobs.size();
118
bool Abstract::hasJob(int index) const
120
return (index >= 0 && index < d->jobs.size() && d->jobs[index] != NULL);
123
void Abstract::returnResult(int result)
125
kDebug() << "Returning" << result;
131
} // namespace Schedulers