KIO::Job Class
class KIO::JobHeader: | #include <KIO/Job> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
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::Job * | parentJob() const |
QString | queryMetaData(const QString &key) |
void | setMetaData(const KIO::MetaData &metaData) |
void | setParentJob(KIO::Job *parentJob) |
void | setUiDelegateExtension(KIO::JobUiDelegateExtension *extension) |
(since 5.0) 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.
values the meta data to add
See also setMetaData() and mergeMetaData().
void Job::addMetaData(const QString &key, const QString &value)
Add key/value pair to the meta data that is sent to the worker.
key the key of the meta data
value the value of the meta data
See also setMetaData() and 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.
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).
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.
reqUrl the request URL that generated this error message
method the method that generated this error message (unimplemented)
Returns 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 also suspend.
[override virtual protected]
bool Job::doSuspend()
Reimplements: KJob::doSuspend().
Suspend this job
See also 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.
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
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.
values the meta data to merge
See also setMetaData() and addMetaData().
KIO::MetaData Job::metaData() const
Get meta data received from the worker. (Valid when first data is received and/or worker is finished)
Returns the job's meta data
See also setMetaData().
KIO::Job *Job::parentJob() const
Returns the parent job, or nullptr
if there is none
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)
key the key of the meta data to retrieve
Returns the value of the meta data, or QString() if the 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 job is the last subjob. emitResult must be called to indicate that the job is complete.
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.
metaData the meta data to set
See also metaData(), addMetaData(), and mergeMetaData().
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.
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().
[since 5.0]
KIO::JobUiDelegateExtension *Job::uiDelegateExtension() const
Retrieves the UI delegate extension used by this job.
This function was introduced in 5.0.
See also setUiDelegateExtension().