KDUpdater::Task Class
class KDUpdater::TaskThe Task class is the base class for all tasks in KDUpdater. More...
Header: | #include <Task> |
Inherits: | QObject |
Inherited By: |
Public Types
enum | Capability { NoCapability, Pausable, Stoppable } |
Public Functions
bool | autoDelete() const |
int | capabilities() const |
int | error() const |
QString | errorString() const |
bool | isFinished() const |
bool | isPaused() const |
bool | isRunning() const |
bool | isStopped() const |
QString | name() const |
int | progressPercent() const |
QString | progressText() const |
void | setAutoDelete(bool autoDelete) |
Public Slots
Signals
void | error(int code, const QString &errorText) |
void | finished() |
void | paused() |
void | progressText(const QString &progressText) |
void | progressValue(int percent) |
void | resumed() |
void | started() |
void | stopped() |
Protected Functions
virtual bool | doPause() = 0 |
virtual bool | doResume() = 0 |
virtual void | doRun() = 0 |
virtual bool | doStop() = 0 |
Detailed Description
This class is the base class for all task classes in KDUpdater. Task is an activity that occupies certain amount of execution time. It can be started, stopped (or canceled), paused and resumed. Tasks can report progress and error messages which an application can show in any sort of UI. The KDUpdater::Task class provides a common interface for dealing with all kinds of tasks in KDUpdater.
User should be careful of these points:
- Task classes can be started only once.
- Instances of this class cannot be created. Only instances of the subclasses can.
Member Type Documentation
enum Task::Capability
This enum value sets the capabilities of the task.
Constant | Value | Description |
---|---|---|
KDUpdater::Task::NoCapability | 0 | The task has no capabilities, so it cannot be paused or stopped. |
KDUpdater::Task::Pausable | 1 | The task can be paused. |
KDUpdater::Task::Stoppable | 2 | The task can be stopped. |
Member Function Documentation
bool Task::autoDelete() const
Returns true
if the task will be automatically deleted.
See also setAutoDelete().
int Task::capabilities() const
Returns the capabilities of the task. It is a combination of one or more Task::Capability flags.
[pure virtual protected]
bool Task::doPause()
Returns true
if the task is paused.
[pure virtual protected]
bool Task::doResume()
Returns true
if the task is resumed.
[pure virtual protected]
void Task::doRun()
Returns 0
if the task is run.
[pure virtual protected]
bool Task::doStop()
Returns true
if the task is stopped.
int Task::error() const
Returns the last reported error code.
[signal]
void Task::error(int code, const QString &errorText)
This signal is emitted to notify an error during the execution of this task.
The code parameter indicates the error that was found during the execution of the task, while the errorText is the human-readable description of the last error that occurred.
Note: Signal error is overloaded in this class. To connect to this signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:
connect(task, QOverload<int, const QString &>::of(&Task::error), [=](int code, const QString &errorText){ /* ... */ });
QString Task::errorString() const
Returns the last reported error message text.
[signal]
void Task::finished()
This signal is emitted when the task has finished.
bool Task::isFinished() const
Returns whether the task has finished or not.
Note: Stopped (or canceled) tasks are not finished tasks.
bool Task::isPaused() const
Returns whether the task is paused or not.
bool Task::isRunning() const
Returns whether the task has started and is running.
bool Task::isStopped() const
Returns whether the task is stopped or not.
Note: Finished tasks are not stopped classes.
QString Task::name() const
Returns the name of the task.
[slot]
void Task::pause()
Pauses the task, provided the task has the Task::Pausable capability.
[signal]
void Task::paused()
This signal is emitted when the task has paused.
int Task::progressPercent() const
Returns the progress in percentage made by this task.
QString Task::progressText() const
Returns a string that describes the progress made by this task as a string.
[signal]
void Task::progressText(const QString &progressText)
This signal is emitted to report the progress made by the task. The progressText parameter represents the progress made in a human-readable form.
Note: Signal progressText is overloaded in this class. To connect to this signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:
connect(task, QOverload<const QString &>::of(&Task::progressText), [=](const QString &progressText){ /* ... */ });
[signal]
void Task::progressValue(int percent)
This signal is emitted to report progress made by the task. The percent parameter gives the progress made as a percentage.
[slot]
void Task::resume()
Resumes the task if it was paused.
[signal]
void Task::resumed()
This signal is emitted when the task has resumed.
[slot]
void Task::run()
Starts the task.
void Task::setAutoDelete(bool autoDelete)
Automatically deletes the task if autoDelete is true
.
See also autoDelete().
[signal]
void Task::started()
This signal is emitted when the task has started.
[slot]
void Task::stop()
Stops the task, provided the task has the Task::Stoppable capability.
Note: Once the task is stopped, it cannot be restarted.
[signal]
void Task::stopped()
This signal is emitted when the task has stopped (or canceled).
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.