KDECore
Go to the documentation of this file.
36 progressUnit(
KJob::Bytes), percentage(0),
37 suspended(false), capabilities(
KJob::NoCapabilities),
38 speedTimer(0), isAutoDelete(true), eventLoop(0), isFinished(false)
58 : QObject(parent), d_ptr(&dd)
81 if ( delegate == 0 || delegate->setJob(
this ) )
84 d->uiDelegate = delegate;
88 d->uiDelegate->connectJob(
this );
95 return d_func()->uiDelegate;
100 return d_func()->capabilities;
105 return d_func()->suspended;
122 d->isFinished =
true;
161 d->suspended =
false;
203 Q_ASSERT( ! d->eventLoop );
205 QEventLoop loop(
this );
206 d->eventLoop = &loop;
209 if( !d->isFinished ) {
210 d->eventLoop->exec(QEventLoop::ExcludeUserInputEvents);
214 if ( wasAutoDelete ) {
217 return ( d->error ==
NoError );
222 return d_func()->error;
227 return d_func()->errorText;
232 return d_func()->errorText;
237 return d_func()->processedAmount[unit];
242 return d_func()->totalAmount[unit];
247 return d_func()->percentage;
253 d->error = errorCode;
265 bool should_emit = (d->processedAmount[unit] != amount);
267 d->processedAmount[unit] = amount;
272 if (unit==d->progressUnit) {
274 emitPercent(d->processedAmount[unit], d->totalAmount[unit]);
282 bool should_emit = (d->totalAmount[unit] != amount);
284 d->totalAmount[unit] = amount;
289 if (unit==d->progressUnit) {
291 emitPercent(d->processedAmount[unit], d->totalAmount[unit]);
299 if ( d->percentage!=percentage )
301 d->percentage = percentage;
302 emit
percent(
this, percentage );
309 d->isFinished =
true;
311 if ( d->eventLoop ) {
312 d->eventLoop->quit();
329 unsigned long oldPercentage = d->percentage;
331 if ( d->percentage != oldPercentage ) {
332 emit
percent(
this, d->percentage );
340 if (!d->speedTimer) {
341 d->speedTimer =
new QTimer(
this);
342 connect(d->speedTimer, SIGNAL(
timeout()), SLOT(_k_speedTimeout()));
345 emit
speed(
this, value);
346 d->speedTimer->start(5000);
361 return d->isAutoDelete;
367 d->isAutoDelete = autodelete;
bool resume()
Resumes this job.
The base class for all KJob UI delegate.
unsigned long percent() const
Returns the overall progress of this job.
qulonglong totalAmount(Unit unit) const
Returns the total amount of a given unit for this job.
void finished(KJob *job)
Emitted when the job is finished, in any case.
void setErrorText(const QString &errorText)
Sets the error text.
bool suspend()
Suspends this job.
void suspended(KJob *job)
Emitted when the job is suspended.
void result(KJob *job)
Emitted when the job is finished (except when killed with KJob::Quietly).
void speed(KJob *job, unsigned long speed)
Emitted to display information about the speed of this job.
void ref()
Tells KGlobal about one more operations that should be finished before the application exits.
void emitPercent(qulonglong processedAmount, qulonglong totalAmount)
Utility function for inherited jobs.
qulonglong processedAmount(Unit unit) const
Returns the processed amount of a given unit for this job.
void setAutoDelete(bool autodelete)
set the auto-delete property of the job.
void deref()
Tells KGlobal that one operation such as those described in ref() just finished.
bool kill(KillVerbosity verbosity=Quietly)
Aborts this job.
bool isAutoDelete() const
Returns whether this job automatically deletes itself once the job is finished.
void emitSpeed(unsigned long speed)
Utility function for inherited jobs.
KJobUiDelegate * uiDelegate() const
Retrieves the delegate attached to this job.
void setTotalAmount(Unit unit, qulonglong amount)
Sets the total size.
void setCapabilities(Capabilities capabilities)
Sets the capabilities for this job.
The base class for all jobs.
virtual QString errorString() const
A human-readable error message.
QString errorText() const
Returns the error text if there has been an error.
void setPercent(unsigned long percentage)
Sets the overall progress of the job.
KJob(QObject *parent=0)
Creates a new KJob object.
virtual bool doSuspend()
Suspends this job.
KJobUiDelegate * uiDelegate
virtual bool doResume()
Resumes this job.
virtual void start()=0
Starts the job asynchronously.
void totalSize(KJob *job, qulonglong size)
Emitted when we know the size of this job (data size in bytes for transfers, number of entries for li...
void setProcessedAmount(Unit unit, qulonglong amount)
Sets the processed size.
void setUiDelegate(KJobUiDelegate *delegate)
Attach a UI delegate to this job.
bool isSuspended() const
Returns if the job was suspended with the suspend() call.
void processedSize(KJob *job, qulonglong size)
Regularly emitted to show the progress of this job (current data size in bytes for transfers,...
Capabilities capabilities() const
Returns the capabilities of this job.
virtual ~KJob()
Destroys a KJob object.
void emitResult()
Utility function to emit the result signal, and suicide this job.
void resumed(KJob *job)
Emitted when the job is resumed.
static bool _k_kjobUnitEnumRegistered
int error() const
Returns the error code, if there has been an error.
virtual bool doKill()
Aborts this job quietly.
void setError(int errorCode)
Sets the error code.
bool exec()
Executes the job synchronously.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jan 19 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.