1 #ifndef QTMVVM_COREAPP_H 2 #define QTMVVM_COREAPP_H 6 #include <QtCore/qobject.h> 7 #include <QtCore/qscopedpointer.h> 8 #include <QtCore/qcoreapplication.h> 11 #include "QtMvvmCore/qtmvvmcore_global.h" 12 #include "QtMvvmCore/viewmodel.h" 13 #include "QtMvvmCore/ipresenter.h" 14 #include "QtMvvmCore/message.h" 32 static void disableAutoBoot();
38 template <
typename TViewModel>
39 static inline void show(
const QVariantHash ¶ms = {},
QPointer<ViewModel> parentViewModel =
nullptr);
41 static void show(
const char *viewModelName,
const QVariantHash ¶ms = {});
43 static void show(
const char *viewModelName,
const QVariantHash ¶ms,
QPointer<ViewModel> parentViewModel);
45 static void show(
const QMetaObject *viewModelMetaObject,
const QVariantHash ¶ms = {});
56 static void registerInputTypeMapping(
const QByteArray &type);
58 static void registerInputTypeMapping(
const QByteArray &type,
int targetType);
69 void appStarted(QPrivateSignal);
73 virtual void performRegistrations();
75 virtual int startApp(
const QStringList &arguments) = 0;
77 virtual void closeApp();
83 friend class QtMvvm::CoreAppPrivate;
86 Q_DECL_DEPRECATED
static void showImp(
const QMetaObject *metaObject,
const QVariantHash ¶ms);
90 template<
typename TViewModel>
93 static_assert(std::is_base_of<ViewModel, TViewModel>::value,
"TViewModel must extend QtMvvm::ViewModel");
94 showImp(&TViewModel::staticMetaObject, params, std::move(parentViewModel));
106 #define QTMVVM_REGISTER_CORE_APP(T) namespace {\ 107 void __setup_ ## T ## _hook() { \ 108 static_assert(std::is_base_of<QtMvvm::CoreApp, T>::value, "QTMVVM_REGISTER_CORE_APP must be used with a class that extends QtMvvm::CoreApp"); \ 109 auto app = new T(nullptr); \ 110 app->registerApp(); \ 113 Q_COREAPP_STARTUP_FUNCTION(__setup_ ## T ## _hook) 116 #define coreApp QtMvvm::CoreApp::instance() 119 #endif // QTMVVM_COREAPP_H
static void show(const QVariantHash ¶ms={}, QPointer< ViewModel > parentViewModel=nullptr)
Show a new ViewModel by its type.
A configuration for a simple dialog to be shown from the core code.
A logicaly application object to drive the mvvm application from the core part.
The interface for a GUI view presenter.
static void registerInputTypeMapping(const QByteArray &type)
Register a type to be used as variant type for the given edit type.
A result watcher to get the result once a dialog has finished.
The primary namespace of the QtMvvm library.