QtMvvm  1.0.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::MessageResult Class Reference

A result watcher to get the result once a dialog has finished. More...

#include <message.h>

+ Inheritance diagram for QtMvvm::MessageResult:

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 QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () 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
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const
 
QList< T > findChildren (const QRegExp &regExp, 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< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () 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
QObjectsender () 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)
 

Detailed Description

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.

See also
CoreApp::showDialog, MessageConfig

Definition at line 172 of file message.h.

Member Function Documentation

◆ complete() [1/2]

QtMvvm::MessageResult::complete ( QtMvvm::MessageConfig::StandardButton  button)

Completes the dialog and tells the result that it is finished.

Parameters
buttonThe button that was pressed by the user
Attention
This method should be used by the presenter only, not from the core

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.

See also
MessageResult::dialogDone, MessageResult::result, MessageResult::autoDelete

◆ complete() [2/2]

QtMvvm::MessageResult::complete ( QtMvvm::MessageConfig::StandardButton  button,
const QVariant result 
)
inline

Completes the dialog and tells the result that it is finished.

Parameters
resultThe input result to be set as MessageResult::result
buttonThe button that was pressed by the user
Attention
This method should be used by the presenter only, not from the core

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.

See also
MessageResult::dialogDone, MessageResult::result, MessageResult::autoDelete

Definition at line 204 of file message.h.

◆ dialogDone

QtMvvm::MessageResult::dialogDone ( QtMvvm::MessageConfig::StandardButton  button,
QPrivateSignal   
)
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

Parameters
buttonThe 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.

Warning
You must always direct connect to this signal, because if the auto deletion is enabled, the result will be deleted right after the signal was emitted (and thus after all direct connected slots have been called). You may use MessageResult::result only in a slot connect to this signal, because auf the reason above, and because before the signal it is considered invalid.
See also
MessageResult::result, MessageResult::complete

◆ discardMessage

QtMvvm::MessageResult::discardMessage ( )
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.

See also
MessageResult::setCloseTarget, MessageResult::dialogDone

◆ setCloseTarget() [1/2]

QtMvvm::MessageResult::setCloseTarget ( QObject closeObject,
const QString closeMethod 
)

Sets an object and a method to be called to close the dialog.

Parameters
closeObjectThe object to call the method on
closeMethodThe method to be called
Attention
This method should be used by the presenter only, not from the core

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().

See also
MessageResult::discardMessage

◆ setCloseTarget() [2/2]

Q_INVOKABLE void QtMvvm::MessageResult::setCloseTarget ( QObject closeObject,
const QMetaMethod closeMethod 
)

Sets an object and a method to be called to close the dialog.

Parameters
closeObjectThe object to call the method on
closeMethodThe method to be called
Attention
This method should be used by the presenter only, not from the core

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().

See also
MessageResult::discardMessage

Property Documentation

◆ autoDelete

QtMvvm::MessageResult::autoDelete
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
READautoDelete()
WRITEsetAutoDelete()
NOTIFYautoDeleteChanged()
See also
MessageResult::complete, MessageResult::dialogDone

Definition at line 179 of file message.h.

◆ result

QtMvvm::MessageResult::result
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
READresult()
WRITEsetResult()
See also
MessageResult::hasResult, MessageResult::complete, MessageResult::dialogDone

Definition at line 177 of file message.h.


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