A result watcher to get the result once a dialog has finished. More...
#include <message.h>
Public Slots | |
void | discardMessage () |
Tries to discard the dialog by closing it. More... | |
void | setResult (QVariant result) |
WRITE accessor for MessageResult::result. | |
void | setAutoDelete (bool autoDelete) |
WRITE accessor for MessageResult::autoDelete. | |
Signals | |
void | dialogDone (QtMvvm::MessageConfig::StandardButton button, QPrivateSignal) |
Is emitted as soon as the dialog was completed. More... | |
void | autoDeleteChanged (bool autoDelete, QPrivateSignal) |
NOTIFY accessor for MessageResult::autoDelete. | |
Public Member Functions | |
bool | hasResult () const |
Checks if the dialog has a result. | |
QVariant | result () const |
READ accessor for MessageResult::result. | |
bool | autoDelete () const |
READ accessor for MessageResult::autoDelete. | |
Presenter-Only methods | |
The following methods should be used by the presenter only, not from the core | |
Q_INVOKABLE void | setCloseTarget (QObject *closeObject, const QString &closeMethod) |
Sets an object and a method to be called to close the dialog. More... | |
Q_INVOKABLE void | setCloseTarget (QObject *closeObject, const QMetaMethod &closeMethod) |
Sets an object and a method to be called to close the dialog. More... | |
Q_INVOKABLE void | complete (QtMvvm::MessageConfig::StandardButton button) |
Completes the dialog and tells the result that it is finished. More... | |
Q_INVOKABLE void | complete (QtMvvm::MessageConfig::StandardButton button, const QVariant &result) |
Completes the dialog and tells the result that it is finished. More... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
virtual const QMetaObject * | metaObject () const |
QString | objectName () const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const |
bool | isWindowType () const |
bool | signalsBlocked () const |
bool | blockSignals (bool block) |
QThread * | thread () 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) |
T | findChild (const QString &name, Qt::FindChildOptions options) const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const |
const QObjectList & | children () 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 |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const |
bool | disconnect (const QObject *receiver, const char *method) const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const |
void | dumpObjectInfo () const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const |
QList< QByteArray > | dynamicPropertyNames () const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const |
bool | inherits (const char *className) const |
void | deleteLater () |
Properties | |
QVariant | result |
The result for an input, if the dialog had any. More... | |
bool | autoDelete |
Specifies whether the object should delete itself after completition. 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 | |
QObject * | sender () const |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
bool | isSignalConnected (const QMetaMethod &signal) 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) |
A result watcher to get the result once a dialog has finished.
This class is used to keep track of an active dialog an get the result once it has been completed. You should not create it yourself, is is returned from the core app.
QtMvvm::MessageResult::complete | ( | QtMvvm::MessageConfig::StandardButton | button | ) |
Completes the dialog and tells the result that it is finished.
button | The button that was pressed by the user |
You must use this method from the GUI view code to mark a message result as completed as soon as the user completed the dialog. The button
should be the button the user pressed, or MessageConfig::NoButton if close by another reason. The pressed button should be one that was in the list of buttons specified by the MessageConfig that created the dialog (with the NoButton beeing the only exception).
The method automatically emits the dialogDone() signal and handels self deletion in a threadsafe manner.
|
inline |
Completes the dialog and tells the result that it is finished.
result | The input result to be set as MessageResult::result |
button | The button that was pressed by the user |
You must use this method from the GUI view code to mark a message result as completed as soon as the user completed the dialog. The button
should be the button the user pressed, or MessageConfig::NoButton if close by another reason. The pressed button should be one that was in the list of buttons specified by the MessageConfig that created the dialog (with the NoButton beeing the only exception).
The method automatically emits the dialogDone() signal and handels self deletion in a threadsafe manner.
|
signal |
Is emitted as soon as the dialog was completed.
This is a private signal. It can be connect to as usual, but can only be emitted by the class it belongs to
button | The button that was pressed by the user to complete the dialog |
Is emitted as soon as the dialog was closed with the button that was pressed, or MessageConfig::NoButton when closed another way. If the dialog had an input edit for the user to enter a value, you can retrieve the result via MessageResult::result.
|
slot |
Tries to discard the dialog by closing it.
Calls the closeMethod set by the presenter (if one was set) to close the dialog. Connect to the dialogDone() signal to be notified when the dialog was closed. It is typically emitted with MessageConfig::NoButton when beeing discarded this way.
Sets an object and a method to be called to close the dialog.
closeObject | The object to call the method on |
closeMethod | The method to be called |
Use it from the presenter to register a view and a method on the view to be called to close the view. The closeMethod
should be a paremeterless method signature (e.g. close()
). Not settings a close target means that the dialog cannot be closed from code via discardMessage().
Q_INVOKABLE void QtMvvm::MessageResult::setCloseTarget | ( | QObject * | closeObject, |
const QMetaMethod & | closeMethod | ||
) |
Sets an object and a method to be called to close the dialog.
closeObject | The object to call the method on |
closeMethod | The method to be called |
Use it from the presenter to register a view and a method on the view to be called to close the view. The closeMethod
should be a paremeterless method signature (e.g. close()
). Not settings a close target means that the dialog cannot be closed from code via discardMessage().
|
readwrite |
Specifies whether the object should delete itself after completition.
Default: true
If set to true, the message result will delete itself automatically right after dialogDone() has been emitted. This means it is still safe to access the result in the slots connected to dialogDone(), as long as they are direct connected.
Accessors | |
---|---|
READ | autoDelete() |
WRITE | setAutoDelete() |
NOTIFY | autoDeleteChanged() |
|
readwrite |
The result for an input, if the dialog had any.
Default: Invalid
If the dialog accepts some kind of input, the result is reported via this property. Please note that the property may be changed multiple times with invalid values while the dialog is still open. Only use the result after dialogDone() has been emitted.
Accessors | |
---|---|
READ | result() |
WRITE | setResult() |