1 /***************************************************************************
2 * Copyright (C) 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
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 License *
15 * 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 . *
18 ***************************************************************************/
22 #include <QtCore/QTimer>
42 QString applicationName
;
43 QString applicationIconName
;
48 QMap
<QString
, qlonglong
> totalAmounts
;
49 QMap
<QString
, qlonglong
> processedAmounts
;
51 QList
<QPair
<QString
, QString
> > labels
;
62 Job::Job(QObject
*parent
)
66 //delay a little the job to avoid the user to be distracted with short ones
67 QTimer::singleShot(1500, this, SLOT(show()));
81 QString
Job::applicationName() const
83 return d
->applicationName
;
86 void Job::setApplicationName(const QString
&applicationName
)
88 if (d
->applicationName
!= applicationName
) {
89 d
->applicationName
= applicationName
;
90 scheduleChangedSignal();
94 QString
Job::applicationIconName() const
96 return d
->applicationIconName
;
99 void Job::setApplicationIconName(const QString
&applicationIcon
)
101 if (d
->applicationIconName
!= applicationIcon
) {
102 d
->applicationIconName
= applicationIcon
;
103 scheduleChangedSignal();
107 QString
Job::message() const
112 void Job::setMessage(const QString
&message
)
114 if (d
->message
!= message
) {
115 d
->message
= message
;
116 scheduleChangedSignal();
120 QString
Job::error() const
125 void Job::setError(const QString
&error
)
127 if (d
->error
!= error
) {
129 scheduleChangedSignal();
133 QString
Job::speed() const
138 void Job::setSpeed(const QString
&speed
)
140 if (d
->speed
!= speed
) {
142 scheduleChangedSignal();
146 QMap
<QString
, qlonglong
> Job::totalAmounts() const
148 return d
->totalAmounts
;
151 void Job::setTotalAmounts(QMap
<QString
, qlonglong
> amounts
)
153 if (d
->totalAmounts
!= amounts
) {
154 d
->totalAmounts
= amounts
;
155 scheduleChangedSignal();
159 QMap
<QString
, qlonglong
> Job::processedAmounts() const
161 return d
->processedAmounts
;
164 void Job::setProcessedAmounts(QMap
<QString
, qlonglong
> amounts
)
166 d
->processedAmounts
= amounts
;
167 scheduleChangedSignal();
170 Job::State
Job::state() const
175 void Job::setState(State state
)
177 if (d
->state
!= state
) {
179 scheduleChangedSignal();
183 QList
<QPair
<QString
, QString
> > Job::labels() const
188 void Job::setLabels(QList
<QPair
<QString
, QString
> > labels
)
191 scheduleChangedSignal();
194 uint
Job::percentage() const
196 return d
->percentage
;
199 void Job::setPercentage(uint percentage
)
201 if (d
->percentage
!= percentage
) {
202 d
->percentage
= percentage
;
203 scheduleChangedSignal();
207 bool Job::isSuspendable() const
209 return d
->suspendable
;
212 void Job::setSuspendable(bool suspendable
)
214 if (d
->suspendable
!= suspendable
) {
215 d
->suspendable
= suspendable
;
216 scheduleChangedSignal();
220 bool Job::isKillable() const
225 void Job::setKillable(bool killable
)
227 if (d
->killable
!= killable
) {
228 d
->killable
= killable
;
229 scheduleChangedSignal();
235 kWarning() << "Suspend is not implemented in this job provider.";
240 kWarning() << "Resume is not implemented in this job provider.";
245 kWarning() << "Stop is not implemented in this job provider.";
250 if (state() == Job::Running
) {
256 void Job::scheduleChangedSignal()
258 if (d
->shown
&& !d
->timerId
) {
259 d
->timerId
= startTimer(0);
263 void Job::timerEvent(QTimerEvent
*)
265 killTimer(d
->timerId
);