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

Commit 0404a63

Browse files
committed
updated qml core doc
1 parent 6a0cf3a commit 0404a63

File tree

9 files changed

+135
-24
lines changed

9 files changed

+135
-24
lines changed

doc/coreapp.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ consideration where neccessary.
133133
*/
134134

135135
/*!
136-
@fn QtMvvm::CoreApp::showDialog
136+
@fn QtMvvm::CoreApp::showDialog(const MessageConfig &)
137137

138138
@param config The configuration of the message to be shown
139139
@returns A message result to keep track of the shown dialog
@@ -148,7 +148,7 @@ been closed.
148148
*/
149149

150150
/*!
151-
@fn QtMvvm::CoreApp::safeCastInputType
151+
@fn QtMvvm::CoreApp::safeCastInputType(const QByteArray &, const QVariant &)
152152

153153
@param type The edit type the given value is supposed to be of
154154
@param value The value to be cast to the type specified by the edit type

doc/qtmvvm.dox

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ The following list shows which classes belong to which Qt module, in alphabetica
5454
<b>Available Types</b>
5555
- @ref QtMvvm::MessageConfig "MessageConfig" (uncreatable)
5656
- @ref QtMvvm::MessageResult "MessageResult" (uncreatable)
57+
- @ref QtMvvm::ProgressControl "ProgressControl" (uncreatable)
5758
- MvvmBinding
5859
- Message (singleton)
60+
- CoreApp (singleton)
61+
- ServiceRegistry (singleton)
5962
- @ref QtMvvm::SettingsViewModel "SettingsViewModel" (uncreatable)
6063
- @ref QtMvvm::ViewModel "ViewModel" (uncreatable)
6164
*/

doc/serviceregistry.dox

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,15 @@ as it is requested for the first time. It is created by calling the given `fn` f
365365
The function must return an object that implements the interface of `iid`, unless it is the id
366366
of the service itself. The arguments are passed as object list and are determined by the
367367
`injectables` parameter. That is a list of iids. When the function is called internally, the
368-
registry will "inject" all services found by the iids as parameters of this function, comnined
368+
registry will "inject" all services found by the iids as parameters of this function, combined
369369
to a list of objects.
370370

371371
If the service is registered as weak, registering another service for the same iid will not
372372
throw an exception but instead discard (and delete) this one.
373373

374374
@sa QtMvvm::registerInterface, ServiceRegistry::registerObject,
375-
ServiceRegistry::registerPlugin, ServiceRegistry::serviceObj*/
375+
ServiceRegistry::registerPlugin, ServiceRegistry::serviceObj
376+
*/
376377

377378
/*!
378379
@fn QtMvvm::ServiceRegistry::registerService(QByteArray, QString, QString, DestructionScope, bool)

src/imports/mvvmcore/plugins.qmltypes

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,18 @@ Module {
565565
Parameter { name: "onResult"; type: "QJSValue" }
566566
}
567567
Method { name: "getColor"; revision: 1 }
568+
Method {
569+
name: "showProgress"
570+
revision: 1
571+
type: "QtMvvm::ProgressControl*"
572+
Parameter { name: "title"; type: "string" }
573+
Parameter { name: "label"; type: "string" }
574+
Parameter { name: "maximum"; type: "int" }
575+
Parameter { name: "minimum"; type: "int" }
576+
Parameter { name: "allowCancel"; type: "bool" }
577+
Parameter { name: "value"; type: "int" }
578+
Parameter { name: "cancelText"; type: "string" }
579+
}
568580
Method {
569581
name: "showProgress"
570582
revision: 1
@@ -617,6 +629,15 @@ Module {
617629
Parameter { name: "title"; type: "string" }
618630
}
619631
Method { name: "showProgress"; revision: 1; type: "QtMvvm::ProgressControl*" }
632+
Method {
633+
name: "showIndeterminateProgress"
634+
revision: 1
635+
type: "QtMvvm::ProgressControl*"
636+
Parameter { name: "title"; type: "string" }
637+
Parameter { name: "label"; type: "string" }
638+
Parameter { name: "allowCancel"; type: "bool" }
639+
Parameter { name: "cancelText"; type: "string" }
640+
}
620641
Method {
621642
name: "showIndeterminateProgress"
622643
revision: 1
@@ -639,6 +660,15 @@ Module {
639660
Parameter { name: "title"; type: "string" }
640661
}
641662
Method { name: "showIndeterminateProgress"; revision: 1; type: "QtMvvm::ProgressControl*" }
663+
Method {
664+
name: "showBusy"
665+
revision: 1
666+
type: "QtMvvm::ProgressControl*"
667+
Parameter { name: "title"; type: "string" }
668+
Parameter { name: "label"; type: "string" }
669+
Parameter { name: "allowCancel"; type: "bool" }
670+
Parameter { name: "cancelText"; type: "string" }
671+
}
642672
Method {
643673
name: "showBusy"
644674
revision: 1
@@ -685,18 +715,18 @@ Module {
685715
}
686716
Method {
687717
name: "registerObject"
688-
Parameter { name: "object"; type: "QObject"; isPointer: true }
718+
Parameter { name: "service"; type: "QObject"; isPointer: true }
689719
Parameter { name: "scope"; type: "QtMvvm::QQmlServiceRegistry::DestructionScope" }
690720
Parameter { name: "weak"; type: "bool" }
691721
}
692722
Method {
693723
name: "registerObject"
694-
Parameter { name: "object"; type: "QObject"; isPointer: true }
724+
Parameter { name: "service"; type: "QObject"; isPointer: true }
695725
Parameter { name: "scope"; type: "QtMvvm::QQmlServiceRegistry::DestructionScope" }
696726
}
697727
Method {
698728
name: "registerObject"
699-
Parameter { name: "object"; type: "QObject"; isPointer: true }
729+
Parameter { name: "service"; type: "QObject"; isPointer: true }
700730
}
701731
Method {
702732
name: "registerObject"

src/imports/mvvmcore/qqmlcoreapp.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,40 @@
55

66
#include <QtMvvmCore/CoreApp>
77

8+
#ifdef DOXYGEN_RUN
9+
namespace de::skycoder42::QtMvvm::Core {
10+
11+
/*! @brief A QML singleton to access some QtMvvm::CoreApp functionality
12+
*
13+
* @extends QtQml.QtObject
14+
* @since 1.1
15+
*
16+
* @sa QtMvvm::CoreApp
17+
*/
18+
class CoreApp
19+
#else
820
namespace QtMvvm {
921

1022
class QQmlCoreApp : public QObject
23+
#endif
1124
{
1225
Q_OBJECT
1326

1427
public:
28+
//! @private
1529
explicit QQmlCoreApp(QObject *parent = nullptr);
1630

31+
//! @copydoc QtMvvm::CoreApp::showDialog
1732
Q_INVOKABLE QtMvvm::MessageResult *showDialog(const QtMvvm::MessageConfig &config);
33+
//! @copydoc QtMvvm::CoreApp::safeCastInputType
1834
Q_INVOKABLE QVariant safeCastInputType(const QString &type, const QVariant &value);
1935

2036
public Q_SLOTS:
37+
//! @copydoc QtMvvm::CoreApp::show(const char *, const QVariantHash &, QPointer<ViewModel>);
2138
void show(const QString &viewModelName, const QVariantHash &params = {}, QtMvvm::ViewModel *parentViewModel = nullptr);
2239

2340
Q_SIGNALS:
41+
//! @copydoc QtMvvm::CoreApp::appStarted
2442
void appStarted();
2543
};
2644

src/imports/mvvmcore/qqmlmvvmmessage.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,23 @@ void QtMvvm::QQmlMvvmMessage::getColor(const QJSValue &onResult, const QString &
118118
QtMvvm::getColor(title, color, argb);
119119
}
120120

121-
ProgressControl *QtMvvm::QQmlMvvmMessage::showProgress(const QString &title, const QString &label, int maximum, int minimum, bool allowCancel, int value)
121+
ProgressControl *QtMvvm::QQmlMvvmMessage::showProgress(const QString &title, const QString &label, int maximum, int minimum, bool allowCancel, int value, const QString &cancelText)
122122
{
123-
auto control = QtMvvm::showProgress(title, label, maximum, minimum, allowCancel, value);
123+
auto control = QtMvvm::showProgress(title, label, maximum, minimum, allowCancel, value, cancelText);
124124
QQmlEngine::setObjectOwnership(control, QQmlEngine::JavaScriptOwnership);
125125
return control;
126126
}
127127

128-
ProgressControl *QtMvvm::QQmlMvvmMessage::showIndeterminateProgress(const QString &title, const QString &label, bool allowCancel)
128+
ProgressControl *QtMvvm::QQmlMvvmMessage::showIndeterminateProgress(const QString &title, const QString &label, bool allowCancel, const QString &cancelText)
129129
{
130-
auto control = QtMvvm::showIndeterminateProgress(title, label, allowCancel);
130+
auto control = QtMvvm::showIndeterminateProgress(title, label, allowCancel, cancelText);
131131
QQmlEngine::setObjectOwnership(control, QQmlEngine::JavaScriptOwnership);
132132
return control;
133133
}
134134

135-
ProgressControl *QtMvvm::QQmlMvvmMessage::showBusy(const QString &title, const QString &label, bool allowCancel)
135+
ProgressControl *QtMvvm::QQmlMvvmMessage::showBusy(const QString &title, const QString &label, bool allowCancel, const QString &cancelText)
136136
{
137-
auto control = QtMvvm::showBusy(title, label, allowCancel);
137+
auto control = QtMvvm::showBusy(title, label, allowCancel, cancelText);
138138
QQmlEngine::setObjectOwnership(control, QQmlEngine::JavaScriptOwnership);
139139
return control;
140140
}

src/imports/mvvmcore/qqmlmvvmmessage.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace de::skycoder42::QtMvvm::Core {
1919
*
2020
* @sa QtMvvm::MessageConfig, QtMvvm::CoreApp::showDialog
2121
*/
22-
class Message : public QtObject
22+
class Message
2323
#else
2424
namespace QtMvvm {
2525

@@ -110,23 +110,34 @@ public Q_SLOTS:
110110
const QStringList &supportedMimeTypes = {},
111111
const QUrl &dir = {});
112112

113+
//! @brief A QML version of the QtMvvm::getColor method
114+
//! @copydoc QtMvvm::getColor(const std::function<void(QColor)> &, const QString &, const QColor &, bool)
113115
QTMVVM_REVISION_1 static void getColor(const QJSValue &onResult = {},
114116
const QString &title = {},
115117
const QColor &color = {},
116118
bool argb = false);
117119

120+
//! @brief A QML version of the QtMvvm::showProgress method
121+
//! @copydoc QtMvvm::showProgress(const QString &, const QString &, int, int, bool, int, const QString &)
118122
QTMVVM_REVISION_1 static QtMvvm::ProgressControl *showProgress(const QString &title = {},
119123
const QString &label = {},
120124
int maximum = 100,
121125
int minimum = 0,
122126
bool allowCancel = true,
123-
int value = 0);
127+
int value = 0,
128+
const QString &cancelText = {});
129+
//! @brief A QML version of the QtMvvm::showIndeterminateProgress method
130+
//! @copydoc QtMvvm::showIndeterminateProgress(const QString &, const QString &, bool, const QString &)
124131
QTMVVM_REVISION_1 static QtMvvm::ProgressControl *showIndeterminateProgress(const QString &title = {},
125132
const QString &label = {},
126-
bool allowCancel = true);
133+
bool allowCancel = true,
134+
const QString &cancelText = {});
135+
//! @brief A QML version of the QtMvvm::showBusy method
136+
//! @copydoc QtMvvm::showBusy(const QString &, const QString &, bool, const QString &)
127137
QTMVVM_REVISION_1 static QtMvvm::ProgressControl *showBusy(const QString &title = {},
128138
const QString &label = {},
129-
bool allowCancel = true);
139+
bool allowCancel = true,
140+
const QString &cancelText = {});
130141

131142
#ifndef DOXYGEN_RUN
132143
#undef static

src/imports/mvvmcore/qqmlserviceregistry.h

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,84 @@
88
#include <QtQml/QQmlEngine>
99
#include <QtQml/QQmlComponent>
1010

11+
#ifdef DOXYGEN_RUN
12+
namespace de::skycoder42::QtMvvm::Core {
13+
14+
/*! @brief A QML singleton to access some QtMvvm::ServiceRegistry functionality
15+
*
16+
* @extends QtQml.QtObject
17+
* @since 1.1
18+
*
19+
* @sa QtMvvm::ServiceRegistry
20+
*/
21+
class ServiceRegistry
22+
#else
1123
namespace QtMvvm {
1224

1325
class QQmlServiceRegistry : public QObject
26+
#endif
1427
{
1528
Q_OBJECT
1629

1730
public:
31+
//! @copybrief QtMvvm::ServiceRegistry
1832
enum DestructionScope {
19-
DestroyOnAppQuit = ServiceRegistry::DestroyOnAppQuit,
20-
DestroyOnAppDestroy = ServiceRegistry::DestroyOnAppDestroy,
21-
DestroyOnRegistryDestroy = ServiceRegistry::DestroyOnRegistryDestroy,
22-
23-
DestroyNever = ServiceRegistry::DestroyNever
33+
DestroyOnAppQuit = ServiceRegistry::DestroyOnAppQuit, //!< @copybrief QtMvvm::ServiceRegistry::DestroyOnAppQuit
34+
DestroyOnAppDestroy = ServiceRegistry::DestroyOnAppDestroy, //!< @copybrief QtMvvm::ServiceRegistry::DestroyOnAppDestroy
35+
DestroyOnRegistryDestroy = ServiceRegistry::DestroyOnRegistryDestroy, //!< @copybrief QtMvvm::ServiceRegistry::DestroyOnRegistryDestroy
36+
DestroyNever = ServiceRegistry::DestroyNever //!< @copybrief QtMvvm::ServiceRegistry::DestroyNever
2437
};
2538
Q_ENUM(DestructionScope)
2639

40+
//! @private
2741
explicit QQmlServiceRegistry(QQmlEngine *parent = nullptr);
2842

43+
//! @copydoc QtMvvm::ServiceRegistry::isRegistered() const
2944
Q_INVOKABLE bool isRegistered(const QString &iid) const;
3045

31-
Q_INVOKABLE void registerObject(QObject *object, QtMvvm::QQmlServiceRegistry::DestructionScope scope = DestroyOnAppQuit, bool weak = false);
46+
//! @copydoc QtMvvm::ServiceRegistry::registerObject(TService *, DestructionScope, bool)
47+
Q_INVOKABLE void registerObject(QObject *service, QtMvvm::QQmlServiceRegistry::DestructionScope scope = DestroyOnAppQuit, bool weak = false);
48+
/*!
49+
* @brief Register a service via a constructor function
50+
*
51+
* @param iid The interface id of the type to register the service for
52+
* @param function The function to be called to construct the service
53+
* @param weak Specifies if the registration should be a weak one or a normal one
54+
*
55+
* If the function returns successfully, from now on a service of the given type can be accessed
56+
* via the registry for the interface. The service is lazy initialized an will be created as soon
57+
* as it is requested for the first time. It is created by calling the given `function`.
58+
*
59+
* If the service is registered as weak, registering another service for the same iid will not
60+
* throw an exception but instead discard (and delete) this one.
61+
*/
3262
Q_INVOKABLE void registerObject(const QString &iid, const QJSValue &function, bool weak = false);
63+
/*!
64+
* @brief Register a qml component as service object
65+
*
66+
* @param componentUrl The URL of the component to be created
67+
* @param weak Specifies if the registration should be a weak one or a normal one
68+
*
69+
* This method works similar to the other register methods, but is special in that it
70+
* allows you to register a qml component. On construction, that component is loaded
71+
* synchronously and then insanciated to create an instance of the contained object.
72+
*
73+
* Unlike the other methods, the destruction scope for those is always
74+
* ServiceRegistry::DestroyOnAppDestroy, as the object will depend on the QML engine
75+
*
76+
* If the service is registered as weak, registering another service for the same iid will not
77+
* throw an exception but instead discard (and delete) this one.
78+
*/
3379
Q_INVOKABLE void registerObject(const QUrl &componentUrl, bool weak = false);
3480

81+
//! @copydoc QtMvvm::ServiceRegistry::registerService(QByteArray, QString, QString, DestructionScope, bool)
3582
Q_INVOKABLE void registerPlugin(const QString &iid,
3683
QString pluginType = {},
3784
QString pluginKey = {},
3885
DestructionScope scope = DestroyOnAppDestroy,
3986
bool weak = false);
4087

88+
//! @copydoc QtMvvm::ServiceRegistry::serviceObj(const QByteArray &)
4189
Q_INVOKABLE QObject *service(const QString &iid);
4290

4391
private:

src/mvvmcore/serviceregistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Q_MVVMCORE_EXPORT ServiceRegistry //MAJOR make a QObject for invokable met
3636
//! Checks if a given interface or service is already registered
3737
template <typename TInterface>
3838
bool isRegistered() const;
39-
//! @copybrief ServiceRegistry::isRegistered()
39+
//! @copybrief ServiceRegistry::isRegistered() const
4040
bool isRegistered(const QByteArray &iid) const;
4141

4242
//! Register a service for its interface via the type

0 commit comments

Comments
 (0)