Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit dda9335

Browse files
committed
updated widgets doc
1 parent 5c54297 commit dda9335

17 files changed

+315
-42
lines changed

doc/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ PROJECT_NUMBER = 1.0.0
4444
# for a project that appears at the top of each page and should give viewer a
4545
# quick idea about the purpose of the project. Keep the description short.
4646

47-
PROJECT_BRIEF = "Project desciption here"
47+
PROJECT_BRIEF = "A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel"
4848

4949
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
5050
# in the documentation. The maximum height of the logo should not exceed 55

doc/doc.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ OTHER_FILES += Doxyfile \
66
../README.md \
77
*.dox \
88
snippets/*.cpp \
9-
images/*
9+
images/* \
10+
gh_header.html
1011

1112
system($$QMAKE_MKDIR $$shell_quote($$shell_path($$OUT_PWD/qtmvvm)))
1213

doc/gh_header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</tr>
5252
</tbody>
5353
</table>
54-
<a style="float: right;" target="_blank" href="https://github.com/Skycoder42/QtDataSync">
54+
<a style="float: right;" target="_blank" href="https://github.com/Skycoder42/QtMvvm">
5555
<img style="padding: 10px;" src="$relpath^GitHub_Logo.png"/>
5656
</a>
5757
</div>

doc/inputwidgetfactory.dox

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*!
2+
@class QtMvvm::InputWidgetFactory
3+
4+
The factory is used by the WidgetsPresenter to create input widgets for various types. This is
5+
used to for example create the edits of input dialogs or for the edit fields of a
6+
SettingsDialog.
7+
8+
@sa WidgetsPresenter, WidgetsPresenter::inputWidgetFactory, MessageConfig::TypeInputDialog,
9+
QtMvvm::getInput, SettingsViewModel
10+
*/
11+
12+
/*!
13+
@fn QtMvvm::InputWidgetFactory::createInput
14+
15+
@param type The input type to create a widget for
16+
@param parent The parent widget for the created widget
17+
@param viewProperties A map with extra properties to be set on the edit
18+
@returns A newly created widget suitable for editing input of the given type
19+
@throws PresenterException In case no widget could be found or created for the given type
20+
21+
The factory first checks if the given type is registered as alias. If yes, it continues with
22+
the aliased type. Then it checks for a widget registered as simple widget exists for the given
23+
type and uses that one if present. If no simple widget is set the default mapping for type to
24+
widgets is used (See MessageConfig::TypeInputDialog for a full table of supported types). If no
25+
widget can be found for a type, an exception is thrown.
26+
27+
The viewProperties are used to setup the created widget by settings them as properties on the
28+
widget. For every key-value-pair in the map, QObject::setProperty is called on the widget to
29+
set the property.
30+
31+
@sa MessageConfig::TypeInputDialog, InputWidgetFactory::addSimpleWidget,
32+
InputWidgetFactory::addAlias
33+
*/
34+
35+
/*!
36+
@fn QtMvvm::InputWidgetFactory::addSimpleWidget()
37+
38+
@tparam TType The type to add a widget for
39+
@tparam TWidget The type of the widget to provide for that type
40+
41+
The TWidget type must extend QWidget and have a constructor that takes a single `QWidget*` as
42+
argument.
43+
44+
@sa MessageConfig::createInput, InputWidgetFactory::addAlias
45+
*/
46+
47+
/*!
48+
@fn QtMvvm::InputWidgetFactory::addSimpleWidget(const QByteArray &, const std::function<QWidget*(QWidget*)> &)
49+
50+
@param type The type to add a widget for
51+
@param creator A function that creates a new instance of a widget for the given type
52+
53+
The `QWidget*` argument of the creator function must be used as the parent of the created
54+
widget that is returned by the function.
55+
56+
@sa MessageConfig::createInput, InputWidgetFactory::addAlias
57+
*/
58+
59+
/*!
60+
@fn QtMvvm::InputWidgetFactory::addAlias()
61+
62+
@tparam TAliasType The type to add as a new alias
63+
@tparam TTargetType The type the alias should be translated to
64+
65+
If an input widget for the alias type is requested, one of the target type is created instead.
66+
67+
@sa MessageConfig::createInput, InputWidgetFactory::addSimpleWidget
68+
*/
69+
70+
/*!
71+
@fn QtMvvm::InputWidgetFactory::addAlias(const QByteArray &, const QByteArray &)
72+
73+
@param alias The type to add as a new alias
74+
@param targetType The type the alias should be translated to
75+
76+
If an input widget for the alias type is requested, one of the target type is created instead.
77+
78+
@sa MessageConfig::createInput, InputWidgetFactory::addSimpleWidget
79+
*/

doc/ipresenter.dox

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ void myPresenterInit()
1414
}
1515
Q_COREAPP_STARTUP_FUNCTION(myPresenterInit)
1616
@endcode
17+
18+
@sa #QtMvvm_IPresenterIid
1719
*/
1820

1921
/*!

doc/ipresentingview.dox

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*!
2+
@class QtMvvm::IPresentingView
3+
4+
If a the viewmodel of a view that was presented by the WidgetsPresenter as used as the parent
5+
view of another viewmodel, the parent view can implement this interface in order to be used
6+
as presenter for the view of the child viewmodel. In such a case, if the parent view implements
7+
this interface, the tryPresent() method is called to try the presentation of the child view
8+
9+
@sa #QtMvvm_IPresentingViewIid, WidgetsPresenter
10+
*/
11+
12+
/*!
13+
@fn QtMvvm::IPresentingView::tryPresent
14+
15+
@param view The view that is tryed to be presented
16+
@returns `true` if successfully presented, `false` if not
17+
18+
If true is returned, the presenter assumes presentation was successful and thus completes. If
19+
false is returned, it resumes presenting the view normally, just as if that interface was never
20+
implemented
21+
*/

doc/message.dox

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,22 @@ via QVariant can be used as input value. However, only for the most common types
228228
edit views exist. In case you want to use types not present in the list below, you need to
229229
create edit views yourself
230230

231-
Type | Widgets edit | Quick edit
232-
--------------------|-------------------------------|------------
233-
bool | QCheckBox | CheckBox
234-
switch | -/- | Switch
235-
QString, string | QLineEdit | TextField
236-
int | QSpinBox | SpinBox
237-
double, number | QDoubleSpinBox | DoubleSpinBox
238-
QDate | QDateEdit | -/-
239-
QTime | QTimeEdit | -/-
240-
QDateTime, date | QDateTimeEdit | -/-
241-
QFont | QFontComboBox | FontEdit
242-
QKeySequence | QKeySequenceEdit | -/-
243-
QUrl, url | QLineEdit with QUrlValidator | UrlField
244-
selection, list | QComboBox | ListEdit
245-
radiolist | -/- | RadioListEdit
231+
Type | Widgets edit | Quick edit
232+
------------------------|-------------------------------|------------
233+
bool | QCheckBox | CheckBox
234+
switch | -/- | Switch
235+
QString, string | QLineEdit | TextField
236+
int | QSpinBox | SpinBox
237+
double, number | QDoubleSpinBox | DoubleSpinBox
238+
QDate | QDateEdit | -/-
239+
QTime | QTimeEdit | -/-
240+
QDateTime, date | QDateTimeEdit | -/-
241+
QFont | QFontComboBox | FontEdit
242+
QKeySequence | QKeySequenceEdit | -/-
243+
QUrl, url | QLineEdit with QUrlValidator | UrlField
244+
selection, list | QComboBox | ListEdit
245+
radiolist | -/- | RadioListEdit
246+
action (settings only) | QPushButton | ItemDelegate
246247

247248
The following types have special properties as well:
248249

doc/settingsviewmodel.dox

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Restoring defaults is only allowed if both this property and the attribute of th
2020
are true.
2121

2222
@accessors{
23-
@readAc{canRestoreDefaults}
23+
@readAc{canRestoreDefaults()}
2424
@constantAc
2525
}
2626

@@ -30,16 +30,34 @@ are true.
3030
/*!
3131
@property QtMvvm::SettingsViewModel::restoreConfig
3232

33-
@default{`<i>A basic question messagebox</i>`}
33+
@default{<i>A basic question messagebox</i>}
3434

3535
If you want to modify the text or options, you can replace the messagebox with another dialog.
3636

3737
@accessors{
38-
@readAc{restoreConfig}
38+
@readAc{restoreConfig()}
3939
@constantAc
4040
}
4141
*/
4242

43+
/*!
44+
@property QtMvvm::SettingsViewModel::settingsSetupLoader
45+
46+
@default{<i>Injected</i>}
47+
48+
Do not set this property yourself. It is automatically injected when showing the viewmodel.
49+
You can use the ServiceRegistry::registerInterface if you need to use a loader different from
50+
the default one.
51+
52+
@accessors{
53+
@readAc{settingsSetupLoader()}
54+
@writeAc{setSettingsSetupLoader()}
55+
@notifyAc{settingsSetupLoaderChanged()}
56+
}
57+
58+
@sa #QTMVVM_INJECT
59+
*/
60+
4361
/*!
4462
@var QtMvvm::SettingsViewModel::paramSettings
4563

doc/widgetspresenter.dox

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*!
2+
@class QtMvvm::WidgetsPresenter
3+
4+
This presenter is automatically registered as the default presenter for the IPresenter
5+
interface with the ServiceRegistry, but as weak service, in order to make it possible to
6+
overwrite it.
7+
8+
The class handles all the logic required for presenting widget based views. You can extend
9+
this class and reimplement it's virtual methods if you need to adjust how certain views or
10+
dialogs are presented, or if you want to support custom stuff
11+
*/
12+
13+
/*!
14+
@property QtMvvm::WidgetsPresenter::inputWidgetFactory
15+
16+
@default{<i>Injected</i>}
17+
18+
Do not set this property yourself. It is automatically injected when showing the viewmodel.
19+
You can use the ServiceRegistry::registerInterface if you need to use a factory different from
20+
the default one.
21+
22+
@accessors{
23+
@readAc{inputWidgetFactory()}
24+
@writeAc{setInputWidgetFactory()}
25+
}
26+
27+
@sa #QTMVVM_INJECT
28+
*/
29+
30+
/*!
31+
@fn QtMvvm::WidgetsPresenter::registerView()
32+
33+
@tparam TView The widget type register within the presenter. Must extend QWidget
34+
35+
The widget is registered with the current presenter. It is registered implicitly, which means
36+
that it's name will be used to find it when a viewmodel is presented for it. Thus, it must be
37+
named after the viewmodel. If the viewmodel is for example named `MyViewModel`, then the view
38+
must start with `My` too. For example it can be named `MyWidget`, `MyDialog`, `MyWindow`,
39+
`MyView`, ...
40+
41+
@note Implicit detection of views for viewmodels can sometimes lead to ambiguities and thus a
42+
wrong view beeing found. In such cases, use registerViewExplicitly() instead.
43+
44+
@sa WidgetsPresenter::registerViewExplicitly
45+
*/
46+
47+
/*!
48+
@fn QtMvvm::WidgetsPresenter::registerView(const QMetaObject *)
49+
50+
@param viewType The widget type register within the presenter. Must extend QWidget
51+
52+
The widget is registered with the current presenter. It is registered implicitly, which means
53+
that it's name will be used to find it when a viewmodel is presented for it. Thus, it must be
54+
named after the viewmodel. If the viewmodel is for example named `MyViewModel`, then the view
55+
must start with `My` too. For example it can be named `MyWidget`, `MyDialog`, `MyWindow`,
56+
`MyView`, ...
57+
58+
@note Implicit detection of views for viewmodels can sometimes lead to ambiguities and thus a
59+
wrong view beeing found. In such cases, use registerViewExplicitly() instead.
60+
61+
@sa WidgetsPresenter::registerViewExplicitly
62+
*/
63+
64+
/*!
65+
@fn QtMvvm::WidgetsPresenter::registerViewExplicitly()
66+
67+
@tparam TViewModel The viewmodel to to register the view for
68+
@tparam TView The widget type register within the presenter. Must extend QWidget
69+
70+
The widget is registered with the current presenter. It is registered explicitly, which means
71+
that whenever the given viewmodel is beeing presented, this exact view will be used. Explicit
72+
registration have precedence over implicit ones.
73+
74+
@sa WidgetsPresenter::registerView
75+
*/
76+
77+
/*!
78+
@fn QtMvvm::WidgetsPresenter::registerViewExplicitly(const QMetaObject *, const QMetaObject *)
79+
80+
@param viewModelType The viewmodel to to register the view for
81+
@param viewType The widget type register within the presenter. Must extend QWidget
82+
83+
The widget is registered with the current presenter. It is registered explicitly, which means
84+
that whenever the given viewmodel is beeing presented, this exact view will be used. Explicit
85+
registration have precedence over implicit ones.
86+
87+
@sa WidgetsPresenter::registerView
88+
*/
89+
90+
/*!
91+
@fn QtMvvm::WidgetsPresenter::findWidgetMetaObject
92+
93+
@param viewModelMetaObject The metobject of the viewmodel to find a view for
94+
@returns The metaobject of the view to used, or `nullptr` if none was found
95+
96+
The default implementation simply check all explicitly registered views and then tries to
97+
match the name with the implicitly registered ones. If no match if found, the same is tried
98+
for the parent viewmodel type recursively, until the ViewModel base is reached.
99+
*/
100+
101+
/*!
102+
@fn QtMvvm::WidgetsPresenter::tryPresent
103+
104+
@param view The view to be presented
105+
@param parentView The parent view to present the view to
106+
@returns `true` if successfully presented, `false` if not
107+
108+
This method is called to perform the actual presentation (i.e. the parenting and how to show)
109+
the view. The default implementation first checks if the parent implements IPresentingView and
110+
if yes if it is able to present the view. If not, a bunch of standard widget types are checked
111+
for special presentation methods. QDialogs are presented via QDialog::open. QDockWidgets that
112+
are presented to a QMainWindow are added as dock widget (QMainWindow::addDockWidget). If the
113+
parent or its central widget are a QMdiArea, and the views class name ends with `MdiWindow`,
114+
it is presented as QMdiSubWindow. For all other cases, showForeground() is called.
115+
116+
@sa WidgetsPresenter::showForeground, QDialog, QMainWindow, QDockWidget, QMdiArea
117+
*/

src/mvvmcore/ipresenter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Q_MVVMCORE_EXPORT IPresenter
4646

4747
}
4848

49-
//! The IID of the IPresenter class
49+
//! The IID of the QtMvvm::IPresenter class
5050
#define QtMvvm_IPresenterIid "de.skycoder42.qtmvvm.core.IPresenter"
5151
Q_DECLARE_INTERFACE(QtMvvm::IPresenter, QtMvvm_IPresenterIid)
5252
Q_DECLARE_METATYPE(QtMvvm::IPresenter*)

0 commit comments

Comments
 (0)