KIO.Job

KDE 4.5 PyKDE API Reference

- KDE's Python API

# Job Class Reference

`from PyKDE4.kio import *`

Inherits: KCompositeJob → KJob → QObject
Subclasses: KIO.ChmodJob, KIO.CopyJob, KIO.DeleteJob, KIO.DirectorySizeJob, KIO.SimpleJob, KIO.FileCopyJob, KIO.MetaInfoJob, KIO.PreviewJob
Namespace: KIO

## Detailed Description

The base class for all jobs. For all jobs created in an application, the code looks like

       KIO.Job * job = KIO.someoperation( some parameters );
       connect( job, SIGNAL( result( KJob * ) ),
                this, SLOT( slotResult( KJob * ) ) );

(other connects, specific to the job)

And slotResult is usually at least:

      if ( job->error() )
          job->ui()->showErrorMessage();

See also:
  KIO.Scheduler

## Signals
| canceled (KJob job)
| connected (KIO.Job job)
## Methods
| __init__ (self)
| addMetaData (self, QString key, QString value)
| addMetaData (self, {QString:QString} values)
bool | addSubjob (self, KJob job)
QStringList | detailedErrorStrings (self, KUrl reqUrl=0, int method=-1)
bool | doKill (self)
bool | doResume (self)
bool | doSuspend (self)
QString | errorString (self)
bool | isInteractive (self)
| mergeMetaData (self, {QString:QString} values)
KIO.MetaData | metaData (self)
KIO.MetaData | outgoingMetaData (self)
KIO.Job | parentJob (self)
QString | queryMetaData (self, QString key)
bool | removeSubjob (self, KJob job)
| setMetaData (self, KIO.MetaData metaData)
| setParentJob (self, KIO.Job parentJob)
| showErrorDialog (self, QWidget parent=0)
| start (self)
KIO.JobUiDelegate | ui (self)

## Signal Documentation

canceled | ( | KJob | job
| ) |  |  |

@deprecated. Don't use ! Emitted when the job is canceled. Signal result() is emitted as well, and error() is, in this case, ERR_USER_CANCELED.

Parameters:

  | job | the job that emitted this signal

Signal syntax:
  `QObject.connect(source, SIGNAL("canceled(KJob*)"), target_slot)`

connected | ( | KIO.Job | job
| ) |  |  |

Emitted when the slave successfully connected to the host. There is no guarantee the slave will send this, and this is currently unused (in the applications).

Parameters:

  | job | the job that emitted this signal

Signal syntax:
  `QObject.connect(source, SIGNAL("connected(KIO::Job*)"), target_slot)`

## Method Documentation

__init__ | ( |  | self ) |

addMetaData | ( | self, |
|  | QString | key,
|  | QString | value
| ) |  |  |

Add key/value pairs to the meta data that is sent to the slave. If a certain key already existed, it will be overridden.

Parameters:

  | values | the meta data to add

See also:
  setMetaData()

See also:
  mergeMetaData()

addMetaData | ( | self, |
|  | {QString:QString} | values
| ) |  |  |

Add key/value pairs to the meta data that is sent to the slave. If a certain key already existed, it will be overridden.

Parameters:

  | values | the meta data to add

See also:
  setMetaData()

See also:
  mergeMetaData()

bool addSubjob | ( | self, |
|  | KJob | job
| ) |  |  |

Add a job that has to be finished before a result is emitted. This has obviously to be called before the finish signal is emitted by the slave.

Parameters:

  | job | the subjob to add

QStringList detailedErrorStrings | ( | self, |
|  | KUrl | reqUrl=0,
|  | int | method=-1
| ) |  |  |

Converts an error code and a non-i18n error message into i18n strings suitable for presentation in a detailed error message box.

Parameters:

  | reqUrl | the request URL that generated this error message
  | method | the method that generated this error message (unimplemented)

Returns:
  the following strings: caption, error + description, causes+solutions

bool doKill | ( |  | self ) |

Abort this job. This kills all subjobs and deletes the job.

bool doResume | ( |  | self ) |

Resume this job

See also:
  suspend

bool doSuspend | ( |  | self ) |

Suspend this job

See also:
  resume

QString errorString | ( |  | self ) |

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" ).arg( errortext );

Use this to display the error yourself, but for a dialog box use ui()->showErrorMessage(). 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

bool isInteractive | ( |  | self ) |

Returns whether the user should be asked about things when the job is unsure, like whether to overwrite existing files etc.

Returns:
  true if user interactions are enabled (true by default), false if setUiDelegate(0) was called.

See also:
  setUiDelegate()

mergeMetaData | ( | self, |
|  | {QString:QString} | values
| ) |  |  |

Add key/value pairs to the meta data that is sent to the slave. If a certain key already existed, it will remain unchanged.

Parameters:

  | values | the meta data to merge

See also:
  setMetaData()

See also:
  addMetaData()

KIO.MetaData metaData | ( |  | self ) |

Get meta data received from the slave. (Valid when first data is received and/or slave is finished)

Returns:
  the job's meta data

KIO.MetaData outgoingMetaData | ( |  | self ) |

@internal. For the scheduler. Do not use.

KIO.Job parentJob | ( |  | self ) |

Returns the parent job, if there is one.

Returns:
  the parent job, or 0 if there is none

See also:
  setParentJob

QString queryMetaData | ( | self, |
|  | QString | key
| ) |  |  |

Query meta data received from the slave. (Valid when first data is received and/or slave is finished)

Parameters:

  | key | the key of the meta data to retrieve

Returns:
  the value of the meta data, or QString() if the

key does not exist

bool removeSubjob | ( | self, |
|  | KJob | job
| ) |  |  |

Mark a sub job as being done.

KDE4 change: this doesn't terminate the parent job anymore, call emitResult to do that.

Parameters:

  | job | the subjob to remove

setMetaData | ( | self, |
|  | KIO.MetaData | metaData
| ) |  |  |

Set meta data to be sent to the slave, replacing existing meta data.

Parameters:

  | metaData | the meta data to set

See also:
  addMetaData()

See also:
  mergeMetaData()

setParentJob | ( | self, |
|  | KIO.Job | parentJob
| ) |  |  |

Set the parent Job. One example use of this is when FileCopyJob calls RenameDialog.open, it must pass the correct progress ID of the parent CopyJob (to hide the progress dialog). You can set the parent job only once. By default a job does not have a parent job.

Parameters:

  | parentJob | the new parent job

showErrorDialog | ( | self, |
|  | QWidget | parent=0
| ) |  |  |

Display a dialog box to inform the user of the error given by this job. Only call if error is not 0, and only in the slot connected to result.

Parameters:

  | parent | the parent widget for the dialog box, can be 0 for top-level

Deprecated:
  you should use job->ui()->setWindow(parent) and job->ui()->showErrorMessage() instead

start | ( |  | self ) |

KIO.JobUiDelegate ui | ( |  | self ) |

Retrieves the UI delegate of this job.

This method is basically a convenience for static_cast<KIO.JobUiDelegate*>(uiDelegate()).

Returns:
  the delegate used by the job to communicate with the UI