class KJobabstract |
|
The base class for all jobs.
For all jobs created in an application, the code looks like
KJob * job = someoperation( some parameters ); connect( job, SIGNAL( result( KJob * ) ), this, SLOT( slotResult( KJob * ) ) ); job->start();(other connects, specific to the job) And slotResult is usually at least:
if ( job->error() ) doSomething(); With the synchronous interface the code looks like
KJob *job = someoperation( some parameters ); if ( !job->exec() ) { // An error occurred } else { // Do something } @note: KJob and its subclasses is meant to be used in a fire-and-forget way. It's deleting itself when it has finished using deleteLater() so the job instance disappears after the next event loop run. |
|
Creates a new KJob object.
parent - the parent QObject |
|
|
|
Returns the capabilities of this job.
Returns the capabilities that this job supports See also setCapabilities() |
|
Emitted to display general description of this job. A description has
a title and two optional fields which can be used to complete the
description.
Examples of titles are "Copying", "Creating resource", etc. The fields of the description can be "Source" with an URL, and, "Destination" with an URL for a "Copying" description. job - the job that emitted this signal title - the general description of the job field1 - first field (localized name and value) field2 - second field (localized name and value) |
|
Aborts this job quietly.
This simply kills the job, no error reporting or job deletion should be involved.
Returns true if the operation is supported and succeeded, false otherwise |
|
Resumes this job.
Returns true if the operation is supported and succeeded, false otherwise |
|
Suspends this job.
Returns true if the operation is supported and succeeded, false otherwise |
|
Utility function for inherited jobs.
Emits the percent signal if bigger than previous value,
after calculating it from the parameters.
processedAmount - the processed amount totalAmount - the total amount See also percent() |
|
Utility function to emit the result signal, and suicide this job.
It first notifies the observers to hide the progress for this job using
the finished() signal.
@note: Deletes this job using deleteLater(). See also result() See also finished() |
|
Utility function for inherited jobs.
Emits the speed signal and starts the timer for removing that info
speed - the speed in bytes/s |
|
Returns the error code, if there has been an error.
Only call this method from the slot connected to result().
Returns the error code for this job, 0 if no error. |
|
Converts an error code and a non-i18n error message into an
error message in the current language. The low level (non-i18n)
error message (usually a url) is put into the translated error
message using %1.
Example for errid == ERR_CANNOT_OPEN_FOR_READING: i18n( "Could not read\n%1" , errorText() );Do not call it if error() is not 0. Returns the error message and if there is no error, a message telling the user that the app is broken, so check with error() whether there is an error |
|
Returns the error text if there has been an error.
Only call if error is not 0.
This is really internal, better use errorString.
Returns a string to help understand the error, usually the url related to the error. Only valid if error() is not 0. |
|
Executes the job synchronously.
Returns true if the job has been executed without error, false otherwise |
|
Emitted to display state information about this job.
Examples of message are "Resolving host", "Connecting to host...", etc.
job - the job that emitted this signal plain - the info message rich - the rich text version of the message, or QString() is none is available |
|
Returns whether this job automatically deletes itself once
the job is finished.
Returns whether the job is deleted automatically after finishing. |
|
Returns if the job was suspended with the suspend() call.
Returns if the job was suspended See also suspend() resume() |
|
Aborts this job.
This kills and deletes the job.
verbosity - if equals to EmitResult, Job will emit signal result and ask uiserver to close the progress window. verbosity is set to EmitResult for subjobs. Whether applications should call with Quietly or EmitResult depends on whether they rely on result being emitted or not. Returns true if the operation is supported and succeeded, false otherwise |
|
Returns the overall progress of this job.
Returns the overall progress of this job |
|
Returns the processed amount of a given unit for this job.
unit - the unit of the requested amount Returns the processed size |
|
Resumes this job.
Returns true if the operation is supported and succeeded, false otherwise |
|
set the auto-delete property of the job. If autodelete is
set to false the job will not delete itself once its finished.
The default for any KJob is to automatically delete itself. autodelete - set to false to disable automatic deletion of the job. |
|
Sets the capabilities for this job.
capabilities - are the capabilities supported by this job See also capabilities() |
|
Sets the error code. It should be called when an error
is encountered in the job, just before calling emitResult().
errorCode - the error code See also emitResult() |
|
Sets the error text. It should be called when an error
is encountered in the job, just before calling emitResult().
errorText - the error text See also emitResult() |
|
Sets the overall progress of the job. The percent() signal
is emitted if the value changed.
percentage - the new overall progress |
|
Sets the processed size. The processedAmount() and percent() signals
are emitted if the values changed. The percent() signal is emitted
only for the progress unit.
unit - the unit of the new processed amount amount - the new processed amount |
|
Sets the total size. The totalSize() and percent() signals
are emitted if the values changed. The percent() signal is emitted
only for the progress unit.
unit - the unit of the new total amount amount - the new total amount |
|
Attach a UI delegate to this job.
If the job had another UI delegate, it's automatically deleted. Once attached to the job, the UI delegate will be deleted with the job. delegate - the new UI delegate to use See also KJobUiDelegate |
|
Starts the job asynchronously. When the job is finished, result() is emitted. |
|
Suspends this job.
The job should be kept in a state in which it is possible to resume it.
Returns true if the operation is supported and succeeded, false otherwise |
|
Returns the total amount of a given unit for this job.
unit - the unit of the requested amount Returns the total size |
|
Retrieves the delegate attached to this job.
Returns the delegate attached to this job, or 0 if there's no such delegate |
|
Emitted to display a warning about this job.
job - the job that emitted this signal plain - the warning message rich - the rich text version of the message, or QString() is none is available |
NoCapabilities | - 0x0000 | - | ||
Killable | - 0x0001 | - | ||
Suspendable | - 0x0002 | - |
Quietly | - | - | ||
EmitResult | - | - |
Bytes | - | - | ||
Files | - | - | ||
Directories | - | - |
NoError | - 0 | - | ||
KilledJobError | - 1 | - | ||
UserDefinedError | - 100 | - |