The interface for a GUI view presenter. More...
#include <ipresenter.h>
Public Member Functions | |
virtual void | present (ViewModel *viewModel, const QVariantHash ¶ms, QPointer< ViewModel > parent=nullptr)=0 |
Called to present a viewmodel. More... | |
virtual void | showDialog (const MessageConfig &config, MessageResult *result)=0 |
Called to present a dialog via a message config. More... | |
The interface for a GUI view presenter.
This class is what you need to implement if you want to create your own GUI frontend for mvvm. Once you created your custom presenter class, register it as service before calling CoreApp::bootApp() (Or entering the eventloop, in case of automatic startup, like with QTMVVM_REGISTER_CORE_APP)
To register it, it is recommended to use a startup hook like this:
Definition at line 36 of file ipresenter.h.
|
pure virtual |
Called to present a viewmodel.
viewModel | The ViewModel to be presenter |
params | Additional parameters for the viemodel initialization |
parent | An optional parent for the viewmodels view |
PresenterException | When presenting fails for whatever reason |
This method should:
If this method returns it is assumed the presentation was successful. If you throw the exception, presenting has failed, and the app will automatically destroy the viewmodel and handle cleanups and results.
Implemented in QtMvvm::WidgetsPresenter, and QtMvvm::QuickPresenter.
|
pure virtual |
Called to present a dialog via a message config.
config | The configuration for the dialog to be shown |
result | A reference to the object to report results to |
PresenterException | When presenting fails for whatever reason |
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.
Implemented in QtMvvm::WidgetsPresenter, and QtMvvm::QuickPresenter.