Plasma.ServiceJob

KDE 4.5 PyKDE API Reference

- KDE's Python API

# ServiceJob Class Reference

`from PyKDE4.plasma import *`

Inherits: KJob → QObject
Namespace: Plasma

## Detailed Description

ServiceJob plasma/servicejob.h <Plasma/ServiceJob>

This class provides jobs for use with Plasma.Service

Unlike KJob, you can do the work in start(), since Plasma.Service already delays the call to start() until the event loop is reached.

If the job is quick enough that it is not worth reporting the progress, you just need to implement start() to do the task, then call emitResult() at the end of it. If the task does not complete successfully, you should set a non-zero error code with setError(int) and an error message with setErrorText(QString).

If the job is longer (involving network access, for instance), you should report the progress at regular intervals. See the KJob documentation for information on how to do this.

## Methods
| __init__ (self, QString destination, QString operation, {QString:QVariant} parameters, QObject parent=0)
QString | destination (self)
QString | operationName (self)
{QString:QVariant} | parameters (self)
QVariant | result (self)
| setResult (self, QVariant result)
| start (self)

## Method Documentation

__init__ | ( | self, |
|  | QString | destination,
|  | QString | operation,
|  | {QString:QVariant} | parameters,
|  | QObject | parent=0
| ) |  |  |

Default constructor

@arg destination the subject that the job is acting on @arg operation the action that the job is performing on the destination @arg parameters the parameters of the action @arg parent the parent object for this service

QString destination | ( |  | self ) |

Returns:
  the subject that the job is acting on

QString operationName | ( |  | self ) |

Returns:
  the operation the job is performing on the destination

{QString:QVariant} parameters | ( |  | self ) |

Returns:
  the parameters for the operation

QVariant result | ( |  | self ) |

Returns the result of the operation

The result will be invalid if the job has not completed yet, or if the job does not have a meaningful result.

Note that this should not be used to find out whether the operation was successful. Instead, you should check the value of error().

Returns:
  the result of the operation

setResult | ( | self, |
|  | QVariant | result
| ) |  |  |

Sets the result for an operation.

start | ( |  | self ) |

Default implementation of start, which simply sets the results to false. This makes it easy to create a "failure" job.