open_iA 2025.6
Loading...
Searching...
No Matches
iAJobListView Class Reference

A list of currently running jobs and their progress. More...

#include <iAJobListView.h>

Inheritance diagram for iAJobListView:
[legend]
Collaboration diagram for iAJobListView:
[legend]

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 iAJobListViewget ()
 Access to the single instance of this class (singleton).
 

Detailed Description

A list of currently running jobs and their progress.

Implemented as singleton, since there is only one such list per program instance.

Constructor & Destructor Documentation

◆ ~iAJobListView()

iAJobListView::~iAJobListView ( )

Destructor, automatically cancels any still running jobs.

Even for jobs it's not able to cancel, removes their finish action.

Member Function Documentation

◆ addJob() [1/2]

std::shared_ptr< QObject > iAJobListView::addJob ( QString name,
iAProgress * p,
iAAbortListener * abortListener = nullptr,
std::shared_ptr< iADurationEstimator > estimator = std::shared_ptr<iADurationEstimator>() )
nodiscard

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.

◆ addJob() [2/2]

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

Parameters
namethe name of the job/operation that is run; it is always shown at the top of the list entry, in bold
pthe 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)
ta "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)
abortListeneroptional listener to presses of the abort button; the abort button will be disabled if the default nullptr value is passed here
estimatoran 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.

◆ allJobsDone

void iAJobListView::allJobsDone ( )
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.

◆ get()

iAJobListView * iAJobListView::get ( )
static

Access to the single instance of this class (singleton).

◆ isAnyJobRunning()

bool iAJobListView::isAnyJobRunning ( ) const

Checks whether any jobs are still running or pending to be added.

◆ jobAdded

void iAJobListView::jobAdded ( QObject * o)
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.

◆ newJobSignal

void iAJobListView::newJobSignal ( )
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


The documentation for this class was generated from the following files: