|
open_iA 2024.7
|
A list of currently running jobs and their progress. More...
#include <iAJobListView.h>
Signals | |
| void | allJobsDone () |
| Emitted when all jobs are done. | |
| void | jobAdded (QObject *o) |
| Emitted when a job is added. | |
| void | newJobSignal () |
| Used to link the GUI part of adding a job to the backend part. | |
Public Member Functions | |
| ~iAJobListView () | |
| Destructor, automatically cancels any still running jobs. | |
| std::shared_ptr< QObject > | addJob (QString name, iAProgress *p, iAAbortListener *abortListener=nullptr, std::shared_ptr< iADurationEstimator > estimator=std::shared_ptr< iADurationEstimator >()) |
| Add a job bound to the life time of the returned object. | |
| void | addJob (QString name, iAProgress *p, QObject *t, iAAbortListener *abortListener=nullptr, std::shared_ptr< iADurationEstimator > estimator=std::shared_ptr< iADurationEstimator >()) |
| Typical way of adding a job. | |
| bool | isAnyJobRunning () const |
| Checks whether any jobs are still running or pending to be added. | |
Static Public Member Functions | |
| static iAJobListView * | get () |
| Access to the single instance of this class (singleton). | |
A list of currently running jobs and their progress.
Implemented as singleton, since there is only one such list per program instance.
| iAJobListView::~iAJobListView | ( | ) |
Destructor, automatically cancels any still running jobs.
Even for jobs it's not able to cancel, removes their finish action.
| std::shared_ptr< QObject > iAJobListView::addJob | ( | QString | name, |
| iAProgress * | p, | ||
| iAAbortListener * | abortListener = nullptr, | ||
| std::shared_ptr< iADurationEstimator > | estimator = std::shared_ptr<iADurationEstimator>() ) |
Add a job bound to the life time of the returned object.
useful for situations where no finished signal can be connected (e.g. if a synchronous operation is run) the job will stay in the list as long as somebody holds a reference to the returned QObject; in a typical use case, this method will be called at the start of the method performing the operation, and when the variable holding the returned pointer goes out of scope at the end of the method, the job will be removed automatically from the list. Example:
#include "iAJobListView.h"
#include "iAProgress.h"
...
void myComputeMethod()
{
iAProgress p;
auto jobListHandle = iAJobListView::get()->addJob("Compute Job", &p);
while (computing)
{
// ... do computation
p.emitProgress(percent);
}
} // here, jobListHandle goes out of scope, and the job will be automatically removed from the list!
For comments on the parameters, see the other addJob variant.
| void iAJobListView::addJob | ( | QString | name, |
| iAProgress * | p, | ||
| QObject * | t, | ||
| iAAbortListener * | abortListener = nullptr, | ||
| std::shared_ptr< iADurationEstimator > | estimator = std::shared_ptr<iADurationEstimator>() ) |
Typical way of adding a job.
Specify its name, the progress observer, the task (to whose finished signal the removal of the entry is connected), and optional abort listener and progress estimator
| name | the name of the job/operation that is run; it is always shown at the top of the list entry, in bold |
| p | the progress observer that reports on the job's progress; its progress signal connects to the job entries' progress bar, and the setStatus signal connects to a secondary text information shown below the name of the task (in non-bold font) |
| t | a "handle" of the job - templated so that any type which has a "finished" signal can be passed in; this could be a QThread, or a QFuture as returned by runAsync (see iARunAsync.h) |
| abortListener | optional listener to presses of the abort button; the abort button will be disabled if the default nullptr value is passed here |
| estimator | an estimator for the remaining duration of the job, in case an unusual way of computing the elapsed and/or estimated remaining time is required. By default, a simple estimation based on the current finished percentage and the time elapsed so far will be used. |
|
signal |
Emitted when all jobs are done.
Is used in main window to hide widget as it means that no more jobs are currently running.
|
static |
Access to the single instance of this class (singleton).
| bool iAJobListView::isAnyJobRunning | ( | ) | const |
Checks whether any jobs are still running or pending to be added.
|
signal |
Emitted when a job is added.
Used in main window to show widget, as it indicates that there is at least on currently running job.
|
signal |
Used to link the GUI part of adding a job to the backend part.
Required for decoupling these two to allow adding jobs from a backend thread