QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
Task manager for managing a set of long-running QgsTask tasks. More...
#include <qgstaskmanager.h>
Classes | |
struct | TaskDefinition |
Definition of a task for inclusion in the manager. More... | |
Public Slots | |
void | triggerTask (QgsTask *task) |
Triggers a task, e.g. | |
Signals | |
void | allTasksFinished () |
Emitted when all tasks are complete. | |
void | countActiveTasksChanged (int count) |
Emitted when the number of active tasks changes. | |
void | finalTaskProgressChanged (double progress) |
Will be emitted when only a single task remains to complete and that task has reported a progress change. | |
void | progressChanged (long taskId, double progress) |
Will be emitted when a task reports a progress change. | |
void | statusChanged (long taskId, int status) |
Will be emitted when a task reports a status change. | |
void | taskAboutToBeDeleted (long taskId) |
Emitted when a task is about to be deleted. | |
void | taskAdded (long taskId) |
Emitted when a new task has been added to the manager. | |
void | taskTriggered (QgsTask *task) |
Emitted when a task is triggered. | |
Public Member Functions | |
QgsTaskManager (QObject *parent=nullptr) | |
Constructor for QgsTaskManager. | |
~QgsTaskManager () override | |
QList< QgsTask * > | activeTasks () const |
Returns a list of the active (queued or running) tasks. | |
long | addTask (const TaskDefinition &task, int priority=0) |
Adds a task to the manager, using a full task definition (including dependency handling). | |
long | addTask (QgsTask *task, int priority=0) |
Adds a task to the manager. | |
void | cancelAll () |
Instructs all tasks tracked by the manager to terminate. | |
int | count () const |
Returns the number of tasks tracked by the manager. | |
int | countActiveTasks (bool includeHidden=true) const |
Returns the number of active (queued or running) tasks. | |
QSet< long > | dependencies (long taskId) const |
Returns the set of task IDs on which a task is dependent. | |
bool | dependenciesSatisfied (long taskId) const |
Returns true if all dependencies for the specified task are satisfied. | |
QList< QgsMapLayer * > | dependentLayers (long taskId) const |
Returns a list of layers on which as task is dependent. | |
QgsTask * | task (long id) const |
Returns the task with matching ID. | |
long | taskId (QgsTask *task) const |
Returns the unique task ID corresponding to a task managed by the class. | |
QList< QgsTask * > | tasks () const |
Returns all tasks tracked by the manager. | |
QList< QgsTask * > | tasksDependentOnLayer (QgsMapLayer *layer) const |
Returns a list of tasks which depend on a layer. | |
QThreadPool * | threadPool () |
Returns the threadpool utilized by the task manager. | |
Friends | |
class | TestQgsTaskManager |
Task manager for managing a set of long-running QgsTask tasks.
This class can be created directly, or accessed via QgsApplication::taskManager().
Definition at line 393 of file qgstaskmanager.h.
QgsTaskManager::QgsTaskManager | ( | QObject * | parent = nullptr | ) |
Constructor for QgsTaskManager.
parent | parent QObject |
Definition at line 393 of file qgstaskmanager.cpp.
|
override |
Definition at line 401 of file qgstaskmanager.cpp.
QList< QgsTask * > QgsTaskManager::activeTasks | ( | ) | const |
Returns a list of the active (queued or running) tasks.
Definition at line 666 of file qgstaskmanager.cpp.
long QgsTaskManager::addTask | ( | const TaskDefinition & | task, |
int | priority = 0 |
||
) |
Adds a task to the manager, using a full task definition (including dependency handling).
Ownership of the task is transferred to the manager, and the task manager will be responsible for starting the task. The priority argument can be used to control the run queue's order of execution, with larger numbers taking precedence over lower priority numbers.
Definition at line 431 of file qgstaskmanager.cpp.
long QgsTaskManager::addTask | ( | QgsTask * | task, |
int | priority = 0 |
||
) |
Adds a task to the manager.
Ownership of the task is transferred to the manager, and the task manager will be responsible for starting the task. The priority argument can be used to control the run queue's order of execution, with larger numbers taking precedence over lower priority numbers.
Definition at line 426 of file qgstaskmanager.cpp.
|
signal |
Emitted when all tasks are complete.
void QgsTaskManager::cancelAll | ( | ) |
Instructs all tasks tracked by the manager to terminate.
Individual tasks may take some time to cancel, or may totally ignore this instruction. Calling this does not block but will instead signal the tasks to cancel and then return immediately.
Definition at line 548 of file qgstaskmanager.cpp.
int QgsTaskManager::count | ( | ) | const |
Returns the number of tasks tracked by the manager.
Definition at line 530 of file qgstaskmanager.cpp.
int QgsTaskManager::countActiveTasks | ( | bool | includeHidden = true | ) | const |
Returns the number of active (queued or running) tasks.
The includeHidden argument dictates whether hidden tasks should be shown.
Definition at line 674 of file qgstaskmanager.cpp.
|
signal |
Emitted when the number of active tasks changes.
QSet< long > QgsTaskManager::dependencies | ( | long | taskId | ) | const |
Returns the set of task IDs on which a task is dependent.
Definition at line 582 of file qgstaskmanager.cpp.
bool QgsTaskManager::dependenciesSatisfied | ( | long | taskId | ) | const |
Returns true
if all dependencies for the specified task are satisfied.
Definition at line 562 of file qgstaskmanager.cpp.
QList< QgsMapLayer * > QgsTaskManager::dependentLayers | ( | long | taskId | ) | const |
Returns a list of layers on which as task is dependent.
The task will automatically be canceled if any of these layers are about to be removed.
taskId | task ID |
Definition at line 643 of file qgstaskmanager.cpp.
|
signal |
Will be emitted when only a single task remains to complete and that task has reported a progress change.
progress | percent of progress, from 0.0 - 100.0 |
|
signal |
Will be emitted when a task reports a progress change.
taskId | ID of task |
progress | percent of progress, from 0.0 - 100.0 |
|
signal |
Will be emitted when a task reports a status change.
taskId | ID of task |
status | new task status |
QgsTask * QgsTaskManager::task | ( | long | id | ) | const |
Returns the task with matching ID.
id | task ID |
nullptr
Definition at line 515 of file qgstaskmanager.cpp.
|
signal |
Emitted when a task is about to be deleted.
taskId | ID of task |
|
signal |
Emitted when a new task has been added to the manager.
taskId | ID of task |
long QgsTaskManager::taskId | ( | QgsTask * | task | ) | const |
Returns the unique task ID corresponding to a task managed by the class.
task | task to find |
Definition at line 536 of file qgstaskmanager.cpp.
QList< QgsTask * > QgsTaskManager::tasks | ( | ) | const |
Returns all tasks tracked by the manager.
Definition at line 524 of file qgstaskmanager.cpp.
QList< QgsTask * > QgsTaskManager::tasksDependentOnLayer | ( | QgsMapLayer * | layer | ) | const |
Returns a list of tasks which depend on a layer.
Definition at line 649 of file qgstaskmanager.cpp.
|
signal |
Emitted when a task is triggered.
This occurs when a user clicks on the task from the QGIS GUI, and can be used to show detailed progress reports or re-open a related dialog.
QThreadPool * QgsTaskManager::threadPool | ( | ) |
Returns the threadpool utilized by the task manager.
Definition at line 421 of file qgstaskmanager.cpp.
|
slot |
Triggers a task, e.g.
as a result of a GUI interaction.
Definition at line 694 of file qgstaskmanager.cpp.
|
friend |
Definition at line 659 of file qgstaskmanager.h.