|
Q_INVOKABLE | QuickPresenter (QObject *parent=nullptr) |
| Invokable constructor.
|
|
void | present (ViewModel *viewModel, const QVariantHash ¶ms, QPointer< ViewModel > parent) override |
| Called to present a viewmodel. More...
|
|
void | showDialog (const MessageConfig &config, MessageResult *result) override |
| Called to present a dialog via a message config. More...
|
|
virtual bool | presentToQml (QObject *qmlPresenter, QObject *viewObject) |
| Is called to present a view to presenter living in QML. More...
|
|
InputViewFactory * | inputViewFactory () const |
| READ accessor for QuickPresenter::inputViewFactory.
|
|
virtual const QMetaObject * | metaObject () const const |
|
virtual void * | qt_metacast (const char *) |
|
virtual int | qt_metacall (QMetaObject::Call, int, void **) |
|
| QObject (QObject *parent) |
|
virtual bool | event (QEvent *e) |
|
virtual bool | eventFilter (QObject *watched, QEvent *event) |
|
QString | objectName () const const |
|
void | setObjectName (const QString &name) |
|
bool | isWidgetType () const const |
|
bool | isWindowType () const const |
|
bool | signalsBlocked () const const |
|
bool | blockSignals (bool block) |
|
QThread * | thread () const const |
|
void | moveToThread (QThread *targetThread) |
|
int | startTimer (int interval, Qt::TimerType timerType) |
|
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
|
void | killTimer (int id) |
|
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
|
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
|
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
|
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
|
const QObjectList & | children () const const |
|
void | setParent (QObject *parent) |
|
void | installEventFilter (QObject *filterObj) |
|
void | removeEventFilter (QObject *obj) |
|
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
|
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
|
bool | disconnect (const QObject *receiver, const char *method) const const |
|
void | dumpObjectTree () |
|
void | dumpObjectInfo () |
|
void | dumpObjectTree () const const |
|
void | dumpObjectInfo () const const |
|
bool | setProperty (const char *name, const QVariant &value) |
|
QVariant | property (const char *name) const const |
|
QList< QByteArray > | dynamicPropertyNames () const const |
|
void | destroyed (QObject *obj) |
|
void | objectNameChanged (const QString &objectName) |
|
QObject * | parent () const const |
|
bool | inherits (const char *className) const const |
|
void | deleteLater () |
|
|
template<typename TPresenter > |
static void | registerAsPresenter () |
| Register a subclass of the QuickPresenter as the active presenter for the CoreApp.
|
|
static void | addViewSearchDir (const QString &dirPath) |
| Adds a directory to search for input views. More...
|
|
template<typename TViewModel > |
static void | registerViewExplicitly (const QUrl &viewUrl) |
| Register a view for a viewmodel to be found by the presenter. More...
|
|
static void | registerViewExplicitly (const QMetaObject *viewModelType, const QUrl &viewUrl) |
| Register a view for a viewmodel to be found by the presenter. More...
|
|
static InputViewFactory * | getInputViewFactory () |
| Returns the internally used input view factory.
|
|
QString | tr (const char *sourceText, const char *disambiguation, int n) |
|
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
|
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
|
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
|
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
|
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
|
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
|
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
|
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
|
bool | disconnect (const QMetaObject::Connection &connection) |
|
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
|
The IPresenter implementation for the quick module.
This presenter is automatically registered as the default presenter for the IPresenter interface with the ServiceRegistry, but as weak service, in order to make it possible to overwrite it.
The class handles all the logic required for presenting Quick Controsl 2 based views. You can extend this class and reimplement it's virtual methods if you need to adjust how certain views or dialogs are presented, or if you want to support custom stuff.
By default, the presenter will use the ":/qtmvvm/views"
directory for finding views. When presenting a viewmodel, the presenter tries to find a view url with a matching name. If the viewmodel is for example named MyViewModel
, then the view must start with My
too. For example it can be named MyView.qml
or MyDialog.qml
- Note
- Implicit detection of views for viewmodels can sometimes lead to ambiguities and thus a wrong view beeing found. In such cases, use registerViewExplicitly() instead.
Definition at line 19 of file quickpresenter.h.
QtMvvm::QuickPresenter::presentMethodIndex |
( |
const QMetaObject * |
presenterMetaObject, |
|
|
QObject * |
viewObject |
|
) |
| |
|
protectedvirtual |
Tries to find the index of a method to present the view object on the presenter.
- Parameters
-
presenterMetaObject | The metobject of the presenter to search a method on |
viewObject | The QML item to be presented on that presenter |
- Returns
- The index of the method from the meta object to be called, or
-1
if no method could be found.
This method is called to find the method. The method must take a single argument, the view to be presented, and return a bool to report whether presenting actually worked or not. The default implementation first checks if the view extends QQuickPopup, and if yes looks for the presentPopup
method. If the view is a normal QQuickItem, the name is analyzed. If the name contains Drawer
, the presentDrawerContent
method is checkd. If the name contains Tab
, the presentTab
method is checkd. If none applies or none was found, the method looks for the presentItem
method. If that one is not found as well, `-1 is returned.
- See also
- QuickPresenter::presentToQml
QtMvvm::QuickPresenter::presentToQml |
( |
QObject * |
qmlPresenter, |
|
|
QObject * |
viewObject |
|
) |
| |
|
virtual |
Is called to present a view to presenter living in QML.
- Parameters
-
qmlPresenter | The presenter to present the view to |
viewObject | The view QML object to be presented |
- Returns
true
if successfully presented, false
if not
Is called from the qml presentation part to actually present a view to another view that takes the role of a presenter, or the actual main presenter.
The default implementation uses presentMethodIndex() to find a method to call, then calls it and returns the result of that method call. If no method was found, false is returned.
- See also
- QuickPresenter::presentMethodIndex
template<typename TViewModel >
QtMvvm::QuickPresenter::registerViewExplicitly |
( |
const QUrl & |
viewUrl | ) |
|
|
static |
Register a view for a viewmodel to be found by the presenter.
- Template Parameters
-
TViewModel | The viewmodel to to register the view for |
- Parameters
-
viewUrl | The QML url register within the presenter. Must be a valid qml component |
The url is registered with the current presenter. It is registered explicitly, which means that whenever the given viewmodel is beeing presented, this exact url will be used. Explicit registration have precedence over implicit ones.
- See also
- QuickPresenter::addViewSearchDir
Definition at line 87 of file quickpresenter.h.
Called to present a dialog via a message config.
- Parameters
-
config | The configuration for the dialog to be shown |
result | A reference to the object to report results to |
- Exceptions
-
This method should create a simple dialog based of the configuration passed to it. Read the MessageConfig for more details on the parameters. The MessageConfig::type and MessageConfig::subType properties are used to determine the kind of dialog to be shown. The other properties are used to configure the dialog.
The result is a reference to a result object to report the result value and the pressed button to. The result is owned by the caller, you must never delete it. Use the special "GUI methods" to report the result and configure a close target.
If this method returns it is assumed the presentation was successful. If you throw the exception, presenting has failed, and the app will automatically complete the message result with the MessageConfig::NoButton constant.
- Note
- If you need to present asynchronous, then you need to perform this step yourself in case the asynchronous presentation failed.
- See also
- IPresenter::present, MessageConfig, MessageResult, MessageResult::complete, MessageResult::setCloseTarget
Implements QtMvvm::IPresenter.