1 #ifndef QTMVVM_VIEWMODEL_H 2 #define QTMVVM_VIEWMODEL_H 6 #include <QtCore/qobject.h> 7 #include <QtCore/qscopedpointer.h> 8 #include <QtCore/qvariant.h> 9 #include <QtCore/qpointer.h> 11 #include "QtMvvmCore/qtmvvmcore_global.h" 12 #include "QtMvvmCore/injection.h" 18 class ViewModelPrivate;
31 virtual void onInit(
const QVariantHash ¶ms);
33 virtual void onResult(quint32 requestCode,
const QVariant &result);
37 void resultReady(
const QVariant &result);
41 template <
typename TViewModel>
42 inline void show(
const QVariantHash ¶ms = {})
const;
44 void show(
const char *viewModelName,
const QVariantHash ¶ms = {})
const;
46 void show(
const QMetaObject *viewMetaObject,
const QVariantHash ¶ms = {})
const;
48 template <
typename TViewModel>
49 inline void showForResult(quint32 requestCode,
const QVariantHash ¶ms = {})
const;
51 void showForResult(quint32 requestCode,
const char *viewModelName,
const QVariantHash ¶ms = {})
const;
53 void showForResult(quint32 requestCode,
const QMetaObject *viewMetaObject,
const QVariantHash ¶ms = {})
const;
65 template<
typename TViewModel>
68 static_assert(std::is_base_of<ViewModel, TViewModel>::value,
"TViewModel must extend QtMvvm::ViewModel");
69 showImp(&TViewModel::staticMetaObject, params, const_cast<ViewModel*>(
this));
72 template<
typename TViewModel>
75 static_assert(std::is_base_of<ViewModel, TViewModel>::value,
"TViewModel must extend QtMvvm::ViewModel");
76 showImp(&TViewModel::staticMetaObject, params, const_cast<ViewModel*>(
this), requestCode);
81 #endif // QTMVVM_VIEWMODEL_H
A logicaly application object to drive the mvvm application from the core part.
The base class for all viewmodels.
void showForResult(quint32 requestCode, const QVariantHash ¶ms={}) const
Show another viewmodel as a child of this one and expect its result.
void show(const QVariantHash ¶ms={}) const
Show another viewmodel as a child of this one.
The primary namespace of the QtMvvm library.