class Job

The base class for all jobs. More...

Full nameKIO::Job
Definition#include <jobclasses.h>
InheritsQObject (qt) [public ]
Inherited byChmodJob, CopyJob, DeleteJob, FileCopyJob, ListJob, MimetypeJob, MultiGetJob, PreviewJob, SimpleJob, StatJob, TransferJob
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Signals

Protected Methods

Protected Slots

Protected Members


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( KIO::Job * ) ),
            this, SLOT( slotResult( KIO::Job * ) ) );

(other connects, specific to the job)

And slotResult is usually at least:


  if ( job->error() )
      job->showErrorDialog( this or 0L  );

 Job ( bool showProgressInfo )

Job

[protected]

 ~Job ()

~Job

[virtual]

void  kill ( bool quietly = true )

kill

[virtual]

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

Parameters:
quietlyif false, Job will emit signal result and ask kio_uiserver to close the progress window. quietly is set to true for subjobs. Whether applications should call with true or false depends on whether they rely on result being emitted or not.

int  error ()

error

[const]

Returns: the error code for this job, 0 if no error Error codes are defined in KIO::Error. Only call this method from the slot connected to result.

int  progressId ()

progressId

[const]

Returns: the progress id for this job, as returned by uiserver

const QString &  errorText ()

errorText

[const]

Returns: a string to help understand the error, usually the url related to the error. Only call if error is not 0. This is really internal, better use errorString or errorDialog.

QString  errorString ()

errorString

[const]

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 Job::showErrorDialog.

QStringList  detailedErrorStrings (const KURL *reqUrl = 0L, int method = -1)

detailedErrorStrings

[const]

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

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

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

void  showErrorDialog ( QWidget * parent = 0L )

showErrorDialog

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:
parentthe parent widget for the dialog box

void  setAutoErrorHandlingEnabled ( bool enable, QWidget *parentWidget = 0 )

setAutoErrorHandlingEnabled

Enable or disable the automatic error handling. When automatic error handling is enabled and an error occurs, then showErrorDialog is called with the specified parentWidget (if supplied) , right before the emission of the result signal.

The default is false.

See also isAutoErrorHandlingEnabled , showErrorDialog

Parameters:
enableenable or disable automatic error handling
parentWidgetthe parent widget, passed to showErrorDialog

bool  isAutoErrorHandlingEnabled ()

isAutoErrorHandlingEnabled

[const]

Returns whether automatic error handling is enabled or disabled. See also setAutoErrorHandlingEnabled .

void  setWindow (QWidget *window)

setWindow

Associate this job with a window given by window.

QWidgetwindow ()

window

[const]

Returns the window this job is associated with.

void  setMetaData ( const KIO::MetaData &)

setMetaData

Set meta data to be sent to the slave.

void  addMetaData (const QString &key, const QString &value)

addMetaData

Add key/value pair to the meta data that is sent to the slave.

void  addMetaData (const QMap<QString,QString> &values)

addMetaData

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

void  mergeMetaData (const QMap<QString,QString> &values)

mergeMetaData

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

MetaData  outgoingMetaData ()

outgoingMetaData

[const]

MetaData  metaData ()

metaData

[const]

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

QString  queryMetaData (const QString &key)

queryMetaData

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

void  result ( KIO::Job *job )

result

[signal]

Emitted when the job is finished, in any case (completed, canceled, failed...). Use error to know the result.

void  canceled ( KIO::Job *job )

canceled

[signal]

Emitted when the job is canceled. Signal result is emitted as well, and error() is, in this case, ERR_USER_CANCELED.

void  infoMessage ( KIO::Job *, const QString & msg )

infoMessage

[signal]

Emitted to display information about this job, as sent by the slave. Examples of message are "Resolving host", "Connecting to host...", etc.

void  connected ( KIO::Job * )

connected

[signal]

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).

void  percent ( KIO::Job *job, unsigned long percent )

percent

[signal]

Progress signal showing the overall progress of the job This is valid for any kind of job, and allows using a a progress bar very easily. (see KProgress)

void  totalSize ( KIO::Job *, KIO::filesize_t size )

totalSize

[signal]

Emitted when we know the size of this job (data size for transfers, number of entries for listings).

void  processedSize ( KIO::Job *, KIO::filesize_t size )

processedSize

[signal]

Regularly emitted to show the progress of this job (current data size for transfers, entries listed).

void  speed ( KIO::Job *, unsigned long bytes_per_second )

speed

[signal]

Emitted to display information about the speed of this job.

void  slotResult ( KIO::Job *job )

slotResult

[protected slots virtual slot]

Called whenever a subjob finishes. Default implementation checks for errors and propagates to parent job, then calls removeSubjob. Override if you don't want subjobs errors to be propagated.

void  slotSpeed ( KIO::Job*, unsigned long bytes_per_second )

slotSpeed

[protected slots slot]

Forward signal from subjob.

void  slotInfoMessage ( KIO::Job*, const QString & )

slotInfoMessage

[protected slots slot]

Forward signal from subjob.

void  slotSpeedTimeout ()

slotSpeedTimeout

[protected slots slot]

Remove speed information.

void  addSubjob ( Job *job, bool inheritMetaData=true )

addSubjob

[protected virtual]

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.

If inheritMetaData is true, the subjob will inherit the meta data from this job.

void  removeSubjob ( Job *job )

removeSubjob

[protected virtual]

Mark a sub job as being done. If it's the last to wait on the job will emit a result - jobs with two steps might want to override slotResult in order to avoid calling this method.

void  emitPercent ( KIO::filesize_t processedSize, KIO::filesize_t totalSize )

emitPercent

[protected]

Utility function for inherited jobs. Emits the percent signal if bigger than m_percent, after calculating it from the parameters.

void  emitSpeed ( unsigned long bytes_per_second )

emitSpeed

[protected]

Utility function for inherited jobs. Emits the speed signal and starts the timer for removing that info

void  emitResult ()

emitResult

[protected]

Utility function to emit the result signal, and suicide this job. It first tells the observer to hide the progress dialog for this job.

QPtrList subjobs

subjobs

[protected]

int m_error

m_error

[protected]

QString m_errorText

m_errorText

[protected]

unsigned long m_percent

m_percent

[protected]

int m_progressId

m_progressId

[protected]

QTimer * m_speedTimer

m_speedTimer

[protected]

QGuardedPtr<QWidget> m_window

m_window

[protected]

MetaData m_outgoingMetaData

m_outgoingMetaData

[protected]

MetaData m_incomingMetaData

m_incomingMetaData

[protected]

void  virtual_hook ( int id, void* data )

virtual_hook

[protected virtual]


Generated by: dfaure on faure on Tue Apr 16 08:49:48 2002, using kdoc 2.0a53.