6 changed files with 304 additions and 5 deletions
@ -0,0 +1,138 @@ |
|||
/*! |
|||
@class QtMvvm::SettingsViewModel |
|||
|
|||
It's a ready made viewmodel to show a settings dialog. See @ref settings_xml. To show the |
|||
dialog, call show from another ViewModel or the CoreApp: |
|||
|
|||
@code{.cpp} |
|||
show<QtMvvm::SettingsViewModel>(); |
|||
@endcode |
|||
|
|||
TODO link to image page |
|||
*/ |
|||
|
|||
/*! |
|||
@property QtMvvm::SettingsViewModel::canRestoreDefaults |
|||
|
|||
@default{`true`} |
|||
|
|||
Restoring defaults is only allowed if both this property and the attribute of the settings XML |
|||
are true. |
|||
|
|||
@accessors{ |
|||
@readAc{canRestoreDefaults} |
|||
@constantAc |
|||
} |
|||
|
|||
@sa @ref settings_xml_elements_config_attribs |
|||
*/ |
|||
|
|||
/*! |
|||
@property QtMvvm::SettingsViewModel::restoreConfig |
|||
|
|||
@default{`<i>A basic question messagebox</i>`} |
|||
|
|||
If you want to modify the text or options, you can replace the messagebox with another dialog. |
|||
|
|||
@accessors{ |
|||
@readAc{restoreConfig} |
|||
@constantAc |
|||
} |
|||
*/ |
|||
|
|||
/*! |
|||
@var QtMvvm::SettingsViewModel::paramSettings |
|||
|
|||
<b>Value:</b> `"settings"` |
|||
|
|||
@sa SettingsViewModel::showParams |
|||
*/ |
|||
|
|||
/*! |
|||
@var QtMvvm::SettingsViewModel::paramSetupFile |
|||
|
|||
<b>Value:</b> `"setupFile"` |
|||
|
|||
@sa SettingsViewModel::showParams |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::SettingsViewModel::showParams |
|||
|
|||
@param settings The QSettings to operate on. Can be null to use the default settings |
|||
@param setupFile The path to a file to be used to create the settings. Can be empty to use the |
|||
default path |
|||
@return A paramater hash to be passed to ViewModel::show |
|||
|
|||
It's a shortcut to generate parameters for the show methods to show a settings viewmodel. Use |
|||
them as: |
|||
|
|||
@code{.cpp} |
|||
show<QtMvvm::SettingsViewModel>(QtMvvm::SettingsViewModel::showParams(...)); |
|||
@endcode |
|||
|
|||
@note Unless you need to explicitly set the settings or setup file a normal show without any |
|||
parameters will just do fine. |
|||
|
|||
@sa ViewModel::show, SettingsViewModel::paramSettings, SettingsViewModel::paramSetupFile |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::SettingsViewModel::loadSetup |
|||
|
|||
@param frontend The name of the current frontend |
|||
@returns The loaded settings setup |
|||
|
|||
If loading fails an empty setup is returned. Logging is performed internally, so you can just |
|||
proceed without error checking and show an empty settings dialog. |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::SettingsViewModel::loadValue |
|||
|
|||
@param key The full key of the settings entry to be loaded |
|||
@param defaultValue a default value to return in case the value is not found in the settings |
|||
@returns The value found under the given key |
|||
|
|||
You can override this method if you want to support loading and saving settings from a |
|||
different source then the normally used QSettings |
|||
|
|||
@sa SettingsViewModel::saveValue, SettingsViewModel::resetValue |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::SettingsViewModel::saveValue |
|||
|
|||
@param key The full key of the settings entry to be saved |
|||
@param value The value to be stored under the key |
|||
|
|||
You can override this method if you want to support loading and saving settings from a |
|||
different source then the normally used QSettings |
|||
|
|||
@sa SettingsViewModel::loadValue, SettingsViewModel::resetValue |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::SettingsViewModel::resetValue |
|||
|
|||
@param key The full key of the settings entry to be resetted |
|||
|
|||
You can override this method if you want to support loading and saving settings from a |
|||
different source then the normally used QSettings |
|||
|
|||
@sa SettingsViewModel::loadValue, SettingsViewModel::saveValue |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::SettingsViewModel::callAction |
|||
|
|||
@param key The key of the entry that triggered the action |
|||
@param parameters A map with additional parameters for the action call |
|||
|
|||
This method is called by the GUI when an entry with the |
|||
@ref settings_xml_types_action "action" type is pressed by the user. The key is what would |
|||
normally be used as the settings key. The parameters are deduced from the settings XML. See |
|||
the type documentation for more details. |
|||
|
|||
@sa @ref settings_xml_types_action |
|||
*/ |
@ -0,0 +1,117 @@ |
|||
/*! |
|||
@class QtMvvm::ViewModel |
|||
|
|||
The ViewModel is the primary class of the core library is must be implemented to create |
|||
custom viewmodels to be shown via the mvvm mechanism. To create a custom viewmodel, simply |
|||
implement this class and show the viewmodel via one of the show methods. Viewmodels presented |
|||
that way support automatic injection via injectable properties. |
|||
|
|||
@attention In order for a viewmodel be showble, it must implement an invokable constructor |
|||
with a single QObject* parameter for the parent. It basically should look like this: |
|||
@code{.cpp} |
|||
Q_INVOKABLE explicit MyViewModel(QObject *parent = nullptr); |
|||
@endcode |
|||
|
|||
@sa CoreApp::show, #QTMVVM_INJECT |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::onInit |
|||
|
|||
@param params The parameters to initialize the viewmodel with |
|||
|
|||
This method is called by the presenter right after creating the view and reparenting the |
|||
viewmodel to the view. The parameters are the ones that have been passed to the show method |
|||
called to show this viewmodel instance. Reimplement this method if you need to perform |
|||
initializations after beeing assigned to a viewmodel or if you want to support a parametrized |
|||
viewmodel. |
|||
|
|||
@sa ViewModel::show, ViewModel::showForResult, CoreApp::show |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::onResult |
|||
|
|||
@param requestCode The request code of the show request for the viewmodel that triggered the |
|||
result |
|||
@param result The result passed from the viewmodel |
|||
|
|||
When showing a child viewmodel via showForResult(), then the result of that show request is |
|||
reported back via this function. The requestCode is the one that was passed to the |
|||
showForResult() method, and the result what the viewmodel reported back. If the showed |
|||
viewmodel emitted resultReady() before beeing destroyed, this value passed to that signal is |
|||
whats reported as result. If the child viewmodel gets destroyed without ever emitting that |
|||
signal, this method is still called, but with an invalid QVariant as result. |
|||
|
|||
@sa ViewModel::showForResult, ViewModel::resultReady |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::resultReady |
|||
|
|||
@param result The result that should be passed to the parent viewmodel |
|||
|
|||
Viewmodels that have been created via showForResult() must emit this signal to report back the |
|||
result of the show request. Doing so will lead to the onResult() method of the showing |
|||
viewmodel beeing with the emitted result as second parameter. Not emitting this signal before |
|||
the viewmodel gets destroy leads to the onResult() beeing called with an invalid result. |
|||
|
|||
@sa ViewModel::showForResult, ViewModel::onResult |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::show(const QVariantHash &) const |
|||
|
|||
@param params The show parameters to be passed to the created viewmodel |
|||
|
|||
This method will send a show request to the core app to show a viewmodel of the given type. |
|||
The parameters are passed to the onInit() method by the presenter after creating and parenting |
|||
the view. The viewmodel will be shown asynchronously, so this method will return immediatly. |
|||
|
|||
@sa ViewModel::showForResult, ViewModel::onInit, CoreApp::show |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::show(const char *, const QVariantHash &) const |
|||
|
|||
@param viewModelName The name of the viewmodel class to be shown |
|||
@copydetails ViewModel::show(const QVariantHash &) const |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::show(const QMetaObject *, const QVariantHash &) const |
|||
|
|||
@param viewMetaObject The metaobject of the viewmodel class to be shown |
|||
@copydetails ViewModel::show(const QVariantHash &) const |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::showForResult(quint32, const QVariantHash &) const |
|||
|
|||
@param requestCode The code of the show request |
|||
@param params The show parameters to be passed to the created viewmodel |
|||
|
|||
This method will send a show request to the core app to show a viewmodel of the given type. |
|||
The parameters are passed to the onInit() method by the presenter after creating and parenting |
|||
the view. The viewmodel will be shown asynchronously, so this method will return immediatly. |
|||
The viewmodel is show for a result, meaning that a result is reported back via onInit() as |
|||
soon as the shown viewmodel emits resultReady() or has been destroyed. The request code is |
|||
passed to the onResult() method in order to identify the show request. |
|||
|
|||
@sa ViewModel::show, ViewModel::onInit, ViewModel::resultReady, ViewModel::onResult, |
|||
CoreApp::show |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::showForResult(quint32, const char *, const QVariantHash &) const |
|||
|
|||
@param viewModelName The name of the viewmodel class to be shown |
|||
@copydetails ViewModel::showForResult(quint32, const QVariantHash &) const |
|||
*/ |
|||
|
|||
/*! |
|||
@fn QtMvvm::ViewModel::showForResult(quint32, const QMetaObject *, const QVariantHash &) const |
|||
|
|||
@param viewMetaObject The metaobject of the viewmodel class to be shown |
|||
@copydetails ViewModel::showForResult(quint32, const QVariantHash &) const |
|||
*/ |
Loading…
Reference in new issue