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();
61 void inputWidgetFactoryChanged(
InputWidgetFactory* inputWidgetFactory, QPrivateSignal);
70 virtual
void showForeground(
QWidget *view) const;
87 template<typename TPresenter>
90 static_assert(std::is_base_of<WidgetsPresenter, TPresenter>::value,
"TPresenter must inherit QtMvvm::WidgetsPresenter!");
94 template<
typename TView>
97 static_assert(std::is_base_of<QWidget, TView>::value,
"TWidget must inherit QWidget!");
100 Q_UNUSED(
new TView(static_cast<ViewModel*>(
nullptr), static_cast<QWidget*>(
nullptr)))
102 registerView(&TView::staticMetaObject);
105 template<
typename TViewModel,
typename TView>
108 static_assert(std::is_base_of<QWidget, TView>::value,
"TWidget must inherit QWidget!");
109 static_assert(std::is_base_of<ViewModel, TViewModel>::value,
"TViewModel must inherit ViewModel!");
112 Q_UNUSED(
new TView(static_cast<ViewModel*>(
nullptr), static_cast<QWidget*>(
nullptr)))
114 registerViewExplicitly(&TViewModel::staticMetaObject, &TView::staticMetaObject);
119 #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(bool weak=false)
Register a service for its interface via the type.
static ServiceRegistry * instance()
Returns the ServiceRegistry singleton instance.