Browse Source

fixed todos, added images

pull/2/head 1.0.0
Skycoder42 7 years ago
parent
commit
b92c15e73b
No known key found for this signature in database GPG Key ID: 8E01AD9EF0578D2B
  1. 3
      README.md
  2. 42
      doc/images.dox
  3. BIN
      doc/images/quick/quick_about.png
  4. BIN
      doc/images/quick/quick_drawer.png
  5. BIN
      doc/images/quick/quick_ds_edit.png
  6. BIN
      doc/images/quick/quick_ds_exchange.png
  7. BIN
      doc/images/quick/quick_ds_export.png
  8. BIN
      doc/images/quick/quick_ds_grant.png
  9. BIN
      doc/images/quick/quick_ds_import.png
  10. BIN
      doc/images/quick/quick_ds_import_trust.png
  11. BIN
      doc/images/quick/quick_ds_main_1.png
  12. BIN
      doc/images/quick/quick_ds_main_2.png
  13. BIN
      doc/images/quick/quick_ds_remote.png
  14. BIN
      doc/images/quick/quick_ds_reset.png
  15. BIN
      doc/images/quick/quick_file.png
  16. BIN
      doc/images/quick/quick_input.png
  17. BIN
      doc/images/quick/quick_main.png
  18. BIN
      doc/images/quick/quick_message.png
  19. BIN
      doc/images/quick/quick_result.png
  20. BIN
      doc/images/quick/quick_settings_1.png
  21. BIN
      doc/images/quick/quick_settings_2.png
  22. BIN
      doc/images/quick/quick_tabs.png
  23. BIN
      doc/images/widgets/widgets_about.png
  24. BIN
      doc/images/widgets/widgets_ds_edit.png
  25. BIN
      doc/images/widgets/widgets_ds_exchange.png
  26. BIN
      doc/images/widgets/widgets_ds_export.png
  27. BIN
      doc/images/widgets/widgets_ds_grant.png
  28. BIN
      doc/images/widgets/widgets_ds_import.png
  29. BIN
      doc/images/widgets/widgets_ds_import_trust.png
  30. BIN
      doc/images/widgets/widgets_ds_main.png
  31. BIN
      doc/images/widgets/widgets_ds_remote.png
  32. BIN
      doc/images/widgets/widgets_ds_reset.png
  33. BIN
      doc/images/widgets/widgets_file.png
  34. BIN
      doc/images/widgets/widgets_input.png
  35. BIN
      doc/images/widgets/widgets_main.png
  36. BIN
      doc/images/widgets/widgets_message.png
  37. BIN
      doc/images/widgets/widgets_result.png
  38. BIN
      doc/images/widgets/widgets_settings.png
  39. BIN
      doc/images/widgets/widgets_tabs.png
  40. 186
      doc/message.dox
  41. 5
      doc/serviceregistry.dox
  42. 2
      doc/settingsviewmodel.dox
  43. 117
      doc/settingsxml.dox
  44. 2
      examples/mvvmcore/SampleCore/SampleCore.pro
  45. 5
      src/imports/mvvmquick/PresentingStackView.qml
  46. 2
      src/mvvmcore/coreapp.cpp
  47. 2
      src/mvvmcore/coreapp.h
  48. 1
      src/mvvmcore/injection.h
  49. 2
      src/mvvmcore/message.cpp
  50. 34
      src/mvvmcore/message.h
  51. 2
      src/mvvmcore/serviceregistry.cpp
  52. 2
      src/mvvmcore/settingsviewmodel.cpp
  53. 2
      src/mvvmcore/settingsviewmodel.h
  54. 19
      src/mvvmdatasynccore/datasyncviewmodel.cpp
  55. 10
      src/mvvmdatasynccore/datasyncviewmodel.h
  56. 16
      src/mvvmdatasynccore/networkexchangeviewmodel.cpp
  57. 10
      src/mvvmdatasynccore/networkexchangeviewmodel.h
  58. 2
      src/mvvmquick/quickpresenter.cpp
  59. 2
      src/mvvmquick/quickpresenter.h
  60. 6
      src/mvvmwidgets/widgetspresenter.cpp
  61. 2
      src/mvvmwidgets/widgetspresenter.h

3
README.md

@ -9,7 +9,7 @@ A mvvm oriented library for Qt, to create Projects for Widgets and Quick Control
![Demo Animation Widgets](./doc/images/sample_basic_widgets.gif) ![Demo Animation Widgets](./doc/images/sample_basic_widgets.gif)
![Demo Animation Quick](./doc/images/sample_basic_quick.gif) ![Demo Animation Quick](./doc/images/sample_basic_quick.gif)
For more images, check the [Images page](https://skycoder42.github.io/QtMvvm/TODO) For more images, check the [Images page](https://skycoder42.github.io/QtMvvm/images_page.html)
## Features ## Features
The main feature of QtMvvm is the seperation between ui and logic. With this library, you can create a core library, containing your application logic, as well as ui controllers (called "ViewModels"), and create multiple ui projects on top of it. This way you can for example provide both, a widgets and a qt quick based application, or create different uis for different devices, without having to code anything twice. The main feature of QtMvvm is the seperation between ui and logic. With this library, you can create a core library, containing your application logic, as well as ui controllers (called "ViewModels"), and create multiple ui projects on top of it. This way you can for example provide both, a widgets and a qt quick based application, or create different uis for different devices, without having to code anything twice.
@ -104,7 +104,6 @@ The following chapters will explain how to create a QtMvvm Project and how to co
- ViewModel - ViewModel
- ServiceRegistry - ServiceRegistry
- IPresenter - IPresenter
- TODO add more
The easiest way to create a QtMvvm Project is to use the provided project template. If you did not install via a package manager or the repository, follow the steps below to add the wizard. The easiest way to create a QtMvvm Project is to use the provided project template. If you did not install via a package manager or the repository, follow the steps below to add the wizard.

42
doc/images.dox

@ -0,0 +1,42 @@
/*!
@page images_page Images page
@brief A collection of images to show off different UIs
@tableofcontents
This page shows of a bunch of images to show off how the mvvm applications can look. It is
presented in the form of tables, always comparing how a view looks on widgets next to a ui with
quick controls 2. All UIs in the same table row have been creating using the same core app and
thus use the same viewmodel.
@section images_page_main Primary QtMvvm modules
These are the images of the sample application build with the main QtMvvm modules. On the left
is the widgets variant, on the right the quick controls 2
Widgets UI | Quick UI
----------------------------------------------------|----------
@image html widgets_main.png "Main View" | @image html quick_main.png "Main View"
@image html widgets_result.png "Result View" | @image html quick_result.png "Result View"
@image html widgets_tabs.png "Tabs View" | @image html quick_tabs.png "Tabs View"
@image html widgets_input.png "Input Dialog" | @image html quick_input.png "Input Dialog"
@image html widgets_file.png "File Dialog" | @image html quick_file.png "File Dialog"
@image html widgets_message.png "Message Box" | @image html quick_message.png "Message Box"
@image html widgets_about.png "About Dialog" | @image html quick_about.png "About Dialog"
@image html widgets_settings.png "Settings View" | @image html quick_settings_1.png "Settings View Page 1" @image html quick_settings_2.png "Settings View Page 2"
@section images_page_datasync Datasync QtMvvm modules
These are the images of the sample application using the datasync mvvm module. On the left
is the widgets variant, on the right the quick controls 2
Widgets UI | Quick UI
--------------------------------------------------------------------|----------
@image html widgets_ds_main.png "Main View" | @image html quick_ds_main_1.png "Main View" @image html quick_ds_main_2.png "Main View"
@image html widgets_ds_edit.png "Edit Identity Dialog" | @image html quick_ds_edit.png "Edit Identity Dialog"
@image html widgets_ds_remote.png "Edit Remote Dialog" | @image html quick_ds_remote.png "Edit Remote View"
@image html widgets_ds_reset.png "Reset Identity Dialog" | @image html quick_ds_reset.png "Reset Identity Dialog"
@image html widgets_ds_exchange.png "Exchange View" | @image html quick_ds_exchange.png "Exchange View"
@image html widgets_ds_import.png "Import Dialog" | @image html widgets_ds_import.png "Import Dialog"
@image html widgets_ds_import_trust.png "Import Trusted Dialog" | @image html quick_ds_import_trust.png "Import Trusted Dialog"
@image html widgets_ds_export.png "Export Dialog" | @image html quick_ds_export.png "Export Dialog"
@image html widgets_ds_grant.png "Grant Dialog" | @image html quick_ds_grant.png "Grant Dialog"
*/

BIN
doc/images/quick/quick_about.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
doc/images/quick/quick_drawer.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
doc/images/quick/quick_ds_edit.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
doc/images/quick/quick_ds_exchange.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
doc/images/quick/quick_ds_export.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
doc/images/quick/quick_ds_grant.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
doc/images/quick/quick_ds_import.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
doc/images/quick/quick_ds_import_trust.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
doc/images/quick/quick_ds_main_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
doc/images/quick/quick_ds_main_2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
doc/images/quick/quick_ds_remote.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
doc/images/quick/quick_ds_reset.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
doc/images/quick/quick_file.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
doc/images/quick/quick_input.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
doc/images/quick/quick_main.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
doc/images/quick/quick_message.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
doc/images/quick/quick_result.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
doc/images/quick/quick_settings_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
doc/images/quick/quick_settings_2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
doc/images/quick/quick_tabs.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
doc/images/widgets/widgets_about.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
doc/images/widgets/widgets_ds_edit.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
doc/images/widgets/widgets_ds_exchange.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
doc/images/widgets/widgets_ds_export.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
doc/images/widgets/widgets_ds_grant.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
doc/images/widgets/widgets_ds_import.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
doc/images/widgets/widgets_ds_import_trust.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
doc/images/widgets/widgets_ds_main.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
doc/images/widgets/widgets_ds_remote.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
doc/images/widgets/widgets_ds_reset.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
doc/images/widgets/widgets_file.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
doc/images/widgets/widgets_input.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
doc/images/widgets/widgets_main.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
doc/images/widgets/widgets_message.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
doc/images/widgets/widgets_result.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
doc/images/widgets/widgets_settings.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
doc/images/widgets/widgets_tabs.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

186
doc/message.dox

@ -212,6 +212,13 @@ message to show:
Critical Error | MessageConfig::SubTypeQuestion Critical Error | MessageConfig::SubTypeQuestion
About Dialog | MessageConfig::SubTypeAbout About Dialog | MessageConfig::SubTypeAbout
The widgets implementation does support a few extra properties for this type:
- modal (bool = true), configure application modality
- windowTitle (QString), the window title
- details (QString), the message box details box
- checkable (bool = false), gives the messagebox a small checkbox
- checkString (QString), the string to display for that checkbox
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeInputDialog, @sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeInputDialog,
MessageConfig::TypeFileDialog MessageConfig::TypeFileDialog
*/ */
@ -484,6 +491,8 @@ MessageConfig::NoButton when beeing discarded this way.
/*! /*!
@fn QtMvvm::MessageResult::dialogDone @fn QtMvvm::MessageResult::dialogDone
@privsig
@param button The button that was pressed by the user to complete the dialog @param button The button that was pressed by the user to complete the dialog
Is emitted as soon as the dialog was closed with the button that was pressed, or Is emitted as soon as the dialog was closed with the button that was pressed, or
@ -638,3 +647,180 @@ mode that is used.
@sa QtMvvm::information, MessageConfig, CoreApp::showDialog @sa QtMvvm::information, MessageConfig, CoreApp::showDialog
*/ */
/*!
@fn QtMvvm::getInput(const QString &, const QString &, const char *, const QVariant &, const QVariantMap &, const QString &, const QString &)
@param title The input dialog title (MessageConfig::title)
@param text A label to describe what to input (MessageConfig::text)
@param inputType The data type of the edit to be used (MessageConfig::subType)
@param defaultValue A default value to initialize the edit with (MessageConfig::defaultValue)
@param viewProperties Additional properties to be passed to the edit (MessageConfig::viewProperties)
@param okText An optional text overwrite for the OK button (MessageConfig::buttonTexts)
@param cancelText An optional text overwrite for the CANCEL button (MessageConfig::buttonTexts)
Shows an input dialog. The kind of edit to use is determined by using the `inputType`. The
view properties will be applied to both, the dialog and the edit.
@sa MessageConfig, CoreApp::showDialog
*/
/*!
@fn QtMvvm::getInput(const QString &, const QString &, const char *, const std::function<void(QVariant)> &, const QVariant &, const QVariantMap &, const QString &, const QString &)
@param onResult A handler to be called when the input dialog has been closed. Reports the
result or an invalid variant in case the input has been canceled.
@copydetails QtMvvm::getInput(const QString &, const QString &, const char *, const QVariant &, const QVariantMap &, const QString &, const QString &)
*/
/*!
@fn QtMvvm::getInput(const QString &, const QString &, const char *, QObject *, const std::function<void(QVariant)> &, const QVariant &, const QVariantMap &, const QString &, const QString &)
@param scope A scope to limit to. `onResult` is only called as long as scope has not been deleted
@copydetails QtMvvm::getInput(const QString &, const QString &, const char *, const std::function<void(QVariant)> &, const QVariant &, const QVariantMap &, const QString &, const QString &)
*/
/*!
@fn QtMvvm::getInput(const QString &, const QString &, const TEdit &, const QVariantMap &, const QString &, const QString &)
@param title The input dialog title (MessageConfig::title)
@param text A label to describe what to input (MessageConfig::text)
@param defaultValue A default value to initialize the edit with (MessageConfig::defaultValue)
@param viewProperties Additional properties to be passed to the edit (MessageConfig::viewProperties)
@param okText An optional text overwrite for the OK button (MessageConfig::buttonTexts)
@param cancelText An optional text overwrite for the CANCEL button (MessageConfig::buttonTexts)
@tparam TEdit The input to type to create an edit for and to get a value of
Shows an input dialog. The kind of edit to use is determined by using the `TEdit` type name.
The view properties will be applied to both, the dialog and the edit.
@sa MessageConfig, CoreApp::showDialog
*/
/*!
@fn QtMvvm::getInput(const QString &, const QString &, const std::function<void(TEdit, bool)> &, const TEdit &, const QVariantMap &, const QString &, const QString &)
@param onResult A handler to be called when the input dialog has been closed. Reports the
result and `true` as second parameter, or a default constructed value and `false` in case the
input has been canceled
@copydetails QtMvvm::getInput(const QString &, const QString &, const TEdit &, const QVariantMap &, const QString &, const QString &)
*/
/*!
@fn QtMvvm::getInput(const QString &, const QString &, QObject *, const std::function<void(TEdit, bool)> &, const TEdit &, const QVariantMap &, const QString &, const QString &)
@param scope A scope to limit to. `onResult` is only called as long as scope has not been deleted
@copydetails QtMvvm::getInput(const QString &, const QString &, const std::function<void(TEdit, bool)> &, const TEdit &, const QVariantMap &, const QString &, const QString &)
*/
/*!
@fn QtMvvm::getExistingDirectory(const QString &, const QUrl &)
@param title The input dialog title (MessageConfig::title)
@param dir The directory URL to start the file dialog from (MessageConfig::defaultValue)
Shows a folder dialog to let the user select an existing directory.
@sa MessageConfig, CoreApp::showDialog
*/
/*!
@fn QtMvvm::getExistingDirectory(const std::function<void(QUrl)> &, const QString &, const QUrl &)
@param onResult A handler to be called when the folder dialog has been closed. Reports the
selected directory URL or an invalid URL in case the input has been canceled.
@copydetails QtMvvm::getExistingDirectory(const QString &, const QUrl &)
*/
/*!
@fn QtMvvm::getExistingDirectory(QObject *, const std::function<void(QUrl)> &, const QString &, const QUrl &)
@param scope A scope to limit to. `onResult` is only called as long as scope has not been deleted
@copydetails QtMvvm::getExistingDirectory(const std::function<void(QUrl)> &, const QString &, const QUrl &)
*/
/*!
@fn QtMvvm::getOpenFile(const QString &, const QStringList &, const QUrl &)
@param title The input dialog title (MessageConfig::title)
@param supportedMimeTypes A list of all allowed mimetypes (MessageConfig::viewProperties, extra property named `mimeTypes`)
@param dir The directory URL to start the file dialog from (MessageConfig::defaultValue)
Shows a file dialog to let the user select an existing file. The selectable files are limited
to the mime types allowed.
@sa MessageConfig, CoreApp::showDialog
*/
/*!
@fn QtMvvm::getOpenFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
@param onResult A handler to be called when the file dialog has been closed. Reports the
selected file URL or an invalid URL in case the input has been canceled.
@copydetails QtMvvm::getOpenFile(const QString &, const QStringList &, const QUrl &)
*/
/*!
@fn QtMvvm::getOpenFile(QObject *, const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
@param scope A scope to limit to. `onResult` is only called as long as scope has not been deleted
@copydetails QtMvvm::getOpenFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
*/
/*!
@fn QtMvvm::getOpenFiles(const QString &, const QStringList &, const QUrl &)
@param title The input dialog title (MessageConfig::title)
@param supportedMimeTypes A list of all allowed mimetypes (MessageConfig::viewProperties, extra property named `mimeTypes`)
@param dir The directory URL to start the file dialog from (MessageConfig::defaultValue)
Shows a file dialog to let the user select multiple existing files. The selectable files are
limited to the mime types allowed.
@sa MessageConfig, CoreApp::showDialog
*/
/*!
@fn QtMvvm::getOpenFiles(const std::function<void(QList<QUrl>)> &, const QString &, const QStringList &, const QUrl &)
@param onResult A handler to be called when the file dialog has been closed. Reports the
selected file URLs in a list or an empty list in case the input has been canceled.
@copydetails QtMvvm::getOpenFiles(const QString &, const QStringList &, const QUrl &)
*/
/*!
@fn QtMvvm::getOpenFiles(QObject *, const std::function<void(QList<QUrl>)> &, const QString &, const QStringList &, const QUrl &)
@param scope A scope to limit to. `onResult` is only called as long as scope has not been deleted
@copydetails QtMvvm::getOpenFiles(const std::function<void(QList<QUrl>)> &, const QString &, const QStringList &, const QUrl &)
*/
/*!
@fn QtMvvm::getSaveFile(const QString &, const QStringList &, const QUrl &)
@param title The input dialog title (MessageConfig::title)
@param supportedMimeTypes A list of all allowed mimetypes (MessageConfig::viewProperties, extra property named `mimeTypes`)
@param dir The directory URL to start the file dialog from (MessageConfig::defaultValue)
Shows a file dialog to let the user select an (non existing) file name for saving. The
selectable files are limited to the mime types allowed.
@sa MessageConfig, CoreApp::showDialog
*/
/*!
@fn QtMvvm::getSaveFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
@param onResult A handler to be called when the file dialog has been closed. Reports the
selected file URL or an invalid URL in case the input has been canceled.
@copydetails QtMvvm::getSaveFile(const QString &, const QStringList &, const QUrl &)
*/
/*!
@fn QtMvvm::getSaveFile(QObject *, const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
@param scope A scope to limit to. `onResult` is only called as long as scope has not been deleted
@copydetails QtMvvm::getSaveFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
*/

5
doc/serviceregistry.dox

@ -6,6 +6,9 @@ with the registry are available for DI. When using lazy initialization, services
can also have dependencies to be injected. When the registry creates them it will can also have dependencies to be injected. When the registry creates them it will
automatically inject them. Automatic DI is also done for ViewModel created by the CoreApp. automatically inject them. Automatic DI is also done for ViewModel created by the CoreApp.
@note If a service has a slot named `qtmvvm_init()` it is called automatically by the registry
right after all dependant services have been injected.
The following example shows how to use DI. The first shows how to use it with a simple, The following example shows how to use DI. The first shows how to use it with a simple,
interface-less service for an already created object: interface-less service for an already created object:
@ -20,6 +23,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void baum(); void baum();
void qtmvvm_init(); //is called by the registry
}; };
// myclass.h // myclass.h
@ -76,6 +80,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void baum() override; void baum() override;
void qtmvvm_init(); //is called by the registry
}; };
// myclass.h // myclass.h

2
doc/settingsviewmodel.dox

@ -8,7 +8,7 @@ dialog, call show from another ViewModel or the CoreApp:
show<QtMvvm::SettingsViewModel>(); show<QtMvvm::SettingsViewModel>();
@endcode @endcode
TODO link to image page @sa @ref images_page
*/ */
/*! /*!

117
doc/settingsxml.dox

@ -2,11 +2,25 @@
@page settings_xml The XML settings format @page settings_xml The XML settings format
@brief Documentation of the XML format used to create settings uis @brief Documentation of the XML format used to create settings uis
@tableofcontents
This format is used to create settings.xml files to be read by the default XML This format is used to create settings.xml files to be read by the default XML
QtMvvm::ISettingsSetupLoader. The files are read via that service and mapped to QtMvvm::ISettingsSetupLoader. The files are read via that service and mapped to
QtMvvm::SettingsElements::Setup. QtMvvm::SettingsElements::Setup.
@tableofcontents @section settings_xml_translator Translations
All the settings files you have can be easily translated via a standard ts/qm file. In order for
this to work, all you have to do is add the following lines to your pro file:
@code{.pro}
QTMVVM_TS_SETTINGS += settings.xml
_never_true_condition: SOURCES += $$files($$PWD/.ts-dummy/*)
PRE_TARGETDEPS += qtmvvm-tsgen #optional
@endcode
This will automatically generate a dummy cpp file in the `.ts-dummy` folder for each file
added to the `QTMVVM_TS_SETTINGS` variable. These files contain dummy code that will then be
read by lupdate automatically and added to all your ts files.
@section settings_xml_elements Elements @section settings_xml_elements Elements
The possible elements of such a file The possible elements of such a file
@ -18,10 +32,10 @@ The `<SettingsConfig>` element must be the root Element of the XML document and
QtMvvm::SettingsElements::Setup. QtMvvm::SettingsElements::Setup.
@subsubsection settings_xml_elements_config_attribs Attributes @subsubsection settings_xml_elements_config_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
----------------|-------|-----------|------------- ----------------|-------|-----------|---------------|-------------
allowSearch | bool | `true` | @copybrief QtMvvm::SettingsElements::Setup::allowSearch allowSearch | bool | `true` | no | @copybrief QtMvvm::SettingsElements::Setup::allowSearch
allowRestore | bool | `true` | @copybrief QtMvvm::SettingsElements::Setup::allowRestore allowRestore | bool | `true` | no | @copybrief QtMvvm::SettingsElements::Setup::allowRestore
@subsubsection settings_xml_elements_config_elements Content @subsubsection settings_xml_elements_config_elements Content
Can be an arbitrary number of Elements from the following list. However, only one type of Can be an arbitrary number of Elements from the following list. However, only one type of
@ -40,13 +54,13 @@ be of the same type as well:
The `<Category>` element is mapped to the QtMvvm::SettingsElements::Category. The `<Category>` element is mapped to the QtMvvm::SettingsElements::Category.
@subsubsection settings_xml_elements_category_attribs Attributes @subsubsection settings_xml_elements_category_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
------------|---------------------------------------|---------------------------------------------------|------------- ------------|---------------------------------------|---------------------------------------------------|---------------|-------------
title | string | `"General Settings"` | @copybrief QtMvvm::SettingsElements::Category::title title | string | `"General Settings"` | yes | @copybrief QtMvvm::SettingsElements::Category::title
icon | url | `"qrc:/de/skycoder42/qtmvvm/icons/settings.svg"` | @copybrief QtMvvm::SettingsElements::Category::icon icon | url | `"qrc:/de/skycoder42/qtmvvm/icons/settings.svg"` | no | @copybrief QtMvvm::SettingsElements::Category::icon
tooltip | string | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Category::tooltip tooltip | string | <i>Empty</i> | yes | @copybrief QtMvvm::SettingsElements::Category::tooltip
frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Category::frontends frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Category::frontends
selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Category::selectors selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Category::selectors
@subsubsection settings_xml_elements_category_elements Content @subsubsection settings_xml_elements_category_elements Content
Can be an arbitrary number of Elements from the following list. However, only one type of Can be an arbitrary number of Elements from the following list. However, only one type of
@ -64,13 +78,13 @@ be of the same type as well:
The `<Section>` element is mapped to the QtMvvm::SettingsElements::Section. The `<Section>` element is mapped to the QtMvvm::SettingsElements::Section.
@subsubsection settings_xml_elements_section_attribs Attributes @subsubsection settings_xml_elements_section_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
------------|---------------------------------------|---------------|------------- ------------|---------------------------------------|---------------|---------------|-------------
title | string | `"General"` | @copybrief QtMvvm::SettingsElements::Section::title title | string | `"General"` | yes | @copybrief QtMvvm::SettingsElements::Section::title
icon | url | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Section::icon icon | url | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Section::icon
tooltip | string | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Section::tooltip tooltip | string | <i>Empty</i> | yes | @copybrief QtMvvm::SettingsElements::Section::tooltip
frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Section::frontends frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Section::frontends
selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Section::selectors selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Section::selectors
@subsubsection settings_xml_elements_section_elements Content @subsubsection settings_xml_elements_section_elements Content
Can be an arbitrary number of Elements from the following list. However, only one type of Can be an arbitrary number of Elements from the following list. However, only one type of
@ -91,12 +105,12 @@ of organizing them into subgroups. If the title is empty, the tooltip is ignored
The descriptors however still apply. The descriptors however still apply.
@subsubsection settings_xml_elements_group_attribs Attributes @subsubsection settings_xml_elements_group_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
------------|---------------------------------------|---------------|------------- ------------|---------------------------------------|---------------|---------------|-------------
title | string | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Group::title title | string | <i>Empty</i> | yes | @copybrief QtMvvm::SettingsElements::Group::title
tooltip | string | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Group::tooltip tooltip | string | <i>Empty</i> | yes | @copybrief QtMvvm::SettingsElements::Group::tooltip
frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Group::frontends frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Group::frontends
selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Group::selectors selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Group::selectors
@subsubsection settings_xml_elements_group_elements Content @subsubsection settings_xml_elements_group_elements Content
Can be an arbitrary number of Elements from the following list. However, only one type of Can be an arbitrary number of Elements from the following list. However, only one type of
@ -112,15 +126,15 @@ be of the same type as well:
The `<Entry>` element is mapped to the QtMvvm::SettingsElements::Entry. The `<Entry>` element is mapped to the QtMvvm::SettingsElements::Entry.
@subsubsection settings_xml_elements_entry_attribs Attributes @subsubsection settings_xml_elements_entry_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
----------------|---------------------------------------|-------------------|------------- ----------------|---------------------------------------|-------------------|---------------|-------------
key | string | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Entry::key key | string | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Entry::key
type | @ref settings_xml_types_type | `"QString"` | @copybrief QtMvvm::SettingsElements::Entry::type type | @ref settings_xml_types_type | `"QString"` | no | @copybrief QtMvvm::SettingsElements::Entry::type
title | string | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Entry::title title | string | <i>Empty</i> | yes | @copybrief QtMvvm::SettingsElements::Entry::title
tooltip | string | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Entry::tooltip tooltip | string | <i>Empty</i> | yes | @copybrief QtMvvm::SettingsElements::Entry::tooltip
defaultValue | variant | <i>Invalid</i> | @copybrief QtMvvm::SettingsElements::Entry::defaultValue defaultValue | variant | <i>Invalid</i> | yes | @copybrief QtMvvm::SettingsElements::Entry::defaultValue
frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Entry::frontends frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Entry::frontends
selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | @copybrief QtMvvm::SettingsElements::Entry::selectors selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Entry::selectors
@subsubsection settings_xml_elements_entry_elements Content @subsubsection settings_xml_elements_entry_elements Content
Can be an arbitrary number of Elements from the following list. They can be mixed and in any Can be an arbitrary number of Elements from the following list. They can be mixed and in any
@ -133,7 +147,7 @@ order
The `<SearchKey>` Element is converted to a string added to the The `<SearchKey>` Element is converted to a string added to the
QtMvvm::SettingsElements::Entry::searchKeys property. A searchkey can only be a child of an QtMvvm::SettingsElements::Entry::searchKeys property. A searchkey can only be a child of an
Entry, and all the keys are merged to a list. It's a leaf element and must contain the string Entry, and all the keys are merged to a list. It's a leaf element and must contain the string
that becomes the search key that becomes the search key. The contens of the search key will be translated.
@subsection settings_xml_elements_property Property @subsection settings_xml_elements_property Property
The `<Property>` Element is an XML description of a generic QVariant property. Each property The `<Property>` Element is an XML description of a generic QVariant property. Each property
@ -142,11 +156,12 @@ parent element. Properties can be children of entries, as well as properties and
long as for the last two their type is `object` long as for the last two their type is `object`
@subsubsection settings_xml_elements_property_attribs Attributes @subsubsection settings_xml_elements_property_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
--------|-------------------------------|-------------------|------------- --------|-------------------------------|-------------------|---------------|-------------
key | string | <i>Required</i> | The key of the property key | string | <i>Required</i> | no | The key of the property
type | @ref settings_xml_types_type | <i>Required</i> | The type of the properties value type | @ref settings_xml_types_type | <i>Required</i> | no | The type of the properties value
ts | bool | `false` | Specify whether the properties value should be translated. Does not apply to `list` or `object` types ts | bool | `false` | no | Specify whether the properties value (content) should be translated. Does not apply to `list` or `object` types
@subsubsection settings_xml_elements_property_elements Content @subsubsection settings_xml_elements_property_elements Content
The content depend on the `type` attribute. The following tables shows which type leads The content depend on the `type` attribute. The following tables shows which type leads
@ -165,10 +180,10 @@ QVariant values. Each element can be of a different type, but typically they all
same. same.
@subsubsection settings_xml_elements_element_attribs Attributes @subsubsection settings_xml_elements_element_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
--------|-------------------------------|-------------------|------------- --------|-------------------------------|-------------------|---------------|-------------
type | @ref settings_xml_types_type | <i>Required</i> | The type of the list element type | @ref settings_xml_types_type | <i>Required</i> | no | The type of the list element
ts | bool | `false` | Specify whether the element value should be translated. Does not apply to `list` or `object` types ts | bool | `false` | no | Specify whether the element value (content) should be translated. Does not apply to `list` or `object` types
@subsubsection settings_xml_elements_element_elements Content @subsubsection settings_xml_elements_element_elements Content
The content depend on the `type` attribute. The following tables shows which type leads The content depend on the `type` attribute. The following tables shows which type leads
@ -190,9 +205,9 @@ element must be a `<Group>` element (Each element that support includes as one c
marked as primary). It is possible to specify an include element in another included document. marked as primary). It is possible to specify an include element in another included document.
@subsubsection settings_xml_elements_include_attribs Attributes @subsubsection settings_xml_elements_include_attribs Attributes
Name | Type | Default | Description Name | Type | Default | Translated | Description
------------|-------|-----------|------------- ------------|-------|-----------|---------------|-------------
optional | bool | `false` | An optional include. If the file cannot be found it is skipped instead of aborting with an error optional | bool | `false` | no | An optional include. If the file cannot be found it is skipped instead of aborting with an error
@subsubsection settings_xml_elements_include_elements Content @subsubsection settings_xml_elements_include_elements Content
The content of the include element must be a path to an XML file to be read as include. If the The content of the include element must be a path to an XML file to be read as include. If the
@ -278,6 +293,10 @@ will trigger QtMvvm::SettingsViewModel::callAction. The Entries `key` attribute
the first parameter to the method. The parameters can be specified by adding a `<Property>` the first parameter to the method. The parameters can be specified by adding a `<Property>`
to the entry with the key `args` and the type `object`. The property of this object are the to the entry with the key `args` and the type `object`. The property of this object are the
elements of the map passed as the second parameter. elements of the map passed as the second parameter.
*/
//! TODO add small sample code snippits? @section settings_xml_sample Sample settings XML file
The following code block is a sample settings XML file. It is the same that is beeing used in
the example application.
@include settings.xml
*/

2
examples/mvvmcore/SampleCore/SampleCore.pro

@ -26,7 +26,7 @@ RESOURCES += \
sample_core.qrc sample_core.qrc
QTMVVM_TS_SETTINGS += settings.xml QTMVVM_TS_SETTINGS += settings.xml
_never_true_condition: SOURCES += $$files($$PWD/.ts-dummy/*) #TODO document _never_true_condition: SOURCES += $$files($$PWD/.ts-dummy/*)
PRE_TARGETDEPS += qtmvvm-tsgen PRE_TARGETDEPS += qtmvvm-tsgen
TRANSLATIONS += samplecore_de.ts TRANSLATIONS += samplecore_de.ts

5
src/imports/mvvmquick/PresentingStackView.qml

@ -78,10 +78,13 @@ StackView {
* *
* Use this method in your main presenter to present items via this sub presenter. * Use this method in your main presenter to present items via this sub presenter.
* *
* If the presented item has a boolean property named `presentAsRoot`, the item will
* replace all contents on the stack instead of beeing pushed on it.
*
* @sa QtMvvmApp::presentItem, @ref QtQuick.Item "Item" * @sa QtMvvmApp::presentItem, @ref QtQuick.Item "Item"
*/ */
function presentItem(item) { function presentItem(item) {
if(item.presentAsRoot) { //TODO document if(typeof item.presentAsRoot == "boolean" && item.presentAsRoot) {
if(safeReplace(null, item)) if(safeReplace(null, item))
return true; return true;
else else

2
src/mvvmcore/coreapp.cpp

@ -90,7 +90,7 @@ void CoreApp::bootApp()
if(res == EXIT_SUCCESS) { if(res == EXIT_SUCCESS) {
connect(qApp, &QCoreApplication::aboutToQuit, connect(qApp, &QCoreApplication::aboutToQuit,
this, &CoreApp::closeApp); this, &CoreApp::closeApp);
emit appStarted(); emit appStarted({});
} else } else
qApp->exit(res); qApp->exit(res);
} }

2
src/mvvmcore/coreapp.h

@ -51,7 +51,7 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
//! Is emitted once the app has successfully started //! Is emitted once the app has successfully started
void appStarted(); void appStarted(QPrivateSignal);
protected: protected:
//! Is called as part of the app registration, before any view setups //! Is called as part of the app registration, before any view setups

1
src/mvvmcore/injection.h

@ -6,7 +6,6 @@
//! The primary namespace of the QtMvvm library //! The primary namespace of the QtMvvm library
namespace QtMvvm { namespace QtMvvm {
//TODO sa in service registry
//! Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE //! Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE
template <typename TInterface> template <typename TInterface>
inline void registerInterfaceConverter() { inline void registerInterfaceConverter() {

2
src/mvvmcore/message.cpp

@ -265,7 +265,7 @@ void MessageResult::setAutoDelete(bool autoDelete)
return; return;
d->autoDelete = autoDelete; d->autoDelete = autoDelete;
emit autoDeleteChanged(autoDelete); emit autoDeleteChanged(autoDelete, {});
} }
// ------------- Private Implementation ------------- // ------------- Private Implementation -------------

34
src/mvvmcore/message.h

@ -218,10 +218,10 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
//! Is emitted as soon as the dialog was completed //! Is emitted as soon as the dialog was completed
void dialogDone(QtMvvm::MessageConfig::StandardButton button); void dialogDone(QtMvvm::MessageConfig::StandardButton button, QPrivateSignal);
//! @notifyAcFn{MessageResult::autoDelete} //! @notifyAcFn{MessageResult::autoDelete}
void autoDeleteChanged(bool autoDelete); void autoDeleteChanged(bool autoDelete, QPrivateSignal);
private: private:
QScopedPointer<MessageResultPrivate> d; QScopedPointer<MessageResultPrivate> d;
@ -321,7 +321,7 @@ Q_MVVMCORE_EXPORT MessageResult *getInput(const QString &title,
const QVariantMap &viewProperties = {}, const QVariantMap &viewProperties = {},
const QString &okText = {}, const QString &okText = {},
const QString &cancelText = {}); const QString &cancelText = {});
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const char *, const std::function<void(QVariant)> &, const QVariant &, const QVariantMap &, const QString &, const QString &) //! @copybrief QtMvvm::getInput(const QString &, const QString &, const char *, const std::function<void(QVariant)> &, const QVariant &, const QVariantMap &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void getInput(const QString &title, Q_MVVMCORE_EXPORT void getInput(const QString &title,
const QString &text, const QString &text,
const char *inputType, const char *inputType,
@ -331,7 +331,7 @@ Q_MVVMCORE_EXPORT void getInput(const QString &title,
const QVariantMap &viewProperties = {}, const QVariantMap &viewProperties = {},
const QString &okText = {}, const QString &okText = {},
const QString &cancelText = {}); const QString &cancelText = {});
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const char *, const QVariant &, const QVariantMap &, const QString &, const QString &) //! @copybrief QtMvvm::getInput(const QString &, const QString &, const char *, const QVariant &, const QVariantMap &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void getInput(const QString &title, Q_MVVMCORE_EXPORT void getInput(const QString &title,
const QString &text, const QString &text,
const char *inputType, const char *inputType,
@ -351,7 +351,7 @@ inline MessageResult *getInput(const QString &title,
const QString &cancelText = {}) { const QString &cancelText = {}) {
return getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), QVariant::fromValue(defaultValue), viewProperties, okText, cancelText); return getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), QVariant::fromValue(defaultValue), viewProperties, okText, cancelText);
} }
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const std::function<void(TEdit, bool)> &, const TEdit &, const QVariantMap &, const QString &, const QString &) //! @copybrief QtMvvm::getInput(const QString &, const QString &, const std::function<void(TEdit, bool)> &, const TEdit &, const QVariantMap &, const QString &, const QString &)
template <typename TEdit> template <typename TEdit>
inline void getInput(const QString &title, inline void getInput(const QString &title,
const QString &text, const QString &text,
@ -365,7 +365,7 @@ inline void getInput(const QString &title,
onResult(v.template value<TEdit>(), v.isValid()); onResult(v.template value<TEdit>(), v.isValid());
}, QVariant::fromValue(defaultValue), viewProperties, okText, cancelText); }, QVariant::fromValue(defaultValue), viewProperties, okText, cancelText);
} }
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const TEdit &, const QVariantMap &, const QString &, const QString &) //! @copybrief QtMvvm::getInput(const QString &, const QString &, const TEdit &, const QVariantMap &, const QString &, const QString &)
template <typename TEdit> template <typename TEdit>
inline void getInput(const QString &title, inline void getInput(const QString &title,
const QString &text, const QString &text,
@ -387,59 +387,59 @@ inline void getInput(const QString &title,
//! @brief A shortcut to show a file dialog to select an existing directory //! @brief A shortcut to show a file dialog to select an existing directory
Q_MVVMCORE_EXPORT MessageResult *getExistingDirectory(const QString &title = {}, Q_MVVMCORE_EXPORT MessageResult *getExistingDirectory(const QString &title = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getExistingDirectory(const std::function<void(QUrl)> &, const QString &, const QUrl &) //! @copybrief QtMvvm::getExistingDirectory(const std::function<void(QUrl)> &, const QString &, const QUrl &)
Q_MVVMCORE_EXPORT void getExistingDirectory(QObject *scope, Q_MVVMCORE_EXPORT void getExistingDirectory(QObject *scope,
const std::function<void(QUrl)> &onResult, const std::function<void(QUrl)> &onResult,
const QString &title = {}, const QString &title = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getExistingDirectory(const QString &, const QUrl &) //! @copybrief QtMvvm::getExistingDirectory(const QString &, const QUrl &)
Q_MVVMCORE_EXPORT void getExistingDirectory(const std::function<void(QUrl)> &onResult, Q_MVVMCORE_EXPORT void getExistingDirectory(const std::function<void(QUrl)> &onResult,
const QString &title = {}, const QString &title = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @brief A shortcut to show a file dialog to select an existing file //! A shortcut to show a file dialog to select an existing file
Q_MVVMCORE_EXPORT MessageResult *getOpenFile(const QString &title = {}, Q_MVVMCORE_EXPORT MessageResult *getOpenFile(const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &) //! @copybrief QtMvvm::getOpenFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFile(QObject *scope, Q_MVVMCORE_EXPORT void getOpenFile(QObject *scope,
const std::function<void(QUrl)> &onResult, const std::function<void(QUrl)> &onResult,
const QString &title = {}, const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFile(const QString &, const QStringList &, const QUrl &) //! @copybrief QtMvvm::getOpenFile(const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFile(const std::function<void(QUrl)> &onResult, Q_MVVMCORE_EXPORT void getOpenFile(const std::function<void(QUrl)> &onResult,
const QString &title = {}, const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @brief A shortcut to show a file dialog to select multiple existing files //! A shortcut to show a file dialog to select multiple existing files
Q_MVVMCORE_EXPORT MessageResult *getOpenFiles(const QString &title = {}, Q_MVVMCORE_EXPORT MessageResult *getOpenFiles(const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFiles(const std::function<void(QList<QUrl>)> &, const QString &, const QStringList &, const QUrl &) //! @copybrief QtMvvm::getOpenFiles(const std::function<void(QList<QUrl>)> &, const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFiles(QObject *scope, Q_MVVMCORE_EXPORT void getOpenFiles(QObject *scope,
const std::function<void(QList<QUrl>)> &onResult, const std::function<void(QList<QUrl>)> &onResult,
const QString &title = {}, const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFiles(const QString &, const QStringList &, const QUrl &) //! @copybrief QtMvvm::getOpenFiles(const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFiles(const std::function<void(QList<QUrl>)> &onResult, Q_MVVMCORE_EXPORT void getOpenFiles(const std::function<void(QList<QUrl>)> &onResult,
const QString &title = {}, const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @brief A shortcut to show a file dialog to select a new file for saving //! A shortcut to show a file dialog to select a new file for saving
Q_MVVMCORE_EXPORT MessageResult *getSaveFile(const QString &title = {}, Q_MVVMCORE_EXPORT MessageResult *getSaveFile(const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getSaveFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &) //! @copybrief QtMvvm::getSaveFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getSaveFile(QObject *scope, Q_MVVMCORE_EXPORT void getSaveFile(QObject *scope,
const std::function<void(QUrl)> &onResult, const std::function<void(QUrl)> &onResult,
const QString &title = {}, const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},
const QUrl &dir = {}); const QUrl &dir = {});
//! @copydoc QtMvvm::getSaveFile(const QString &, const QStringList &, const QUrl &) //! @copybrief QtMvvm::getSaveFile(const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getSaveFile(const std::function<void(QUrl)> &onResult, Q_MVVMCORE_EXPORT void getSaveFile(const std::function<void(QUrl)> &onResult,
const QString &title = {}, const QString &title = {},
const QStringList &supportedMimeTypes = {}, const QStringList &supportedMimeTypes = {},

2
src/mvvmcore/serviceregistry.cpp

@ -202,7 +202,7 @@ ServiceRegistryPrivate::MetaServiceInfo::MetaServiceInfo(const QMetaObject *meta
QObject *ServiceRegistryPrivate::MetaServiceInfo::construct(ServiceRegistryPrivate *d) const QObject *ServiceRegistryPrivate::MetaServiceInfo::construct(ServiceRegistryPrivate *d) const
{ {
auto instance = d->constructInjectedLocked(metaObject, nullptr); //services are created without a parent auto instance = d->constructInjectedLocked(metaObject, nullptr); //services are created without a parent
auto initMethod = metaObject->indexOfMethod("qtmvvm_init()"); //TODO document auto initMethod = metaObject->indexOfMethod("qtmvvm_init()");
if(initMethod != -1) { if(initMethod != -1) {
auto method = metaObject->method(initMethod); auto method = metaObject->method(initMethod);
method.invoke(instance); method.invoke(instance);

2
src/mvvmcore/settingsviewmodel.cpp

@ -87,7 +87,7 @@ void SettingsViewModel::setSettingsSetupLoader(ISettingsSetupLoader *settingsSet
return; return;
d->setupLoader = settingsSetupLoader; d->setupLoader = settingsSetupLoader;
emit settingsSetupLoaderChanged(d->setupLoader); emit settingsSetupLoaderChanged(d->setupLoader, {});
} }
void SettingsViewModel::onInit(const QVariantHash &params) void SettingsViewModel::onInit(const QVariantHash &params)

2
src/mvvmcore/settingsviewmodel.h

@ -69,7 +69,7 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
//! @notifyAcFn{SettingsViewModel::settingsSetupLoader} //! @notifyAcFn{SettingsViewModel::settingsSetupLoader}
void settingsSetupLoaderChanged(QtMvvm::ISettingsSetupLoader* settingsSetupLoader); void settingsSetupLoaderChanged(QtMvvm::ISettingsSetupLoader* settingsSetupLoader, QPrivateSignal);
//! Is emitted when the initialization has been completed and the viewmodel is ready for loading settings //! Is emitted when the initialization has been completed and the viewmodel is ready for loading settings
void beginLoadSetup(); void beginLoadSetup();

19
src/mvvmdatasynccore/datasyncviewmodel.cpp

@ -25,6 +25,11 @@
#undef logCritical #undef logCritical
#include <QtMvvmCore/private/qtmvvm_logging_p.h> #include <QtMvvmCore/private/qtmvvm_logging_p.h>
#define PSIG(x) [this]() { \
(this->*(x))(QPrivateSignal{}); \
}
using namespace QtMvvm; using namespace QtMvvm;
using namespace QtDataSync; using namespace QtDataSync;
@ -271,7 +276,7 @@ void DataSyncViewModel::setColorMap(DataSyncViewModel::ColorMap colorMap)
return; return;
d->colorMap = colorMap; d->colorMap = colorMap;
emit colorMapChanged(d->colorMap); emit colorMapChanged(d->colorMap, {});
} }
void DataSyncViewModel::resetColorMap() void DataSyncViewModel::resetColorMap()
@ -283,7 +288,7 @@ void DataSyncViewModel::resetColorMap()
d->colorMap.insert(SyncManager::Synchronized, Qt::darkGreen); d->colorMap.insert(SyncManager::Synchronized, Qt::darkGreen);
d->colorMap.insert(SyncManager::Error, Qt::darkRed); d->colorMap.insert(SyncManager::Error, Qt::darkRed);
d->colorMap.insert(SyncManager::Disconnected, Qt::darkYellow); d->colorMap.insert(SyncManager::Disconnected, Qt::darkYellow);
emit colorMapChanged(d->colorMap); emit colorMapChanged(d->colorMap, {});
} }
void DataSyncViewModel::showImportDialog(LoginRequest request) void DataSyncViewModel::showImportDialog(LoginRequest request)
@ -353,9 +358,9 @@ void DataSyncViewModel::onInit(const QVariantHash &params)
//sync manager //sync manager
connect(d->syncManager, &SyncManager::syncStateChanged, connect(d->syncManager, &SyncManager::syncStateChanged,
this, &DataSyncViewModel::statusStringChanged); this, PSIG(&DataSyncViewModel::statusStringChanged));
connect(d->syncManager, &SyncManager::lastErrorChanged, connect(d->syncManager, &SyncManager::lastErrorChanged,
this, &DataSyncViewModel::statusStringChanged); this, PSIG(&DataSyncViewModel::statusStringChanged));
//account manager //account manager
connect(d->accountManager, &AccountManager::loginRequested, connect(d->accountManager, &AccountManager::loginRequested,
@ -371,9 +376,9 @@ void DataSyncViewModel::onInit(const QVariantHash &params)
d->accountModel->setup(d->accountManager, d->syncManager); d->accountModel->setup(d->accountManager, d->syncManager);
d->sortedModel->sort(0); d->sortedModel->sort(0);
emit syncManagerChanged(d->syncManager); emit syncManagerChanged(d->syncManager, {});
emit accountManagerChanged(d->accountManager); emit accountManagerChanged(d->accountManager, {});
emit ready(); emit ready({});
} catch(SetupDoesNotExistException &e) { } catch(SetupDoesNotExistException &e) {
logCritical() << "Failed to init DataSyncViewModel with error:" logCritical() << "Failed to init DataSyncViewModel with error:"
<< e.what(); << e.what();

10
src/mvvmdatasynccore/datasyncviewmodel.h

@ -98,16 +98,16 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
//! @notifyAcFn{DataSyncViewModel::syncManager} //! @notifyAcFn{DataSyncViewModel::syncManager}
void syncManagerChanged(QtDataSync::SyncManager* syncManager); void syncManagerChanged(QtDataSync::SyncManager* syncManager, QPrivateSignal);
//! @notifyAcFn{DataSyncViewModel::accountManager} //! @notifyAcFn{DataSyncViewModel::accountManager}
void accountManagerChanged(QtDataSync::AccountManager* accountManager); void accountManagerChanged(QtDataSync::AccountManager* accountManager, QPrivateSignal);
//! @notifyAcFn{DataSyncViewModel::colorMap} //! @notifyAcFn{DataSyncViewModel::colorMap}
void colorMapChanged(ColorMap colorMap); void colorMapChanged(ColorMap colorMap, QPrivateSignal);
//! @notifyAcFn{DataSyncViewModel::statusString} //! @notifyAcFn{DataSyncViewModel::statusString}
void statusStringChanged(); void statusStringChanged(QPrivateSignal);
//! Is emitted as soon as all the datasync managers have been initialized //! Is emitted as soon as all the datasync managers have been initialized
void ready(); void ready(QPrivateSignal);
protected: protected:
void onInit(const QVariantHash &params) override; void onInit(const QVariantHash &params) override;

16
src/mvvmdatasynccore/networkexchangeviewmodel.cpp

@ -14,6 +14,10 @@
#undef logCritical #undef logCritical
#include <QtMvvmCore/private/qtmvvm_logging_p.h> #include <QtMvvmCore/private/qtmvvm_logging_p.h>
#define PSIGARG(x, argt) [this](argt arg) { \
(this->*(x))(arg, QPrivateSignal{}); \
}
using namespace QtMvvm; using namespace QtMvvm;
using namespace QtDataSync; using namespace QtDataSync;
@ -98,7 +102,7 @@ void NetworkExchangeViewModel::setPort(quint16 port)
return; return;
d->port = port; d->port = port;
emit portChanged(d->port); emit portChanged(d->port, {});
} }
void NetworkExchangeViewModel::setDeviceName(QString deviceName) void NetworkExchangeViewModel::setDeviceName(QString deviceName)
@ -132,20 +136,20 @@ void NetworkExchangeViewModel::onInit(const QVariantHash &params)
} }
connect(d->exchangeManager->accountManager(), &AccountManager::deviceNameChanged, connect(d->exchangeManager->accountManager(), &AccountManager::deviceNameChanged,
this, &NetworkExchangeViewModel::deviceNameChanged); this, PSIGARG(&NetworkExchangeViewModel::deviceNameChanged, QString));
connect(d->exchangeManager, &UserExchangeManager::userDataReceived, connect(d->exchangeManager, &UserExchangeManager::userDataReceived,
this, &NetworkExchangeViewModel::newUserData); this, &NetworkExchangeViewModel::newUserData);
connect(d->exchangeManager, &UserExchangeManager::exchangeError, connect(d->exchangeManager, &UserExchangeManager::exchangeError,
this, &NetworkExchangeViewModel::exchangeError); this, &NetworkExchangeViewModel::exchangeError);
connect(d->exchangeManager, &UserExchangeManager::activeChanged, connect(d->exchangeManager, &UserExchangeManager::activeChanged,
this, &NetworkExchangeViewModel::activeChanged); this, PSIGARG(&NetworkExchangeViewModel::activeChanged, bool));
emit userExchangeManagerChanged(d->exchangeManager); emit userExchangeManagerChanged(d->exchangeManager, {});
emit deviceNameChanged(deviceName()); emit deviceNameChanged(deviceName(), {});
d->deviceModel->setup(d->exchangeManager); d->deviceModel->setup(d->exchangeManager);
d->sortedModel->sort(0); d->sortedModel->sort(0);
emit ready(); emit ready({});
} catch(SetupDoesNotExistException &e) { } catch(SetupDoesNotExistException &e) {
logCritical() << "Failed to init DataSyncViewModel with error:" logCritical() << "Failed to init DataSyncViewModel with error:"
<< e.what(); << e.what();

10
src/mvvmdatasynccore/networkexchangeviewmodel.h

@ -74,16 +74,16 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
//! Is emitted as soon as all the user exchange manager has been initialized //! Is emitted as soon as all the user exchange manager has been initialized
void ready(); void ready(QPrivateSignal);
//! @notifyAcFn{NetworkExchangeViewModel::userExchangeManager} //! @notifyAcFn{NetworkExchangeViewModel::userExchangeManager}
void userExchangeManagerChanged(QtDataSync::UserExchangeManager* userExchangeManager); void userExchangeManagerChanged(QtDataSync::UserExchangeManager* userExchangeManager, QPrivateSignal);
//! @notifyAcFn{NetworkExchangeViewModel::port} //! @notifyAcFn{NetworkExchangeViewModel::port}
void portChanged(quint16 port); void portChanged(quint16 port, QPrivateSignal);
//! @notifyAcFn{NetworkExchangeViewModel::deviceName} //! @notifyAcFn{NetworkExchangeViewModel::deviceName}
void deviceNameChanged(QString deviceName); void deviceNameChanged(QString deviceName, QPrivateSignal);
//! @notifyAcFn{NetworkExchangeViewModel::active} //! @notifyAcFn{NetworkExchangeViewModel::active}
void activeChanged(bool active); void activeChanged(bool active, QPrivateSignal);
protected: protected:
void onInit(const QVariantHash &params) override; void onInit(const QVariantHash &params) override;

2
src/mvvmquick/quickpresenter.cpp

@ -100,7 +100,7 @@ InputViewFactory *QuickPresenter::inputViewFactory() const
void QuickPresenter::setInputViewFactory(InputViewFactory *inputViewFactory) void QuickPresenter::setInputViewFactory(InputViewFactory *inputViewFactory)
{ {
d->inputViewFactory = inputViewFactory; d->inputViewFactory = inputViewFactory;
emit inputViewFactoryChanged(inputViewFactory); emit inputViewFactoryChanged(inputViewFactory, {});
} }
QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType) QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType)

2
src/mvvmquick/quickpresenter.h

@ -57,7 +57,7 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
//! @notifyAcFn{QuickPresenter::inputViewFactory} //! @notifyAcFn{QuickPresenter::inputViewFactory}
void inputViewFactoryChanged(InputViewFactory* inputViewFactory); void inputViewFactoryChanged(InputViewFactory* inputViewFactory, QPrivateSignal);
protected: protected:
//! Is called to find the URL of the view to be used for the given viewmodel //! Is called to find the URL of the view to be used for the given viewmodel

6
src/mvvmwidgets/widgetspresenter.cpp

@ -124,7 +124,7 @@ InputWidgetFactory *WidgetsPresenter::inputWidgetFactory() const
void WidgetsPresenter::setInputWidgetFactory(InputWidgetFactory *inputWidgetFactory) void WidgetsPresenter::setInputWidgetFactory(InputWidgetFactory *inputWidgetFactory)
{ {
d->inputViewFactory = inputWidgetFactory; d->inputViewFactory = inputWidgetFactory;
emit inputWidgetFactoryChanged(inputWidgetFactory); emit inputWidgetFactoryChanged(inputWidgetFactory, {});
} }
const QMetaObject *WidgetsPresenter::findWidgetMetaObject(const QMetaObject *viewModelMetaObject) const QMetaObject *WidgetsPresenter::findWidgetMetaObject(const QMetaObject *viewModelMetaObject)
@ -254,7 +254,7 @@ void WidgetsPresenter::presentMessageBox(const MessageConfig &config, QPointer<M
if(!mIcon.isNull()) if(!mIcon.isNull())
info.icon = mIcon; info.icon = mIcon;
qtHelp = config.viewProperties().value(QStringLiteral("addQtVersion"), true).toBool(); qtHelp = config.viewProperties().value(QStringLiteral("addQtVersion"), true).toBool();
qtHelp = config.viewProperties().value(QStringLiteral("showQtHelp"), qtHelp).toBool();//TODO document too qtHelp = config.viewProperties().value(QStringLiteral("showQtHelp"), qtHelp).toBool();
} }
info.escapeButton = QMessageBox::NoButton; //use no button for non button closes info.escapeButton = QMessageBox::NoButton; //use no button for non button closes
@ -271,7 +271,7 @@ void WidgetsPresenter::presentMessageBox(const MessageConfig &config, QPointer<M
//special properties //special properties
QSharedPointer<bool> checked; QSharedPointer<bool> checked;
auto props = config.viewProperties(); //TODO document all these auto props = config.viewProperties();
if(!props.value(QStringLiteral("modal"), false).toBool()) if(!props.value(QStringLiteral("modal"), false).toBool())
info.parent = QApplication::activeWindow(); info.parent = QApplication::activeWindow();
if(props.contains(QStringLiteral("windowTitle"))) if(props.contains(QStringLiteral("windowTitle")))

2
src/mvvmwidgets/widgetspresenter.h

@ -58,7 +58,7 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
//! @notifyAcFn{WidgetsPresenter::inputWidgetFactory} //! @notifyAcFn{WidgetsPresenter::inputWidgetFactory}
void inputWidgetFactoryChanged(InputWidgetFactory* inputWidgetFactory); void inputWidgetFactoryChanged(InputWidgetFactory* inputWidgetFactory, QPrivateSignal);
protected: protected:
//! Is called to find the meta object of the view to be used for the given viewmodel //! Is called to find the meta object of the view to be used for the given viewmodel

Loading…
Cancel
Save