|
| ViewModel (QObject *parent=nullptr) |
| Default constructor with parent.
|
|
| 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 () |
|
|
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) |
|
| objectName |
|
The base class for all viewmodels.
The ViewModel is the primary class of the core library is must be implemented to create custom viewmodels to be shown via the mvvm mechanism. To create a custom viewmodel, simply implement this class and show the viewmodel via one of the show methods. Viewmodels presented that way support automatic injection via injectable properties.
- Attention
- In order for a viewmodel be showble, it must implement an invokable constructor with a single QObject* parameter for the parent. It basically should look like this:
- See also
- CoreApp::show, QTMVVM_INJECT
Definition at line 20 of file viewmodel.h.
QtMvvm::ViewModel::onResult |
( |
quint32 |
requestCode, |
|
|
const QVariant & |
result |
|
) |
| |
|
virtualslot |
Called by the presenter when a result of a showed viewmodel is ready.
- Parameters
-
requestCode | The request code of the show request for the viewmodel that triggered the result |
result | The result passed from the viewmodel |
When showing a child viewmodel via showForResult(), then the result of that show request is reported back via this function. The requestCode is the one that was passed to the showForResult() method, and the result what the viewmodel reported back. If the showed viewmodel emitted resultReady() before beeing destroyed, this value passed to that signal is whats reported as result. If the child viewmodel gets destroyed without ever emitting that signal, this method is still called, but with an invalid QVariant as result.
- See also
- ViewModel::showForResult, ViewModel::resultReady
Reimplemented in QtMvvm::DataSyncViewModel, and QtMvvm::NetworkExchangeViewModel.
template<typename TViewModel >
QtMvvm::ViewModel::show |
( |
const QVariantHash & |
params = {} | ) |
const |
|
inlineprotected |
Show another viewmodel as a child of this one.
- Parameters
-
params | The show parameters to be passed to the created viewmodel |
This method will send a show request to the core app to show a viewmodel of the given type. The parameters are passed to the onInit() method by the presenter after creating and parenting the view. The viewmodel will be shown asynchronously, so this method will return immediatly.
- See also
- ViewModel::showForResult, ViewModel::onInit, CoreApp::show
Definition at line 66 of file viewmodel.h.
template<typename TViewModel >
QtMvvm::ViewModel::showForResult |
( |
quint32 |
requestCode, |
|
|
const QVariantHash & |
params = {} |
|
) |
| const |
|
inlineprotected |
Show another viewmodel as a child of this one and expect its result.
- Parameters
-
requestCode | The code of the show request |
params | The show parameters to be passed to the created viewmodel |
This method will send a show request to the core app to show a viewmodel of the given type. The parameters are passed to the onInit() method by the presenter after creating and parenting the view. The viewmodel will be shown asynchronously, so this method will return immediatly. The viewmodel is show for a result, meaning that a result is reported back via onInit() as soon as the shown viewmodel emits resultReady() or has been destroyed. The request code is passed to the onResult() method in order to identify the show request.
- See also
- ViewModel::show, ViewModel::onInit, ViewModel::resultReady, ViewModel::onResult, CoreApp::show
Definition at line 73 of file viewmodel.h.