QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
Public Slots | Signals | Public Member Functions | Properties | List of all members
QtMvvm::ProgressControl Class Reference

A Helper class to control a generic progress dialog. More...

#include <message.h>

+ Inheritance diagram for QtMvvm::ProgressControl:

Public Slots

void close ()
 Closes the dialog asynchronously. More...
 
void updateLabel (const QString &text)
 Updates the descriptive text displayed in the progress dialog. More...
 
void setAutoDelete (bool autoDelete)
 WRITE accessor for ProgressControl::autoDelete.
 
void setIndeterminate (bool indeterminate)
 WRITE accessor for ProgressControl::indeterminate.
 
void setMinimum (int minimum)
 WRITE accessor for ProgressControl::minimum.
 
void setMaximum (int maximum)
 WRITE accessor for ProgressControl::maximum.
 
void setProgress (int progress)
 WRITE accessor for ProgressControl::progress.
 
void setProgress (double progressPercent)
 WRITE accessor for ProgressControl::progressPercent.
 

Signals

void autoDeleteChanged (bool autoDelete, QPrivateSignal)
 NOTIFY accessor for ProgressControl::autoDelete.
 
void indeterminateChanged (bool indeterminate, QPrivateSignal)
 NOTIFY accessor for ProgressControl::indeterminate.
 
void minimumChanged (int minimum, QPrivateSignal)
 NOTIFY accessor for ProgressControl::minimum.
 
void maximumChanged (int maximum, QPrivateSignal)
 NOTIFY accessor for ProgressControl::maximum.
 
void progressChanged (int progress, QPrivateSignal)
 NOTIFY accessor for ProgressControl::progress.
 
void canceled (QtMvvm::MessageConfig::StandardButton btn, QPrivateSignal)
 Is emitted when the user canceled the dialog. More...
 
void closed (QPrivateSignal)
 Is emitted after the dialog gui has been closed. More...
 
Presenter-Only signals

The following signals should be used by the presenter only, not from the core

void changeLabel (const QString &text, QPrivateSignal)
 Is emitted when the descriptive text in the dialog should be updated. More...
 
void closeRequested (QPrivateSignal)
 Is emitted when a closed was requested from the core code. More...
 

Public Member Functions

 ProgressControl (QObject *parent=nullptr)
 Constructor.
 
bool autoDelete () const
 READ accessor for ProgressControl::autoDelete.
 
bool isIndeterminate () const
 READ accessor for ProgressControl::indeterminate.
 
int minimum () const
 READ accessor for ProgressControl::minimum.
 
int maximum () const
 READ accessor for ProgressControl::maximum.
 
int progress () const
 READ accessor for ProgressControl::progress.
 
Presenter-Only methods

The following methods should be used by the presenter only, not from the core

Q_INVOKABLE void requestCancel (QtMvvm::MessageConfig::StandardButton btn)
 Signals the core app that the user tried to cancel the progress. More...
 
Q_INVOKABLE void notifyClosed ()
 Signals the core app that the dialog was closed. More...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
virtual void * qt_metacast (const char *)
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 

Properties

bool autoDelete
 Specifies whether the object should delete itself after completition. More...
 
bool indeterminate
 Specifies whether the dialog should show an indeterminate or a normal progress. More...
 
int minimum
 The minimum value of the progress bar. More...
 
int maximum
 The maximum value of the progress bar. More...
 
int progress
 The current value of the progress bar. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Detailed Description

A Helper class to control a generic progress dialog.

This class is used together with dialogs of the MessageConfig::TypeProgressDialog type to control the currently displayed progress from the core code. The class is semi thread safe, as it is designed to be used from the core an the gui in parallel.

From the core code, i.e. wherever you created the progress instance (directly or indirectly), you can access:

From the GUI, if you intend to create your own presenter frontend, you can use:

See also
MessageConfig::TypeProgressDialog, QtMvvm::showProgress, QtMvvm::showIndeterminateProgress, QtMvvm::showBusy

Definition at line 264 of file message.h.

Member Function Documentation

◆ canceled

QtMvvm::ProgressControl::canceled ( QtMvvm::MessageConfig::StandardButton  btn,
QPrivateSignal   
)
signal

Is emitted when the user canceled the dialog.

Parameters
btnThe button that was pressed by the user

Cancelling in this case means the user pressed the cancel button (MessageConfig::Cancel) or tried to close the dialog (MessageConfig::NoButton). In both cases, the dialog stays visible*! Your core code must react to the request by connecting this signal and ideally gracefully cancel the operation and then close() the dialog.

You can ignore the signal in case you showed a non cancelable dialog.

Note
For cancel-operations that take a while, it is recommended to tell the user that cancelling is in progress, as after pressing cancel he can't do anything until the dialog is closed.
See also
ProgressControl::close, ProgressControl::requestCancel

◆ changeLabel

QtMvvm::ProgressControl::changeLabel ( const QString text,
QPrivateSignal   
)
signal

Is emitted when the descriptive text in the dialog should be updated.

Parameters
textThe new label text

You should use this text and replace the default descriptive text set by MessageConfig::text

See also
ProgressControl::updateLabel, MessageConfig::text

◆ close

QtMvvm::ProgressControl::close ( )
slot

Closes the dialog asynchronously.

You must use this method from the core code to close the dialog, either after successfully completing your long running operation, or as the result of a canceled operation, in case the user did cancel.

See also
ProgressControl::canceled, ProgressControl::closeRequested

◆ closed

QtMvvm::ProgressControl::closed ( QPrivateSignal  )
signal

Is emitted after the dialog gui has been closed.

See also
ProgressControl::close, ProgressControl::closeRequested, ProgressControl::notifyClosed

◆ closeRequested

QtMvvm::ProgressControl::closeRequested ( QPrivateSignal  )
signal

Is emitted when a closed was requested from the core code.

When the close() method is called from the core app, this signal eventually gets emitted. You must close the dialog immediatly and report that via the notifyClosed() method.

See also
ProgressControl::close, ProgressControl::notifyClosed, ProgressControl::closed

◆ notifyClosed()

QtMvvm::ProgressControl::notifyClosed ( )

Signals the core app that the dialog was closed.

You must call this method as soon as you received a closeRequested() and have actually closed the dialog. You must call both, this method and MessageResult::complete.

See also
ProgressControl::closeRequested, ProgressControl::closed, MessageResult::complete

◆ requestCancel()

QtMvvm::ProgressControl::requestCancel ( QtMvvm::MessageConfig::StandardButton  btn)

Signals the core app that the user tried to cancel the progress.

Parameters
btnThe button that was pressed by the user

Call this method when the user either presses the cancel button (then pass MessageConfig::Cancel) or tried to close the window (pass MessageConfig::NoButton). Your GUI implementation should react to that with disabling the cancel button, but still show the progress, as the core app is to decide whether to accept that cancel request and if yes will eventually close the dialog. Internally, this method will emit canceled() in a thread-safe manner.

Note
Your dialog should only allow cancelling when the MessageConfig has the MessageConfig::Cancel set as a button.
See also
ProgressControl::canceled

◆ updateLabel

QtMvvm::ProgressControl::updateLabel ( const QString text)
slot

Updates the descriptive text displayed in the progress dialog.

The label text refers to the text initially set via MessageConfig::text. With this method, you can easily update this text as your operation commences.

See also
MessageConfig::text, ProgressControl::changeLabel

Property Documentation

◆ autoDelete

QtMvvm::ProgressControl::autoDelete
readwrite

Specifies whether the object should delete itself after completition.

Default: true

If set to true, the progress control will delete itself automatically right after closed() has been emitted.

Accessors
READautoDelete()
WRITEsetAutoDelete()
NOTIFYautoDeleteChanged()
See also
ProgressControl::closed

Definition at line 269 of file message.h.

◆ indeterminate

QtMvvm::ProgressControl::indeterminate
readwrite

Specifies whether the dialog should show an indeterminate or a normal progress.

Default: false

If set to true, the dialog will ignore the minimum, maximum and progress properties and simply show an indeterminate progress. Setting it back to false restores a normal progress bar using these 3.

Accessors
READisIndeterminate()
WRITEsetIndeterminate()
NOTIFYindeterminateChanged()
See also
ProgressControl::minimum, ProgressControl::maximum, ProgressControl::progress

Definition at line 272 of file message.h.

◆ maximum

QtMvvm::ProgressControl::maximum
readwrite

The maximum value of the progress bar.

Default: 100

The progress percentage (as number in [0,1]) is calculated as (progress - minimum)/(maximum - minimum) and that value is used to display a progress. Chaning this property affects the result accordingly.

Accessors
READmaximum()
WRITEsetMaximum()
NOTIFYmaximumChanged()
See also
ProgressControl::minimum, ProgressControl::progress, ProgressControl::indeterminate

Definition at line 276 of file message.h.

◆ minimum

QtMvvm::ProgressControl::minimum
readwrite

The minimum value of the progress bar.

Default: 0

The progress percentage (as number in [0,1]) is calculated as (progress - minimum)/(maximum - minimum) and that value is used to display a progress. Chaning this property affects the result accordingly.

Accessors
READminimum()
WRITEsetMinimum()
NOTIFYminimumChanged()
See also
ProgressControl::maximum, ProgressControl::progress, ProgressControl::indeterminate

Definition at line 274 of file message.h.

◆ progress

QtMvvm::ProgressControl::progress
readwrite

The current value of the progress bar.

Default: -1

The progress percentage (as number in [0,1]) is calculated as (progress - minimum)/(maximum - minimum) and that value is used to display a progress. Chaning this property affects the result accordingly.

Setting it to -1 is a "special value", that means no progress has been set yet, and may or may not lead to a different presentation of that state from the simple minimum.

Accessors
READprogress()
WRITEsetProgress()
NOTIFYprogressChanged()
See also
ProgressControl::minimum, ProgressControl::maximum, ProgressControl::indeterminate

Definition at line 278 of file message.h.


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