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" 19 class ViewModelPrivate;
32 virtual void onInit(
const QVariantHash ¶ms);
34 virtual void onResult(quint32 requestCode,
const QVariant &result);
38 void resultReady(
const QVariant &result);
41 QTMVVM_REVISION_1
void instanceInvoked(
const QVariantHash ¶ms, QPrivateSignal);
45 template <
typename TViewModel>
46 inline void show(
const QVariantHash ¶ms = {})
const;
48 void show(
const char *viewModelName,
const QVariantHash ¶ms = {})
const;
50 void show(
const QMetaObject *viewMetaObject,
const QVariantHash ¶ms = {})
const;
52 template <
typename TViewModel>
53 inline void showForResult(quint32 requestCode,
const QVariantHash ¶ms = {})
const;
55 void showForResult(quint32 requestCode,
const char *viewModelName,
const QVariantHash ¶ms = {})
const;
57 void showForResult(quint32 requestCode,
const QMetaObject *viewMetaObject,
const QVariantHash ¶ms = {})
const;
61 friend class QtMvvm::CoreAppPrivate;
69 #define QTMVVM_SINGLETON Q_CLASSINFO("qtmvvm_singleton", "true") 72 #define QTMVVM_CONTAINER_VM(x) Q_CLASSINFO("qtmvvm_container_viewmodel", #x) 76 template<
typename TViewModel>
79 static_assert(std::is_base_of<ViewModel, TViewModel>::value,
"TViewModel must extend QtMvvm::ViewModel");
80 showImp(&TViewModel::staticMetaObject, params, const_cast<ViewModel*>(
this));
83 template<
typename TViewModel>
86 static_assert(std::is_base_of<ViewModel, TViewModel>::value,
"TViewModel must extend QtMvvm::ViewModel");
87 showImp(&TViewModel::staticMetaObject, params, const_cast<ViewModel*>(
this), requestCode);
94 #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.