1 #ifndef QTMVVM_WIDGETSPRESENTER_H 2 #define QTMVVM_WIDGETSPRESENTER_H 4 #include <QtCore/qobject.h> 5 #include <QtCore/qscopedpointer.h> 7 #include <QtMvvmCore/ipresenter.h> 8 #include <QtMvvmCore/serviceregistry.h> 10 #include <QtWidgets/qwidget.h> 12 #include "QtMvvmWidgets/qtmvvmwidgets_global.h" 13 #include "QtMvvmWidgets/inputwidgetfactory.h" 17 class WidgetsPresenterPrivate;
25 Q_PROPERTY(
InputWidgetFactory* inputWidgetFactory READ inputWidgetFactory WRITE setInputWidgetFactory NOTIFY inputWidgetFactoryChanged)
34 template <typename TPresenter>
35 static
void registerAsPresenter();
38 template <typename TView>
39 static
void registerView();
41 static
void registerView(const
QMetaObject *viewType);
44 template <typename TViewModel, typename TView>
45 static
void registerViewExplicitly();
64 void inputWidgetFactoryChanged(
InputWidgetFactory* inputWidgetFactory, QPrivateSignal);
73 virtual
void showForeground(
QWidget *view) const;
94 template<typename TPresenter>
97 static_assert(std::is_base_of<WidgetsPresenter, TPresenter>::value,
"TPresenter must inherit QtMvvm::WidgetsPresenter!");
101 template<
typename TView>
104 static_assert(std::is_base_of<QWidget, TView>::value,
"TWidget must inherit QWidget!");
107 Q_UNUSED(
new TView(static_cast<ViewModel*>(
nullptr), static_cast<QWidget*>(
nullptr)))
109 registerView(&TView::staticMetaObject);
112 template<
typename TViewModel,
typename TView>
115 static_assert(std::is_base_of<QWidget, TView>::value,
"TWidget must inherit QWidget!");
116 static_assert(std::is_base_of<ViewModel, TViewModel>::value,
"TViewModel must inherit ViewModel!");
119 Q_UNUSED(
new TView(static_cast<ViewModel*>(
nullptr), static_cast<QWidget*>(
nullptr)))
121 registerViewExplicitly(&TViewModel::staticMetaObject, &TView::staticMetaObject);
126 #endif // QTMVVM_WIDGETSPRESENTER_H
A configuration for a simple dialog to be shown from the core code.
The interface for a GUI view presenter.
#define QTMVVM_INJECT(classType, name)
Mark a property for injection.
The base class for all viewmodels.
A result watcher to get the result once a dialog has finished.
The primary namespace of the QtMvvm library.
void registerInterface(DestructionScope scope=DestroyOnAppDestroy, bool weak=false)
Register a service for its interface via the type.
static ServiceRegistry * instance()
Returns the ServiceRegistry singleton instance.