KIO::Job Class
Header: | #include <KIO/Job> |
Inherits: | KCompositeJob |
Inherited By: | KIO::BatchRenameJob, KIO::ChmodJob, KIO::CopyJob, KIO::DeleteJob, KIO::DirectorySizeJob, KIO::DropJob, KIO::FileCopyJob, KIO::MkpathJob, KIO::PasteJob, KIO::PreviewJob, KIO::RestoreJob, and KIO::SimpleJob |
Public Functions
void | addMetaData(const QMap<QString, QString> &values) |
void | addMetaData(const QString &key, const QString &value) |
QStringList | detailedErrorStrings(const QUrl *reqUrl = nullptr, int method = -1) const |
void | mergeMetaData(const QMap<QString, QString> &values) |
KIO::MetaData | metaData() const |
KIO::MetaData | outgoingMetaData() const |
KIO::Job * | parentJob() const |
QString | queryMetaData(const QString &key) |
void | setMetaData(const KIO::MetaData &metaData) |
void | setParentJob(KIO::Job *parentJob) |
void | setUiDelegateExtension(KIO::JobUiDelegateExtension *extension) |
KIO::JobUiDelegateExtension * | uiDelegateExtension() const |
Reimplemented Public Functions
virtual QString | errorString() const override |
Signals
void | connected(KIO::Job *job) |
Reimplemented Protected Functions
virtual bool | addSubjob(KJob *job) override |
virtual bool | doKill() override |
virtual bool | doResume() override |
virtual bool | doSuspend() override |
virtual bool | removeSubjob(KJob *job) override |
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, &KJob::result, this, &MyClass::slotResult);
(other connects, specific to the job)
And slotResult is usually at least:
void MyClass::slotResult(KJob *job) { if (job->error()) { job->uiDelegate()->showErrorMessage(); } }
Member Function Documentation
void Job::addMetaData(const QMap<QString, QString> &values)
Add key/value pairs to the meta data that is sent to the worker. If a certain key already existed, it will be overridden. @param values the meta data to add @see setMetaData() @see mergeMetaData()
void Job::addMetaData(const QString &key, const QString &value)
Add key/value pair to the meta data that is sent to the worker. @param key the key of the meta data @param value the value of the meta data @see setMetaData() @see mergeMetaData()
[override virtual protected]
bool Job::addSubjob(KJob *job)
Reimplements: KCompositeJob::addSubjob(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 worker.
@param job the subjob to add
[signal]
void Job::connected(KIO::Job *job)
Emitted when the worker successfully connected to the host. There is no guarantee the worker will send this, and this is currently unused (in the applications). @param job the job that emitted this signal
QStringList Job::detailedErrorStrings(const QUrl *reqUrl = nullptr, int method = -1) const
Converts an error code and a non-i18n error message into i18n strings suitable for presentation in a detailed error message box.
@param reqUrl the request URL that generated this error message @param method the method that generated this error message (unimplemented) @return the following strings: title, error + description, causes+solutions
[override virtual protected]
bool Job::doKill()
Reimplements: KJob::doKill().
Abort this job. This kills all subjobs and deletes the job.
[override virtual protected]
bool Job::doResume()
Reimplements: KJob::doResume().
Resume this job @see suspend
[override virtual protected]
bool Job::doSuspend()
Reimplements: KJob::doSuspend().
Suspend this job @see resume
[override virtual]
QString Job::errorString() const
Reimplements: KJob::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", errortext);
Use this to display the error yourself, but for a dialog box use uiDelegate()->showErrorMessage(). Do not call it if error() is not 0. @return 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
void Job::mergeMetaData(const QMap<QString, QString> &values)
Add key/value pairs to the meta data that is sent to the worker. If a certain key already existed, it will remain unchanged. @param values the meta data to merge @see setMetaData() @see addMetaData()
KIO::MetaData Job::metaData() const
Get meta data received from the worker. (Valid when first data is received and/or worker is finished) @return the job's meta data
See also setMetaData().
KIO::MetaData Job::outgoingMetaData() const
@internal. For the scheduler. Do not use.
KIO::Job *Job::parentJob() const
Returns the parent job, if there is one. @return the parent job, or @c nullptr if there is none @see setParentJob
See also setParentJob().
QString Job::queryMetaData(const QString &key)
Query meta data received from the worker. (Valid when first data is received and/or worker is finished) @param key the key of the meta data to retrieve @return the value of the meta data, or QString() if the @p key does not exist
[override virtual protected]
bool Job::removeSubjob(KJob *job)
Reimplements: KCompositeJob::removeSubjob(KJob *job).
Mark a sub job as being done.
Note that this does not terminate the parent job, even if @p job is the last subjob. emitResult must be called to indicate that the job is complete.
@param job the subjob to remove
void Job::setMetaData(const KIO::MetaData &metaData)
Set meta data to be sent to the worker, replacing existing meta data. @param metaData the meta data to set @see addMetaData() @see mergeMetaData()
See also metaData().
void Job::setParentJob(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. @param parentJob the new parent job
See also parentJob().
void Job::setUiDelegateExtension(KIO::JobUiDelegateExtension *extension)
Sets the UI delegate extension to be used by this job. The default UI delegate extension is KIO::defaultJobUiDelegateExtension()
See also uiDelegateExtension().
KIO::JobUiDelegateExtension *Job::uiDelegateExtension() const
Retrieves the UI delegate extension used by this job. @since 5.0
See also setUiDelegateExtension().