aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/folderlistmodel/plugin.cpp15
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.h1
-rw-r--r--src/imports/labsanimation/labsanimation.pro4
-rw-r--r--src/imports/labsanimation/plugin.cpp4
-rw-r--r--src/imports/labsanimation/qquickboundaryrule.cpp (renamed from src/quick/util/qquickboundaryrule.cpp)0
-rw-r--r--src/imports/labsanimation/qquickboundaryrule_p.h (renamed from src/quick/util/qquickboundaryrule_p.h)3
-rw-r--r--src/imports/layouts/plugin.cpp11
-rw-r--r--src/imports/layouts/plugins.qmltypes49
-rw-r--r--src/imports/layouts/qquicklayout_p.h5
-rw-r--r--src/imports/layouts/qquicklinearlayout_p.h5
-rw-r--r--src/imports/layouts/qquickstacklayout_p.h2
-rw-r--r--src/imports/localstorage/localstorage.pro7
-rw-r--r--src/imports/localstorage/plugin.cpp775
-rw-r--r--src/imports/localstorage/qquicklocalstorage.cpp792
-rw-r--r--src/imports/localstorage/qquicklocalstorage_p.h75
-rw-r--r--src/imports/models/plugins.qmltypes14
-rw-r--r--src/imports/particles/plugins.qmltypes170
-rw-r--r--src/imports/qtqml/plugins.qmltypes4
-rw-r--r--src/imports/qtquick2/plugins.qmltypes463
-rw-r--r--src/imports/settings/plugin.cpp2
-rw-r--r--src/imports/settings/qqmlsettings_p.h1
-rw-r--r--src/imports/shapes/plugin.cpp15
-rw-r--r--src/imports/shapes/plugins.qmltypes38
-rw-r--r--src/imports/statemachine/finalstate.h2
-rw-r--r--src/imports/statemachine/plugin.cpp14
-rw-r--r--src/imports/statemachine/plugins.qmltypes14
-rw-r--r--src/imports/statemachine/signaltransition.h7
-rw-r--r--src/imports/statemachine/state.h2
-rw-r--r--src/imports/statemachine/statemachine.h2
-rw-r--r--src/imports/statemachine/statemachine.pro3
-rw-r--r--src/imports/statemachine/statemachineforeign.h80
-rw-r--r--src/imports/statemachine/timeouttransition.h2
-rw-r--r--src/imports/testlib/main.cpp101
-rw-r--r--src/imports/testlib/plugins.qmltypes2
-rw-r--r--src/imports/wavefrontmesh/plugin.cpp2
-rw-r--r--src/imports/wavefrontmesh/qwavefrontmesh.h2
-rw-r--r--src/imports/window/plugins.qmltypes11
-rw-r--r--src/particles/qquickage_p.h1
-rw-r--r--src/particles/qquickangledirection_p.h3
-rw-r--r--src/particles/qquickcumulativedirection_p.h3
-rw-r--r--src/particles/qquickcustomaffector_p.h2
-rw-r--r--src/particles/qquickcustomparticle_p.h1
-rw-r--r--src/particles/qquickdirection_p.h4
-rw-r--r--src/particles/qquickellipseextruder_p.h1
-rw-r--r--src/particles/qquickfriction_p.h1
-rw-r--r--src/particles/qquickgravity_p.h2
-rw-r--r--src/particles/qquickgroupgoal_p.h1
-rw-r--r--src/particles/qquickimageparticle_p.h1
-rw-r--r--src/particles/qquickitemparticle_p.h4
-rw-r--r--src/particles/qquicklineextruder_p.h1
-rw-r--r--src/particles/qquickmaskextruder_p.h1
-rw-r--r--src/particles/qquickparticleaffector_p.h3
-rw-r--r--src/particles/qquickparticleemitter_p.h1
-rw-r--r--src/particles/qquickparticleextruder_p.h4
-rw-r--r--src/particles/qquickparticlegroup_p.h1
-rw-r--r--src/particles/qquickparticlepainter_p.h3
-rw-r--r--src/particles/qquickparticlesmodule.cpp64
-rw-r--r--src/particles/qquickparticlesystem_p.h1
-rw-r--r--src/particles/qquickpointattractor_p.h1
-rw-r--r--src/particles/qquickpointdirection_p.h1
-rw-r--r--src/particles/qquickrectangleextruder_p.h1
-rw-r--r--src/particles/qquickspritegoal_p.h1
-rw-r--r--src/particles/qquicktargetdirection_p.h3
-rw-r--r--src/particles/qquicktrailemitter_p.h1
-rw-r--r--src/particles/qquickturbulence_p.h4
-rw-r--r--src/particles/qquickwander_p.h1
-rw-r--r--src/qml/common/qqmlapiversion_p.h2
-rw-r--r--src/qml/common/qv4compileddata_p.h5
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp13
-rw-r--r--src/qml/doc/src/javascript/finetuning.qdoc104
-rw-r--r--src/qml/doc/src/javascript/topic.qdoc7
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc5
-rw-r--r--src/qml/jsruntime/qv4engine.cpp16
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp2
-rw-r--r--src/qml/parser/qqmljs.g195
-rw-r--r--src/qml/parser/qqmljsast.cpp6
-rw-r--r--src/qml/parser/qqmljsast_p.h74
-rw-r--r--src/qml/parser/qqmljskeywords_p.h12
-rw-r--r--src/qml/parser/qqmljslexer.cpp82
-rw-r--r--src/qml/qml/qqml.cpp181
-rw-r--r--src/qml/qml/qqml.h113
-rw-r--r--src/qml/qml/qqmlbinding.cpp2
-rw-r--r--src/qml/qml/qqmlcomponent.cpp134
-rw-r--r--src/qml/qml/qqmlcomponent.h27
-rw-r--r--src/qml/qml/qqmlcomponent_p.h8
-rw-r--r--src/qml/qml/qqmlcomponentattached_p.h5
-rw-r--r--src/qml/qml/qqmlcontext.cpp2
-rw-r--r--src/qml/qml/qqmlcontext_p.h11
-rw-r--r--src/qml/qml/qqmlengine.cpp31
-rw-r--r--src/qml/qml/qqmlengine_p.h7
-rw-r--r--src/qml/qml/qqmlincubator.cpp58
-rw-r--r--src/qml/qml/qqmlincubator.h5
-rw-r--r--src/qml/qml/qqmlincubator_p.h9
-rw-r--r--src/qml/qml/qqmllocale_p.h3
-rw-r--r--src/qml/qml/qqmlloggingcategory_p.h3
-rw-r--r--src/qml/qml/qqmlmetatype.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp53
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h27
-rw-r--r--src/qml/qml/qqmlprivate.h389
-rw-r--r--src/qml/qml/qqmlproperty.cpp2
-rw-r--r--src/qml/qml/qqmlpropertyvalidator.cpp2
-rw-r--r--src/qml/qml/qqmltypenotavailable_p.h3
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp86
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h37
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp2
-rw-r--r--src/qml/qmldirparser/qqmldirparser.cpp8
-rw-r--r--src/qml/qmldirparser/qqmldirparser_p.h19
-rw-r--r--src/qml/types/qqmlbind_p.h1
-rw-r--r--src/qml/types/qqmlconnections_p.h8
-rw-r--r--src/qml/types/qqmltimer_p.h1
-rw-r--r--src/qmlmodels/qqmldelegatecomponent_p.h5
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp119
-rw-r--r--src/qmlmodels/qqmldelegatemodel_p.h7
-rw-r--r--src/qmlmodels/qqmldelegatemodel_p_p.h16
-rw-r--r--src/qmlmodels/qqmlinstantiator_p.h2
-rw-r--r--src/qmlmodels/qqmllistmodel_p.h12
-rw-r--r--src/qmlmodels/qqmllistmodelworkeragent_p.h2
-rw-r--r--src/qmlmodels/qqmlmodelsmodule.cpp31
-rw-r--r--src/qmlmodels/qqmlmodelsmodule_p.h16
-rw-r--r--src/qmlmodels/qqmlobjectmodel_p.h5
-rw-r--r--src/qmlmodels/qqmltableinstancemodel.cpp9
-rw-r--r--src/qmlmodels/qqmltablemodel_p.h1
-rw-r--r--src/qmlmodels/qqmltablemodelcolumn_p.h1
-rw-r--r--src/qmlmodels/qquickpackage_p.h4
-rw-r--r--src/qmltest/qmltest.pro5
-rw-r--r--src/qmltest/quicktestevent_p.h4
-rw-r--r--src/qmltest/quicktestresult_p.h2
-rw-r--r--src/qmltest/quicktestutil.cpp111
-rw-r--r--src/qmltest/quicktestutil_p.h89
-rw-r--r--src/qmlworkerscript/qqmlworkerscriptmodule.cpp3
-rw-r--r--src/qmlworkerscript/qquickworkerscript_p.h1
-rw-r--r--src/quick/handlers/qquickdragaxis_p.h4
-rw-r--r--src/quick/handlers/qquickdraghandler.cpp3
-rw-r--r--src/quick/handlers/qquickdraghandler_p.h2
-rw-r--r--src/quick/handlers/qquickhoverhandler_p.h2
-rw-r--r--src/quick/handlers/qquickpinchhandler.cpp7
-rw-r--r--src/quick/handlers/qquickpinchhandler_p.h2
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp69
-rw-r--r--src/quick/handlers/qquickpointerhandler_p.h10
-rw-r--r--src/quick/handlers/qquickpointerhandler_p_p.h7
-rw-r--r--src/quick/handlers/qquickpointhandler_p.h2
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp9
-rw-r--r--src/quick/handlers/qquicktaphandler_p.h3
-rw-r--r--src/quick/handlers/qquickwheelhandler_p.h3
-rw-r--r--src/quick/items/context2d/qquickcanvasitem_p.h1
-rw-r--r--src/quick/items/qquickaccessibleattached_p.h5
-rw-r--r--src/quick/items/qquickanchors_p.h1
-rw-r--r--src/quick/items/qquickanimatedimage_p.h1
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h1
-rw-r--r--src/quick/items/qquickborderimage_p.h1
-rw-r--r--src/quick/items/qquickdrag.cpp2
-rw-r--r--src/quick/items/qquickdrag_p.h8
-rw-r--r--src/quick/items/qquickdroparea_p.h3
-rw-r--r--src/quick/items/qquickevents_p_p.h30
-rw-r--r--src/quick/items/qquickflickable_p.h1
-rw-r--r--src/quick/items/qquickflickable_p_p.h1
-rw-r--r--src/quick/items/qquickflipable_p.h1
-rw-r--r--src/quick/items/qquickfocusscope_p.h1
-rw-r--r--src/quick/items/qquickgraphicsinfo_p.h7
-rw-r--r--src/quick/items/qquickgridview_p.h3
-rw-r--r--src/quick/items/qquickimage_p.h1
-rw-r--r--src/quick/items/qquickimagebase_p.h4
-rw-r--r--src/quick/items/qquickitem.h2
-rw-r--r--src/quick/items/qquickitem_p.h22
-rw-r--r--src/quick/items/qquickitemanimation_p.h3
-rw-r--r--src/quick/items/qquickitemgrabresult.h3
-rw-r--r--src/quick/items/qquickitemsmodule.cpp447
-rw-r--r--src/quick/items/qquickitemsmodule_p.h10
-rw-r--r--src/quick/items/qquickitemview_p.h4
-rw-r--r--src/quick/items/qquickitemviewtransition_p.h5
-rw-r--r--src/quick/items/qquicklistview.cpp29
-rw-r--r--src/quick/items/qquicklistview_p.h4
-rw-r--r--src/quick/items/qquickloader.cpp4
-rw-r--r--src/quick/items/qquickloader_p.h1
-rw-r--r--src/quick/items/qquickmousearea_p.h1
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h5
-rw-r--r--src/quick/items/qquickopenglinfo_p.h7
-rw-r--r--src/quick/items/qquickpainteditem.h3
-rw-r--r--src/quick/items/qquickpathview_p.h3
-rw-r--r--src/quick/items/qquickpincharea_p.h3
-rw-r--r--src/quick/items/qquickpositioners_p.h11
-rw-r--r--src/quick/items/qquickrectangle_p.h4
-rw-r--r--src/quick/items/qquickrepeater_p.h1
-rw-r--r--src/quick/items/qquickscalegrid_p_p.h1
-rw-r--r--src/quick/items/qquickscreen_p.h9
-rw-r--r--src/quick/items/qquickshadereffect_p.h1
-rw-r--r--src/quick/items/qquickshadereffectmesh_p.h10
-rw-r--r--src/quick/items/qquickshadereffectsource_p.h1
-rw-r--r--src/quick/items/qquicksprite_p.h1
-rw-r--r--src/quick/items/qquickspritesequence_p.h1
-rw-r--r--src/quick/items/qquickstateoperations_p.h3
-rw-r--r--src/quick/items/qquicktableview_p.h5
-rw-r--r--src/quick/items/qquicktext_p.h2
-rw-r--r--src/quick/items/qquicktextdocument.h1
-rw-r--r--src/quick/items/qquicktextedit_p.h1
-rw-r--r--src/quick/items/qquicktextinput_p.h1
-rw-r--r--src/quick/items/qquicktranslate_p.h5
-rw-r--r--src/quick/items/qquickwindow.cpp12
-rw-r--r--src/quick/items/qquickwindow.h3
-rw-r--r--src/quick/items/qquickwindow_p.h20
-rw-r--r--src/quick/items/qquickwindowmodule.cpp17
-rw-r--r--src/quick/items/qquickwindowmodule_p.h4
-rw-r--r--src/quick/qtquick2.cpp2
-rw-r--r--src/quick/util/qquickanimation_p.h13
-rw-r--r--src/quick/util/qquickanimationcontroller_p.h1
-rw-r--r--src/quick/util/qquickanimator_p.h16
-rw-r--r--src/quick/util/qquickapplication_p.h3
-rw-r--r--src/quick/util/qquickbehavior_p.h1
-rw-r--r--src/quick/util/qquickfontloader_p.h1
-rw-r--r--src/quick/util/qquickfontmetrics_p.h2
-rw-r--r--src/quick/util/qquickforeignutils_p.h120
-rw-r--r--src/quick/util/qquickpath_p.h21
-rw-r--r--src/quick/util/qquickpathinterpolator_p.h1
-rw-r--r--src/quick/util/qquickpropertychanges_p.h7
-rw-r--r--src/quick/util/qquickshortcut_p.h3
-rw-r--r--src/quick/util/qquicksmoothedanimation_p.h1
-rw-r--r--src/quick/util/qquickspringanimation_p.h1
-rw-r--r--src/quick/util/qquickstate_p.h2
-rw-r--r--src/quick/util/qquickstatechangescript_p.h1
-rw-r--r--src/quick/util/qquickstategroup_p.h1
-rw-r--r--src/quick/util/qquicksystempalette_p.h1
-rw-r--r--src/quick/util/qquicktextmetrics_p.h2
-rw-r--r--src/quick/util/qquicktransition_p.h1
-rw-r--r--src/quick/util/qquickutilmodule.cpp112
-rw-r--r--src/quick/util/qquickvalidator_p.h2
-rw-r--r--src/quick/util/qquickvaluetypes_p.h3
-rw-r--r--src/quick/util/util.pri5
-rw-r--r--src/quickshapes/qquickshape_p.h8
229 files changed, 4268 insertions, 1952 deletions
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index 31cd793737..ebce18a6e2 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -55,19 +55,14 @@ public:
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel"));
- qmlRegisterType<QQuickFolderListModel>(uri,1,0,"FolderListModel");
- qmlRegisterType<QQuickFolderListModel>(uri,2,0,"FolderListModel");
- qmlRegisterType<QQuickFolderListModel,1>(uri,2,1,"FolderListModel");
- qmlRegisterType<QQuickFolderListModel,2>(uri,2,2,"FolderListModel");
- // Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
- qmlRegisterModule(uri, 2, QT_VERSION_MINOR);
+ // Major version 1 only has a single revision, 0.
+ qmlRegisterType<QQuickFolderListModel>(uri, 1, 0, "FolderListModel");
- // revision in Qt 5.11: added status property
- qmlRegisterType<QQuickFolderListModel,11>(uri, 2, 11, "FolderListModel");
+ qmlRegisterTypesAndRevisions<QQuickFolderListModel>(uri, 2);
- // revision in Qt 5.12: added sortCaseSensitive property
- qmlRegisterType<QQuickFolderListModel,12>(uri, 2, 12, "FolderListModel");
+ // Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
+ qmlRegisterModule(uri, 2, QT_VERSION_MINOR);
}
};
//![class decl]
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h
index d93e7daf3f..5897bd2e0f 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.h
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h
@@ -79,6 +79,7 @@ class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus
Q_PROPERTY(bool sortCaseSensitive READ sortCaseSensitive WRITE setSortCaseSensitive REVISION 12)
//![class props]
+ QML_NAMED_ELEMENT(FolderListModel)
//![abslistmodel]
public:
QQuickFolderListModel(QObject *parent = nullptr);
diff --git a/src/imports/labsanimation/labsanimation.pro b/src/imports/labsanimation/labsanimation.pro
index 64e076401f..128bc28ddb 100644
--- a/src/imports/labsanimation/labsanimation.pro
+++ b/src/imports/labsanimation/labsanimation.pro
@@ -4,8 +4,12 @@ TARGETPATH = Qt/labs/animation
IMPORT_VERSION = 1.0
SOURCES += \
+ qquickboundaryrule.cpp \
plugin.cpp
+HEADERS += \
+ qquickboundaryrule_p.h
+
QT = qml-private quick-private
load(qml_plugin)
diff --git a/src/imports/labsanimation/plugin.cpp b/src/imports/labsanimation/plugin.cpp
index d8c0c071ca..a74a30663a 100644
--- a/src/imports/labsanimation/plugin.cpp
+++ b/src/imports/labsanimation/plugin.cpp
@@ -40,7 +40,7 @@
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
-#include <private/qquickboundaryrule_p.h>
+#include "qquickboundaryrule_p.h"
QT_BEGIN_NAMESPACE
@@ -70,7 +70,7 @@ public:
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.animation"));
- qmlRegisterType<QQuickBoundaryRule>(uri, 1, 0, "BoundaryRule");
+ qmlRegisterTypesAndRevisions<QQuickBoundaryRule>(uri, 1);
qmlRegisterModule(uri, 1, 0);
}
};
diff --git a/src/quick/util/qquickboundaryrule.cpp b/src/imports/labsanimation/qquickboundaryrule.cpp
index 3558c8bfa0..3558c8bfa0 100644
--- a/src/quick/util/qquickboundaryrule.cpp
+++ b/src/imports/labsanimation/qquickboundaryrule.cpp
diff --git a/src/quick/util/qquickboundaryrule_p.h b/src/imports/labsanimation/qquickboundaryrule_p.h
index 3325b675c5..1681558304 100644
--- a/src/quick/util/qquickboundaryrule_p.h
+++ b/src/imports/labsanimation/qquickboundaryrule_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
class QQuickAbstractAnimation;
class QQuickBoundaryRulePrivate;
-class Q_QUICK_PRIVATE_EXPORT QQuickBoundaryRule : public QObject, public QQmlPropertyValueInterceptor
+class QQuickBoundaryRule : public QObject, public QQmlPropertyValueInterceptor
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickBoundaryRule)
@@ -77,6 +77,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBoundaryRule : public QObject, public QQmlPro
Q_PROPERTY(OvershootFilter overshootFilter READ overshootFilter WRITE setOvershootFilter NOTIFY overshootFilterChanged)
Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
Q_PROPERTY(int returnDuration READ returnDuration WRITE setReturnDuration NOTIFY returnDurationChanged)
+ QML_NAMED_ELEMENT(BoundaryRule)
public:
enum OvershootFilter {
diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp
index d28109c3cf..93b95e1c1e 100644
--- a/src/imports/layouts/plugin.cpp
+++ b/src/imports/layouts/plugin.cpp
@@ -57,15 +57,8 @@ public:
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Layouts"));
- qmlRegisterType<QQuickRowLayout>(uri, 1, 0, "RowLayout");
- qmlRegisterType<QQuickColumnLayout>(uri, 1, 0, "ColumnLayout");
- qmlRegisterType<QQuickGridLayout>(uri, 1, 0, "GridLayout");
- qmlRegisterType<QQuickStackLayout>(uri, 1, 3, "StackLayout");
- qmlRegisterUncreatableType<QQuickLayout>(uri, 1, 0, "Layout",
- QStringLiteral("Do not create objects of type Layout"));
- qmlRegisterUncreatableType<QQuickLayout>(uri, 1, 2, "Layout",
- QStringLiteral("Do not create objects of type Layout"));
- qmlRegisterRevision<QQuickGridLayoutBase, 1>(uri, 1, 1);
+ qmlRegisterTypesAndRevisions<QQuickRowLayout, QQuickColumnLayout, QQuickGridLayout,
+ QQuickStackLayout, QQuickLayout, QQuickGridLayoutBase>(uri, 1);
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
qmlRegisterModule(uri, 1, QT_VERSION_MINOR);
diff --git a/src/imports/layouts/plugins.qmltypes b/src/imports/layouts/plugins.qmltypes
index 6015164511..4ebef4ac51 100644
--- a/src/imports/layouts/plugins.qmltypes
+++ b/src/imports/layouts/plugins.qmltypes
@@ -12,15 +12,27 @@ Module {
name: "QQuickColumnLayout"
defaultProperty: "data"
prototype: "QQuickLinearLayout"
- exports: ["QtQuick.Layouts/ColumnLayout 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Layouts/ColumnLayout 1.0",
+ "QtQuick.Layouts/ColumnLayout 1.1",
+ "QtQuick.Layouts/ColumnLayout 1.11",
+ "QtQuick.Layouts/ColumnLayout 1.4",
+ "QtQuick.Layouts/ColumnLayout 1.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
}
Component {
name: "QQuickGridLayout"
defaultProperty: "data"
prototype: "QQuickGridLayoutBase"
- exports: ["QtQuick.Layouts/GridLayout 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Layouts/GridLayout 1.0",
+ "QtQuick.Layouts/GridLayout 1.1",
+ "QtQuick.Layouts/GridLayout 1.11",
+ "QtQuick.Layouts/GridLayout 1.4",
+ "QtQuick.Layouts/GridLayout 1.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "Flow"
values: {
@@ -45,9 +57,15 @@ Module {
name: "QQuickLayout"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick.Layouts/Layout 1.0", "QtQuick.Layouts/Layout 1.2"]
+ exports: [
+ "QtQuick.Layouts/Layout 1.0",
+ "QtQuick.Layouts/Layout 1.1",
+ "QtQuick.Layouts/Layout 1.11",
+ "QtQuick.Layouts/Layout 1.4",
+ "QtQuick.Layouts/Layout 1.7"
+ ]
isCreatable: false
- exportMetaObjectRevisions: [0, 0]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
attachedType: "QQuickLayoutAttached"
}
Component {
@@ -82,15 +100,26 @@ Module {
name: "QQuickRowLayout"
defaultProperty: "data"
prototype: "QQuickLinearLayout"
- exports: ["QtQuick.Layouts/RowLayout 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Layouts/RowLayout 1.0",
+ "QtQuick.Layouts/RowLayout 1.1",
+ "QtQuick.Layouts/RowLayout 1.11",
+ "QtQuick.Layouts/RowLayout 1.4",
+ "QtQuick.Layouts/RowLayout 1.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
}
Component {
name: "QQuickStackLayout"
defaultProperty: "data"
prototype: "QQuickLayout"
- exports: ["QtQuick.Layouts/StackLayout 1.3"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Layouts/StackLayout 1.11",
+ "QtQuick.Layouts/StackLayout 1.3",
+ "QtQuick.Layouts/StackLayout 1.4",
+ "QtQuick.Layouts/StackLayout 1.7"
+ ]
+ exportMetaObjectRevisions: [11, 3, 4, 7]
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "currentIndex"; type: "int" }
Method {
diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h
index b31bffa290..c022a2fd47 100644
--- a/src/imports/layouts/qquicklayout_p.h
+++ b/src/imports/layouts/qquicklayout_p.h
@@ -61,6 +61,10 @@ class QQuickLayout : public QQuickItem, public QQuickItemChangeListener
{
Q_OBJECT
+ QML_NAMED_ELEMENT(Layout)
+ QML_UNCREATABLE("Do not create objects of type Layout.")
+ QML_ATTACHED(QQuickLayoutAttached)
+
public:
enum SizeHint {
MinimumSize = 0,
@@ -331,6 +335,5 @@ inline QQuickLayoutAttached *attachedLayoutObject(QQuickItem *item, bool create
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickLayout)
-QML_DECLARE_TYPEINFO(QQuickLayout, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKLAYOUT_P_H
diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h
index 6706ebf9fa..634e51a048 100644
--- a/src/imports/layouts/qquicklinearlayout_p.h
+++ b/src/imports/layouts/qquicklinearlayout_p.h
@@ -57,6 +57,8 @@ class QQuickGridLayoutBase : public QQuickLayout
Q_OBJECT
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
+ QML_ANONYMOUS
+ QML_ADDED_IN_MINOR_VERSION(1)
public:
@@ -140,6 +142,7 @@ class QQuickGridLayout : public QQuickGridLayoutBase
Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
+ QML_NAMED_ELEMENT(GridLayout)
public:
explicit QQuickGridLayout(QQuickItem *parent = 0);
qreal columnSpacing() const;
@@ -223,6 +226,7 @@ public:
class QQuickRowLayout : public QQuickLinearLayout
{
Q_OBJECT
+ QML_NAMED_ELEMENT(RowLayout)
public:
explicit QQuickRowLayout(QQuickItem *parent = 0)
@@ -238,6 +242,7 @@ public:
class QQuickColumnLayout : public QQuickLinearLayout
{
Q_OBJECT
+ QML_NAMED_ELEMENT(ColumnLayout)
public:
explicit QQuickColumnLayout(QQuickItem *parent = 0)
diff --git a/src/imports/layouts/qquickstacklayout_p.h b/src/imports/layouts/qquickstacklayout_p.h
index 46181c6f50..537d54900f 100644
--- a/src/imports/layouts/qquickstacklayout_p.h
+++ b/src/imports/layouts/qquickstacklayout_p.h
@@ -51,6 +51,8 @@ class QQuickStackLayout : public QQuickLayout
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
+ QML_NAMED_ELEMENT(StackLayout)
+ QML_ADDED_IN_MINOR_VERSION(3)
public:
explicit QQuickStackLayout(QQuickItem *parent = 0);
diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro
index 5c8177e238..607a6cbbdd 100644
--- a/src/imports/localstorage/localstorage.pro
+++ b/src/imports/localstorage/localstorage.pro
@@ -5,7 +5,12 @@ IMPORT_VERSION = 2.$$QT_MINOR_VERSION
QT = sql qml-private core-private
-SOURCES += plugin.cpp
+SOURCES += \
+ plugin.cpp \
+ qquicklocalstorage.cpp
+
+HEADERS += \
+ qquicklocalstorage_p.h
load(qml_plugin)
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 9004d1ee6f..5eaa552297 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -36,781 +36,14 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QStringList>
+
+#include "qquicklocalstorage_p.h"
+
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
-#include <private/qqmlengine_p.h>
-#include <QDebug>
-#include <QtSql/qsqldatabase.h>
-#include <QtSql/qsqlquery.h>
-#include <QtSql/qsqlerror.h>
-#include <QtSql/qsqlrecord.h>
-#include <QtSql/qsqlfield.h>
-#include <QtCore/qstandardpaths.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qcryptographichash.h>
-#include <QtCore/qsettings.h>
-#include <QtCore/qdir.h>
-#include <private/qv4sqlerrors_p.h>
-#include <private/qv4engine_p.h>
-#include <private/qv4object_p.h>
-#include <private/qv4functionobject_p.h>
-#include <private/qv4objectproto_p.h>
-#include <private/qv4scopedvalue_p.h>
-#include <private/qv4jscall_p.h>
-#include <private/qv4objectiterator_p.h>
QT_BEGIN_NAMESPACE
-#define V4THROW_SQL(error, desc) { \
- QV4::ScopedString v(scope, scope.engine->newString(desc)); \
- QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \
- scope.engine->throwError(ex); \
- RETURN_UNDEFINED(); \
-}
-
-#define V4THROW_SQL2(error, desc) { \
- QV4::ScopedString v(scope, scope.engine->newString(desc)); \
- QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \
- args->setReturnValue(scope.engine->throwError(ex)); \
- return; \
-}
-
-#define V4THROW_REFERENCE(string) { \
- QV4::ScopedString v(scope, scope.engine->newString(string)); \
- scope.engine->throwReferenceError(v); \
- RETURN_UNDEFINED(); \
-}
-
-
-class QQmlSqlDatabaseData : public QV4::ExecutionEngine::Deletable
-{
-public:
- QQmlSqlDatabaseData(QV4::ExecutionEngine *engine);
- ~QQmlSqlDatabaseData() override;
-
- QV4::PersistentValue databaseProto;
- QV4::PersistentValue queryProto;
- QV4::PersistentValue rowsProto;
-};
-
-V4_DEFINE_EXTENSION(QQmlSqlDatabaseData, databaseData)
-
-namespace QV4 {
-
-namespace Heap {
- struct QQmlSqlDatabaseWrapper : public Object {
- enum Type { Database, Query, Rows };
- void init()
- {
- Object::init();
- type = Database;
- database = new QSqlDatabase;
- version = new QString;
- sqlQuery = new QSqlQuery;
- }
-
- void destroy() {
- delete database;
- delete version;
- delete sqlQuery;
- Object::destroy();
- }
-
- Type type;
- QSqlDatabase *database;
-
- QString *version; // type == Database
-
- bool inTransaction; // type == Query
- bool readonly; // type == Query
-
- QSqlQuery *sqlQuery; // type == Rows
- bool forwardOnly; // type == Rows
- };
-}
-
-class QQmlSqlDatabaseWrapper : public Object
-{
-public:
- V4_OBJECT2(QQmlSqlDatabaseWrapper, Object)
- V4_NEEDS_DESTROY
-
- static Heap::QQmlSqlDatabaseWrapper *create(QV4::ExecutionEngine *engine)
- {
- return engine->memoryManager->allocate<QQmlSqlDatabaseWrapper>();
- }
-
- ~QQmlSqlDatabaseWrapper() {
- }
-
- static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
-};
-
-}
-
-using namespace QV4;
-
-DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper);
-
-
-
-static ReturnedValue qmlsqldatabase_version(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int)
-{
- Scope scope(b);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database)
- V4THROW_REFERENCE("Not a SQLDatabase object");
-
- RETURN_RESULT(Encode(scope.engine->newString(*r->d()->version)));
-}
-
-static ReturnedValue qmlsqldatabase_rows_length(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int)
-{
- Scope scope(b);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
- V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
-
- int s = r->d()->sqlQuery->size();
- if (s < 0) {
- // Inefficient
- if (r->d()->sqlQuery->last()) {
- s = r->d()->sqlQuery->at() + 1;
- } else {
- s = 0;
- }
- }
- RETURN_RESULT(Encode(s));
-}
-
-static ReturnedValue qmlsqldatabase_rows_forwardOnly(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int)
-{
- Scope scope(b);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
- V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
- RETURN_RESULT(Encode(r->d()->sqlQuery->isForwardOnly()));
-}
-
-static ReturnedValue qmlsqldatabase_rows_setForwardOnly(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
-{
- Scope scope(b);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
- V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
- if (argc < 1)
- RETURN_RESULT(scope.engine->throwTypeError());
-
- r->d()->sqlQuery->setForwardOnly(argv[0].toBoolean());
- RETURN_UNDEFINED();
-}
-
-QQmlSqlDatabaseData::~QQmlSqlDatabaseData()
-{
-}
-
-static ReturnedValue qmlsqldatabase_rows_index(const QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = nullptr)
-{
- Scope scope(v4);
-
- if (r->d()->sqlQuery->at() == (int)index || r->d()->sqlQuery->seek(index)) {
- QSqlRecord record = r->d()->sqlQuery->record();
- // XXX optimize
- ScopedObject row(scope, v4->newObject());
- for (int ii = 0; ii < record.count(); ++ii) {
- QVariant v = record.value(ii);
- ScopedString s(scope, v4->newIdentifier(record.fieldName(ii)));
- ScopedValue val(scope, v.isNull() ? Encode::null() : v4->fromVariant(v));
- row->put(s.getPointer(), val);
- }
- if (hasProperty)
- *hasProperty = true;
- return row.asReturnedValue();
- } else {
- if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
- }
-}
-
-ReturnedValue QQmlSqlDatabaseWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
-{
- if (!id.isArrayIndex())
- return Object::virtualGet(m, id, receiver, hasProperty);
-
- uint index = id.asArrayIndex();
- Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>());
- const QQmlSqlDatabaseWrapper *r = static_cast<const QQmlSqlDatabaseWrapper *>(m);
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
- return Object::virtualGet(m, id, receiver, hasProperty);
-
- return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty);
-}
-
-static ReturnedValue qmlsqldatabase_rows_item(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
-{
- Scope scope(b);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
- V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
-
- RETURN_RESULT(qmlsqldatabase_rows_index(r, scope.engine, argc ? argv[0].toUInt32() : 0));
-}
-
-static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValue &value)
-{
- // toVariant() maps a null JS value to QVariant(VoidStar), but the SQL module
- // expects a null variant. (this is because of QTBUG-40880)
- if (value->isNull())
- return QVariant();
- return engine->toVariant(value, /*typehint*/-1);
-}
-
-static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
-{
- Scope scope(b);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Query)
- V4THROW_REFERENCE("Not a SQLDatabase::Query object");
-
- if (!r->d()->inTransaction)
- V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,QQmlEngine::tr("executeSql called outside transaction()"));
-
- QSqlDatabase db = *r->d()->database;
-
- QString sql = argc ? argv[0].toQString() : QString();
-
- if (r->d()->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) {
- V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction"));
- }
-
- QSqlQuery query(db);
- bool err = false;
-
- ScopedValue result(scope, Value::undefinedValue());
-
- if (query.prepare(sql)) {
- if (argc > 1) {
- ScopedValue values(scope, argv[1]);
- if (values->as<ArrayObject>()) {
- ScopedArrayObject array(scope, values);
- quint32 size = array->getLength();
- QV4::ScopedValue v(scope);
- for (quint32 ii = 0; ii < size; ++ii) {
- query.bindValue(ii, toSqlVariant(scope.engine, (v = array->get(ii))));
- }
- } else if (values->as<Object>()) {
- ScopedObject object(scope, values);
- ObjectIterator it(scope, object, ObjectIterator::EnumerableOnly);
- ScopedValue key(scope);
- QV4::ScopedValue val(scope);
- while (1) {
- key = it.nextPropertyName(val);
- if (key->isNull())
- break;
- QVariant v = toSqlVariant(scope.engine, val);
- if (key->isString()) {
- query.bindValue(key->stringValue()->toQString(), v);
- } else {
- Q_ASSERT(key->isInteger());
- query.bindValue(key->integerValue(), v);
- }
- }
- } else {
- query.bindValue(0, toSqlVariant(scope.engine, values));
- }
- }
- if (query.exec()) {
- QV4::Scoped<QQmlSqlDatabaseWrapper> rows(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
- QV4::ScopedObject p(scope, databaseData(scope.engine)->rowsProto.value());
- rows->setPrototypeUnchecked(p.getPointer());
- rows->d()->type = Heap::QQmlSqlDatabaseWrapper::Rows;
- *rows->d()->database = db;
- *rows->d()->sqlQuery = query;
-
- ScopedObject resultObject(scope, scope.engine->newObject());
- result = resultObject.asReturnedValue();
- // XXX optimize
- ScopedString s(scope);
- ScopedValue v(scope);
- resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Value::fromInt32(query.numRowsAffected())));
- resultObject->put((s = scope.engine->newIdentifier("insertId")).getPointer(), (v = scope.engine->newString(query.lastInsertId().toString())));
- resultObject->put((s = scope.engine->newIdentifier("rows")).getPointer(), rows);
- } else {
- err = true;
- }
- } else {
- err = true;
- }
- if (err)
- V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,query.lastError().text());
-
- RETURN_RESULT(result->asReturnedValue());
-}
-
-struct TransactionRollback {
- QSqlDatabase *db;
- bool *inTransactionFlag;
-
- TransactionRollback(QSqlDatabase *database, bool *transactionFlag)
- : db(database)
- , inTransactionFlag(transactionFlag)
- {
- if (inTransactionFlag)
- *inTransactionFlag = true;
- }
-
- ~TransactionRollback()
- {
- if (inTransactionFlag)
- *inTransactionFlag = false;
- if (db)
- db->rollback();
- }
-
- void clear() {
- db = nullptr;
- if (inTransactionFlag)
- *inTransactionFlag = false;
- inTransactionFlag = nullptr;
- }
-};
-
-
-static ReturnedValue qmlsqldatabase_changeVersion(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
-{
- Scope scope(b);
- if (argc < 2)
- RETURN_UNDEFINED();
-
- Scoped<QQmlSqlDatabaseWrapper> r(scope, *thisObject);
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database)
- V4THROW_REFERENCE("Not a SQLDatabase object");
-
- QSqlDatabase db = *r->d()->database;
- QString from_version = argv[0].toQString();
- QString to_version = argv[1].toQString();
- ScopedFunctionObject callback(scope, argc > 2 ? argv[2] : Value::undefinedValue());
-
- if (from_version != *r->d()->version)
- V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version));
-
- bool ok = true;
- if (!!callback) {
- Scoped<QQmlSqlDatabaseWrapper> query(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
- ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
- query->setPrototypeUnchecked(p.getPointer());
- query->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
- *query->d()->database = db;
- *query->d()->version = *r->d()->version;
-
- ok = false;
- db.transaction();
-
- JSCallData jsCall(scope, 1);
- *jsCall->thisObject = scope.engine->globalObject;
- jsCall->args[0] = query;
-
- TransactionRollback rollbackOnException(&db, &query->d()->inTransaction);
- callback->call(jsCall);
- rollbackOnException.clear();
- if (!db.commit()) {
- db.rollback();
- V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QQmlEngine::tr("SQL transaction failed"));
- } else {
- ok = true;
- }
- }
-
- if (ok) {
- Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
- ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value());
- w->setPrototypeUnchecked(p.getPointer());
- w->d()->type = Heap::QQmlSqlDatabaseWrapper::Database;
- *w->d()->database = db;
- *w->d()->version = to_version;
-#if QT_CONFIG(settings)
- const QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(scope.engine->qmlEngine());
- QSettings ini(enginePrivate->offlineStorageDatabaseDirectory() + db.connectionName() + QLatin1String(".ini"), QSettings::IniFormat);
- ini.setValue(QLatin1String("Version"), to_version);
-#endif
- RETURN_RESULT(w.asReturnedValue());
- }
-
- RETURN_UNDEFINED();
-}
-
-static ReturnedValue qmlsqldatabase_transaction_shared(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool readOnly)
-{
- Scope scope(b);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
- if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database)
- V4THROW_REFERENCE("Not a SQLDatabase object");
-
- const FunctionObject *callback = argc ? argv[0].as<FunctionObject>() : nullptr;
- if (!callback)
- V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback"));
-
- QSqlDatabase db = *r->d()->database;
-
- Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
- QV4::ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
- w->setPrototypeUnchecked(p.getPointer());
- w->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
- *w->d()->database = db;
- *w->d()->version = *r->d()->version;
- w->d()->readonly = readOnly;
-
- db.transaction();
- if (callback) {
- JSCallData jsCall(scope, 1);
- *jsCall->thisObject = scope.engine->globalObject;
- jsCall->args[0] = w;
- TransactionRollback rollbackOnException(&db, &w->d()->inTransaction);
- callback->call(jsCall);
- rollbackOnException.clear();
-
- if (!db.commit())
- db.rollback();
- }
-
- RETURN_UNDEFINED();
-}
-
-static ReturnedValue qmlsqldatabase_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
-{
- return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, false);
-}
-
-static ReturnedValue qmlsqldatabase_read_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
-{
- return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, true);
-}
-
-QQmlSqlDatabaseData::QQmlSqlDatabaseData(ExecutionEngine *v4)
-{
- Scope scope(v4);
- {
- ScopedObject proto(scope, v4->newObject());
- proto->defineDefaultProperty(QStringLiteral("transaction"), qmlsqldatabase_transaction);
- proto->defineDefaultProperty(QStringLiteral("readTransaction"), qmlsqldatabase_read_transaction);
- proto->defineAccessorProperty(QStringLiteral("version"), qmlsqldatabase_version, nullptr);
- proto->defineDefaultProperty(QStringLiteral("changeVersion"), qmlsqldatabase_changeVersion);
- databaseProto = proto;
- }
-
- {
- ScopedObject proto(scope, v4->newObject());
- proto->defineDefaultProperty(QStringLiteral("executeSql"), qmlsqldatabase_executeSql);
- queryProto = proto;
- }
- {
- ScopedObject proto(scope, v4->newObject());
- proto->defineDefaultProperty(QStringLiteral("item"), qmlsqldatabase_rows_item);
- proto->defineAccessorProperty(QStringLiteral("length"), qmlsqldatabase_rows_length, nullptr);
- proto->defineAccessorProperty(QStringLiteral("forwardOnly"),
- qmlsqldatabase_rows_forwardOnly, qmlsqldatabase_rows_setForwardOnly);
- rowsProto = proto;
- }
-}
-
-/*
-HTML5 "spec" says "rs.rows[n]", but WebKit only impelments "rs.rows.item(n)". We do both (and property iterator).
-We add a "forwardOnly" property that stops Qt caching results (code promises to only go forward
-through the data.
-*/
-
-
-/*!
- \qmlmodule QtQuick.LocalStorage 2.\QtMinorVersion
- \title Qt Quick Local Storage QML Types
- \ingroup qmlmodules
- \brief Provides a JavaScript object singleton type for accessing a local
- SQLite database
-
- This is a singleton type for reading and writing to SQLite databases.
-
-
- \section1 Methods
-
- \list
- \li object \b{\l{#openDatabaseSync}{openDatabaseSync}}(string name, string version, string description, int estimated_size, jsobject callback(db))
- \endlist
-
-
- \section1 Detailed Description
-
- To use the types in this module, import the module and call the
- relevant functions using the \c LocalStorage type:
-
- \qml \QtMinorVersion
- import QtQuick 2.\1
- import QtQuick.LocalStorage 2.\1
-
- Item {
- Component.onCompleted: {
- var db = LocalStorage.openDatabaseSync(...)
- }
- }
- \endqml
-
-
-These databases are user-specific and QML-specific, but accessible to all QML applications.
-They are stored in the \c Databases subdirectory
-of QQmlEngine::offlineStoragePath(), currently as SQLite databases.
-
-Database connections are automatically closed during Javascript garbage collection.
-
-The API can be used from JavaScript functions in your QML:
-
-\snippet qml/localstorage/hello.qml 0
-
-The API conforms to the Synchronous API of the HTML5 Web Database API,
-\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink.
-
-The \l{Qt Quick Examples - Local Storage}{SQL Local Storage example} demonstrates the basics of
-using the Offline Storage API.
-
-\section3 Open or Create a Database
-
-\qml \QtMinorVersion
-import QtQuick.LocalStorage 2.\1 as Sql
-
-db = Sql.openDatabaseSync(identifier, version, description, estimated_size, callback(db))
-\endqml
-
-The above code returns the database identified by \e identifier. If the database does not already exist, it
-is created, and the function \e callback is called with the database as a parameter. \e identifier is the
-name of the physical file (with or without full path) containing the database. \e description and
-\e estimated_size are written to the INI file (described below), but are currently unused.
-
-May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR.
-
-When a database is first created, an INI file is also created specifying its characteristics:
-
-\table
-\header \li \b {Key} \li \b {Value}
-\row \li Identifier \li The name of the database passed to \c openDatabase()
-\row \li Version \li The version of the database passed to \c openDatabase()
-\row \li Description \li The description of the database passed to \c openDatabase()
-\row \li EstimatedSize \li The estimated size (in bytes) of the database passed to \c openDatabase()
-\row \li Driver \li Currently "QSQLITE"
-\endtable
-
-This data can be used by application tools.
-
-\section3 db.changeVersion(from, to, callback(tx))
-
-This method allows you to perform a \e{Scheme Upgrade}. If it succeeds it returns a new
-database object of version \e to. Otherwise it returns \e undefined.
-
-If the current version of \e db is not \e from, then an exception is thrown.
-
-Otherwise, a database transaction is created and passed to \e callback. In this function,
-you can call \e executeSql on \e tx to upgrade the database.
-
-May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR.
-
-See example below.
-
-\badcode
- var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000);
- if (db.version == "0.1") {
- db.changeVersion("0.1", "0.2", function(tx) {
- tx.executeSql("INSERT INTO trip_log VALUES(?, ?, ?)",
- [ "01/10/2016","Sylling - Vikersund", "53" ]);
- }
- });
-\endcode
-
-\section3 db.transaction(callback(tx))
-
-This method creates a read/write transaction and passed to \e callback. In this function,
-you can call \e executeSql on \e tx to read and modify the database.
-
-If the callback throws exceptions, the transaction is rolled back.
-Below you will find an example of a database transaction which catches exceptions.
-
-
-\quotefromfile localstorage/localstorage/Database.js
-\skipuntil dbInit()
-\printto dbGetHandle
-
-In the example you can see an \c insert statement where values are assigned to the fields,
-and the record is written into the table. That is an \c insert statement with a syntax that is usual
-for a relational database. It is however also possible to work with JSON objects and
-store them in a table.
-
-Let's suppose a simple example where we store trips in JSON format using \c date as the unique key.
-An example of a table that could be used for that purpose:
-
-\badcode
- create table trip_log(date text, data text)
-\endcode
-
-The assignment of values to a JSON object:
-
-\badcode
- var obj = {description = "Vikersund - Noresund", distance = "60"}
-\endcode
-
-In that case, the data could be saved in the following way:
-
-\badcode
- db.transaction(function(tx) {
- result = tx.executeSQL("insert into trip_log values (?,?)",
- ["01/11/2016", JSON.stringify(obj)])
-
-\endcode
-
-\section3 db.readTransaction(callback(tx))
-
-This method creates a read-only transaction and passed to \e callback. In this function,
-you can call \e executeSql on \e tx to read the database (with \c select statements).
-
-\section3 results = tx.executeSql(statement, values)
-
-This method executes an SQL \e statement, binding the list of \e values to SQL positional parameters ("?").
-
-It returns a results object, with the following properties:
-
-\table
-\header \li \b {Type} \li \b {Property} \li \b {Value} \li \b {Applicability}
-\row \li int \li rows.length \li The number of rows in the result \li SELECT
-\row \li var \li rows.item(i) \li Function that returns row \e i of the result \li SELECT
-\row \li int \li rowsAffected \li The number of rows affected by a modification \li UPDATE, DELETE
-\row \li string \li insertId \li The id of the row inserted \li INSERT
-\endtable
-
-May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR.
-
-See below for an example:
-
-\quotefromfile localstorage/localstorage/Database.js
-\skipto dbReadAll()
-\printto dbUpdate(Pdate
-
-\section1 Method Documentation
-
-\target openDatabaseSync
-\code
-object openDatabaseSync(string name, string version, string description, int estimated_size, jsobject callback(db))
-\endcode
-
-Opens or creates a local storage sql database by the given parameters.
-
-\list
-\li \c name is the database name
-\li \c version is the database version
-\li \c description is the database display name
-\li \c estimated_size is the database's estimated size, in bytes
-\li \c callback is an optional parameter, which is invoked if the database has not yet been created.
-\endlist
-
-Returns the created database object.
-
-*/
-class QQuickLocalStorage : public QObject
-{
- Q_OBJECT
-public:
- QQuickLocalStorage(QObject *parent=nullptr) : QObject(parent)
- {
- }
- ~QQuickLocalStorage() override {
- }
-
- Q_INVOKABLE void openDatabaseSync(QQmlV4Function* args);
-};
-
-void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
-{
-#if QT_CONFIG(settings)
- QV4::Scope scope(args->v4engine());
- if (scope.engine->qmlEngine()->offlineStoragePath().isEmpty())
- V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled."));
-
- QV4::ScopedValue v(scope);
- QString dbname = (v = (*args)[0])->toQStringNoThrow();
- QString dbversion = (v = (*args)[1])->toQStringNoThrow();
- QString dbdescription = (v = (*args)[2])->toQStringNoThrow();
- int dbestimatedsize = (v = (*args)[3])->toInt32();
- FunctionObject *dbcreationCallback = (v = (*args)[4])->as<FunctionObject>();
- QString basename = args->v4engine()->qmlEngine()->offlineStorageDatabaseFilePath(dbname);
- QFileInfo dbFile(basename);
- if (!QDir().mkpath(dbFile.dir().absolutePath())) {
- const QString message = QQmlEngine::tr("LocalStorage: can't create path %1").
- arg(QDir::toNativeSeparators(dbFile.dir().absolutePath()));
- V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, message);
- }
- QString dbid = dbFile.fileName();
- bool created = false;
- QString version = dbversion;
- QSqlDatabase database;
-
- {
- QSettings ini(basename+QLatin1String(".ini"),QSettings::IniFormat);
-
- if (QSqlDatabase::connectionNames().contains(dbid)) {
- database = QSqlDatabase::database(dbid);
- version = ini.value(QLatin1String("Version")).toString();
- if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty())
- V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("SQL: database version mismatch"));
- } else {
- created = !QFile::exists(basename+QLatin1String(".sqlite"));
- if (created) {
- ini.setValue(QLatin1String("Name"), dbname);
- if (dbcreationCallback)
- version = QString();
- ini.setValue(QLatin1String("Version"), version);
- ini.setValue(QLatin1String("Description"), dbdescription);
- ini.setValue(QLatin1String("EstimatedSize"), dbestimatedsize);
- ini.setValue(QLatin1String("Driver"), QLatin1String("QSQLITE"));
- } else {
- if (!dbversion.isEmpty() && ini.value(QLatin1String("Version")) != dbversion) {
- // Incompatible
- V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR,QQmlEngine::tr("SQL: database version mismatch"));
- }
- version = ini.value(QLatin1String("Version")).toString();
- }
- database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid);
- database.setDatabaseName(basename+QLatin1String(".sqlite"));
- }
- if (!database.isOpen())
- database.open();
- }
-
- QV4::Scoped<QQmlSqlDatabaseWrapper> db(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
- QV4::ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value());
- db->setPrototypeUnchecked(p.getPointer());
- *db->d()->database = database;
- *db->d()->version = version;
-
- if (created && dbcreationCallback) {
- JSCallData jsCall(scope, 1);
- *jsCall->thisObject = scope.engine->globalObject;
- jsCall->args[0] = db;
- dbcreationCallback->call(jsCall);
- }
-
- args->setReturnValue(db.asReturnedValue());
-#else
- Q_UNUSED(args)
-#endif // settings
-}
-
-static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
- QQuickLocalStorage *api = new QQuickLocalStorage();
-
- return api;
-}
-
class QQmlLocalStoragePlugin : public QQmlExtensionPlugin
{
Q_OBJECT
@@ -823,7 +56,7 @@ public:
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.LocalStorage"));
- qmlRegisterSingletonType<QQuickLocalStorage>(uri, 2, 0, "LocalStorage", module_api_factory);
+ qmlRegisterTypesAndRevisions<QQuickLocalStorage>(uri, 2);
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
qmlRegisterModule(uri, 2, QT_VERSION_MINOR);
diff --git a/src/imports/localstorage/qquicklocalstorage.cpp b/src/imports/localstorage/qquicklocalstorage.cpp
new file mode 100644
index 0000000000..333e697e3c
--- /dev/null
+++ b/src/imports/localstorage/qquicklocalstorage.cpp
@@ -0,0 +1,792 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicklocalstorage_p.h"
+
+#include <QtQml/private/qqmlengine_p.h>
+#include <QtQml/private/qv4global_p.h>
+#include <QtQml/private/qv4scopedvalue_p.h>
+#include <QtQml/private/qv4object_p.h>
+#include <QtQml/private/qv4sqlerrors_p.h>
+#include <QtQml/private/qv4jscall_p.h>
+#include <QtQml/private/qv4objectiterator_p.h>
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+
+#include <QtSql/qsqldatabase.h>
+#include <QtSql/qsqlquery.h>
+#include <QtSql/qsqlrecord.h>
+#include <QtSql/qsqlerror.h>
+
+#if QT_CONFIG(settings)
+#include <QtCore/qsettings.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#define V4THROW_SQL(error, desc) { \
+ QV4::ScopedString v(scope, scope.engine->newString(desc)); \
+ QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \
+ scope.engine->throwError(ex); \
+ RETURN_UNDEFINED(); \
+}
+
+#define V4THROW_SQL2(error, desc) { \
+ QV4::ScopedString v(scope, scope.engine->newString(desc)); \
+ QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \
+ args->setReturnValue(scope.engine->throwError(ex)); \
+ return; \
+}
+
+#define V4THROW_REFERENCE(string) { \
+ QV4::ScopedString v(scope, scope.engine->newString(string)); \
+ scope.engine->throwReferenceError(v); \
+ RETURN_UNDEFINED(); \
+}
+
+
+class QQmlSqlDatabaseData : public QV4::ExecutionEngine::Deletable
+{
+public:
+ QQmlSqlDatabaseData(QV4::ExecutionEngine *engine);
+ ~QQmlSqlDatabaseData() override;
+
+ QV4::PersistentValue databaseProto;
+ QV4::PersistentValue queryProto;
+ QV4::PersistentValue rowsProto;
+};
+
+V4_DEFINE_EXTENSION(QQmlSqlDatabaseData, databaseData)
+
+namespace QV4 {
+
+namespace Heap {
+ struct QQmlSqlDatabaseWrapper : public Object {
+ enum Type { Database, Query, Rows };
+ void init()
+ {
+ Object::init();
+ type = Database;
+ database = new QSqlDatabase;
+ version = new QString;
+ sqlQuery = new QSqlQuery;
+ }
+
+ void destroy() {
+ delete database;
+ delete version;
+ delete sqlQuery;
+ Object::destroy();
+ }
+
+ Type type;
+ QSqlDatabase *database;
+
+ QString *version; // type == Database
+
+ bool inTransaction; // type == Query
+ bool readonly; // type == Query
+
+ QSqlQuery *sqlQuery; // type == Rows
+ bool forwardOnly; // type == Rows
+ };
+}
+
+class QQmlSqlDatabaseWrapper : public Object
+{
+public:
+ V4_OBJECT2(QQmlSqlDatabaseWrapper, Object)
+ V4_NEEDS_DESTROY
+
+ static Heap::QQmlSqlDatabaseWrapper *create(QV4::ExecutionEngine *engine)
+ {
+ return engine->memoryManager->allocate<QQmlSqlDatabaseWrapper>();
+ }
+
+ ~QQmlSqlDatabaseWrapper() {
+ }
+
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+};
+
+}
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper);
+
+
+
+static ReturnedValue qmlsqldatabase_version(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int)
+{
+ Scope scope(b);
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database)
+ V4THROW_REFERENCE("Not a SQLDatabase object");
+
+ RETURN_RESULT(Encode(scope.engine->newString(*r->d()->version)));
+}
+
+static ReturnedValue qmlsqldatabase_rows_length(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int)
+{
+ Scope scope(b);
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
+ V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
+
+ int s = r->d()->sqlQuery->size();
+ if (s < 0) {
+ // Inefficient
+ if (r->d()->sqlQuery->last()) {
+ s = r->d()->sqlQuery->at() + 1;
+ } else {
+ s = 0;
+ }
+ }
+ RETURN_RESULT(Encode(s));
+}
+
+static ReturnedValue qmlsqldatabase_rows_forwardOnly(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int)
+{
+ Scope scope(b);
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
+ V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
+ RETURN_RESULT(Encode(r->d()->sqlQuery->isForwardOnly()));
+}
+
+static ReturnedValue qmlsqldatabase_rows_setForwardOnly(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
+ V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
+ if (argc < 1)
+ RETURN_RESULT(scope.engine->throwTypeError());
+
+ r->d()->sqlQuery->setForwardOnly(argv[0].toBoolean());
+ RETURN_UNDEFINED();
+}
+
+QQmlSqlDatabaseData::~QQmlSqlDatabaseData()
+{
+}
+
+static ReturnedValue qmlsqldatabase_rows_index(const QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = nullptr)
+{
+ Scope scope(v4);
+
+ if (r->d()->sqlQuery->at() == (int)index || r->d()->sqlQuery->seek(index)) {
+ QSqlRecord record = r->d()->sqlQuery->record();
+ // XXX optimize
+ ScopedObject row(scope, v4->newObject());
+ for (int ii = 0; ii < record.count(); ++ii) {
+ QVariant v = record.value(ii);
+ ScopedString s(scope, v4->newIdentifier(record.fieldName(ii)));
+ ScopedValue val(scope, v.isNull() ? Encode::null() : v4->fromVariant(v));
+ row->put(s.getPointer(), val);
+ }
+ if (hasProperty)
+ *hasProperty = true;
+ return row.asReturnedValue();
+ } else {
+ if (hasProperty)
+ *hasProperty = false;
+ return Encode::undefined();
+ }
+}
+
+ReturnedValue QQmlSqlDatabaseWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
+{
+ if (!id.isArrayIndex())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
+ uint index = id.asArrayIndex();
+ Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>());
+ const QQmlSqlDatabaseWrapper *r = static_cast<const QQmlSqlDatabaseWrapper *>(m);
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
+ return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty);
+}
+
+static ReturnedValue qmlsqldatabase_rows_item(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
+ V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
+
+ RETURN_RESULT(qmlsqldatabase_rows_index(r, scope.engine, argc ? argv[0].toUInt32() : 0));
+}
+
+static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValue &value)
+{
+ // toVariant() maps a null JS value to QVariant(VoidStar), but the SQL module
+ // expects a null variant. (this is because of QTBUG-40880)
+ if (value->isNull())
+ return QVariant();
+ return engine->toVariant(value, /*typehint*/-1);
+}
+
+static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Query)
+ V4THROW_REFERENCE("Not a SQLDatabase::Query object");
+
+ if (!r->d()->inTransaction)
+ V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,QQmlEngine::tr("executeSql called outside transaction()"));
+
+ QSqlDatabase db = *r->d()->database;
+
+ QString sql = argc ? argv[0].toQString() : QString();
+
+ if (r->d()->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) {
+ V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction"));
+ }
+
+ QSqlQuery query(db);
+ bool err = false;
+
+ ScopedValue result(scope, Value::undefinedValue());
+
+ if (query.prepare(sql)) {
+ if (argc > 1) {
+ ScopedValue values(scope, argv[1]);
+ if (values->as<ArrayObject>()) {
+ ScopedArrayObject array(scope, values);
+ quint32 size = array->getLength();
+ QV4::ScopedValue v(scope);
+ for (quint32 ii = 0; ii < size; ++ii) {
+ query.bindValue(ii, toSqlVariant(scope.engine, (v = array->get(ii))));
+ }
+ } else if (values->as<Object>()) {
+ ScopedObject object(scope, values);
+ ObjectIterator it(scope, object, ObjectIterator::EnumerableOnly);
+ ScopedValue key(scope);
+ QV4::ScopedValue val(scope);
+ while (1) {
+ key = it.nextPropertyName(val);
+ if (key->isNull())
+ break;
+ QVariant v = toSqlVariant(scope.engine, val);
+ if (key->isString()) {
+ query.bindValue(key->stringValue()->toQString(), v);
+ } else {
+ Q_ASSERT(key->isInteger());
+ query.bindValue(key->integerValue(), v);
+ }
+ }
+ } else {
+ query.bindValue(0, toSqlVariant(scope.engine, values));
+ }
+ }
+ if (query.exec()) {
+ QV4::Scoped<QQmlSqlDatabaseWrapper> rows(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
+ QV4::ScopedObject p(scope, databaseData(scope.engine)->rowsProto.value());
+ rows->setPrototypeUnchecked(p.getPointer());
+ rows->d()->type = Heap::QQmlSqlDatabaseWrapper::Rows;
+ *rows->d()->database = db;
+ *rows->d()->sqlQuery = query;
+
+ ScopedObject resultObject(scope, scope.engine->newObject());
+ result = resultObject.asReturnedValue();
+ // XXX optimize
+ ScopedString s(scope);
+ ScopedValue v(scope);
+ resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Value::fromInt32(query.numRowsAffected())));
+ resultObject->put((s = scope.engine->newIdentifier("insertId")).getPointer(), (v = scope.engine->newString(query.lastInsertId().toString())));
+ resultObject->put((s = scope.engine->newIdentifier("rows")).getPointer(), rows);
+ } else {
+ err = true;
+ }
+ } else {
+ err = true;
+ }
+ if (err)
+ V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,query.lastError().text());
+
+ RETURN_RESULT(result->asReturnedValue());
+}
+
+struct TransactionRollback {
+ QSqlDatabase *db;
+ bool *inTransactionFlag;
+
+ TransactionRollback(QSqlDatabase *database, bool *transactionFlag)
+ : db(database)
+ , inTransactionFlag(transactionFlag)
+ {
+ if (inTransactionFlag)
+ *inTransactionFlag = true;
+ }
+
+ ~TransactionRollback()
+ {
+ if (inTransactionFlag)
+ *inTransactionFlag = false;
+ if (db)
+ db->rollback();
+ }
+
+ void clear() {
+ db = nullptr;
+ if (inTransactionFlag)
+ *inTransactionFlag = false;
+ inTransactionFlag = nullptr;
+ }
+};
+
+
+static ReturnedValue qmlsqldatabase_changeVersion(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ if (argc < 2)
+ RETURN_UNDEFINED();
+
+ Scoped<QQmlSqlDatabaseWrapper> r(scope, *thisObject);
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database)
+ V4THROW_REFERENCE("Not a SQLDatabase object");
+
+ QSqlDatabase db = *r->d()->database;
+ QString from_version = argv[0].toQString();
+ QString to_version = argv[1].toQString();
+ ScopedFunctionObject callback(scope, argc > 2 ? argv[2] : Value::undefinedValue());
+
+ if (from_version != *r->d()->version)
+ V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version));
+
+ bool ok = true;
+ if (!!callback) {
+ Scoped<QQmlSqlDatabaseWrapper> query(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
+ ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
+ query->setPrototypeUnchecked(p.getPointer());
+ query->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
+ *query->d()->database = db;
+ *query->d()->version = *r->d()->version;
+
+ ok = false;
+ db.transaction();
+
+ JSCallData jsCall(scope, 1);
+ *jsCall->thisObject = scope.engine->globalObject;
+ jsCall->args[0] = query;
+
+ TransactionRollback rollbackOnException(&db, &query->d()->inTransaction);
+ callback->call(jsCall);
+ rollbackOnException.clear();
+ if (!db.commit()) {
+ db.rollback();
+ V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QQmlEngine::tr("SQL transaction failed"));
+ } else {
+ ok = true;
+ }
+ }
+
+ if (ok) {
+ Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
+ ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value());
+ w->setPrototypeUnchecked(p.getPointer());
+ w->d()->type = Heap::QQmlSqlDatabaseWrapper::Database;
+ *w->d()->database = db;
+ *w->d()->version = to_version;
+#if QT_CONFIG(settings)
+ const QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(scope.engine->qmlEngine());
+ QSettings ini(enginePrivate->offlineStorageDatabaseDirectory() + db.connectionName() + QLatin1String(".ini"), QSettings::IniFormat);
+ ini.setValue(QLatin1String("Version"), to_version);
+#endif
+ RETURN_RESULT(w.asReturnedValue());
+ }
+
+ RETURN_UNDEFINED();
+}
+
+static ReturnedValue qmlsqldatabase_transaction_shared(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool readOnly)
+{
+ Scope scope(b);
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>());
+ if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database)
+ V4THROW_REFERENCE("Not a SQLDatabase object");
+
+ const FunctionObject *callback = argc ? argv[0].as<FunctionObject>() : nullptr;
+ if (!callback)
+ V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback"));
+
+ QSqlDatabase db = *r->d()->database;
+
+ Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
+ QV4::ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
+ w->setPrototypeUnchecked(p.getPointer());
+ w->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
+ *w->d()->database = db;
+ *w->d()->version = *r->d()->version;
+ w->d()->readonly = readOnly;
+
+ db.transaction();
+ if (callback) {
+ JSCallData jsCall(scope, 1);
+ *jsCall->thisObject = scope.engine->globalObject;
+ jsCall->args[0] = w;
+ TransactionRollback rollbackOnException(&db, &w->d()->inTransaction);
+ callback->call(jsCall);
+ rollbackOnException.clear();
+
+ if (!db.commit())
+ db.rollback();
+ }
+
+ RETURN_UNDEFINED();
+}
+
+static ReturnedValue qmlsqldatabase_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, false);
+}
+
+static ReturnedValue qmlsqldatabase_read_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, true);
+}
+
+QQmlSqlDatabaseData::QQmlSqlDatabaseData(ExecutionEngine *v4)
+{
+ Scope scope(v4);
+ {
+ ScopedObject proto(scope, v4->newObject());
+ proto->defineDefaultProperty(QStringLiteral("transaction"), qmlsqldatabase_transaction);
+ proto->defineDefaultProperty(QStringLiteral("readTransaction"), qmlsqldatabase_read_transaction);
+ proto->defineAccessorProperty(QStringLiteral("version"), qmlsqldatabase_version, nullptr);
+ proto->defineDefaultProperty(QStringLiteral("changeVersion"), qmlsqldatabase_changeVersion);
+ databaseProto = proto;
+ }
+
+ {
+ ScopedObject proto(scope, v4->newObject());
+ proto->defineDefaultProperty(QStringLiteral("executeSql"), qmlsqldatabase_executeSql);
+ queryProto = proto;
+ }
+ {
+ ScopedObject proto(scope, v4->newObject());
+ proto->defineDefaultProperty(QStringLiteral("item"), qmlsqldatabase_rows_item);
+ proto->defineAccessorProperty(QStringLiteral("length"), qmlsqldatabase_rows_length, nullptr);
+ proto->defineAccessorProperty(QStringLiteral("forwardOnly"),
+ qmlsqldatabase_rows_forwardOnly, qmlsqldatabase_rows_setForwardOnly);
+ rowsProto = proto;
+ }
+}
+
+/*
+HTML5 "spec" says "rs.rows[n]", but WebKit only impelments "rs.rows.item(n)". We do both (and property iterator).
+We add a "forwardOnly" property that stops Qt caching results (code promises to only go forward
+through the data.
+*/
+
+
+/*!
+ \qmlmodule QtQuick.LocalStorage 2.\QtMinorVersion
+ \title Qt Quick Local Storage QML Types
+ \ingroup qmlmodules
+ \brief Provides a JavaScript object singleton type for accessing a local
+ SQLite database
+
+ This is a singleton type for reading and writing to SQLite databases.
+
+
+ \section1 Methods
+
+ \list
+ \li object \b{\l{#openDatabaseSync}{openDatabaseSync}}(string name, string version, string description, int estimated_size, jsobject callback(db))
+ \endlist
+
+
+ \section1 Detailed Description
+
+ To use the types in this module, import the module and call the
+ relevant functions using the \c LocalStorage type:
+
+ \qml \QtMinorVersion
+ import QtQuick 2.\1
+ import QtQuick.LocalStorage 2.\1
+
+ Item {
+ Component.onCompleted: {
+ var db = LocalStorage.openDatabaseSync(...)
+ }
+ }
+ \endqml
+
+
+These databases are user-specific and QML-specific, but accessible to all QML applications.
+They are stored in the \c Databases subdirectory
+of QQmlEngine::offlineStoragePath(), currently as SQLite databases.
+
+Database connections are automatically closed during Javascript garbage collection.
+
+The API can be used from JavaScript functions in your QML:
+
+\snippet qml/localstorage/hello.qml 0
+
+The API conforms to the Synchronous API of the HTML5 Web Database API,
+\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink.
+
+The \l{Qt Quick Examples - Local Storage}{SQL Local Storage example} demonstrates the basics of
+using the Offline Storage API.
+
+\section3 Open or Create a Database
+
+\qml \QtMinorVersion
+import QtQuick.LocalStorage 2.\1 as Sql
+
+db = Sql.openDatabaseSync(identifier, version, description, estimated_size, callback(db))
+\endqml
+
+The above code returns the database identified by \e identifier. If the database does not already exist, it
+is created, and the function \e callback is called with the database as a parameter. \e identifier is the
+name of the physical file (with or without full path) containing the database. \e description and
+\e estimated_size are written to the INI file (described below), but are currently unused.
+
+May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR.
+
+When a database is first created, an INI file is also created specifying its characteristics:
+
+\table
+\header \li \b {Key} \li \b {Value}
+\row \li Identifier \li The name of the database passed to \c openDatabase()
+\row \li Version \li The version of the database passed to \c openDatabase()
+\row \li Description \li The description of the database passed to \c openDatabase()
+\row \li EstimatedSize \li The estimated size (in bytes) of the database passed to \c openDatabase()
+\row \li Driver \li Currently "QSQLITE"
+\endtable
+
+This data can be used by application tools.
+
+\section3 db.changeVersion(from, to, callback(tx))
+
+This method allows you to perform a \e{Scheme Upgrade}. If it succeeds it returns a new
+database object of version \e to. Otherwise it returns \e undefined.
+
+If the current version of \e db is not \e from, then an exception is thrown.
+
+Otherwise, a database transaction is created and passed to \e callback. In this function,
+you can call \e executeSql on \e tx to upgrade the database.
+
+May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR.
+
+See example below.
+
+\badcode
+ var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000);
+ if (db.version == "0.1") {
+ db.changeVersion("0.1", "0.2", function(tx) {
+ tx.executeSql("INSERT INTO trip_log VALUES(?, ?, ?)",
+ [ "01/10/2016","Sylling - Vikersund", "53" ]);
+ }
+ });
+\endcode
+
+\section3 db.transaction(callback(tx))
+
+This method creates a read/write transaction and passed to \e callback. In this function,
+you can call \e executeSql on \e tx to read and modify the database.
+
+If the callback throws exceptions, the transaction is rolled back.
+Below you will find an example of a database transaction which catches exceptions.
+
+
+\quotefromfile localstorage/localstorage/Database.js
+\skipuntil dbInit()
+\printto dbGetHandle
+
+In the example you can see an \c insert statement where values are assigned to the fields,
+and the record is written into the table. That is an \c insert statement with a syntax that is usual
+for a relational database. It is however also possible to work with JSON objects and
+store them in a table.
+
+Let's suppose a simple example where we store trips in JSON format using \c date as the unique key.
+An example of a table that could be used for that purpose:
+
+\badcode
+ create table trip_log(date text, data text)
+\endcode
+
+The assignment of values to a JSON object:
+
+\badcode
+ var obj = {description = "Vikersund - Noresund", distance = "60"}
+\endcode
+
+In that case, the data could be saved in the following way:
+
+\badcode
+ db.transaction(function(tx) {
+ result = tx.executeSQL("insert into trip_log values (?,?)",
+ ["01/11/2016", JSON.stringify(obj)])
+
+\endcode
+
+\section3 db.readTransaction(callback(tx))
+
+This method creates a read-only transaction and passed to \e callback. In this function,
+you can call \e executeSql on \e tx to read the database (with \c select statements).
+
+\section3 results = tx.executeSql(statement, values)
+
+This method executes an SQL \e statement, binding the list of \e values to SQL positional parameters ("?").
+
+It returns a results object, with the following properties:
+
+\table
+\header \li \b {Type} \li \b {Property} \li \b {Value} \li \b {Applicability}
+\row \li int \li rows.length \li The number of rows in the result \li SELECT
+\row \li var \li rows.item(i) \li Function that returns row \e i of the result \li SELECT
+\row \li int \li rowsAffected \li The number of rows affected by a modification \li UPDATE, DELETE
+\row \li string \li insertId \li The id of the row inserted \li INSERT
+\endtable
+
+May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR.
+
+See below for an example:
+
+\quotefromfile localstorage/localstorage/Database.js
+\skipto dbReadAll()
+\printto dbUpdate(Pdate
+
+\section1 Method Documentation
+
+\target openDatabaseSync
+\code
+object openDatabaseSync(string name, string version, string description, int estimated_size, jsobject callback(db))
+\endcode
+
+Opens or creates a local storage sql database by the given parameters.
+
+\list
+\li \c name is the database name
+\li \c version is the database version
+\li \c description is the database display name
+\li \c estimated_size is the database's estimated size, in bytes
+\li \c callback is an optional parameter, which is invoked if the database has not yet been created.
+\endlist
+
+Returns the created database object.
+
+*/
+
+void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
+{
+#if QT_CONFIG(settings)
+ QV4::Scope scope(args->v4engine());
+ if (scope.engine->qmlEngine()->offlineStoragePath().isEmpty())
+ V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled."));
+
+ QV4::ScopedValue v(scope);
+ QString dbname = (v = (*args)[0])->toQStringNoThrow();
+ QString dbversion = (v = (*args)[1])->toQStringNoThrow();
+ QString dbdescription = (v = (*args)[2])->toQStringNoThrow();
+ int dbestimatedsize = (v = (*args)[3])->toInt32();
+ FunctionObject *dbcreationCallback = (v = (*args)[4])->as<FunctionObject>();
+ QString basename = args->v4engine()->qmlEngine()->offlineStorageDatabaseFilePath(dbname);
+ QFileInfo dbFile(basename);
+ if (!QDir().mkpath(dbFile.dir().absolutePath())) {
+ const QString message = QQmlEngine::tr("LocalStorage: can't create path %1").
+ arg(QDir::toNativeSeparators(dbFile.dir().absolutePath()));
+ V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, message);
+ }
+ QString dbid = dbFile.fileName();
+ bool created = false;
+ QString version = dbversion;
+ QSqlDatabase database;
+
+ {
+ QSettings ini(basename+QLatin1String(".ini"),QSettings::IniFormat);
+
+ if (QSqlDatabase::connectionNames().contains(dbid)) {
+ database = QSqlDatabase::database(dbid);
+ version = ini.value(QLatin1String("Version")).toString();
+ if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty())
+ V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("SQL: database version mismatch"));
+ } else {
+ created = !QFile::exists(basename+QLatin1String(".sqlite"));
+ if (created) {
+ ini.setValue(QLatin1String("Name"), dbname);
+ if (dbcreationCallback)
+ version = QString();
+ ini.setValue(QLatin1String("Version"), version);
+ ini.setValue(QLatin1String("Description"), dbdescription);
+ ini.setValue(QLatin1String("EstimatedSize"), dbestimatedsize);
+ ini.setValue(QLatin1String("Driver"), QLatin1String("QSQLITE"));
+ } else {
+ if (!dbversion.isEmpty() && ini.value(QLatin1String("Version")) != dbversion) {
+ // Incompatible
+ V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR,QQmlEngine::tr("SQL: database version mismatch"));
+ }
+ version = ini.value(QLatin1String("Version")).toString();
+ }
+ database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid);
+ database.setDatabaseName(basename+QLatin1String(".sqlite"));
+ }
+ if (!database.isOpen())
+ database.open();
+ }
+
+ QV4::Scoped<QQmlSqlDatabaseWrapper> db(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
+ QV4::ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value());
+ db->setPrototypeUnchecked(p.getPointer());
+ *db->d()->database = database;
+ *db->d()->version = version;
+
+ if (created && dbcreationCallback) {
+ JSCallData jsCall(scope, 1);
+ *jsCall->thisObject = scope.engine->globalObject;
+ jsCall->args[0] = db;
+ dbcreationCallback->call(jsCall);
+ }
+
+ args->setReturnValue(db.asReturnedValue());
+#else
+ Q_UNUSED(args)
+#endif // settings
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/localstorage/qquicklocalstorage_p.h b/src/imports/localstorage/qquicklocalstorage_p.h
new file mode 100644
index 0000000000..d2ebc85ce9
--- /dev/null
+++ b/src/imports/localstorage/qquicklocalstorage_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLOCALSTORAGE_P_H
+#define QQUICKLOCALSTORAGE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+#include <QtQml/private/qv4engine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickLocalStorage : public QObject
+{
+ Q_OBJECT
+ QML_NAMED_ELEMENT(LocalStorage)
+ QML_SINGLETON
+
+public:
+ QQuickLocalStorage(QObject *parent = nullptr) : QObject(parent) {}
+ ~QQuickLocalStorage() override = default;
+
+ Q_INVOKABLE void openDatabaseSync(QQmlV4Function* args);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKLOCALSTORAGE_P_H
diff --git a/src/imports/models/plugins.qmltypes b/src/imports/models/plugins.qmltypes
index 58122b9b45..89a839e502 100644
--- a/src/imports/models/plugins.qmltypes
+++ b/src/imports/models/plugins.qmltypes
@@ -398,7 +398,7 @@ Module {
defaultProperty: "delegate"
prototype: "QQmlInstanceModel"
exports: ["QtQml.Models/DelegateModel 2.1"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [1]
attachedType: "QQmlDelegateModelAttached"
Property { name: "model"; type: "QVariant" }
Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
@@ -434,7 +434,7 @@ Module {
name: "QQmlDelegateModelGroup"
prototype: "QObject"
exports: ["QtQml.Models/DelegateModelGroup 2.1"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [1]
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "name"; type: "string" }
Property { name: "includeByDefault"; type: "bool" }
@@ -539,13 +539,13 @@ Module {
name: "QQmlListElement"
prototype: "QObject"
exports: ["QtQml.Models/ListElement 2.1"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [1]
}
Component {
name: "QQmlListModel"
prototype: "QAbstractListModel"
- exports: ["QtQml.Models/ListModel 2.1"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQml.Models/ListModel 2.1", "QtQml.Models/ListModel 2.14"]
+ exportMetaObjectRevisions: [1, 14]
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "dynamicRoles"; type: "bool" }
Property { name: "agent"; revision: 14; type: "QObject"; isReadonly: true; isPointer: true }
@@ -642,7 +642,7 @@ Module {
"QtQml.Models/ObjectModel 2.1",
"QtQml.Models/ObjectModel 2.3"
]
- exportMetaObjectRevisions: [0, 3]
+ exportMetaObjectRevisions: [1, 3]
attachedType: "QQmlObjectModelAttached"
Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
Method { name: "clear"; revision: 3 }
@@ -698,7 +698,7 @@ Module {
defaultProperty: "data"
prototype: "QObject"
exports: ["QtQml.Models/Package 2.14"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [14]
attachedType: "QQuickPackageAttached"
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
}
diff --git a/src/imports/particles/plugins.qmltypes b/src/imports/particles/plugins.qmltypes
index 0a5e124c3c..48da0b26ed 100644
--- a/src/imports/particles/plugins.qmltypes
+++ b/src/imports/particles/plugins.qmltypes
@@ -12,8 +12,14 @@ Module {
name: "QQuickAgeAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/Age 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Age 2.0",
+ "QtQuick.Particles/Age 2.1",
+ "QtQuick.Particles/Age 2.11",
+ "QtQuick.Particles/Age 2.4",
+ "QtQuick.Particles/Age 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "lifeLeft"; type: "int" }
Property { name: "advancePosition"; type: "bool" }
Signal {
@@ -79,8 +85,14 @@ Module {
name: "QQuickAttractorAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/Attractor 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Attractor 2.0",
+ "QtQuick.Particles/Attractor 2.1",
+ "QtQuick.Particles/Attractor 2.11",
+ "QtQuick.Particles/Attractor 2.4",
+ "QtQuick.Particles/Attractor 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "Proportion"
values: {
@@ -157,8 +169,14 @@ Module {
name: "QQuickCustomAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/Affector 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Affector 2.0",
+ "QtQuick.Particles/Affector 2.1",
+ "QtQuick.Particles/Affector 2.11",
+ "QtQuick.Particles/Affector 2.4",
+ "QtQuick.Particles/Affector 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "relative"; type: "bool" }
Property { name: "position"; type: "QQuickDirection"; isPointer: true }
Property { name: "velocity"; type: "QQuickDirection"; isPointer: true }
@@ -205,8 +223,14 @@ Module {
name: "QQuickCustomParticle"
defaultProperty: "data"
prototype: "QQuickParticlePainter"
- exports: ["QtQuick.Particles/CustomParticle 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/CustomParticle 2.0",
+ "QtQuick.Particles/CustomParticle 2.1",
+ "QtQuick.Particles/CustomParticle 2.11",
+ "QtQuick.Particles/CustomParticle 2.4",
+ "QtQuick.Particles/CustomParticle 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "fragmentShader"; type: "QByteArray" }
Property { name: "vertexShader"; type: "QByteArray" }
}
@@ -236,8 +260,14 @@ Module {
name: "QQuickFrictionAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/Friction 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Friction 2.0",
+ "QtQuick.Particles/Friction 2.1",
+ "QtQuick.Particles/Friction 2.11",
+ "QtQuick.Particles/Friction 2.4",
+ "QtQuick.Particles/Friction 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "factor"; type: "double" }
Property { name: "threshold"; type: "double" }
Signal {
@@ -261,8 +291,14 @@ Module {
name: "QQuickGravityAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/Gravity 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Gravity 2.0",
+ "QtQuick.Particles/Gravity 2.1",
+ "QtQuick.Particles/Gravity 2.11",
+ "QtQuick.Particles/Gravity 2.4",
+ "QtQuick.Particles/Gravity 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "magnitude"; type: "double" }
Property { name: "acceleration"; type: "double" }
Property { name: "angle"; type: "double" }
@@ -291,8 +327,14 @@ Module {
name: "QQuickGroupGoalAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/GroupGoal 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/GroupGoal 2.0",
+ "QtQuick.Particles/GroupGoal 2.1",
+ "QtQuick.Particles/GroupGoal 2.11",
+ "QtQuick.Particles/GroupGoal 2.4",
+ "QtQuick.Particles/GroupGoal 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "goalState"; type: "string" }
Property { name: "jump"; type: "bool" }
Signal {
@@ -316,8 +358,14 @@ Module {
name: "QQuickImageParticle"
defaultProperty: "data"
prototype: "QQuickParticlePainter"
- exports: ["QtQuick.Particles/ImageParticle 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/ImageParticle 2.0",
+ "QtQuick.Particles/ImageParticle 2.1",
+ "QtQuick.Particles/ImageParticle 2.11",
+ "QtQuick.Particles/ImageParticle 2.4",
+ "QtQuick.Particles/ImageParticle 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "Status"
values: {
@@ -495,8 +543,14 @@ Module {
name: "QQuickItemParticle"
defaultProperty: "data"
prototype: "QQuickParticlePainter"
- exports: ["QtQuick.Particles/ItemParticle 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/ItemParticle 2.0",
+ "QtQuick.Particles/ItemParticle 2.1",
+ "QtQuick.Particles/ItemParticle 2.11",
+ "QtQuick.Particles/ItemParticle 2.4",
+ "QtQuick.Particles/ItemParticle 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
attachedType: "QQuickItemParticleAttached"
Property { name: "fade"; type: "bool" }
Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
@@ -575,9 +629,15 @@ Module {
name: "QQuickParticleAffector"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick.Particles/ParticleAffector 2.0"]
+ exports: [
+ "QtQuick.Particles/ParticleAffector 2.0",
+ "QtQuick.Particles/ParticleAffector 2.1",
+ "QtQuick.Particles/ParticleAffector 2.11",
+ "QtQuick.Particles/ParticleAffector 2.4",
+ "QtQuick.Particles/ParticleAffector 2.7"
+ ]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "system"; type: "QQuickParticleSystem"; isPointer: true }
Property { name: "groups"; type: "QStringList" }
Property { name: "whenCollidingWith"; type: "QStringList" }
@@ -643,8 +703,14 @@ Module {
name: "QQuickParticleEmitter"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick.Particles/Emitter 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Emitter 2.0",
+ "QtQuick.Particles/Emitter 2.1",
+ "QtQuick.Particles/Emitter 2.11",
+ "QtQuick.Particles/Emitter 2.4",
+ "QtQuick.Particles/Emitter 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "Lifetime"
values: {
@@ -839,9 +905,15 @@ Module {
name: "QQuickParticlePainter"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick.Particles/ParticlePainter 2.0"]
+ exports: [
+ "QtQuick.Particles/ParticlePainter 2.0",
+ "QtQuick.Particles/ParticlePainter 2.1",
+ "QtQuick.Particles/ParticlePainter 2.11",
+ "QtQuick.Particles/ParticlePainter 2.4",
+ "QtQuick.Particles/ParticlePainter 2.7"
+ ]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "system"; type: "QQuickParticleSystem"; isPointer: true }
Property { name: "groups"; type: "QStringList" }
Signal { name: "countChanged" }
@@ -871,8 +943,14 @@ Module {
name: "QQuickParticleSystem"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick.Particles/ParticleSystem 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/ParticleSystem 2.0",
+ "QtQuick.Particles/ParticleSystem 2.1",
+ "QtQuick.Particles/ParticleSystem 2.11",
+ "QtQuick.Particles/ParticleSystem 2.4",
+ "QtQuick.Particles/ParticleSystem 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "running"; type: "bool" }
Property { name: "paused"; type: "bool" }
Property { name: "empty"; type: "bool"; isReadonly: true }
@@ -966,8 +1044,14 @@ Module {
name: "QQuickSpriteGoalAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/SpriteGoal 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/SpriteGoal 2.0",
+ "QtQuick.Particles/SpriteGoal 2.1",
+ "QtQuick.Particles/SpriteGoal 2.11",
+ "QtQuick.Particles/SpriteGoal 2.4",
+ "QtQuick.Particles/SpriteGoal 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "goalState"; type: "string" }
Property { name: "jump"; type: "bool" }
Property { name: "systemStates"; type: "bool" }
@@ -1119,8 +1203,14 @@ Module {
name: "QQuickTrailEmitter"
defaultProperty: "data"
prototype: "QQuickParticleEmitter"
- exports: ["QtQuick.Particles/TrailEmitter 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/TrailEmitter 2.0",
+ "QtQuick.Particles/TrailEmitter 2.1",
+ "QtQuick.Particles/TrailEmitter 2.11",
+ "QtQuick.Particles/TrailEmitter 2.4",
+ "QtQuick.Particles/TrailEmitter 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "EmitSize"
values: {
@@ -1182,8 +1272,14 @@ Module {
name: "QQuickTurbulenceAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/Turbulence 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Turbulence 2.0",
+ "QtQuick.Particles/Turbulence 2.1",
+ "QtQuick.Particles/Turbulence 2.11",
+ "QtQuick.Particles/Turbulence 2.4",
+ "QtQuick.Particles/Turbulence 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "strength"; type: "double" }
Property { name: "noiseSource"; type: "QUrl" }
Signal {
@@ -1207,8 +1303,14 @@ Module {
name: "QQuickWanderAffector"
defaultProperty: "data"
prototype: "QQuickParticleAffector"
- exports: ["QtQuick.Particles/Wander 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Particles/Wander 2.0",
+ "QtQuick.Particles/Wander 2.1",
+ "QtQuick.Particles/Wander 2.11",
+ "QtQuick.Particles/Wander 2.4",
+ "QtQuick.Particles/Wander 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "AffectableParameters"
values: {
diff --git a/src/imports/qtqml/plugins.qmltypes b/src/imports/qtqml/plugins.qmltypes
index 7bccfea26a..e4ddb3ddd1 100644
--- a/src/imports/qtqml/plugins.qmltypes
+++ b/src/imports/qtqml/plugins.qmltypes
@@ -170,7 +170,7 @@ Module {
name: "QQmlLocale"
exports: ["QtQml/Locale 2.2"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [2]
Enum {
name: "MeasurementSystem"
values: {
@@ -213,7 +213,7 @@ Module {
name: "QQmlLoggingCategory"
prototype: "QObject"
exports: ["QtQml/LoggingCategory 2.12", "QtQml/LoggingCategory 2.8"]
- exportMetaObjectRevisions: [12, 0]
+ exportMetaObjectRevisions: [12, 8]
Enum {
name: "DefaultLogLevel"
values: {
diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes
index 0ba918e34e..a773a8c428 100644
--- a/src/imports/qtquick2/plugins.qmltypes
+++ b/src/imports/qtquick2/plugins.qmltypes
@@ -1168,8 +1168,11 @@ Module {
Component {
name: "QQuickAnchorAnimation"
prototype: "QQuickAbstractAnimation"
- exports: ["QtQuick/AnchorAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/AnchorAnimation 2.0",
+ "QtQuick/AnchorAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "targets"; type: "QQuickItem"; isList: true; isReadonly: true }
Property { name: "duration"; type: "int" }
Property { name: "easing"; type: "QEasingCurve" }
@@ -1243,8 +1246,16 @@ Module {
name: "QQuickAnimatedImage"
defaultProperty: "data"
prototype: "QQuickImage"
- exports: ["QtQuick/AnimatedImage 2.0", "QtQuick/AnimatedImage 2.11"]
- exportMetaObjectRevisions: [0, 11]
+ exports: [
+ "QtQuick/AnimatedImage 2.0",
+ "QtQuick/AnimatedImage 2.1",
+ "QtQuick/AnimatedImage 2.11",
+ "QtQuick/AnimatedImage 2.3",
+ "QtQuick/AnimatedImage 2.4",
+ "QtQuick/AnimatedImage 2.5",
+ "QtQuick/AnimatedImage 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 3, 4, 5, 7]
Property { name: "playing"; type: "bool" }
Property { name: "paused"; type: "bool" }
Property { name: "currentFrame"; type: "int" }
@@ -1258,8 +1269,15 @@ Module {
name: "QQuickAnimatedSprite"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/AnimatedSprite 2.0", "QtQuick/AnimatedSprite 2.12"]
- exportMetaObjectRevisions: [0, 12]
+ exports: [
+ "QtQuick/AnimatedSprite 2.0",
+ "QtQuick/AnimatedSprite 2.1",
+ "QtQuick/AnimatedSprite 2.11",
+ "QtQuick/AnimatedSprite 2.12",
+ "QtQuick/AnimatedSprite 2.4",
+ "QtQuick/AnimatedSprite 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 12, 4, 7]
Enum {
name: "LoopParameters"
values: {
@@ -1436,9 +1454,9 @@ Module {
Component {
name: "QQuickAnimator"
prototype: "QQuickAbstractAnimation"
- exports: ["QtQuick/Animator 2.2"]
+ exports: ["QtQuick/Animator 2.12", "QtQuick/Animator 2.2"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12, 2]
Property { name: "target"; type: "QQuickItem"; isPointer: true }
Property { name: "easing"; type: "QEasingCurve" }
Property { name: "duration"; type: "int" }
@@ -1489,11 +1507,15 @@ Module {
prototype: "QQuickImplicitSizeItem"
exports: [
"QtQuick/Positioner 2.0",
+ "QtQuick/Positioner 2.1",
+ "QtQuick/Positioner 2.11",
+ "QtQuick/Positioner 2.4",
"QtQuick/Positioner 2.6",
+ "QtQuick/Positioner 2.7",
"QtQuick/Positioner 2.9"
]
isCreatable: false
- exportMetaObjectRevisions: [0, 6, 9]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9]
attachedType: "QQuickPositionerAttached"
Property { name: "spacing"; type: "double" }
Property { name: "populate"; type: "QQuickTransition"; isPointer: true }
@@ -1526,8 +1548,14 @@ Module {
name: "QQuickBorderImage"
defaultProperty: "data"
prototype: "QQuickImageBase"
- exports: ["QtQuick/BorderImage 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/BorderImage 2.0",
+ "QtQuick/BorderImage 2.1",
+ "QtQuick/BorderImage 2.11",
+ "QtQuick/BorderImage 2.4",
+ "QtQuick/BorderImage 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "TileMode"
values: {
@@ -1545,7 +1573,7 @@ Module {
name: "QQuickBorderImageMesh"
prototype: "QQuickShaderEffectMesh"
exports: ["QtQuick/BorderImageMesh 2.8"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [8]
Enum {
name: "TileMode"
values: {
@@ -1563,8 +1591,14 @@ Module {
name: "QQuickCanvasItem"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/Canvas 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/Canvas 2.0",
+ "QtQuick/Canvas 2.1",
+ "QtQuick/Canvas 2.11",
+ "QtQuick/Canvas 2.4",
+ "QtQuick/Canvas 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "RenderTarget"
values: {
@@ -1655,8 +1689,8 @@ Module {
Component {
name: "QQuickColorAnimation"
prototype: "QQuickPropertyAnimation"
- exports: ["QtQuick/ColorAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/ColorAnimation 2.0", "QtQuick/ColorAnimation 2.12"]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "from"; type: "QColor" }
Property { name: "to"; type: "QColor" }
}
@@ -1664,8 +1698,16 @@ Module {
name: "QQuickColumn"
defaultProperty: "data"
prototype: "QQuickBasePositioner"
- exports: ["QtQuick/Column 2.0", "QtQuick/Column 2.6"]
- exportMetaObjectRevisions: [0, 6]
+ exports: [
+ "QtQuick/Column 2.0",
+ "QtQuick/Column 2.1",
+ "QtQuick/Column 2.11",
+ "QtQuick/Column 2.4",
+ "QtQuick/Column 2.6",
+ "QtQuick/Column 2.7",
+ "QtQuick/Column 2.9"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9]
}
Component {
name: "QQuickCurve"
@@ -1752,7 +1794,7 @@ Module {
prototype: "QObject"
exports: ["QtQuick/DragAxis 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Property { name: "minimum"; type: "double" }
Property { name: "maximum"; type: "double" }
Property { name: "enabled"; type: "bool" }
@@ -1761,7 +1803,7 @@ Module {
name: "QQuickDragHandler"
prototype: "QQuickMultiPointHandler"
exports: ["QtQuick/DragHandler 2.12", "QtQuick/DragHandler 2.14"]
- exportMetaObjectRevisions: [0, 14]
+ exportMetaObjectRevisions: [12, 14]
Enum {
name: "SnapMode"
values: {
@@ -1781,8 +1823,14 @@ Module {
name: "QQuickDropArea"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/DropArea 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/DropArea 2.0",
+ "QtQuick/DropArea 2.1",
+ "QtQuick/DropArea 2.11",
+ "QtQuick/DropArea 2.4",
+ "QtQuick/DropArea 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "containsDrag"; type: "bool"; isReadonly: true }
Property { name: "keys"; type: "QStringList" }
Property { name: "drag"; type: "QQuickDropAreaDrag"; isReadonly: true; isPointer: true }
@@ -1859,7 +1907,7 @@ Module {
prototype: "QObject"
exports: ["QtQuick/EventPoint 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Enum {
name: "States"
values: {
@@ -1898,7 +1946,7 @@ Module {
prototype: "QQuickEventPoint"
exports: ["QtQuick/EventTouchPoint 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Property { name: "rotation"; type: "double"; isReadonly: true }
Property { name: "pressure"; type: "double"; isReadonly: true }
Property { name: "ellipseDiameters"; type: "QSizeF"; isReadonly: true }
@@ -1910,11 +1958,15 @@ Module {
prototype: "QQuickItem"
exports: [
"QtQuick/Flickable 2.0",
+ "QtQuick/Flickable 2.1",
"QtQuick/Flickable 2.10",
+ "QtQuick/Flickable 2.11",
"QtQuick/Flickable 2.12",
+ "QtQuick/Flickable 2.4",
+ "QtQuick/Flickable 2.7",
"QtQuick/Flickable 2.9"
]
- exportMetaObjectRevisions: [0, 10, 12, 9]
+ exportMetaObjectRevisions: [0, 1, 10, 11, 12, 4, 7, 9]
Enum {
name: "BoundsBehavior"
values: {
@@ -2039,8 +2091,14 @@ Module {
name: "QQuickFlipable"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/Flipable 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/Flipable 2.0",
+ "QtQuick/Flipable 2.1",
+ "QtQuick/Flipable 2.11",
+ "QtQuick/Flipable 2.4",
+ "QtQuick/Flipable 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "Side"
values: {
@@ -2056,8 +2114,16 @@ Module {
name: "QQuickFlow"
defaultProperty: "data"
prototype: "QQuickBasePositioner"
- exports: ["QtQuick/Flow 2.0", "QtQuick/Flow 2.6"]
- exportMetaObjectRevisions: [0, 6]
+ exports: [
+ "QtQuick/Flow 2.0",
+ "QtQuick/Flow 2.1",
+ "QtQuick/Flow 2.11",
+ "QtQuick/Flow 2.4",
+ "QtQuick/Flow 2.6",
+ "QtQuick/Flow 2.7",
+ "QtQuick/Flow 2.9"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9]
Enum {
name: "Flow"
values: {
@@ -2073,8 +2139,14 @@ Module {
name: "QQuickFocusScope"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/FocusScope 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/FocusScope 2.0",
+ "QtQuick/FocusScope 2.1",
+ "QtQuick/FocusScope 2.11",
+ "QtQuick/FocusScope 2.4",
+ "QtQuick/FocusScope 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
}
Component {
name: "QQuickFontLoader"
@@ -2098,7 +2170,7 @@ Module {
name: "QQuickFontMetrics"
prototype: "QObject"
exports: ["QtQuick/FontMetrics 2.4"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [4]
Property { name: "font"; type: "QFont" }
Property { name: "ascent"; type: "double"; isReadonly: true }
Property { name: "descent"; type: "double"; isReadonly: true }
@@ -2245,7 +2317,7 @@ Module {
prototype: "QObject"
exports: ["QtQuick/GraphicsInfo 2.8"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [8]
Enum {
name: "GraphicsApi"
values: {
@@ -2314,8 +2386,16 @@ Module {
name: "QQuickGrid"
defaultProperty: "data"
prototype: "QQuickBasePositioner"
- exports: ["QtQuick/Grid 2.0", "QtQuick/Grid 2.1", "QtQuick/Grid 2.6"]
- exportMetaObjectRevisions: [0, 1, 6]
+ exports: [
+ "QtQuick/Grid 2.0",
+ "QtQuick/Grid 2.1",
+ "QtQuick/Grid 2.11",
+ "QtQuick/Grid 2.4",
+ "QtQuick/Grid 2.6",
+ "QtQuick/Grid 2.7",
+ "QtQuick/Grid 2.9"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9]
Enum {
name: "Flow"
values: {
@@ -2384,10 +2464,16 @@ Module {
exports: [
"QtQuick/GridView 2.0",
"QtQuick/GridView 2.1",
+ "QtQuick/GridView 2.10",
+ "QtQuick/GridView 2.11",
+ "QtQuick/GridView 2.12",
"QtQuick/GridView 2.13",
- "QtQuick/GridView 2.7"
+ "QtQuick/GridView 2.3",
+ "QtQuick/GridView 2.4",
+ "QtQuick/GridView 2.7",
+ "QtQuick/GridView 2.9"
]
- exportMetaObjectRevisions: [0, 1, 13, 7]
+ exportMetaObjectRevisions: [0, 1, 10, 11, 12, 13, 3, 4, 7, 9]
attachedType: "QQuickGridViewAttached"
Enum {
name: "Flow"
@@ -2419,7 +2505,7 @@ Module {
name: "QQuickHoverHandler"
prototype: "QQuickSinglePointHandler"
exports: ["QtQuick/HoverHandler 2.12"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Property { name: "hovered"; type: "bool"; isReadonly: true }
}
Component {
@@ -2428,11 +2514,15 @@ Module {
prototype: "QQuickImageBase"
exports: [
"QtQuick/Image 2.0",
+ "QtQuick/Image 2.1",
+ "QtQuick/Image 2.11",
"QtQuick/Image 2.14",
"QtQuick/Image 2.3",
- "QtQuick/Image 2.5"
+ "QtQuick/Image 2.4",
+ "QtQuick/Image 2.5",
+ "QtQuick/Image 2.7"
]
- exportMetaObjectRevisions: [0, 14, 3, 5]
+ exportMetaObjectRevisions: [0, 1, 11, 14, 3, 4, 5, 7]
Enum {
name: "HAlignment"
values: {
@@ -2805,12 +2895,17 @@ Module {
prototype: "QQuickFlickable"
exports: [
"QtQuick/ItemView 2.1",
+ "QtQuick/ItemView 2.10",
+ "QtQuick/ItemView 2.11",
+ "QtQuick/ItemView 2.12",
"QtQuick/ItemView 2.13",
"QtQuick/ItemView 2.3",
- "QtQuick/ItemView 2.7"
+ "QtQuick/ItemView 2.4",
+ "QtQuick/ItemView 2.7",
+ "QtQuick/ItemView 2.9"
]
isCreatable: false
- exportMetaObjectRevisions: [1, 13, 3, 7]
+ exportMetaObjectRevisions: [1, 10, 11, 12, 13, 3, 4, 7, 9]
Enum {
name: "LayoutDirection"
values: {
@@ -3163,10 +3258,16 @@ Module {
exports: [
"QtQuick/ListView 2.0",
"QtQuick/ListView 2.1",
+ "QtQuick/ListView 2.10",
+ "QtQuick/ListView 2.11",
+ "QtQuick/ListView 2.12",
+ "QtQuick/ListView 2.13",
+ "QtQuick/ListView 2.3",
"QtQuick/ListView 2.4",
- "QtQuick/ListView 2.7"
+ "QtQuick/ListView 2.7",
+ "QtQuick/ListView 2.9"
]
- exportMetaObjectRevisions: [0, 1, 4, 7]
+ exportMetaObjectRevisions: [0, 1, 10, 11, 12, 13, 3, 4, 7, 9]
attachedType: "QQuickListViewAttached"
Enum {
name: "Orientation"
@@ -3219,8 +3320,14 @@ Module {
name: "QQuickLoader"
defaultProperty: "data"
prototype: "QQuickImplicitSizeItem"
- exports: ["QtQuick/Loader 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/Loader 2.0",
+ "QtQuick/Loader 2.1",
+ "QtQuick/Loader 2.11",
+ "QtQuick/Loader 2.4",
+ "QtQuick/Loader 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "Status"
values: {
@@ -3247,7 +3354,7 @@ Module {
name: "QQuickMatrix4x4"
prototype: "QQuickTransform"
exports: ["QtQuick/Matrix4x4 2.3"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [3]
Property { name: "matrix"; type: "QMatrix4x4" }
}
Component {
@@ -3256,11 +3363,14 @@ Module {
prototype: "QQuickItem"
exports: [
"QtQuick/MouseArea 2.0",
+ "QtQuick/MouseArea 2.1",
+ "QtQuick/MouseArea 2.11",
"QtQuick/MouseArea 2.4",
"QtQuick/MouseArea 2.5",
+ "QtQuick/MouseArea 2.7",
"QtQuick/MouseArea 2.9"
]
- exportMetaObjectRevisions: [0, 4, 5, 9]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 5, 7, 9]
Property { name: "mouseX"; type: "double"; isReadonly: true }
Property { name: "mouseY"; type: "double"; isReadonly: true }
Property { name: "containsMouse"; type: "bool"; isReadonly: true }
@@ -3346,8 +3456,14 @@ Module {
name: "QQuickMultiPointTouchArea"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/MultiPointTouchArea 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/MultiPointTouchArea 2.0",
+ "QtQuick/MultiPointTouchArea 2.1",
+ "QtQuick/MultiPointTouchArea 2.11",
+ "QtQuick/MultiPointTouchArea 2.4",
+ "QtQuick/MultiPointTouchArea 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "touchPoints"; type: "QQuickTouchPoint"; isList: true; isReadonly: true }
Property { name: "minimumTouchPoints"; type: "int" }
Property { name: "maximumTouchPoints"; type: "int" }
@@ -3380,23 +3496,29 @@ Module {
Component {
name: "QQuickNumberAnimation"
prototype: "QQuickPropertyAnimation"
- exports: ["QtQuick/NumberAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/NumberAnimation 2.0",
+ "QtQuick/NumberAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "from"; type: "double" }
Property { name: "to"; type: "double" }
}
Component {
name: "QQuickOpacityAnimator"
prototype: "QQuickAnimator"
- exports: ["QtQuick/OpacityAnimator 2.2"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/OpacityAnimator 2.12",
+ "QtQuick/OpacityAnimator 2.2"
+ ]
+ exportMetaObjectRevisions: [12, 2]
}
Component {
name: "QQuickOpenGLInfo"
prototype: "QObject"
exports: ["QtQuick/OpenGLInfo 2.4"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [4]
Enum {
name: "ContextProfile"
values: {
@@ -3436,9 +3558,15 @@ Module {
name: "QQuickPaintedItem"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/PaintedItem 2.0"]
+ exports: [
+ "QtQuick/PaintedItem 2.0",
+ "QtQuick/PaintedItem 2.1",
+ "QtQuick/PaintedItem 2.11",
+ "QtQuick/PaintedItem 2.4",
+ "QtQuick/PaintedItem 2.7"
+ ]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "RenderTarget"
values: {
@@ -3463,15 +3591,21 @@ Module {
name: "QQuickParallelAnimation"
defaultProperty: "animations"
prototype: "QQuickAnimationGroup"
- exports: ["QtQuick/ParallelAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/ParallelAnimation 2.0",
+ "QtQuick/ParallelAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
}
Component {
name: "QQuickParentAnimation"
defaultProperty: "animations"
prototype: "QQuickAnimationGroup"
- exports: ["QtQuick/ParentAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/ParentAnimation 2.0",
+ "QtQuick/ParentAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "target"; type: "QQuickItem"; isPointer: true }
Property { name: "newParent"; type: "QQuickItem"; isPointer: true }
Property { name: "via"; type: "QQuickItem"; isPointer: true }
@@ -3514,7 +3648,7 @@ Module {
name: "QQuickPathAngleArc"
prototype: "QQuickCurve"
exports: ["QtQuick/PathAngleArc 2.11"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [11]
Property { name: "centerX"; type: "double" }
Property { name: "centerY"; type: "double" }
Property { name: "radiusX"; type: "double" }
@@ -3526,8 +3660,8 @@ Module {
Component {
name: "QQuickPathAnimation"
prototype: "QQuickAbstractAnimation"
- exports: ["QtQuick/PathAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/PathAnimation 2.0", "QtQuick/PathAnimation 2.12"]
+ exportMetaObjectRevisions: [0, 12]
Enum {
name: "Orientation"
values: {
@@ -3649,13 +3783,13 @@ Module {
name: "QQuickPathMove"
prototype: "QQuickCurve"
exports: ["QtQuick/PathMove 2.9"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [9]
}
Component {
name: "QQuickPathMultiline"
prototype: "QQuickCurve"
exports: ["QtQuick/PathMultiline 2.14"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [14]
Property { name: "start"; type: "QPointF"; isReadonly: true }
Property { name: "paths"; type: "QVariant" }
}
@@ -3670,7 +3804,7 @@ Module {
name: "QQuickPathPolyline"
prototype: "QQuickCurve"
exports: ["QtQuick/PathPolyline 2.14"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [14]
Property { name: "start"; type: "QPointF"; isReadonly: true }
Property { name: "path"; type: "QVariant" }
}
@@ -3697,10 +3831,13 @@ Module {
prototype: "QQuickItem"
exports: [
"QtQuick/PathView 2.0",
+ "QtQuick/PathView 2.1",
+ "QtQuick/PathView 2.11",
"QtQuick/PathView 2.13",
+ "QtQuick/PathView 2.4",
"QtQuick/PathView 2.7"
]
- exportMetaObjectRevisions: [0, 13, 7]
+ exportMetaObjectRevisions: [0, 1, 11, 13, 4, 7]
attachedType: "QQuickPathViewAttached"
Enum {
name: "HighlightRangeMode"
@@ -3806,8 +3943,8 @@ Module {
Component {
name: "QQuickPauseAnimation"
prototype: "QQuickAbstractAnimation"
- exports: ["QtQuick/PauseAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/PauseAnimation 2.0", "QtQuick/PauseAnimation 2.12"]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "duration"; type: "int" }
Signal {
name: "durationChanged"
@@ -3853,8 +3990,15 @@ Module {
name: "QQuickPinchArea"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/PinchArea 2.0", "QtQuick/PinchArea 2.5"]
- exportMetaObjectRevisions: [0, 5]
+ exports: [
+ "QtQuick/PinchArea 2.0",
+ "QtQuick/PinchArea 2.1",
+ "QtQuick/PinchArea 2.11",
+ "QtQuick/PinchArea 2.4",
+ "QtQuick/PinchArea 2.5",
+ "QtQuick/PinchArea 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 5, 7]
Property { name: "enabled"; type: "bool" }
Property { name: "pinch"; type: "QQuickPinch"; isReadonly: true; isPointer: true }
Signal {
@@ -3897,7 +4041,7 @@ Module {
name: "QQuickPinchHandler"
prototype: "QQuickMultiPointHandler"
exports: ["QtQuick/PinchHandler 2.12"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Property { name: "minimumScale"; type: "double" }
Property { name: "maximumScale"; type: "double" }
Property { name: "minimumRotation"; type: "double" }
@@ -3918,7 +4062,7 @@ Module {
name: "QQuickPointHandler"
prototype: "QQuickSinglePointHandler"
exports: ["QtQuick/PointHandler 2.12"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Property { name: "translation"; type: "QVector2D"; isReadonly: true }
}
Component {
@@ -3926,7 +4070,7 @@ Module {
prototype: "QObject"
exports: ["QtQuick/PointerDevice 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Enum {
name: "DeviceTypes"
values: {
@@ -4003,7 +4147,7 @@ Module {
prototype: "QObject"
exports: ["QtQuick/PointerEvent 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Property { name: "device"; type: "QQuickPointerDevice"; isReadonly: true; isPointer: true }
Property { name: "modifiers"; type: "Qt::KeyboardModifiers"; isReadonly: true }
Property { name: "button"; type: "Qt::MouseButtons"; isReadonly: true }
@@ -4014,7 +4158,7 @@ Module {
prototype: "QObject"
exports: ["QtQuick/PointerHandler 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Enum {
name: "GrabPermissions"
values: {
@@ -4052,14 +4196,14 @@ Module {
prototype: "QQuickSinglePointEvent"
exports: ["QtQuick/PointerMouseEvent 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
}
Component {
name: "QQuickPointerTouchEvent"
prototype: "QQuickPointerEvent"
exports: ["QtQuick/PointerTouchEvent 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
}
Component {
name: "QQuickPositionerAttached"
@@ -4071,8 +4215,8 @@ Module {
Component {
name: "QQuickPropertyAction"
prototype: "QQuickAbstractAnimation"
- exports: ["QtQuick/PropertyAction 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/PropertyAction 2.0", "QtQuick/PropertyAction 2.12"]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "target"; type: "QObject"; isPointer: true }
Property { name: "property"; type: "string" }
Property { name: "properties"; type: "string" }
@@ -4091,8 +4235,11 @@ Module {
Component {
name: "QQuickPropertyAnimation"
prototype: "QQuickAbstractAnimation"
- exports: ["QtQuick/PropertyAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/PropertyAnimation 2.0",
+ "QtQuick/PropertyAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "duration"; type: "int" }
Property { name: "from"; type: "QVariant" }
Property { name: "to"; type: "QVariant" }
@@ -4128,8 +4275,14 @@ Module {
name: "QQuickRectangle"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/Rectangle 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/Rectangle 2.0",
+ "QtQuick/Rectangle 2.1",
+ "QtQuick/Rectangle 2.11",
+ "QtQuick/Rectangle 2.4",
+ "QtQuick/Rectangle 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "color"; type: "QColor" }
Property { name: "gradient"; type: "QJSValue" }
Property { name: "border"; type: "QQuickPen"; isReadonly: true; isPointer: true }
@@ -4139,8 +4292,14 @@ Module {
name: "QQuickRepeater"
defaultProperty: "delegate"
prototype: "QQuickItem"
- exports: ["QtQuick/Repeater 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/Repeater 2.0",
+ "QtQuick/Repeater 2.1",
+ "QtQuick/Repeater 2.11",
+ "QtQuick/Repeater 2.4",
+ "QtQuick/Repeater 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "model"; type: "QVariant" }
Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "count"; type: "int"; isReadonly: true }
@@ -4172,8 +4331,11 @@ Module {
Component {
name: "QQuickRotationAnimation"
prototype: "QQuickPropertyAnimation"
- exports: ["QtQuick/RotationAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/RotationAnimation 2.0",
+ "QtQuick/RotationAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Enum {
name: "RotationDirection"
values: {
@@ -4190,8 +4352,11 @@ Module {
Component {
name: "QQuickRotationAnimator"
prototype: "QQuickAnimator"
- exports: ["QtQuick/RotationAnimator 2.2"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/RotationAnimator 2.12",
+ "QtQuick/RotationAnimator 2.2"
+ ]
+ exportMetaObjectRevisions: [12, 2]
Enum {
name: "RotationDirection"
values: {
@@ -4211,8 +4376,16 @@ Module {
name: "QQuickRow"
defaultProperty: "data"
prototype: "QQuickBasePositioner"
- exports: ["QtQuick/Row 2.0", "QtQuick/Row 2.6"]
- exportMetaObjectRevisions: [0, 6]
+ exports: [
+ "QtQuick/Row 2.0",
+ "QtQuick/Row 2.1",
+ "QtQuick/Row 2.11",
+ "QtQuick/Row 2.4",
+ "QtQuick/Row 2.6",
+ "QtQuick/Row 2.7",
+ "QtQuick/Row 2.9"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9]
Property { name: "layoutDirection"; type: "Qt::LayoutDirection" }
Property { name: "effectiveLayoutDirection"; type: "Qt::LayoutDirection"; isReadonly: true }
}
@@ -4230,8 +4403,8 @@ Module {
Component {
name: "QQuickScaleAnimator"
prototype: "QQuickAnimator"
- exports: ["QtQuick/ScaleAnimator 2.2"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/ScaleAnimator 2.12", "QtQuick/ScaleAnimator 2.2"]
+ exportMetaObjectRevisions: [12, 2]
}
Component {
name: "QQuickScaleGrid"
@@ -4249,8 +4422,8 @@ Module {
Component {
name: "QQuickScriptAction"
prototype: "QQuickAbstractAnimation"
- exports: ["QtQuick/ScriptAction 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/ScriptAction 2.0", "QtQuick/ScriptAction 2.12"]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "script"; type: "QQmlScriptString" }
Property { name: "scriptName"; type: "string" }
}
@@ -4258,15 +4431,24 @@ Module {
name: "QQuickSequentialAnimation"
defaultProperty: "animations"
prototype: "QQuickAnimationGroup"
- exports: ["QtQuick/SequentialAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/SequentialAnimation 2.0",
+ "QtQuick/SequentialAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
}
Component {
name: "QQuickShaderEffect"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/ShaderEffect 2.0", "QtQuick/ShaderEffect 2.4"]
- exportMetaObjectRevisions: [0, 4]
+ exports: [
+ "QtQuick/ShaderEffect 2.0",
+ "QtQuick/ShaderEffect 2.1",
+ "QtQuick/ShaderEffect 2.11",
+ "QtQuick/ShaderEffect 2.4",
+ "QtQuick/ShaderEffect 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "CullMode"
values: {
@@ -4306,10 +4488,14 @@ Module {
prototype: "QQuickItem"
exports: [
"QtQuick/ShaderEffectSource 2.0",
+ "QtQuick/ShaderEffectSource 2.1",
+ "QtQuick/ShaderEffectSource 2.11",
+ "QtQuick/ShaderEffectSource 2.4",
"QtQuick/ShaderEffectSource 2.6",
+ "QtQuick/ShaderEffectSource 2.7",
"QtQuick/ShaderEffectSource 2.9"
]
- exportMetaObjectRevisions: [0, 6, 9]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9]
Enum {
name: "WrapMode"
values: {
@@ -4357,7 +4543,7 @@ Module {
"QtQuick/Shortcut 2.6",
"QtQuick/Shortcut 2.9"
]
- exportMetaObjectRevisions: [0, 6, 9]
+ exportMetaObjectRevisions: [5, 6, 9]
Property { name: "sequence"; type: "QVariant" }
Property { name: "sequences"; revision: 9; type: "QVariantList" }
Property { name: "nativeText"; revision: 6; type: "string"; isReadonly: true }
@@ -4378,8 +4564,11 @@ Module {
Component {
name: "QQuickSmoothedAnimation"
prototype: "QQuickNumberAnimation"
- exports: ["QtQuick/SmoothedAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/SmoothedAnimation 2.0",
+ "QtQuick/SmoothedAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Enum {
name: "ReversingMode"
values: {
@@ -4395,8 +4584,11 @@ Module {
Component {
name: "QQuickSpringAnimation"
prototype: "QQuickNumberAnimation"
- exports: ["QtQuick/SpringAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/SpringAnimation 2.0",
+ "QtQuick/SpringAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "velocity"; type: "double" }
Property { name: "spring"; type: "double" }
Property { name: "damping"; type: "double" }
@@ -4528,8 +4720,14 @@ Module {
name: "QQuickSpriteSequence"
defaultProperty: "sprites"
prototype: "QQuickItem"
- exports: ["QtQuick/SpriteSequence 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/SpriteSequence 2.0",
+ "QtQuick/SpriteSequence 2.1",
+ "QtQuick/SpriteSequence 2.11",
+ "QtQuick/SpriteSequence 2.4",
+ "QtQuick/SpriteSequence 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Property { name: "running"; type: "bool" }
Property { name: "interpolate"; type: "bool" }
Property { name: "goalSprite"; type: "string" }
@@ -4687,7 +4885,7 @@ Module {
defaultProperty: "flickableData"
prototype: "QQuickFlickable"
exports: ["QtQuick/TableView 2.12", "QtQuick/TableView 2.14"]
- exportMetaObjectRevisions: [0, 14]
+ exportMetaObjectRevisions: [12, 14]
attachedType: "QQuickTableViewAttached"
Property { name: "rows"; type: "int"; isReadonly: true }
Property { name: "columns"; type: "int"; isReadonly: true }
@@ -4717,7 +4915,7 @@ Module {
name: "QQuickTapHandler"
prototype: "QQuickSinglePointHandler"
exports: ["QtQuick/TapHandler 2.12"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [12]
Enum {
name: "GesturePolicy"
values: {
@@ -4751,14 +4949,17 @@ Module {
prototype: "QQuickImplicitSizeItem"
exports: [
"QtQuick/Text 2.0",
+ "QtQuick/Text 2.1",
"QtQuick/Text 2.10",
- "QtQuick/Text 2.12",
+ "QtQuick/Text 2.11",
"QtQuick/Text 2.2",
"QtQuick/Text 2.3",
+ "QtQuick/Text 2.4",
"QtQuick/Text 2.6",
+ "QtQuick/Text 2.7",
"QtQuick/Text 2.9"
]
- exportMetaObjectRevisions: [0, 10, 12, 2, 3, 6, 9]
+ exportMetaObjectRevisions: [0, 1, 10, 11, 2, 3, 4, 6, 7, 9]
Enum {
name: "HAlignment"
values: {
@@ -4954,12 +5155,14 @@ Module {
"QtQuick/TextEdit 2.0",
"QtQuick/TextEdit 2.1",
"QtQuick/TextEdit 2.10",
+ "QtQuick/TextEdit 2.11",
"QtQuick/TextEdit 2.2",
"QtQuick/TextEdit 2.3",
+ "QtQuick/TextEdit 2.4",
"QtQuick/TextEdit 2.6",
"QtQuick/TextEdit 2.7"
]
- exportMetaObjectRevisions: [0, 1, 10, 2, 3, 6, 7]
+ exportMetaObjectRevisions: [0, 1, 10, 11, 2, 3, 4, 6, 7]
Enum {
name: "HAlignment"
values: {
@@ -5238,13 +5441,15 @@ Module {
prototype: "QQuickImplicitSizeItem"
exports: [
"QtQuick/TextInput 2.0",
+ "QtQuick/TextInput 2.1",
+ "QtQuick/TextInput 2.11",
"QtQuick/TextInput 2.2",
"QtQuick/TextInput 2.4",
"QtQuick/TextInput 2.6",
"QtQuick/TextInput 2.7",
"QtQuick/TextInput 2.9"
]
- exportMetaObjectRevisions: [0, 2, 4, 6, 7, 9]
+ exportMetaObjectRevisions: [0, 1, 11, 2, 4, 6, 7, 9]
Enum {
name: "EchoMode"
values: {
@@ -5494,7 +5699,7 @@ Module {
name: "QQuickTextMetrics"
prototype: "QObject"
exports: ["QtQuick/TextMetrics 2.4"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [4]
Property { name: "font"; type: "QFont" }
Property { name: "text"; type: "string" }
Property { name: "advanceWidth"; type: "double"; isReadonly: true }
@@ -5511,7 +5716,7 @@ Module {
name: "QQuickTouchPoint"
prototype: "QObject"
exports: ["QtQuick/TouchPoint 2.0", "QtQuick/TouchPoint 2.9"]
- exportMetaObjectRevisions: [0, 0]
+ exportMetaObjectRevisions: [0, 9]
Property { name: "pointId"; type: "int"; isReadonly: true }
Property { name: "uniqueId"; revision: 9; type: "QPointingDeviceUniqueId"; isReadonly: true }
Property { name: "pressed"; type: "bool"; isReadonly: true }
@@ -5557,8 +5762,11 @@ Module {
Component {
name: "QQuickUniformAnimator"
prototype: "QQuickAnimator"
- exports: ["QtQuick/UniformAnimator 2.2"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/UniformAnimator 2.12",
+ "QtQuick/UniformAnimator 2.2"
+ ]
+ exportMetaObjectRevisions: [12, 2]
Property { name: "uniform"; type: "string" }
Signal {
name: "uniformChanged"
@@ -5568,8 +5776,11 @@ Module {
Component {
name: "QQuickVector3dAnimation"
prototype: "QQuickPropertyAnimation"
- exports: ["QtQuick/Vector3dAnimation 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick/Vector3dAnimation 2.0",
+ "QtQuick/Vector3dAnimation 2.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "from"; type: "QVector3D" }
Property { name: "to"; type: "QVector3D" }
}
@@ -5627,7 +5838,7 @@ Module {
name: "QQuickWheelHandler"
prototype: "QQuickSinglePointHandler"
exports: ["QtQuick/WheelHandler 2.14"]
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [14]
Property { name: "orientation"; type: "Qt::Orientation" }
Property { name: "invertible"; type: "bool" }
Property { name: "activeTimeout"; type: "double" }
@@ -5659,14 +5870,14 @@ Module {
Component {
name: "QQuickXAnimator"
prototype: "QQuickAnimator"
- exports: ["QtQuick/XAnimator 2.2"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/XAnimator 2.12", "QtQuick/XAnimator 2.2"]
+ exportMetaObjectRevisions: [12, 2]
}
Component {
name: "QQuickYAnimator"
prototype: "QQuickAnimator"
- exports: ["QtQuick/YAnimator 2.2"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/YAnimator 2.12", "QtQuick/YAnimator 2.2"]
+ exportMetaObjectRevisions: [12, 2]
}
Component {
name: "QRegExpValidator"
diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp
index eb7d5027a4..db941d9845 100644
--- a/src/imports/settings/plugin.cpp
+++ b/src/imports/settings/plugin.cpp
@@ -54,7 +54,7 @@ public:
void registerTypes(const char *uri) override
{
Q_ASSERT(QByteArray(uri) == QByteArray("Qt.labs.settings"));
- qmlRegisterType<QQmlSettings>(uri, 1, 0, "Settings");
+ qmlRegisterTypesAndRevisions<QQmlSettings>(uri, 1);
qmlRegisterModule(uri, 1, 1); // QTBUG-73239
}
};
diff --git a/src/imports/settings/qqmlsettings_p.h b/src/imports/settings/qqmlsettings_p.h
index a86c8b4751..3f1b83f541 100644
--- a/src/imports/settings/qqmlsettings_p.h
+++ b/src/imports/settings/qqmlsettings_p.h
@@ -66,6 +66,7 @@ class QQmlSettings : public QObject, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString category READ category WRITE setCategory FINAL)
Q_PROPERTY(QString fileName READ fileName WRITE setFileName FINAL)
+ QML_NAMED_ELEMENT(Settings)
public:
explicit QQmlSettings(QObject *parent = 0);
diff --git a/src/imports/shapes/plugin.cpp b/src/imports/shapes/plugin.cpp
index 0679a70630..80d197a544 100644
--- a/src/imports/shapes/plugin.cpp
+++ b/src/imports/shapes/plugin.cpp
@@ -57,21 +57,12 @@ public:
void registerTypes(const char *uri) override
{
Q_ASSERT(QByteArray(uri) == QByteArray("QtQuick.Shapes"));
- qmlRegisterType<QQuickShape>(uri, 1, 0, "Shape");
- qmlRegisterType<QQuickShapePath>(uri, 1, 0, "ShapePath");
- qmlRegisterUncreatableType<QQuickShapeGradient>(uri, 1, 0, "ShapeGradient", QQuickShapeGradient::tr("ShapeGradient is an abstract base class"));
- qmlRegisterType<QQuickShapeLinearGradient>(uri, 1, 0, "LinearGradient");
- qmlRegisterType<QQuickShapeRadialGradient>(uri, 1, 0, "RadialGradient");
- qmlRegisterType<QQuickShapeConicalGradient>(uri, 1, 0, "ConicalGradient");
+ qmlRegisterTypesAndRevisions<QQuickShape, QQuickShapePath, QQuickShapeGradient,
+ QQuickShapeLinearGradient, QQuickShapeRadialGradient,
+ QQuickShapeConicalGradient>(uri, 1);
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions
qmlRegisterModule(uri, 1, QT_VERSION_MINOR);
-
- // revision in Qt 5.11: added containsMode property
- qmlRegisterType<QQuickShape, 11>(uri, 1, 11, "Shape");
-
- // revision in Qt 5.14: added scale property
- qmlRegisterType<QQuickShapePath, 14>(uri, 1, 14, "ShapePath"); // QTBUG-61942
}
};
diff --git a/src/imports/shapes/plugins.qmltypes b/src/imports/shapes/plugins.qmltypes
index cd779e7149..fed68b5137 100644
--- a/src/imports/shapes/plugins.qmltypes
+++ b/src/imports/shapes/plugins.qmltypes
@@ -12,8 +12,14 @@ Module {
name: "QQuickShape"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick.Shapes/Shape 1.0", "QtQuick.Shapes/Shape 1.11"]
- exportMetaObjectRevisions: [0, 11]
+ exports: [
+ "QtQuick.Shapes/Shape 1.0",
+ "QtQuick.Shapes/Shape 1.1",
+ "QtQuick.Shapes/Shape 1.11",
+ "QtQuick.Shapes/Shape 1.4",
+ "QtQuick.Shapes/Shape 1.7"
+ ]
+ exportMetaObjectRevisions: [0, 1, 11, 4, 7]
Enum {
name: "RendererType"
values: {
@@ -51,8 +57,11 @@ Module {
name: "QQuickShapeConicalGradient"
defaultProperty: "stops"
prototype: "QQuickShapeGradient"
- exports: ["QtQuick.Shapes/ConicalGradient 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Shapes/ConicalGradient 1.0",
+ "QtQuick.Shapes/ConicalGradient 1.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "centerX"; type: "double" }
Property { name: "centerY"; type: "double" }
Property { name: "angle"; type: "double" }
@@ -61,9 +70,12 @@ Module {
name: "QQuickShapeGradient"
defaultProperty: "stops"
prototype: "QQuickGradient"
- exports: ["QtQuick.Shapes/ShapeGradient 1.0"]
+ exports: [
+ "QtQuick.Shapes/ShapeGradient 1.0",
+ "QtQuick.Shapes/ShapeGradient 1.12"
+ ]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [0, 12]
Enum {
name: "SpreadMode"
values: {
@@ -78,8 +90,11 @@ Module {
name: "QQuickShapeLinearGradient"
defaultProperty: "stops"
prototype: "QQuickShapeGradient"
- exports: ["QtQuick.Shapes/LinearGradient 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Shapes/LinearGradient 1.0",
+ "QtQuick.Shapes/LinearGradient 1.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "x1"; type: "double" }
Property { name: "y1"; type: "double" }
Property { name: "x2"; type: "double" }
@@ -142,8 +157,11 @@ Module {
name: "QQuickShapeRadialGradient"
defaultProperty: "stops"
prototype: "QQuickShapeGradient"
- exports: ["QtQuick.Shapes/RadialGradient 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Shapes/RadialGradient 1.0",
+ "QtQuick.Shapes/RadialGradient 1.12"
+ ]
+ exportMetaObjectRevisions: [0, 12]
Property { name: "centerX"; type: "double" }
Property { name: "centerY"; type: "double" }
Property { name: "centerRadius"; type: "double" }
diff --git a/src/imports/statemachine/finalstate.h b/src/imports/statemachine/finalstate.h
index 974d8a8fac..9cdbb51584 100644
--- a/src/imports/statemachine/finalstate.h
+++ b/src/imports/statemachine/finalstate.h
@@ -45,6 +45,7 @@
#include <QtCore/QFinalState>
#include <QtQml/QQmlListProperty>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -54,6 +55,7 @@ class FinalState : public QFinalState
Q_OBJECT
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged)
Q_CLASSINFO("DefaultProperty", "children")
+ QML_ELEMENT
public:
explicit FinalState(QState *parent = 0);
diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp
index bf7499b31a..c36e5097c6 100644
--- a/src/imports/statemachine/plugin.cpp
+++ b/src/imports/statemachine/plugin.cpp
@@ -42,6 +42,7 @@
#include "state.h"
#include "statemachine.h"
#include "timeouttransition.h"
+#include "statemachineforeign.h"
#include <QHistoryState>
#include <QQmlExtensionPlugin>
@@ -58,15 +59,10 @@ public:
QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
- qmlRegisterType<State>(uri, 1, 0, "State");
- qmlRegisterType<StateMachine>(uri, 1, 0, "StateMachine");
- qmlRegisterType<QHistoryState>(uri, 1, 0, "HistoryState");
- qmlRegisterType<FinalState>(uri, 1, 0, "FinalState");
- qmlRegisterUncreatableType<QState>(uri, 1, 0, "QState", "Don't use this, use State instead");
- qmlRegisterUncreatableType<QAbstractState>(uri, 1, 0, "QAbstractState", "Don't use this, use State instead");
- qmlRegisterUncreatableType<QSignalTransition>(uri, 1, 0, "QSignalTransition", "Don't use this, use SignalTransition instead");
- qmlRegisterCustomType<SignalTransition>(uri, 1, 0, "SignalTransition", new SignalTransitionParser);
- qmlRegisterType<TimeoutTransition>(uri, 1, 0, "TimeoutTransition");
+ qmlRegisterTypesAndRevisions<
+ State, StateMachine, FinalState, TimeoutTransition, SignalTransition,
+ QHistoryStateForeign, QStateForeign, QAbstractStateForeign, QSignalTransitionForeign
+ >(uri, 1);
qmlProtectModule(uri, 1);
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
diff --git a/src/imports/statemachine/plugins.qmltypes b/src/imports/statemachine/plugins.qmltypes
index 541b1cc114..206159f057 100644
--- a/src/imports/statemachine/plugins.qmltypes
+++ b/src/imports/statemachine/plugins.qmltypes
@@ -137,8 +137,11 @@ Module {
Component {
name: "SignalTransition"
prototype: "QSignalTransition"
- exports: ["QtQml.StateMachine/SignalTransition 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQml.StateMachine/SignalTransition 1.0",
+ "QtQml.StateMachine/SignalTransition 1.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "signal"; type: "QJSValue" }
Property { name: "guard"; type: "QQmlScriptString" }
Signal { name: "invokeYourself" }
@@ -166,8 +169,11 @@ Module {
Component {
name: "TimeoutTransition"
prototype: "QSignalTransition"
- exports: ["QtQml.StateMachine/TimeoutTransition 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQml.StateMachine/TimeoutTransition 1.0",
+ "QtQml.StateMachine/TimeoutTransition 1.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "timeout"; type: "int" }
}
}
diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h
index f005c5e9b1..748e230b3e 100644
--- a/src/imports/statemachine/signaltransition.h
+++ b/src/imports/statemachine/signaltransition.h
@@ -57,6 +57,7 @@ class SignalTransition : public QSignalTransition, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QJSValue signal READ signal WRITE setSignal NOTIFY qmlSignalChanged)
Q_PROPERTY(QQmlScriptString guard READ guard WRITE setGuard NOTIFY guardChanged)
+ QML_ELEMENT
public:
explicit SignalTransition(QState *parent = nullptr);
@@ -101,6 +102,12 @@ public:
void applyBindings(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
+template<>
+inline QQmlCustomParser *qmlCreateCustomParser<SignalTransition>()
+{
+ return new SignalTransitionParser;
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/imports/statemachine/state.h b/src/imports/statemachine/state.h
index 8e8cefab19..4b17ea0e5f 100644
--- a/src/imports/statemachine/state.h
+++ b/src/imports/statemachine/state.h
@@ -45,6 +45,7 @@
#include <QtCore/QState>
#include <QtQml/QQmlParserStatus>
#include <QtQml/QQmlListProperty>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -54,6 +55,7 @@ class State : public QState, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged)
Q_CLASSINFO("DefaultProperty", "children")
+ QML_ELEMENT
public:
explicit State(QState *parent = 0);
diff --git a/src/imports/statemachine/statemachine.h b/src/imports/statemachine/statemachine.h
index 1fa7a9da43..04894477b3 100644
--- a/src/imports/statemachine/statemachine.h
+++ b/src/imports/statemachine/statemachine.h
@@ -45,6 +45,7 @@
#include <QtCore/QStateMachine>
#include <QtQml/QQmlParserStatus>
#include <QtQml/QQmlListProperty>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -58,6 +59,7 @@ class StateMachine : public QStateMachine, public QQmlParserStatus
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY qmlRunningChanged)
Q_CLASSINFO("DefaultProperty", "children")
+ QML_ELEMENT
public:
explicit StateMachine(QObject *parent = 0);
diff --git a/src/imports/statemachine/statemachine.pro b/src/imports/statemachine/statemachine.pro
index 926a9d4a5e..7affc768e2 100644
--- a/src/imports/statemachine/statemachine.pro
+++ b/src/imports/statemachine/statemachine.pro
@@ -19,6 +19,7 @@ HEADERS = \
$$PWD/signaltransition.h \
$$PWD/state.h \
$$PWD/statemachine.h \
- $$PWD/timeouttransition.h
+ $$PWD/timeouttransition.h \
+ $$PWD/statemachineforeign.h
load(qml_plugin)
diff --git a/src/imports/statemachine/statemachineforeign.h b/src/imports/statemachine/statemachineforeign.h
new file mode 100644
index 0000000000..363c9d0e31
--- /dev/null
+++ b/src/imports/statemachine/statemachineforeign.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef STATEMACHINEFOREIGN_H
+#define STATEMACHINEFOREIGN_H
+
+#include <QtQml/qqml.h>
+#include <QtCore/qhistorystate.h>
+#include <QtCore/qstate.h>
+#include <QtCore/qabstractstate.h>
+#include <QtCore/qsignaltransition.h>
+
+struct QHistoryStateForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QHistoryState)
+ QML_NAMED_ELEMENT(HistoryState)
+};
+
+struct QStateForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QState)
+ QML_NAMED_ELEMENT(QState)
+ QML_UNCREATABLE("Don't use this, use State instead.")
+};
+
+struct QAbstractStateForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QAbstractState)
+ QML_NAMED_ELEMENT(QAbstractState)
+ QML_UNCREATABLE("Don't use this, use State instead.")
+};
+
+struct QSignalTransitionForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QSignalTransition)
+ QML_NAMED_ELEMENT(QSignalTransition)
+ QML_UNCREATABLE("Don't use this, use SignalTransition instead.")
+};
+
+#endif // STATEMACHINEFOREIGN_H
diff --git a/src/imports/statemachine/timeouttransition.h b/src/imports/statemachine/timeouttransition.h
index 2fc850fc70..cc3a22e0e5 100644
--- a/src/imports/statemachine/timeouttransition.h
+++ b/src/imports/statemachine/timeouttransition.h
@@ -42,6 +42,7 @@
#include <QtCore/QSignalTransition>
#include <QtQml/QQmlParserStatus>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
class QTimer;
@@ -51,6 +52,7 @@ class TimeoutTransition : public QSignalTransition, public QQmlParserStatus
Q_OBJECT
Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged)
Q_INTERFACES(QQmlParserStatus)
+ QML_ELEMENT
public:
TimeoutTransition(QState *parent = nullptr);
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
index c52cf417a6..a4e756452e 100644
--- a/src/imports/testlib/main.cpp
+++ b/src/imports/testlib/main.cpp
@@ -37,99 +37,15 @@
**
****************************************************************************/
-#include <private/qv4scopedvalue_p.h>
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
-#include <QtQml/qjsvalue.h>
-#include <QtQml/qjsengine.h>
-#include "QtQuickTest/private/quicktestresult_p.h"
-#include "QtQuickTest/private/quicktestevent_p.h"
-#include "private/qtestoptions_p.h"
-#include "QtQuick/qquickitem.h"
-#include <QtQml/private/qqmlengine_p.h>
-#include <QtGui/QGuiApplication>
-#include <QtGui/qstylehints.h>
+#include <QtQuickTest/private/quicktestresult_p.h>
+#include <QtQuickTest/private/quicktestevent_p.h>
+#include <QtQuickTest/private/quicktestutil_p.h>
+#include <QtQuickTest/private/qtestoptions_p.h>
QML_DECLARE_TYPE(QuickTestResult)
QML_DECLARE_TYPE(QuickTestEvent)
-
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-class QuickTestUtil : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(bool printAvailableFunctions READ printAvailableFunctions NOTIFY printAvailableFunctionsChanged)
- Q_PROPERTY(int dragThreshold READ dragThreshold NOTIFY dragThresholdChanged)
-public:
- QuickTestUtil(QObject *parent = nullptr)
- :QObject(parent)
- {}
-
- ~QuickTestUtil() override
- {}
- bool printAvailableFunctions() const
- {
- return QTest::printAvailableFunctions;
- }
- int dragThreshold() const { return QGuiApplication::styleHints()->startDragDistance(); }
-
-Q_SIGNALS:
- void printAvailableFunctionsChanged();
- void dragThresholdChanged();
-
-public Q_SLOTS:
-
- QJSValue typeName(const QVariant& v) const
- {
- QString name(v.typeName());
- if (v.canConvert<QObject*>()) {
- QQmlType type;
- const QMetaObject *mo = v.value<QObject*>()->metaObject();
- while (!type.isValid() && mo) {
- type = QQmlMetaType::qmlType(mo);
- mo = mo->superClass();
- }
- if (type.isValid()) {
- name = type.qmlTypeName();
- }
- }
-
- QQmlEngine *engine = qmlEngine(this);
- QV4::ExecutionEngine *v4 = engine->handle();
- return QJSValue(v4, v4->newString(name)->asReturnedValue());
- }
-
- bool compare(const QVariant& act, const QVariant& exp) const {
- return act == exp;
- }
-
- QJSValue callerFile(int frameIndex = 0) const
- {
- QQmlEngine *engine = qmlEngine(this);
- QV4::ExecutionEngine *v4 = engine->handle();
- QV4::Scope scope(v4);
-
- QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2);
- return (stack.size() > frameIndex + 1)
- ? QJSValue(v4, v4->newString(stack.at(frameIndex + 1).source)->asReturnedValue())
- : QJSValue();
- }
- int callerLine(int frameIndex = 0) const
- {
- QQmlEngine *engine = qmlEngine(this);
- QV4::ExecutionEngine *v4 = engine->handle();
-
- QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2);
- if (stack.size() > frameIndex + 1)
- return stack.at(frameIndex + 1).line;
- return -1;
- }
-};
-
-QT_END_NAMESPACE
-
QML_DECLARE_TYPE(QuickTestUtil)
QT_BEGIN_NAMESPACE
@@ -144,13 +60,8 @@ public:
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest"));
- qmlRegisterType<QuickTestResult, 0>(uri,1,0,"TestResult");
- qmlRegisterType<QuickTestResult, 1>(uri,1,1,"TestResult");
- qmlRegisterType<QuickTestResult, 13>(uri,1,13,"TestResult");
- qmlRegisterType<QuickTestEvent>(uri,1,0,"TestEvent");
- qmlRegisterType<QuickTestEvent>(uri,1,2,"TestEvent");
- qmlRegisterType<QuickTestUtil>(uri,1,0,"TestUtil");
- qmlRegisterAnonymousType<QQuickTouchEventSequence>(uri, 1);
+ qmlRegisterTypesAndRevisions<QuickTestResult, QuickTestEvent,
+ QuickTestUtil, QQuickTouchEventSequence>(uri, 1);
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
qmlRegisterModule(uri, 1, QT_VERSION_MINOR);
diff --git a/src/imports/testlib/plugins.qmltypes b/src/imports/testlib/plugins.qmltypes
index 6a1371e5f1..0491079e86 100644
--- a/src/imports/testlib/plugins.qmltypes
+++ b/src/imports/testlib/plugins.qmltypes
@@ -46,7 +46,7 @@ Module {
name: "QuickTestEvent"
prototype: "QObject"
exports: ["QtTest/TestEvent 1.0", "QtTest/TestEvent 1.2"]
- exportMetaObjectRevisions: [0, 0]
+ exportMetaObjectRevisions: [0, 2]
Property { name: "defaultMouseDelay"; type: "int"; isReadonly: true }
Method {
name: "keyPress"
diff --git a/src/imports/wavefrontmesh/plugin.cpp b/src/imports/wavefrontmesh/plugin.cpp
index 1a266b7e36..6a1cd91670 100644
--- a/src/imports/wavefrontmesh/plugin.cpp
+++ b/src/imports/wavefrontmesh/plugin.cpp
@@ -57,7 +57,7 @@ public:
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.wavefrontmesh"));
- qmlRegisterType<QWavefrontMesh>(uri, 1, 0, "WavefrontMesh");
+ qmlRegisterTypesAndRevisions<QWavefrontMesh>(uri, 1);
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.12 onward
qmlRegisterModule(uri, 1, QT_VERSION_MINOR);
diff --git a/src/imports/wavefrontmesh/qwavefrontmesh.h b/src/imports/wavefrontmesh/qwavefrontmesh.h
index e3ded8078e..a8a40c1a6a 100644
--- a/src/imports/wavefrontmesh/qwavefrontmesh.h
+++ b/src/imports/wavefrontmesh/qwavefrontmesh.h
@@ -55,6 +55,8 @@ class QWavefrontMesh : public QQuickShaderEffectMesh
Q_PROPERTY(Error lastError READ lastError NOTIFY lastErrorChanged)
Q_PROPERTY(QVector3D projectionPlaneV READ projectionPlaneV WRITE setProjectionPlaneV NOTIFY projectionPlaneVChanged)
Q_PROPERTY(QVector3D projectionPlaneW READ projectionPlaneW WRITE setProjectionPlaneW NOTIFY projectionPlaneWChanged)
+ QML_NAMED_ELEMENT(WavefrontMesh)
+
public:
enum Error {
NoError,
diff --git a/src/imports/window/plugins.qmltypes b/src/imports/window/plugins.qmltypes
index 693673c4cd..5d6cf33f4f 100644
--- a/src/imports/window/plugins.qmltypes
+++ b/src/imports/window/plugins.qmltypes
@@ -24,9 +24,13 @@ Module {
Component {
name: "QQuickScreen"
prototype: "QObject"
- exports: ["QtQuick.Window/Screen 2.0", "QtQuick.Window/Screen 2.3"]
+ exports: [
+ "QtQuick.Window/Screen 2.0",
+ "QtQuick.Window/Screen 2.10",
+ "QtQuick.Window/Screen 2.3"
+ ]
isCreatable: false
- exportMetaObjectRevisions: [0, 3]
+ exportMetaObjectRevisions: [0, 10, 3]
attachedType: "QQuickScreenAttached"
}
Component {
@@ -169,10 +173,11 @@ Module {
exports: [
"QtQuick.Window/Window 2.1",
"QtQuick.Window/Window 2.13",
+ "QtQuick.Window/Window 2.14",
"QtQuick.Window/Window 2.2",
"QtQuick.Window/Window 2.3"
]
- exportMetaObjectRevisions: [0, 13, 2, 3]
+ exportMetaObjectRevisions: [1, 13, 14, 2, 3]
attachedType: "QQuickWindowAttached"
Property { name: "visible"; type: "bool" }
Property { name: "visibility"; type: "Visibility" }
diff --git a/src/particles/qquickage_p.h b/src/particles/qquickage_p.h
index 5db6167dc1..890c6a63c1 100644
--- a/src/particles/qquickage_p.h
+++ b/src/particles/qquickage_p.h
@@ -59,6 +59,7 @@ class QQuickAgeAffector : public QQuickParticleAffector
Q_OBJECT
Q_PROPERTY(int lifeLeft READ lifeLeft WRITE setLifeLeft NOTIFY lifeLeftChanged)
Q_PROPERTY(bool advancePosition READ advancePosition WRITE setAdvancePosition NOTIFY advancePositionChanged)
+ QML_NAMED_ELEMENT(Age)
public:
explicit QQuickAgeAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickangledirection_p.h b/src/particles/qquickangledirection_p.h
index 66290fb19e..d0fdf5a68c 100644
--- a/src/particles/qquickangledirection_p.h
+++ b/src/particles/qquickangledirection_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
#include "qquickdirection_p.h"
+#include <QtQml/qqml.h>
+
QT_BEGIN_NAMESPACE
class QQuickAngleDirection : public QQuickDirection
@@ -60,6 +62,7 @@ class QQuickAngleDirection : public QQuickDirection
Q_PROPERTY(qreal magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged)
Q_PROPERTY(qreal angleVariation READ angleVariation WRITE setAngleVariation NOTIFY angleVariationChanged)
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
+ QML_NAMED_ELEMENT(AngleDirection)
public:
explicit QQuickAngleDirection(QObject *parent = 0);
QPointF sample(const QPointF &from) override;
diff --git a/src/particles/qquickcumulativedirection_p.h b/src/particles/qquickcumulativedirection_p.h
index 39f8ab8a24..5160d8f09a 100644
--- a/src/particles/qquickcumulativedirection_p.h
+++ b/src/particles/qquickcumulativedirection_p.h
@@ -52,6 +52,8 @@
//
#include "qquickdirection_p.h"
#include <QQmlListProperty>
+#include <QtQml/qqml.h>
+
QT_BEGIN_NAMESPACE
class QQuickCumulativeDirection : public QQuickDirection
@@ -59,6 +61,7 @@ class QQuickCumulativeDirection : public QQuickDirection
Q_OBJECT
Q_PROPERTY(QQmlListProperty<QQuickDirection> directions READ directions)
Q_CLASSINFO("DefaultProperty", "directions")
+ QML_NAMED_ELEMENT(CumulativeDirection)
public:
explicit QQuickCumulativeDirection(QObject *parent = 0);
QQmlListProperty<QQuickDirection> directions();
diff --git a/src/particles/qquickcustomaffector_p.h b/src/particles/qquickcustomaffector_p.h
index 5b1ea55659..5e8671514d 100644
--- a/src/particles/qquickcustomaffector_p.h
+++ b/src/particles/qquickcustomaffector_p.h
@@ -52,6 +52,7 @@
//
#include <QObject>
+#include <QtQml/qqml.h>
#include "qquickparticlesystem_p.h"
#include "qquickparticleextruder_p.h"
#include "qquickparticleaffector_p.h"
@@ -66,6 +67,7 @@ class QQuickCustomAffector : public QQuickParticleAffector
Q_PROPERTY(QQuickDirection *position READ position WRITE setPosition NOTIFY positionChanged RESET positionReset)
Q_PROPERTY(QQuickDirection *velocity READ velocity WRITE setVelocity NOTIFY velocityChanged RESET velocityReset)
Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged RESET accelerationReset)
+ QML_NAMED_ELEMENT(Affector)
public:
explicit QQuickCustomAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickcustomparticle_p.h b/src/particles/qquickcustomparticle_p.h
index e2292cb33b..444f7ad215 100644
--- a/src/particles/qquickcustomparticle_p.h
+++ b/src/particles/qquickcustomparticle_p.h
@@ -67,6 +67,7 @@ class QQuickCustomParticle : public QQuickParticlePainter
Q_OBJECT
Q_PROPERTY(QByteArray fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY fragmentShaderChanged)
Q_PROPERTY(QByteArray vertexShader READ vertexShader WRITE setVertexShader NOTIFY vertexShaderChanged)
+ QML_NAMED_ELEMENT(CustomParticle)
public:
explicit QQuickCustomParticle(QQuickItem* parent=0);
diff --git a/src/particles/qquickdirection_p.h b/src/particles/qquickdirection_p.h
index 10960f9920..60b4d8eb1d 100644
--- a/src/particles/qquickdirection_p.h
+++ b/src/particles/qquickdirection_p.h
@@ -53,12 +53,16 @@
#include <QObject>
#include <QPointF>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
class QQuickDirection : public QObject
{
Q_OBJECT
+ QML_NAMED_ELEMENT(NullVector)
+ QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
+
public:
explicit QQuickDirection(QObject *parent = 0);
diff --git a/src/particles/qquickellipseextruder_p.h b/src/particles/qquickellipseextruder_p.h
index 0af7f4d94f..c92443fedf 100644
--- a/src/particles/qquickellipseextruder_p.h
+++ b/src/particles/qquickellipseextruder_p.h
@@ -58,6 +58,7 @@ class QQuickEllipseExtruder : public QQuickParticleExtruder
{
Q_OBJECT
Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)//###Use base class? If it's still box
+ QML_NAMED_ELEMENT(EllipseShape)
public:
explicit QQuickEllipseExtruder(QObject *parent = 0);
QPointF extrude(const QRectF &) override;
diff --git a/src/particles/qquickfriction_p.h b/src/particles/qquickfriction_p.h
index 05ae7a38d5..5686bb37d5 100644
--- a/src/particles/qquickfriction_p.h
+++ b/src/particles/qquickfriction_p.h
@@ -59,6 +59,7 @@ class QQuickFrictionAffector : public QQuickParticleAffector
Q_OBJECT
Q_PROPERTY(qreal factor READ factor WRITE setFactor NOTIFY factorChanged)
Q_PROPERTY(qreal threshold READ threshold WRITE setThreshold NOTIFY thresholdChanged)
+ QML_NAMED_ELEMENT(Friction)
public:
explicit QQuickFrictionAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickgravity_p.h b/src/particles/qquickgravity_p.h
index 333d3d1534..ef7cc770b7 100644
--- a/src/particles/qquickgravity_p.h
+++ b/src/particles/qquickgravity_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
#include "qquickparticleaffector_p.h"
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,7 @@ class QQuickGravityAffector : public QQuickParticleAffector
Q_PROPERTY(qreal magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged)
Q_PROPERTY(qreal acceleration READ magnitude WRITE setAcceleration NOTIFY magnitudeChanged)
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
+ QML_NAMED_ELEMENT(Gravity)
public:
explicit QQuickGravityAffector(QQuickItem *parent = 0);
qreal magnitude() const;
diff --git a/src/particles/qquickgroupgoal_p.h b/src/particles/qquickgroupgoal_p.h
index 9a56ef5cce..022b244ed7 100644
--- a/src/particles/qquickgroupgoal_p.h
+++ b/src/particles/qquickgroupgoal_p.h
@@ -61,6 +61,7 @@ class QQuickGroupGoalAffector : public QQuickParticleAffector
Q_OBJECT
Q_PROPERTY(QString goalState READ goalState WRITE setGoalState NOTIFY goalStateChanged)
Q_PROPERTY(bool jump READ jump WRITE setJump NOTIFY jumpChanged)
+ QML_NAMED_ELEMENT(GroupGoal)
public:
explicit QQuickGroupGoalAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickimageparticle_p.h b/src/particles/qquickimageparticle_p.h
index 059cf67019..83fc75e9c9 100644
--- a/src/particles/qquickimageparticle_p.h
+++ b/src/particles/qquickimageparticle_p.h
@@ -202,6 +202,7 @@ class QQuickImageParticle : public QQuickParticlePainter
Q_PROPERTY(bool spritesInterpolate READ spritesInterpolate WRITE setSpritesInterpolate NOTIFY spritesInterpolateChanged)
Q_PROPERTY(EntryEffect entryEffect READ entryEffect WRITE setEntryEffect NOTIFY entryEffectChanged)
+ QML_NAMED_ELEMENT(ImageParticle)
public:
explicit QQuickImageParticle(QQuickItem *parent = 0);
virtual ~QQuickImageParticle();
diff --git a/src/particles/qquickitemparticle_p.h b/src/particles/qquickitemparticle_p.h
index 7867add4e4..70cfe2a446 100644
--- a/src/particles/qquickitemparticle_p.h
+++ b/src/particles/qquickitemparticle_p.h
@@ -63,6 +63,8 @@ class QQuickItemParticle : public QQuickParticlePainter
Q_OBJECT
Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged)
Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ QML_NAMED_ELEMENT(ItemParticle)
+ QML_ATTACHED(QQuickItemParticleAttached)
public:
explicit QQuickItemParticle(QQuickItem *parent = 0);
~QQuickItemParticle();
@@ -143,6 +145,4 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QML_DECLARE_TYPEINFO(QQuickItemParticle, QML_HAS_ATTACHED_PROPERTIES)
-
#endif // ITEMPARTICLE_H
diff --git a/src/particles/qquicklineextruder_p.h b/src/particles/qquicklineextruder_p.h
index 306f3a1dd6..76ac5aaf11 100644
--- a/src/particles/qquicklineextruder_p.h
+++ b/src/particles/qquicklineextruder_p.h
@@ -57,6 +57,7 @@ class QQuickLineExtruder : public QQuickParticleExtruder
Q_OBJECT
//Default is topleft to bottom right. Flipped makes it topright to bottom left
Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged)
+ QML_NAMED_ELEMENT(LineShape)
public:
explicit QQuickLineExtruder(QObject *parent = 0);
diff --git a/src/particles/qquickmaskextruder_p.h b/src/particles/qquickmaskextruder_p.h
index bbb61b0d28..419d162811 100644
--- a/src/particles/qquickmaskextruder_p.h
+++ b/src/particles/qquickmaskextruder_p.h
@@ -61,6 +61,7 @@ class QQuickMaskExtruder : public QQuickParticleExtruder
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ QML_NAMED_ELEMENT(MaskShape)
public:
explicit QQuickMaskExtruder(QObject *parent = 0);
QPointF extrude(const QRectF &) override;
diff --git a/src/particles/qquickparticleaffector_p.h b/src/particles/qquickparticleaffector_p.h
index 5c9652bc32..fd4887333e 100644
--- a/src/particles/qquickparticleaffector_p.h
+++ b/src/particles/qquickparticleaffector_p.h
@@ -68,6 +68,9 @@ class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleAffector : public QQuickItem
Q_PROPERTY(bool once READ onceOff WRITE setOnceOff NOTIFY onceChanged)
Q_PROPERTY(QQuickParticleExtruder* shape READ shape WRITE setShape NOTIFY shapeChanged)
+ QML_NAMED_ELEMENT(ParticleAffector)
+ QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
+
public:
explicit QQuickParticleAffector(QQuickItem *parent = 0);
virtual void affectSystem(qreal dt);
diff --git a/src/particles/qquickparticleemitter_p.h b/src/particles/qquickparticleemitter_p.h
index 64b9bcef32..b97d3f812a 100644
--- a/src/particles/qquickparticleemitter_p.h
+++ b/src/particles/qquickparticleemitter_p.h
@@ -83,6 +83,7 @@ class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleEmitter : public QQuickItem
Q_PROPERTY(QQuickDirection *velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
Q_PROPERTY(qreal velocityFromMovement READ velocityFromMovement WRITE setVelocityFromMovement NOTIFY velocityFromMovementChanged)
+ QML_NAMED_ELEMENT(Emitter)
public:
explicit QQuickParticleEmitter(QQuickItem *parent = 0);
diff --git a/src/particles/qquickparticleextruder_p.h b/src/particles/qquickparticleextruder_p.h
index 38b2e34c77..24f7a0a2fa 100644
--- a/src/particles/qquickparticleextruder_p.h
+++ b/src/particles/qquickparticleextruder_p.h
@@ -54,6 +54,7 @@
#include <QObject>
#include <QRectF>
#include <QPointF>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -61,6 +62,9 @@ class QQuickParticleExtruder : public QObject
{
Q_OBJECT
+ QML_NAMED_ELEMENT(ParticleExtruder)
+ QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
+
public:
explicit QQuickParticleExtruder(QObject *parent = 0);
virtual QPointF extrude(const QRectF &);
diff --git a/src/particles/qquickparticlegroup_p.h b/src/particles/qquickparticlegroup_p.h
index 0314234569..8d068fbe9c 100644
--- a/src/particles/qquickparticlegroup_p.h
+++ b/src/particles/qquickparticlegroup_p.h
@@ -66,6 +66,7 @@ class QQuickParticleGroup : public QQuickStochasticState, public QQmlParserStatu
//Intercept children requests and assign to the group & system
Q_PROPERTY(QQmlListProperty<QObject> particleChildren READ particleChildren DESIGNABLE false)//### Hidden property for in-state system definitions - ought not to be used in actual "Sprite" states
Q_CLASSINFO("DefaultProperty", "particleChildren")
+ QML_NAMED_ELEMENT(ParticleGroup)
Q_INTERFACES(QQmlParserStatus)
public:
diff --git a/src/particles/qquickparticlepainter_p.h b/src/particles/qquickparticlepainter_p.h
index 16fc6b6f45..e3d13b8a21 100644
--- a/src/particles/qquickparticlepainter_p.h
+++ b/src/particles/qquickparticlepainter_p.h
@@ -64,6 +64,9 @@ class QQuickParticlePainter : public QQuickItem
Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged)
+ QML_NAMED_ELEMENT(ParticlePainter)
+ QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
+
public: // data
typedef QQuickParticleVarLengthArray<QQuickParticleGroupData::ID, 4> GroupIDs;
diff --git a/src/particles/qquickparticlesmodule.cpp b/src/particles/qquickparticlesmodule.cpp
index 03f47a3961..4f2e1cf29d 100644
--- a/src/particles/qquickparticlesmodule.cpp
+++ b/src/particles/qquickparticlesmodule.cpp
@@ -84,47 +84,45 @@ void QQuickParticlesModule::defineModule()
const char* uri = "QtQuick.Particles";
- qmlRegisterType<QQuickParticleSystem>(uri, 2, 0, "ParticleSystem");
- qmlRegisterType<QQuickParticleGroup>(uri, 2, 0, "ParticleGroup");
+ qmlRegisterTypesAndRevisions<
+ QQuickParticleSystem,
+ QQuickParticleGroup,
- qmlRegisterType<QQuickImageParticle>(uri, 2, 0, "ImageParticle");
+ QQuickImageParticle,
#if QT_CONFIG(quick_shadereffect)
- qmlRegisterType<QQuickCustomParticle>(uri, 2, 0, "CustomParticle");
+ QQuickCustomParticle,
#endif
- qmlRegisterType<QQuickItemParticle>(uri, 2, 0, "ItemParticle");
+ QQuickItemParticle,
- qmlRegisterType<QQuickParticleEmitter>(uri, 2, 0, "Emitter");
- qmlRegisterType<QQuickTrailEmitter>(uri, 2, 0, "TrailEmitter");
+ QQuickParticleEmitter,
+ QQuickTrailEmitter,
- qmlRegisterType<QQuickEllipseExtruder>(uri, 2, 0, "EllipseShape");
- qmlRegisterType<QQuickRectangleExtruder>(uri, 2, 0, "RectangleShape");
- qmlRegisterType<QQuickLineExtruder>(uri, 2, 0, "LineShape");
- qmlRegisterType<QQuickMaskExtruder>(uri, 2, 0, "MaskShape");
+ QQuickEllipseExtruder,
+ QQuickRectangleExtruder,
+ QQuickLineExtruder,
+ QQuickMaskExtruder,
- qmlRegisterType<QQuickPointDirection>(uri, 2, 0, "PointDirection");
- qmlRegisterType<QQuickAngleDirection>(uri, 2, 0, "AngleDirection");
- qmlRegisterType<QQuickTargetDirection>(uri, 2, 0, "TargetDirection");
- qmlRegisterType<QQuickCumulativeDirection>(uri, 2, 0, "CumulativeDirection");
+ QQuickPointDirection,
+ QQuickAngleDirection,
+ QQuickTargetDirection,
+ QQuickCumulativeDirection,
- qmlRegisterType<QQuickCustomAffector>(uri, 2, 0, "Affector");
- qmlRegisterType<QQuickWanderAffector>(uri, 2, 0, "Wander");
- qmlRegisterType<QQuickFrictionAffector>(uri, 2, 0, "Friction");
- qmlRegisterType<QQuickAttractorAffector>(uri, 2, 0, "Attractor");
- qmlRegisterType<QQuickGravityAffector>(uri, 2, 0, "Gravity");
- qmlRegisterType<QQuickAgeAffector>(uri, 2, 0, "Age");
- qmlRegisterType<QQuickSpriteGoalAffector>(uri, 2, 0, "SpriteGoal");
- qmlRegisterType<QQuickGroupGoalAffector>(uri, 2, 0, "GroupGoal");
- qmlRegisterType<QQuickTurbulenceAffector>(uri, 2, 0 , "Turbulence");
+ QQuickCustomAffector,
+ QQuickWanderAffector,
+ QQuickFrictionAffector,
+ QQuickAttractorAffector,
+ QQuickGravityAffector,
+ QQuickAgeAffector,
+ QQuickSpriteGoalAffector,
+ QQuickGroupGoalAffector,
+ QQuickTurbulenceAffector,
- //Exposed just for completeness
- qmlRegisterUncreatableType<QQuickParticleAffector>(uri, 2, 0, "ParticleAffector",
- QStringLiteral("Abstract type. Use one of the inheriting types instead."));
- qmlRegisterUncreatableType<QQuickParticlePainter>(uri, 2, 0, "ParticlePainter",
- QStringLiteral("Abstract type. Use one of the inheriting types instead."));
- qmlRegisterUncreatableType<QQuickParticleExtruder>(uri, 2, 0, "ParticleExtruder",
- QStringLiteral("Abstract type. Use one of the inheriting types instead."));
- qmlRegisterUncreatableType<QQuickDirection>(uri, 2, 0, "NullVector",
- QStringLiteral("Abstract type. Use one of the inheriting types instead."));
+ // Exposed just for completeness
+ QQuickParticleAffector,
+ QQuickParticlePainter,
+ QQuickParticleExtruder,
+ QQuickDirection
+ >(uri, 2);
}
QT_END_NAMESPACE
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index 1e34086b0c..dd721a7164 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -349,6 +349,7 @@ class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleSystem : public QQuickItem
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
+ QML_NAMED_ELEMENT(ParticleSystem)
public:
explicit QQuickParticleSystem(QQuickItem *parent = nullptr);
diff --git a/src/particles/qquickpointattractor_p.h b/src/particles/qquickpointattractor_p.h
index 47985b5e82..28bbaaa84f 100644
--- a/src/particles/qquickpointattractor_p.h
+++ b/src/particles/qquickpointattractor_p.h
@@ -62,6 +62,7 @@ class QQuickAttractorAffector : public QQuickParticleAffector
Q_PROPERTY(qreal pointY READ pointY WRITE setPointY NOTIFY pointYChanged)
Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
Q_PROPERTY(Proportion proportionalToDistance READ proportionalToDistance WRITE setProportionalToDistance NOTIFY proportionalToDistanceChanged)
+ QML_NAMED_ELEMENT(Attractor)
public:
enum Proportion{
diff --git a/src/particles/qquickpointdirection_p.h b/src/particles/qquickpointdirection_p.h
index a80be928ad..9103a570c9 100644
--- a/src/particles/qquickpointdirection_p.h
+++ b/src/particles/qquickpointdirection_p.h
@@ -61,6 +61,7 @@ class QQuickPointDirection : public QQuickDirection
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
Q_PROPERTY(qreal xVariation READ xVariation WRITE setXVariation NOTIFY xVariationChanged)
Q_PROPERTY(qreal yVariation READ yVariation WRITE setYVariation NOTIFY yVariationChanged)
+ QML_NAMED_ELEMENT(PointDirection)
public:
explicit QQuickPointDirection(QObject *parent = 0);
QPointF sample(const QPointF &from) override;
diff --git a/src/particles/qquickrectangleextruder_p.h b/src/particles/qquickrectangleextruder_p.h
index 630cf3050d..7c0a6c2bf1 100644
--- a/src/particles/qquickrectangleextruder_p.h
+++ b/src/particles/qquickrectangleextruder_p.h
@@ -59,6 +59,7 @@ class QQuickRectangleExtruder : public QQuickParticleExtruder
{
Q_OBJECT
Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)
+ QML_NAMED_ELEMENT(RectangleShape)
public:
explicit QQuickRectangleExtruder(QObject *parent = 0);
diff --git a/src/particles/qquickspritegoal_p.h b/src/particles/qquickspritegoal_p.h
index e569603550..d5f9bb88ae 100644
--- a/src/particles/qquickspritegoal_p.h
+++ b/src/particles/qquickspritegoal_p.h
@@ -63,6 +63,7 @@ class QQuickSpriteGoalAffector : public QQuickParticleAffector
Q_PROPERTY(QString goalState READ goalState WRITE setGoalState NOTIFY goalStateChanged)
Q_PROPERTY(bool jump READ jump WRITE setJump NOTIFY jumpChanged)
Q_PROPERTY(bool systemStates READ systemStates WRITE setSystemStates NOTIFY systemStatesChanged)
+ QML_NAMED_ELEMENT(SpriteGoal)
public:
explicit QQuickSpriteGoalAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquicktargetdirection_p.h b/src/particles/qquicktargetdirection_p.h
index 13e826743e..232d375d8c 100644
--- a/src/particles/qquicktargetdirection_p.h
+++ b/src/particles/qquicktargetdirection_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
#include "qquickdirection_p.h"
+#include <QtQml/qqml.h>
+
QT_BEGIN_NAMESPACE
class QQuickItem;
@@ -68,6 +70,7 @@ class QQuickTargetDirection : public QQuickDirection
Q_PROPERTY(bool proportionalMagnitude READ proportionalMagnitude WRITE setProportionalMagnitude NOTIFY proprotionalMagnitudeChanged)
Q_PROPERTY(qreal magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged)
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
+ QML_NAMED_ELEMENT(TargetDirection)
public:
explicit QQuickTargetDirection(QObject *parent = 0);
diff --git a/src/particles/qquicktrailemitter_p.h b/src/particles/qquicktrailemitter_p.h
index 22b96afd25..270bec52cf 100644
--- a/src/particles/qquicktrailemitter_p.h
+++ b/src/particles/qquicktrailemitter_p.h
@@ -64,6 +64,7 @@ class QQuickTrailEmitter : public QQuickParticleEmitter
Q_PROPERTY(QQuickParticleExtruder* emitShape READ emissonShape WRITE setEmissionShape NOTIFY emissionShapeChanged)
Q_PROPERTY(qreal emitHeight READ emitterYVariation WRITE setEmitterYVariation NOTIFY emitterYVariationChanged)
Q_PROPERTY(qreal emitWidth READ emitterXVariation WRITE setEmitterXVariation NOTIFY emitterXVariationChanged)
+ QML_NAMED_ELEMENT(TrailEmitter)
public:
enum EmitSize {
diff --git a/src/particles/qquickturbulence_p.h b/src/particles/qquickturbulence_p.h
index e73f3ba153..52011381e4 100644
--- a/src/particles/qquickturbulence_p.h
+++ b/src/particles/qquickturbulence_p.h
@@ -62,7 +62,9 @@ class QQuickTurbulenceAffector : public QQuickParticleAffector
Q_OBJECT
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
Q_PROPERTY(QUrl noiseSource READ noiseSource WRITE setNoiseSource NOTIFY noiseSourceChanged)
- public:
+ QML_NAMED_ELEMENT(Turbulence)
+
+public:
explicit QQuickTurbulenceAffector(QQuickItem *parent = 0);
~QQuickTurbulenceAffector();
void affectSystem(qreal dt) override;
diff --git a/src/particles/qquickwander_p.h b/src/particles/qquickwander_p.h
index 0ad19d4d13..bf7acdacfb 100644
--- a/src/particles/qquickwander_p.h
+++ b/src/particles/qquickwander_p.h
@@ -71,6 +71,7 @@ class QQuickWanderAffector : public QQuickParticleAffector
Q_PROPERTY(qreal xVariance READ xVariance WRITE setXVariance NOTIFY xVarianceChanged)
Q_PROPERTY(qreal yVariance READ yVariance WRITE setYVariance NOTIFY yVarianceChanged)
Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
+ QML_NAMED_ELEMENT(Wander)
public:
enum AffectableParameters {
diff --git a/src/qml/common/qqmlapiversion_p.h b/src/qml/common/qqmlapiversion_p.h
index eca05558d8..576619c518 100644
--- a/src/qml/common/qqmlapiversion_p.h
+++ b/src/qml/common/qqmlapiversion_p.h
@@ -51,6 +51,6 @@
// We mean it.
//
-#define Q_QML_PRIVATE_API_VERSION 5
+#define Q_QML_PRIVATE_API_VERSION 6
#endif // QQMLAPIVERSION_P_H
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index c3ddce5884..11de506a53 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE
// Also change the comment behind the number to describe the latest change. This has the added
// benefit that if another patch changes the version too, it will result in a merge conflict, and
// not get removed silently.
-#define QV4_DATA_STRUCTURE_VERSION 0x24 // Collect function parameter types
+#define QV4_DATA_STRUCTURE_VERSION 0x26// support required properties
class QIODevice;
class QQmlTypeNameCache;
@@ -656,7 +656,8 @@ struct Property
{
quint32_le nameIndex;
union {
- quint32_le_bitfield<0, 29> builtinTypeOrTypeNameIndex;
+ quint32_le_bitfield<0, 28> builtinTypeOrTypeNameIndex;
+ quint32_le_bitfield<28, 1> isRequired;
quint32_le_bitfield<29, 1> isBuiltinType;
quint32_le_bitfield<30, 1> isList;
quint32_le_bitfield<31, 1> isReadOnly;
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 665d2633a7..940d61ba97 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -792,7 +792,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
{
if (node->type == QQmlJS::AST::UiPublicMember::Signal) {
Signal *signal = New<Signal>();
- QString signalName = node->name.toString();
+ const QString signalName = node->name.toString();
signal->nameIndex = registerString(signalName);
QQmlJS::AST::SourceLocation loc = node->typeToken;
@@ -821,8 +821,14 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
p = p->next;
}
- if (signalName.at(0).isUpper())
- COMPILE_EXCEPTION(node->identifierToken, tr("Signal names cannot begin with an upper case letter"));
+ for (const QChar &ch : signalName) {
+ if (ch.isLower())
+ break;
+ if (ch.isUpper()) {
+ COMPILE_EXCEPTION(node->identifierToken,
+ tr("Signal names cannot begin with an upper case letter"));
+ }
+ }
if (illegalNames.contains(signalName))
COMPILE_EXCEPTION(node->identifierToken, tr("Illegal signal name"));
@@ -841,6 +847,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
Property *property = New<Property>();
property->isReadOnly = node->isReadonlyMember;
+ property->isRequired = node->isRequired;
QV4::CompiledData::BuiltinType builtinPropertyType = Parameter::stringToBuiltinType(memberType);
bool typeFound = builtinPropertyType != QV4::CompiledData::BuiltinType::InvalidBuiltin;
diff --git a/src/qml/doc/src/javascript/finetuning.qdoc b/src/qml/doc/src/javascript/finetuning.qdoc
new file mode 100644
index 0000000000..fcd710db8b
--- /dev/null
+++ b/src/qml/doc/src/javascript/finetuning.qdoc
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+
+\page qtqml-javascript-finetuning.html
+\title Fine-tuning the JavaScript Engine
+\brief Describes the environment variables available, to control how Javascript is run.
+
+Running JavaScript code can be influenced by a few environment variables, particularly:
+
+\table
+ \header
+ \li Environment Variable
+ \li Description
+ \row
+ \li \c{QV4_JIT_CALL_THRESHOLD}
+ \li The JavaScript engine contains a Just-In-Time compiler (JIT). The JIT will compile
+ frequently run JavaScript functions into machine code to run faster. This
+ environment variable determines how often a function needs to be run to be
+ considered for JIT compilation. The default value is 3 times.
+ \row
+ \li \c{QV4_FORCE_INTERPRETER}
+ \li Setting this environment variable disables the JIT and runs all
+ functions through the interpreter, no matter how often they are called.
+ \row
+ \li \c{QV4_JS_MAX_STACK_SIZE}
+ \li The JavaScript engine reserves a special memory area as a stack to run JavaScript.
+ This stack is separate from the C++ stack. Usually this area is 4MB in size. If this
+ environment variable contains a number, the JavaScript engine interprets it as the
+ size of the memory area, in bytes, to be allocated as the JavaScript stack.
+ \row
+ \li \c{QV4_GC_MAX_STACK_SIZE}
+ \li In addition to the regular JavaScript stack, the JavaScript engine keeps another stack
+ for the garbage collector, usually 2MB of memory. If the garbage collector needs to
+ handle an excessive number of objects at the same time, this stack might overrun.
+ If it contains a number, this environment variable is interpreted as the size in bytes
+ of the memory area that will be allocated as the stack for the garbage collector.
+ \row
+ \li \c{QV4_CRASH_ON_STACKOVERFLOW}
+ \li Usually the JavaScript engine tries to catch C++ stack overflows caused by
+ excessively recursive JavaScript code, and generates a non-fatal error condition.
+ There are separate recursion checks for compiling JavaScript and running JavaScript. A
+ stack overflow when compiling JavaScript indicates that the code contains deeply nested
+ objects and functions. A stack overflow at run-time indicates that the code results in
+ a deeply recursive program. The check for this is only indirectly related to the
+ JavaScript stack size mentioned above, as each JavaScript function call consumes stack
+ space on both, the C++ and the JavaScript stack. The code that checks for excessive
+ recursion is necessarily conservative, as the available stack size depends on many
+ factors and can often be customized by the user. With this environment variable set, the
+ JavaScript engine does not check for stack overflows when compiling or running
+ JavaScript and will not generate exceptions for them. Instead, when the stack overflows
+ the program attempts an invalid memory access. This most likely terminates the
+ program. In turn, the program gets to use up all the stack space the operating system
+ can provide.
+ \warning malicious code may be able to evade the termination and access unexpected
+ memory locations this way.
+ \row
+ \li \c{QV4_MAX_CALL_DEPTH}
+ \li Stack overflows when running (as opposed to compiling) JavaScript are prevented by
+ controlling the call depth: the number of nested function invocations. By
+ default, an exception is generated if the call depth exceeds 1234. If it contains a
+ number, this environment variable overrides the maximum call depth. Beware that the
+ recursion limit when compiling JavaScript is not affected.
+ \row
+ \li \c{QV4_MM_AGGRESSIVE_GC}
+ \li Setting this environment variable runs the garbage collector before each memory
+ allocation. This is very expensive at run-time, but it quickly uncovers many memory
+ management errors, for example the manual deletion of an object belonging to the QML
+ engine from C++.
+ \row
+ \li \c{QV4_PROFILE_WRITE_PERF_MAP}
+ \li On Linux, the \c perf utility can be used to profile programs. To analyze JIT-compiled
+ JavaScript functions, it needs to know about their names and locations in memory. To
+ provide this information, there's a convention to create a special file called
+ \c{perf-<pid>.map} in \e{/tmp} which perf then reads. This environment variable, if
+ set, causes the JIT to generate this file.
+\endtable
+
+*/
+
diff --git a/src/qml/doc/src/javascript/topic.qdoc b/src/qml/doc/src/javascript/topic.qdoc
index 0c06e14b4c..05fb1ddfdc 100644
--- a/src/qml/doc/src/javascript/topic.qdoc
+++ b/src/qml/doc/src/javascript/topic.qdoc
@@ -81,4 +81,11 @@ These limitations and extensions are documented in the description of the
\l{qtqml-javascript-hostenvironment.html}{JavaScript Host Environment} provided
by the QML engine.
+\section1 Fine Tuning the JavaScript engine
+
+For specific use cases you may want to override some of the parameters the
+JavaScript engine uses for handling memory and compiling JavaScript. See
+\l{qtqml-javascript-finetuning.html}{Fine Tuning the JavaScript engine} for
+more information on these parameters.
+
*/
diff --git a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
index 0faad43f4f..f7d71030b5 100644
--- a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
+++ b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
@@ -479,10 +479,7 @@ Module {
Enum {
name: "Loops"
- values: {
- "Infinite": -2,
- "OnceOnly": 1
- }
+ values: [ "Infinite", "OnceOnly" ]
}
// Signal and Method work the same way. The inner Parameter
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 3d3f452073..590cebfa7c 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -216,15 +216,19 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
memoryManager = new QV4::MemoryManager(this);
if (maxCallDepth == -1) {
- ok = false;
- maxCallDepth = qEnvironmentVariableIntValue("QV4_MAX_CALL_DEPTH", &ok);
- if (!ok || maxCallDepth <= 0) {
+ if (qEnvironmentVariableIsSet("QV4_CRASH_ON_STACKOVERFLOW")) {
+ maxCallDepth = std::numeric_limits<qint32>::max();
+ } else {
+ ok = false;
+ maxCallDepth = qEnvironmentVariableIntValue("QV4_MAX_CALL_DEPTH", &ok);
+ if (!ok || maxCallDepth <= 0) {
#if defined(QT_NO_DEBUG) && !defined(__SANITIZE_ADDRESS__) && !QT_HAS_FEATURE(address_sanitizer)
- maxCallDepth = 1234;
+ maxCallDepth = 1234;
#else
- // no (tail call) optimization is done, so there'll be a lot mare stack frames active
- maxCallDepth = 200;
+ // no (tail call) optimization is done, so there'll be a lot mare stack frames active
+ maxCallDepth = 200;
#endif
+ }
}
}
Q_ASSERT(maxCallDepth > 0);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index c36da3815d..2b5e8bd2b9 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -2077,7 +2077,7 @@ ReturnedValue QObjectMethod::callInternal(const Value *thisObject, const Value *
if (!d()->valueTypeWrapper)
return Encode::undefined();
- object = QQmlObjectOrGadget(d()->propertyCache(), d()->valueTypeWrapper->gadgetPtr);
+ object = QQmlObjectOrGadget(d()->propertyCache(), d()->valueTypeWrapper->gadgetPtr());
}
QQmlPropertyData method;
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 8ac7633ae0..cc560c5912 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -49,6 +49,7 @@
%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "."
%token T_ELSE "else" T_EQ "=" T_EQ_EQ "=="
%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for"
+%token T_FUNCTION_STAR "function *"
%token T_FUNCTION "function" T_GE ">=" T_GT ">"
%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>"
%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if"
@@ -88,6 +89,7 @@
%token T_STATIC "static"
%token T_EXPORT "export"
%token T_FROM "from"
+%token T_REQUIRED "required"
--- template strings
%token T_NO_SUBSTITUTION_TEMPLATE"(no subst template)"
@@ -120,8 +122,9 @@
%token T_FOR_LOOKAHEAD_OK "(for lookahead ok)"
--%left T_PLUS T_MINUS
-%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET T_OF T_STATIC T_FROM T_AS
+%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET T_OF T_STATIC T_FROM T_AS T_REQUIRED
%nonassoc REDUCE_HERE
+%right T_THEN T_ELSE
%start TopLevel
@@ -1175,7 +1178,7 @@ UiObjectMember: T_SIGNAL T_IDENTIFIER Semicolon;
} break;
./
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier Semicolon;
+UiObjectMemberListPropertyNoInitialiser: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier Semicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
@@ -1189,23 +1192,19 @@ UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier S
} break;
./
-UiObjectMember: T_READONLY T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier Semicolon;
+UiObjectMember: UiObjectMemberListPropertyNoInitialiser;
+
+UiObjectMember: T_READONLY UiObjectMemberListPropertyNoInitialiser;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
- node->typeModifier = stringRef(3);
- node->propertyToken = loc(2);
- node->typeModifierToken = loc(3);
- node->typeToken = loc(5);
- node->identifierToken = loc(7);
- node->semicolonToken = loc(8);
sym(1).Node = node;
} break;
./
-UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier Semicolon;
+UiObjectMemberPropertyNoInitialiser: T_PROPERTY UiPropertyType QmlIdentifier Semicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
@@ -1217,42 +1216,47 @@ UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier Semicolon;
} break;
./
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType QmlIdentifier Semicolon;
+
+UiObjectMember: UiObjectMemberPropertyNoInitialiser;
+
+UiObjectMember: T_DEFAULT UiObjectMemberPropertyNoInitialiser;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
node->isDefaultMember = true;
node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5);
sym(1).Node = node;
} break;
./
-UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier Semicolon;
+UiObjectMember: T_DEFAULT UiObjectMemberListPropertyNoInitialiser;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
node->isDefaultMember = true;
node->defaultToken = loc(1);
- node->typeModifier = stringRef(3);
- node->propertyToken = loc(2);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(7);
- node->semicolonToken = loc(8);
sym(1).Node = node;
} break;
./
+
OptionalSemicolon: | Semicolon;
/.
/* we need OptionalSemicolon because UiScriptStatement might already parse the last semicolon
and then we would miss a semicolon (see tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml)*/
./
-UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon;
+UiObjectMember: T_REQUIRED UiObjectMemberPropertyNoInitialiser;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
+ node->requiredToken = loc(1);
+ node->isRequired = true;
+ sym(1).Node = node;
+ } break;
+./
+
+
+UiObjectMemberWithScriptStatement: T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3), sym(5).Statement);
@@ -1264,35 +1268,29 @@ UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatemen
} break;
./
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon;
+UiObjectMember: UiObjectMemberWithScriptStatement;
+
+UiObjectMember: T_READONLY UiObjectMemberWithScriptStatement;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement);
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
sym(1).Node = node;
} break;
./
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon;
+UiObjectMember: T_DEFAULT UiObjectMemberWithScriptStatement;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement);
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
node->isDefaultMember = true;
node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
sym(1).Node = node;
} break;
./
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon;
+UiObjectMemberWithArray: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
@@ -1318,35 +1316,19 @@ UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T
} break;
./
-UiObjectMember: T_READONLY T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon;
+UiObjectMember: UiObjectMemberWithArray;
+
+UiObjectMember: T_READONLY UiObjectMemberWithArray;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
- node->typeModifier = stringRef(3);
- node->propertyToken = loc(2);
- node->typeModifierToken = loc(3);
- node->typeToken = loc(5);
- node->identifierToken = loc(7);
- node->semicolonToken = loc(8); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(7));
- propertyName->identifierToken = loc(7);
- propertyName->next = 0;
-
- AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(10).UiArrayMemberList->finish());
- binding->colonToken = loc(8);
- binding->lbracketToken = loc(9);
- binding->rbracketToken = loc(11);
-
- node->binding = binding;
-
sym(1).Node = node;
} break;
./
-UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_COLON ExpressionStatementLookahead UiQualifiedId UiObjectInitializer Semicolon;
+UiObjectMemberExpressionStatementLookahead: T_PROPERTY UiPropertyType QmlIdentifier T_COLON ExpressionStatementLookahead UiQualifiedId UiObjectInitializer Semicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
@@ -1369,43 +1351,30 @@ UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_COLON ExpressionStatem
} break;
./
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType QmlIdentifier T_COLON ExpressionStatementLookahead UiQualifiedId UiObjectInitializer Semicolon;
+UiObjectMember: UiObjectMemberExpressionStatementLookahead;
+
+UiObjectMember: T_READONLY UiObjectMemberExpressionStatementLookahead;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
+ AST::UiPublicMember *node = sym(2).UiPublicMember;
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(4));
- propertyName->identifierToken = loc(4);
- propertyName->next = 0;
-
- AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
- propertyName, sym(7).UiQualifiedId, sym(8).UiObjectInitializer);
- binding->colonToken = loc(5);
-
- node->binding = binding;
-
sym(1).Node = node;
} break;
./
-UiObjectMember: FunctionDeclarationWithTypes;
+UiObjectMember: GeneratorDeclaration;
/.
case $rule_number: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
+ auto node = new (pool) AST::UiSourceElement(sym(1).Node);
+ sym(1).Node = node;
} break;
./
-UiObjectMember: GeneratorExpression;
+UiObjectMember: FunctionDeclarationWithTypes;
/.
case $rule_number: {
- auto node = new (pool) AST::UiSourceElement(sym(1).Node);
- sym(1).Node = node;
+ sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
} break;
./
@@ -1501,6 +1470,7 @@ QmlIdentifier: T_GET;
QmlIdentifier: T_SET;
QmlIdentifier: T_FROM;
QmlIdentifier: T_OF;
+QmlIdentifier: T_REQUIRED;
JsIdentifier: T_IDENTIFIER;
JsIdentifier: T_PROPERTY;
@@ -1513,6 +1483,7 @@ JsIdentifier: T_FROM;
JsIdentifier: T_STATIC;
JsIdentifier: T_OF;
JsIdentifier: T_AS;
+JsIdentifier: T_REQUIRED;
IdentifierReference: JsIdentifier;
BindingIdentifier: IdentifierReference;
@@ -3232,7 +3203,7 @@ ExpressionStatementLookahead: ;
int token = lookaheadToken(lexer);
if (token == T_LBRACE)
pushToken(T_FORCE_BLOCK);
- else if (token == T_FUNCTION || token == T_CLASS || token == T_LET || token == T_CONST)
+ else if (token == T_FUNCTION || token == T_FUNCTION_STAR || token == T_CLASS || token == T_LET || token == T_CONST)
pushToken(T_FORCE_DECLARATION);
} break;
./
@@ -3980,27 +3951,14 @@ GeneratorRBrace: T_RBRACE;
} break;
./
-GeneratorDeclaration: Function T_STAR BindingIdentifier GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
-/.
- case $rule_number: {
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(3), sym(5).FormalParameterList, sym(8).StatementList);
- node->functionToken = loc(1);
- node->identifierToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->lbraceToken = loc(7);
- node->rbraceToken = loc(9);
- node->isGenerator = true;
- sym(1).Node = node;
- } break;
-./
+FunctionStar: T_FUNCTION_STAR %prec REDUCE_HERE;
-GeneratorDeclaration_Default: GeneratorDeclaration;
-GeneratorDeclaration_Default: Function T_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
+GeneratorDeclaration: FunctionStar BindingIdentifier GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
case $rule_number: {
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(4).FormalParameterList, sym(7).StatementList);
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).StatementList);
node->functionToken = loc(1);
+ node->identifierToken = loc(2);
node->lparenToken = loc(3);
node->rparenToken = loc(5);
node->lbraceToken = loc(6);
@@ -4010,27 +3968,28 @@ GeneratorDeclaration_Default: Function T_STAR GeneratorLParen FormalParameters T
} break;
./
-GeneratorExpression: T_FUNCTION T_STAR BindingIdentifier GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
+GeneratorDeclaration_Default: GeneratorDeclaration;
+GeneratorDeclaration_Default: FunctionStar GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
case $rule_number: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(3), sym(5).FormalParameterList, sym(8).StatementList);
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
node->functionToken = loc(1);
- if (!stringRef(3).isNull())
- node->identifierToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->lbraceToken = loc(7);
- node->rbraceToken = loc(9);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->lbraceToken = loc(5);
+ node->rbraceToken = loc(7);
node->isGenerator = true;
sym(1).Node = node;
} break;
./
-GeneratorExpression: T_FUNCTION T_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
+GeneratorExpression: T_FUNCTION_STAR BindingIdentifier GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
case $rule_number: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(4).FormalParameterList, sym(7).StatementList);
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).StatementList);
node->functionToken = loc(1);
+ if (!stringRef(2).isNull())
+ node->identifierToken = loc(2);
node->lparenToken = loc(3);
node->rparenToken = loc(5);
node->lbraceToken = loc(6);
@@ -4040,6 +3999,20 @@ GeneratorExpression: T_FUNCTION T_STAR GeneratorLParen FormalParameters T_RPAREN
} break;
./
+GeneratorExpression: T_FUNCTION_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
+/.
+ case $rule_number: {
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
+ node->functionToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->lbraceToken = loc(5);
+ node->rbraceToken = loc(7);
+ node->isGenerator = true;
+ sym(1).Node = node;
+ } break;
+./
+
GeneratorBody: FunctionBody;
YieldExpression: T_YIELD;
@@ -4419,7 +4392,7 @@ ExportDeclarationLookahead: ;
/.
case $rule_number: {
int token = lookaheadToken(lexer);
- if (token == T_FUNCTION || token == T_CLASS)
+ if (token == T_FUNCTION || token == T_FUNCTION_STAR || token == T_CLASS)
pushToken(T_FORCE_DECLARATION);
} break;
./
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp
index b63b2191b9..03355b3e38 100644
--- a/src/qml/parser/qqmljsast.cpp
+++ b/src/qml/parser/qqmljsast.cpp
@@ -105,6 +105,12 @@ ClassExpression *Node::asClassDefinition()
return nullptr;
}
+bool Node::ignoreRecursionDepth() const
+{
+ static const bool doIgnore = qEnvironmentVariableIsSet("QV4_CRASH_ON_STACKOVERFLOW");
+ return doIgnore;
+}
+
ExpressionNode *ExpressionNode::expressionCast()
{
return this;
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 39194068bf..bdda46da90 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -275,10 +275,16 @@ public:
virtual FunctionExpression *asFunctionDefinition();
virtual ClassExpression *asClassDefinition();
+ bool ignoreRecursionDepth() const;
+
inline void accept(Visitor *visitor)
{
Visitor::RecursionDepthCheck recursionCheck(visitor);
- if (recursionCheck()) {
+
+ // Stack overflow is uncommon, ignoreRecursionDepth() only returns true if
+ // QV4_CRASH_ON_STACKOVERFLOW is set, and ignoreRecursionDepth() needs to be out of line.
+ // Therefore, check for ignoreRecursionDepth() _after_ calling the inline recursionCheck().
+ if (recursionCheck() || ignoreRecursionDepth()) {
if (visitor->preVisit(this))
accept0(visitor);
visitor->postVisit(this);
@@ -307,6 +313,14 @@ public:
int kind = Kind_Undefined;
};
+template<typename T>
+T lastListElement(T head)
+{
+ auto current = head;
+ while (current->next)
+ current = current->next;
+ return current;
+}
class QML_PARSER_EXPORT UiQualifiedId: public Node
{
@@ -338,7 +352,7 @@ public:
{ return identifierToken; }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : identifierToken; }
+ { return lastListElement(this)->identifierToken; }
// attributes
UiQualifiedId *next;
@@ -397,7 +411,7 @@ public:
{ return typeId->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : typeId->lastSourceLocation(); }
+ { return lastListElement(this)->typeId->lastSourceLocation(); }
inline TypeArgumentList *finish()
{
@@ -678,7 +692,10 @@ public:
{ return literalToken; }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : (expression ? expression->lastSourceLocation() : literalToken); }
+ {
+ auto last = lastListElement(this);
+ return (last->expression ? last->expression->lastSourceLocation() : last->literalToken);
+ }
void accept0(Visitor *visitor) override;
@@ -800,7 +817,7 @@ public:
{ return commaToken; }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : commaToken; }
+ { return lastListElement(this)->commaToken; }
inline Elision *finish ()
{
@@ -961,7 +978,10 @@ public:
{ return elision ? elision->firstSourceLocation() : element->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : (element ? element->lastSourceLocation() : elision->lastSourceLocation()); }
+ {
+ auto last = lastListElement(this);
+ return last->element ? last->element->lastSourceLocation() : last->elision->lastSourceLocation();
+ }
Elision *elision = nullptr;
PatternElement *element = nullptr;
@@ -1036,7 +1056,7 @@ public:
{ return property->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : property->lastSourceLocation(); }
+ { return lastListElement(this)->property->lastSourceLocation(); }
PatternProperty *property;
PatternPropertyList *next;
@@ -1645,7 +1665,9 @@ public:
{ return statement->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); }
+ {
+ return lastListElement(this)->statement->lastSourceLocation();
+ }
inline StatementList *finish ()
{
@@ -2138,7 +2160,9 @@ public:
{ return clause->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); }
+ {
+ return lastListElement(this)->clause->lastSourceLocation();
+ }
inline CaseClauses *finish ()
{
@@ -2429,7 +2453,9 @@ public:
{ return element->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
+ {
+ return lastListElement(this)->element->lastSourceLocation();
+ }
FormalParameterList *finish(MemoryPool *pool);
@@ -2606,7 +2632,9 @@ public:
{ return importSpecifierToken; }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : importSpecifierToken; }
+ {
+ return lastListElement(this)->importSpecifierToken;
+ }
// attributes
SourceLocation importSpecifierToken;
@@ -2843,7 +2871,7 @@ public:
SourceLocation firstSourceLocation() const override
{ return exportSpecifier->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : exportSpecifier->lastSourceLocation(); }
+ { return lastListElement(this)->exportSpecifier->lastSourceLocation(); }
// attributes
ExportSpecifier *exportSpecifier;
@@ -3036,7 +3064,7 @@ public:
{ return member->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
+ { return lastListElement(this)->member->lastSourceLocation(); }
UiObjectMemberList *finish()
{
@@ -3115,7 +3143,7 @@ public:
{ return headerItem->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : headerItem->lastSourceLocation(); }
+ { return lastListElement(this)->headerItem->lastSourceLocation(); }
// attributes
Node *headerItem;
@@ -3179,7 +3207,7 @@ public:
{ return member->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
+ { return lastListElement(this)->member->lastSourceLocation(); }
UiArrayMemberList *finish()
{
@@ -3240,7 +3268,10 @@ public:
{ return colonToken.isValid() ? identifierToken : propertyTypeToken; }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : (colonToken.isValid() ? propertyTypeToken : identifierToken); }
+ {
+ auto last = lastListElement(this);
+ return (last->colonToken.isValid() ? last->propertyTypeToken : last->identifierToken);
+ }
inline UiParameterList *finish ()
{
@@ -3283,6 +3314,8 @@ public:
return defaultToken;
else if (readonlyToken.isValid())
return readonlyToken;
+ else if (requiredToken.isValid())
+ return requiredToken;
return propertyToken;
}
@@ -3306,10 +3339,13 @@ public:
UiObjectMember *binding; // initialized with a QML object or array.
bool isDefaultMember;
bool isReadonlyMember;
+ bool isRequired = false;
UiParameterList *parameters;
+ // TODO: merge source locations
SourceLocation defaultToken;
SourceLocation readonlyToken;
SourceLocation propertyToken;
+ SourceLocation requiredToken;
SourceLocation typeModifierToken;
SourceLocation typeToken;
SourceLocation identifierToken;
@@ -3493,8 +3529,10 @@ public:
{ return memberToken; }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() :
- valueToken.isValid() ? valueToken : memberToken; }
+ {
+ auto last = lastListElement(this);
+ return last->valueToken.isValid() ? last->valueToken : last->memberToken;
+ }
void accept0(Visitor *visitor) override;
diff --git a/src/qml/parser/qqmljskeywords_p.h b/src/qml/parser/qqmljskeywords_p.h
index 96b3709162..3eb054341f 100644
--- a/src/qml/parser/qqmljskeywords_p.h
+++ b/src/qml/parser/qqmljskeywords_p.h
@@ -743,6 +743,18 @@ static inline int classify8(const QChar *s, int parseModeFlags) {
}
}
}
+ } else if (s[2].unicode() == 'q') {
+ if (s[3].unicode() == 'u') {
+ if (s[4].unicode() == 'i') {
+ if (s[5].unicode() == 'r') {
+ if (s[6].unicode() == 'e') {
+ if (s[7].unicode() == 'd') {
+ return Lexer::T_REQUIRED;
+ }
+ }
+ }
+ }
+ }
}
}
}
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp
index 1e0ac72bd1..443e1a7476 100644
--- a/src/qml/parser/qqmljslexer.cpp
+++ b/src/qml/parser/qqmljslexer.cpp
@@ -492,6 +492,42 @@ int Lexer::scanToken()
again:
_validTokenText = false;
+ // handle comment can be called after a '/' has been read
+ // and returns true if it actually encountered a comment
+ auto handleComment = [this](){
+ if (_char == QLatin1Char('*')) {
+ scanChar();
+ while (_codePtr <= _endPtr) {
+ if (_char == QLatin1Char('*')) {
+ scanChar();
+ if (_char == QLatin1Char('/')) {
+ scanChar();
+
+ if (_engine) {
+ _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4,
+ tokenStartLine(), tokenStartColumn() + 2);
+ }
+
+ return true;
+ }
+ } else {
+ scanChar();
+ }
+ }
+ } else if (_char == QLatin1Char('/')) {
+ while (_codePtr <= _endPtr && !isLineTerminator()) {
+ scanChar();
+ }
+ if (_engine) {
+ _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2,
+ tokenStartLine(), tokenStartColumn() + 2);
+ }
+ return true;
+ }
+ return false;
+ };
+
+
while (_char.isSpace()) {
if (isLineTerminator()) {
if (_restrictedKeyword) {
@@ -599,35 +635,9 @@ again:
case ':': return T_COLON;
case '/':
- if (_char == QLatin1Char('*')) {
- scanChar();
- while (_codePtr <= _endPtr) {
- if (_char == QLatin1Char('*')) {
- scanChar();
- if (_char == QLatin1Char('/')) {
- scanChar();
-
- if (_engine) {
- _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4,
- tokenStartLine(), tokenStartColumn() + 2);
- }
-
- goto again;
- }
- } else {
- scanChar();
- }
- }
- } else if (_char == QLatin1Char('/')) {
- while (_codePtr <= _endPtr && !isLineTerminator()) {
- scanChar();
- }
- if (_engine) {
- _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2,
- tokenStartLine(), tokenStartColumn() + 2);
- }
+ if (handleComment())
goto again;
- } if (_char == QLatin1Char('=')) {
+ else if (_char == QLatin1Char('=')) {
scanChar();
return T_DIVIDE_EQ;
}
@@ -829,6 +839,21 @@ again:
if (!identifierWithEscapeChars)
kind = classify(_tokenStartPtr, _tokenLength, parseModeFlags());
+ if (kind == T_FUNCTION) {
+ continue_skipping:
+ while (_codePtr < _endPtr && _char.isSpace())
+ scanChar();
+ if (_char == QLatin1Char('*')) {
+ _tokenLength = _codePtr - _tokenStartPtr - 1;
+ kind = T_FUNCTION_STAR;
+ scanChar();
+ } else if (_char == QLatin1Char('/')) {
+ scanChar();
+ if (handleComment())
+ goto continue_skipping;
+ }
+ }
+
if (_engine) {
if (kind == T_IDENTIFIER && identifierWithEscapeChars)
_tokenSpell = _engine->newStringRef(_tokenText);
@@ -1407,6 +1432,7 @@ static const int uriTokens[] = {
QQmlJSGrammar::T_FINALLY,
QQmlJSGrammar::T_FOR,
QQmlJSGrammar::T_FUNCTION,
+ QQmlJSGrammar::T_FUNCTION_STAR,
QQmlJSGrammar::T_IF,
QQmlJSGrammar::T_IN,
QQmlJSGrammar::T_OF,
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index 5b16a3c9e2..cfbe0c409e 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -103,33 +103,188 @@ QObject *QQmlPrivate::RegisterSingletonFunctor::operator()(QQmlEngine *qeng, QJS
return m_object;
};
+static QVector<int> availableRevisions(const QMetaObject *metaObject)
+{
+ QVector<int> revisions;
+ if (!metaObject)
+ return revisions;
+ const int propertyOffset = metaObject->propertyOffset();
+ const int propertyCount = metaObject->propertyCount();
+ for (int propertyIndex = propertyOffset, propertyEnd = propertyOffset + propertyCount;
+ propertyIndex < propertyEnd; ++propertyIndex) {
+ const QMetaProperty property = metaObject->property(propertyIndex);
+ if (int revision = property.revision())
+ revisions.append(revision);
+ }
+ const int methodOffset = metaObject->methodOffset();
+ const int methodCount = metaObject->methodCount();
+ for (int methodIndex = methodOffset, methodEnd = methodOffset + methodCount;
+ methodIndex < methodEnd; ++methodIndex) {
+ const QMetaMethod method = metaObject->method(methodIndex);
+ if (int revision = method.revision())
+ revisions.append(revision);
+ }
+
+ // Need to also check parent meta objects, as their revisions are inherited.
+ if (const QMetaObject *superMeta = metaObject->superClass())
+ revisions += availableRevisions(superMeta);
+
+ return revisions;
+}
+
/*
This method is "over generalized" to allow us to (potentially) register more types of things in
the future without adding exported symbols.
*/
int QQmlPrivate::qmlregister(RegistrationType type, void *data)
{
- if (type == AutoParentRegistration) {
+ QQmlType dtype;
+ switch (type) {
+ case AutoParentRegistration:
return QQmlMetaType::registerAutoParentFunction(
*reinterpret_cast<RegisterAutoParent *>(data));
- } else if (type == QmlUnitCacheHookRegistration) {
+ case QmlUnitCacheHookRegistration:
return QQmlMetaType::registerUnitCacheHook(
*reinterpret_cast<RegisterQmlUnitCacheHook *>(data));
+ case TypeAndRevisionsRegistration: {
+ const RegisterTypeAndRevisions &type = *reinterpret_cast<RegisterTypeAndRevisions *>(data);
+ const char *elementName = classElementName(type.classInfoMetaObject);
+ const bool creatable = (elementName != nullptr)
+ && boolClassInfo(type.classInfoMetaObject, "QML.Creatable", true);
+
+ const QString noCreateReason = creatable
+ ? QString()
+ : QString::fromUtf8(classInfo(type.classInfoMetaObject, "QML.UncreatableReason"));
+ RegisterType revisionRegistration = {
+ 1,
+ type.typeId,
+ type.listId,
+ creatable ? type.objectSize : 0,
+ nullptr,
+ noCreateReason,
+ type.uri,
+ type.versionMajor,
+ -1,
+ nullptr,
+ type.metaObject,
+ type.attachedPropertiesFunction,
+ type.attachedPropertiesMetaObject,
+ type.parserStatusCast,
+ type.valueSourceCast,
+ type.valueInterceptorCast,
+ type.extensionObjectCreate,
+ type.extensionMetaObject,
+ nullptr,
+ -1
+ };
+
+ const int added = intClassInfo(type.classInfoMetaObject, "QML.AddedInMinorVersion", 0);
+ const int removed = intClassInfo(type.classInfoMetaObject, "QML.RemovedInMinorVersion", -1);
+
+ auto revisions = availableRevisions(type.metaObject);
+ revisions.append(qMax(added, 0));
+ if (type.attachedPropertiesMetaObject)
+ revisions += availableRevisions(type.attachedPropertiesMetaObject);
+
+ std::sort(revisions.begin(), revisions.end());
+ const auto it = std::unique(revisions.begin(), revisions.end());
+ revisions.erase(it, revisions.end());
+
+ const bool typeWasRemoved = removed >= added;
+ for (int revision : revisions) {
+ if (revision < added)
+ continue;
+
+ // When removed, we still add revisions, but anonymous ones
+ if (typeWasRemoved && revision >= removed) {
+ revisionRegistration.elementName = nullptr;
+ revisionRegistration.create = nullptr;
+ } else {
+ revisionRegistration.elementName = elementName;
+ revisionRegistration.create = creatable ? type.create : nullptr;
+ }
+
+ // Equivalent of qmlRegisterRevision<T, revision>(...)
+ revisionRegistration.versionMinor = revision;
+ revisionRegistration.revision = revision;
+ revisionRegistration.customParser = type.customParserFactory();
+
+ qmlregister(TypeRegistration, &revisionRegistration);
+ }
+ break;
}
+ case SingletonAndRevisionsRegistration: {
+ const RegisterSingletonTypeAndRevisions &type
+ = *reinterpret_cast<RegisterSingletonTypeAndRevisions *>(data);
+ const char *elementName = classElementName(type.classInfoMetaObject);
+ RegisterSingletonType revisionRegistration = {
+ QmlCurrentSingletonTypeRegistrationVersion,
+ type.uri,
+ type.versionMajor,
+ -1,
+ elementName,
- QQmlType dtype;
- if (type == TypeRegistration)
+ type.scriptApi,
+ nullptr,
+ type.instanceMetaObject,
+ type.typeId,
+ -1,
+
+ type.generalizedQobjectApi
+ };
+
+ const int added = intClassInfo(type.classInfoMetaObject, "QML.AddedInMinorVersion", 0);
+ const int removed = intClassInfo(type.classInfoMetaObject, "QML.RemovedInMinorVersion", -1);
+
+ auto revisions = availableRevisions(type.instanceMetaObject);
+ revisions.append(qMax(added, 0));
+
+ std::sort(revisions.begin(), revisions.end());
+ const auto it = std::unique(revisions.begin(), revisions.end());
+ revisions.erase(it, revisions.end());
+
+ const bool typeWasRemoved = removed >= added;
+ for (int revision : qAsConst(revisions)) {
+ if (revision < added)
+ continue;
+
+ // When removed, we still add revisions, but anonymous ones
+ if (typeWasRemoved && revision >= removed) {
+ revisionRegistration.typeName = nullptr;
+ revisionRegistration.scriptApi = nullptr;
+ revisionRegistration.generalizedQobjectApi = nullptr;
+ } else {
+ revisionRegistration.typeName = elementName;
+ revisionRegistration.scriptApi = type.scriptApi;
+ revisionRegistration.generalizedQobjectApi = type.generalizedQobjectApi;
+ }
+
+ // Equivalent of qmlRegisterRevision<T, revision>(...)
+ revisionRegistration.versionMinor = revision;
+ revisionRegistration.revision = revision;
+
+ qmlregister(SingletonRegistration, &revisionRegistration);
+ }
+ break;
+ }
+ case TypeRegistration:
dtype = QQmlMetaType::registerType(*reinterpret_cast<RegisterType *>(data));
- else if (type == InterfaceRegistration)
+ break;
+ case InterfaceRegistration:
dtype = QQmlMetaType::registerInterface(*reinterpret_cast<RegisterInterface *>(data));
- else if (type == SingletonRegistration)
+ break;
+ case SingletonRegistration:
dtype = QQmlMetaType::registerSingletonType(*reinterpret_cast<RegisterSingletonType *>(data));
- else if (type == CompositeRegistration)
+ break;
+ case CompositeRegistration:
dtype = QQmlMetaType::registerCompositeType(*reinterpret_cast<RegisterCompositeType *>(data));
- else if (type == CompositeSingletonRegistration)
+ break;
+ case CompositeSingletonRegistration:
dtype = QQmlMetaType::registerCompositeSingletonType(*reinterpret_cast<RegisterCompositeSingletonType *>(data));
- else
+ break;
+ default:
return -1;
+ }
if (!dtype.isValid())
return -1;
@@ -155,6 +310,14 @@ void QQmlPrivate::qmlunregister(RegistrationType type, quintptr data)
case CompositeSingletonRegistration:
QQmlMetaType::unregisterType(data);
break;
+ case TypeAndRevisionsRegistration:
+ case SingletonAndRevisionsRegistration:
+ // Currently unnecessary. We'd need a special data structure to hold
+ // URI + majorVersion and then we'd iterate the minor versions, look up the
+ // associated QQmlType objects by uri/elementName/major/minor and qmlunregister
+ // each of them.
+ Q_UNREACHABLE();
+ break;
}
}
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index b2bf1f328f..ae3893dd73 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -41,9 +41,6 @@
#define QQML_H
#include <QtQml/qqmlprivate.h>
-#include <QtQml/qqmlparserstatus.h>
-#include <QtQml/qqmlpropertyvaluesource.h>
-#include <QtQml/qqmllist.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qmetaobject.h>
@@ -51,6 +48,12 @@
#define QML_VERSION 0x020000
#define QML_VERSION_STR "2.0"
+#define QML_PRIVATE_NAMESPACE \
+ QT_PREPEND_NAMESPACE(QQmlPrivate)
+
+#define QML_REGISTER_TYPES_AND_REVISIONS \
+ QT_PREPEND_NAMESPACE(qmlRegisterTypesAndRevisions)
+
#define QML_DECLARE_TYPE(TYPE) \
Q_DECLARE_METATYPE(TYPE *) \
Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
@@ -64,6 +67,52 @@
#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \
QML_DECLARE_TYPE_HASMETATYPE(INTERFACE)
+#define QML_ELEMENT \
+ Q_CLASSINFO("QML.Element", "auto")
+
+#define QML_ANONYMOUS \
+ Q_CLASSINFO("QML.Element", "anonymous")
+
+#define QML_NAMED_ELEMENT(NAME) \
+ Q_CLASSINFO("QML.Element", #NAME)
+
+#define QML_UNCREATABLE(REASON) \
+ Q_CLASSINFO("QML.Creatable", "false") \
+ Q_CLASSINFO("QML.UncreatableReason", REASON)
+
+#define QML_SINGLETON \
+ Q_CLASSINFO("QML.Singleton", "true") \
+ enum class QmlIsSingleton {yes = true}; \
+ template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlSingleton; \
+ template<typename T, typename... Args> \
+ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor);
+
+#define QML_ADDED_IN_MINOR_VERSION(VERSION) \
+ Q_CLASSINFO("QML.AddedInMinorVersion", #VERSION)
+
+#define QML_REMOVED_IN_MINOR_VERSION(VERSION) \
+ Q_CLASSINFO("QML.RemovedInMinorVersion", #VERSION)
+
+#define QML_ATTACHED(ATTACHED_TYPE) \
+ Q_CLASSINFO("QML.Attached", #ATTACHED_TYPE) \
+ using QmlAttachedType = ATTACHED_TYPE; \
+ template<class, class, bool> friend struct QML_PRIVATE_NAMESPACE::QmlAttached; \
+ template<class> friend struct QML_PRIVATE_NAMESPACE::QmlAttachedAccessor;
+
+#define QML_EXTENDED(EXTENDED_TYPE) \
+ Q_CLASSINFO("QML.Extended", #EXTENDED_TYPE) \
+ using QmlExtendedType = EXTENDED_TYPE; \
+ template<class, class> friend struct QML_PRIVATE_NAMESPACE::QmlExtended; \
+ template<typename T, typename... Args> \
+ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor);
+
+#define QML_FOREIGN(FOREIGN_TYPE) \
+ Q_CLASSINFO("QML.Foreign", #FOREIGN_TYPE) \
+ using QmlForeignType = FOREIGN_TYPE; \
+ template<class, class> friend struct QML_PRIVATE_NAMESPACE::QmlResolved; \
+ template<typename T, typename... Args> \
+ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor);
+
enum { /* TYPEINFO flags */
QML_HAS_ATTACHED_PROPERTIES = 0x01
};
@@ -82,25 +131,11 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
-
-class QQmlPropertyValueInterceptor;
-
-#define QML_GETTYPENAMES \
- const char *className = T::staticMetaObject.className(); \
- const int nameLen = int(strlen(className)); \
- QVarLengthArray<char,48> pointerName(nameLen+2); \
- memcpy(pointerName.data(), className, size_t(nameLen)); \
- pointerName[nameLen] = '*'; \
- pointerName[nameLen+1] = '\0'; \
- const int listLen = int(strlen("QQmlListProperty<")); \
- QVarLengthArray<char,64> listName(listLen + nameLen + 2); \
- memcpy(listName.data(), "QQmlListProperty<", size_t(listLen)); \
- memcpy(listName.data()+listLen, className, size_t(nameLen)); \
- listName[listLen+nameLen] = '>'; \
- listName[listLen+nameLen+1] = '\0';
-
void Q_QML_EXPORT qmlClearTypeRegistrations();
+template<class T>
+QQmlCustomParser *qmlCreateCustomParser();
+
template<typename T>
int qmlRegisterAnonymousType(const char *uri, int versionMajor)
{
@@ -724,6 +759,44 @@ inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, i
return QQmlPrivate::qmlregister(QQmlPrivate::CompositeRegistration, &type);
}
+template<class T, class Resolved, class Extended, bool Singleton>
+struct QmlTypeAndRevisionsRegistration;
+
+template<class T, class Resolved, class Extended>
+struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, false> {
+ static void registerTypeAndRevisions(const char *uri, int versionMajor)
+ {
+ QQmlPrivate::qmlRegisterTypeAndRevisions<Resolved, Extended>(
+ uri, versionMajor, &T::staticMetaObject);
+ }
+};
+
+template<class T, class Resolved>
+struct QmlTypeAndRevisionsRegistration<T, Resolved, void, true> {
+ static void registerTypeAndRevisions(const char *uri, int versionMajor)
+ {
+ QQmlPrivate::qmlRegisterSingletonAndRevisions<Resolved>(
+ uri, versionMajor, &T::staticMetaObject);
+ }
+};
+
+template<typename T = void, typename... Args>
+void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor);
+
+template<typename T, typename... Args>
+void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor)
+{
+ QmlTypeAndRevisionsRegistration<
+ T, typename QQmlPrivate::QmlResolved<T>::Type,
+ typename QQmlPrivate::QmlExtended<T>::Type,
+ QQmlPrivate::QmlSingleton<T>::Value>
+ ::registerTypeAndRevisions(uri, versionMajor);
+ qmlRegisterTypesAndRevisions<Args...>(uri, versionMajor);
+}
+
+template<>
+inline void qmlRegisterTypesAndRevisions<>(const char *, int) {}
+
int Q_QML_EXPORT qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName);
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 3a437eab8d..2f6aabf61e 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -315,7 +315,7 @@ protected:
break;
default:
if (const QV4::QQmlValueTypeWrapper *vtw = result.as<const QV4::QQmlValueTypeWrapper>()) {
- if (vtw->d()->valueType->metaType.id() == pd->propType()) {
+ if (vtw->d()->valueType()->metaType.id() == pd->propType()) {
return vtw->write(m_target.data(), pd->coreIndex());
}
}
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index b26b90d2aa..f03f90e7f3 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -340,6 +340,16 @@ void QQmlComponentPrivate::fromTypeData(const QQmlRefPointer<QQmlTypeData> &data
}
}
+RequiredProperties &QQmlComponentPrivate::requiredProperties()
+{
+ return state.creator->requiredProperties();
+}
+
+bool QQmlComponentPrivate::hadRequiredProperties() const
+{
+ return state.creator->componentHadRequiredProperties();
+}
+
void QQmlComponentPrivate::clear()
{
if (typeData) {
@@ -364,8 +374,8 @@ QObject *QQmlComponentPrivate::doBeginCreate(QQmlComponent *q, QQmlContext *cont
bool QQmlComponentPrivate::setInitialProperty(QObject *component, const QString& name, const QVariant &value)
{
- QQmlProperty prop(component, name);
- auto privProp = QQmlPropertyPrivate::get(prop);
+ QQmlProperty prop = QQmlComponentPrivate::removePropertyFromRequired(component, name, requiredProperties());
+ QQmlPropertyPrivate *privProp = QQmlPropertyPrivate::get(prop);
if (!prop.isValid() || !privProp->writeValueProperty(value, nullptr)) {
QQmlError error{};
error.setUrl(url);
@@ -809,6 +819,10 @@ QObject *QQmlComponent::create(QQmlContext *context)
QObject *rv = d->doBeginCreate(this, context);
if (rv)
completeCreate();
+ if (rv && !d->requiredProperties().empty()) {
+ delete rv;
+ return nullptr;
+ }
return rv;
}
@@ -829,6 +843,10 @@ QObject *QQmlComponent::createWithInitialProperties(const QVariantMap& initialPr
setInitialProperties(rv, initialProperties);
completeCreate();
}
+ if (!d->requiredProperties().empty()) {
+ d->requiredProperties().clear();
+ return nullptr;
+ }
return rv;
}
@@ -981,6 +999,57 @@ void QQmlComponentPrivate::complete(QQmlEnginePrivate *enginePriv, ConstructionS
}
/*!
+ * \internal
+ * Finds the matching toplevel property with name \a name of the component \a createdComponent.
+ * If it was a required property or an alias to a required property contained in \a
+ * requiredProperties, it is removed from it.
+ *
+ * If wasInRequiredProperties is non-null, the referenced boolean is set to true iff the property
+ * was found in requiredProperties.
+ *
+ * Returns the QQmlProperty with name \a name (which might be invalid if there is no such property),
+ * for further processing (for instance, actually setting the property value).
+ *
+ * Note: This method is used in QQmlComponent and QQmlIncubator to manage required properties. Most
+ * classes which create components should not need it and should only need to call
+ * setInitialProperties.
+ */
+QQmlProperty QQmlComponentPrivate::removePropertyFromRequired(QObject *createdComponent, const QString &name, RequiredProperties &requiredProperties, bool* wasInRequiredProperties)
+{
+ QQmlProperty prop(createdComponent, name);
+ auto privProp = QQmlPropertyPrivate::get(prop);
+ if (prop.isValid()) {
+ // resolve outstanding required properties
+ auto targetProp = &privProp->core;
+ if (targetProp->isAlias()) {
+ auto target = createdComponent;
+ QQmlPropertyIndex originalIndex(targetProp->coreIndex());
+ QQmlPropertyIndex propIndex;
+ QQmlPropertyPrivate::findAliasTarget(target, originalIndex, &target, &propIndex);
+ QQmlData *data = QQmlData::get(target);
+ Q_ASSERT(data && data->propertyCache);
+ targetProp = data->propertyCache->property(propIndex.coreIndex());
+ } else {
+ // we need to get the pointer from the property cache instead of directly using
+ // targetProp else the lookup will fail
+ QQmlData *data = QQmlData::get(createdComponent);
+ Q_ASSERT(data && data->propertyCache);
+ targetProp = data->propertyCache->property(targetProp->coreIndex());
+ }
+ auto it = requiredProperties.find(targetProp);
+ if (it != requiredProperties.end()) {
+ if (wasInRequiredProperties)
+ *wasInRequiredProperties = true;
+ requiredProperties.erase(it);
+ } else {
+ if (wasInRequiredProperties)
+ *wasInRequiredProperties = false;
+ }
+ }
+ return prop;
+}
+
+/*!
This method provides advanced control over component instance creation.
In general, programmers should use QQmlComponent::create() to create a
component.
@@ -999,6 +1068,11 @@ void QQmlComponent::completeCreate()
void QQmlComponentPrivate::completeCreate()
{
+ const RequiredProperties& unsetRequiredProperties = requiredProperties();
+ for (const auto& unsetRequiredProperty: unsetRequiredProperties) {
+ QQmlError error = unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
+ state.errors.push_back(error);
+ }
if (state.completePending) {
++creationDepth.localData();
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
@@ -1186,7 +1260,7 @@ struct QmlIncubatorObject : public QV4::Object
static ReturnedValue method_forceCompletion(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
void statusChanged(QQmlIncubator::Status);
- void setInitialState(QObject *);
+ void setInitialState(QObject *, RequiredProperties &requiredProperties);
};
}
@@ -1211,7 +1285,8 @@ public:
void setInitialState(QObject *o) override {
QV4::Scope scope(incubatorObject.engine());
QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject.as<QV4::QmlIncubatorObject>());
- i->setInitialState(o);
+ auto d = QQmlIncubatorPrivate::get(this);
+ i->setInitialState(o, d->requiredProperties());
}
QV4::PersistentValue incubatorObject; // keep a strong internal reference while incubating
@@ -1283,7 +1358,7 @@ static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
*/
-void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v)
+void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v, RequiredProperties &requiredProperties, QObject *createdComponent)
{
QV4::Scope scope(engine);
QV4::ScopedObject object(scope);
@@ -1302,6 +1377,7 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV
break;
object = o;
const QStringList properties = name->toQString().split(QLatin1Char('.'));
+ bool isTopLevelProperty = properties.size() == 1;
for (int i = 0; i < properties.length() - 1; ++i) {
name = engine->newString(properties.at(i));
object = object->get(name);
@@ -1318,12 +1394,40 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV
if (engine->hasException) {
engine->hasException = false;
continue;
+ } else if (isTopLevelProperty) {
+ auto prop = removePropertyFromRequired(createdComponent, name->toQString(), requiredProperties);
}
}
engine->hasException = false;
}
+QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(const RequiredPropertyInfo &unsetRequiredProperty)
+{
+ QQmlError error;
+ QString description = QLatin1String("Required property %1 was not initialized").arg(unsetRequiredProperty.propertyName);
+ switch (unsetRequiredProperty.aliasesToRequired.size()) {
+ case 0:
+ break;
+ case 1: {
+ const auto info = unsetRequiredProperty.aliasesToRequired.first();
+ description += QLatin1String("\nIt can be set via the alias property %1 from %2\n").arg(info.propertyName, info.fileUrl.toString());
+ break;
+ }
+ default:
+ description += QLatin1String("\nIt can be set via one of the following alias properties:");
+ for (auto aliasInfo: unsetRequiredProperty.aliasesToRequired) {
+ description += QLatin1String("\n- %1 (%2)").arg(aliasInfo.propertyName, aliasInfo.fileUrl.toString());
+ }
+ description += QLatin1Char('\n');
+ }
+ error.setDescription(description);
+ error.setUrl(unsetRequiredProperty.fileUrl);
+ error.setLine(unsetRequiredProperty.location.line);
+ error.setColumn(unsetRequiredProperty.location.column);
+ return error;
+}
+
/*!
\internal
*/
@@ -1371,7 +1475,17 @@ void QQmlComponent::createObject(QQmlV4Function *args)
if (!valuemap->isUndefined()) {
QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->qmlContext());
- QQmlComponentPrivate::setInitialProperties(v4, qmlContext, object, valuemap);
+ QQmlComponentPrivate::setInitialProperties(v4, qmlContext, object, valuemap, d->requiredProperties(), rv);
+ }
+ if (!d->requiredProperties().empty()) {
+ QList<QQmlError> errors;
+ for (const auto &requiredProperty: d->requiredProperties()) {
+ errors.push_back(QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(requiredProperty));
+ }
+ qmlWarning(rv, errors);
+ args->setReturnValue(QV4::Encode::null());
+ delete rv;
+ return;
}
d->completeCreate();
@@ -1503,7 +1617,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
}
// XXX used by QSGLoader
-void QQmlComponentPrivate::initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate)
+void QQmlComponentPrivate::initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate, RequiredProperties &requiredProperties)
{
QV4::ExecutionEngine *v4engine = engine->handle();
QV4::Scope scope(v4engine);
@@ -1512,7 +1626,7 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(QV4::QmlContext
Q_ASSERT(object->as<QV4::Object>());
if (!valuemap.isUndefined())
- setInitialProperties(v4engine, qmlContext, object, valuemap);
+ setInitialProperties(v4engine, qmlContext, object, valuemap, requiredProperties, toCreate);
}
QQmlComponentExtension::QQmlComponentExtension(QV4::ExecutionEngine *v4)
@@ -1602,7 +1716,7 @@ void QV4::Heap::QmlIncubatorObject::destroy() {
Object::destroy();
}
-void QV4::QmlIncubatorObject::setInitialState(QObject *o)
+void QV4::QmlIncubatorObject::setInitialState(QObject *o, RequiredProperties &requiredProperties)
{
QQmlComponent_setQmlParent(o, d()->parent);
@@ -1611,7 +1725,7 @@ void QV4::QmlIncubatorObject::setInitialState(QObject *o)
QV4::Scope scope(v4);
QV4::ScopedObject obj(scope, QV4::QObjectWrapper::wrap(v4, o));
QV4::Scoped<QV4::QmlContext> qmlCtxt(scope, d()->qmlContext);
- QQmlComponentPrivate::setInitialProperties(v4, qmlCtxt, obj, d()->valuemap);
+ QQmlComponentPrivate::setInitialProperties(v4, qmlCtxt, obj, d()->valuemap, requiredProperties, o);
}
}
diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h
index f259c99b08..cb5d5a787c 100644
--- a/src/qml/qml/qqmlcomponent.h
+++ b/src/qml/qml/qqmlcomponent.h
@@ -70,6 +70,9 @@ class Q_QML_EXPORT QQmlComponent : public QObject
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(QUrl url READ url CONSTANT)
+ QML_NAMED_ELEMENT(Component)
+ QML_ATTACHED(QQmlComponentAttached)
+ Q_CLASSINFO("QML.Builtin", "QML")
public:
enum CompilationMode { PreferSynchronous, Asynchronous };
@@ -136,9 +139,29 @@ private:
friend class QQmlObjectCreator;
};
-QT_END_NAMESPACE
+// Don't do this at home.
+namespace QQmlPrivate {
+
+// Generally you cannot use QQmlComponentAttached as attached properties object in derived classes.
+// It is private.
+template<class T>
+struct OverridableAttachedType<T, QQmlComponentAttached>
+{
+ using Type = void;
+};
+
+// QQmlComponent itself is allowed to use QQmlComponentAttached, though.
+template<>
+struct OverridableAttachedType<QQmlComponent, QQmlComponentAttached>
+{
+ using Type = QQmlComponentAttached;
+};
+
+} // namespace QQmlPrivate
+
+
+QT_END_NAMESPACE
QML_DECLARE_TYPE(QQmlComponent)
-QML_DECLARE_TYPEINFO(QQmlComponent, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQMLCOMPONENT_H
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index 2170646b89..a919eb45c0 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -86,8 +86,9 @@ public:
QObject *beginCreate(QQmlContextData *);
void completeCreate();
- void initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate);
- static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v);
+ void initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate, RequiredProperties &requiredProperties);
+ static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v, RequiredProperties &requiredProperties, QObject *createdComponent);
+ static QQmlError unsetRequiredPropertyToQQmlError(const RequiredPropertyInfo &unsetRequiredProperty);
virtual void incubateObject(
QQmlIncubator *incubationTask,
@@ -106,6 +107,8 @@ public:
qreal progress;
int start;
+ RequiredProperties& requiredProperties();
+ bool hadRequiredProperties() const;
QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit;
struct ConstructionState {
@@ -134,6 +137,7 @@ public:
static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState);
static void complete(QQmlEnginePrivate *enginePriv, ConstructionState *state);
+ static QQmlProperty removePropertyFromRequired(QObject *createdComponent, const QString &name, RequiredProperties& requiredProperties, bool *wasInRequiredProperties = nullptr);
QQmlEngine *engine;
QQmlGuardedContextData creationContext;
diff --git a/src/qml/qml/qqmlcomponentattached_p.h b/src/qml/qml/qqmlcomponentattached_p.h
index e3bca18857..8ecd9da17d 100644
--- a/src/qml/qml/qqmlcomponentattached_p.h
+++ b/src/qml/qml/qqmlcomponentattached_p.h
@@ -61,6 +61,11 @@ QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QQmlComponentAttached : public QObject
{
Q_OBJECT
+
+ // Used as attached object for QQmlComponent. We want qqmlcomponentattached_p.h to be #include'd
+ // when registering QQmlComponent, but we cannot #include it from qqmlcomponent.h. Therefore we
+ // force an anonymous type registration here.
+ QML_ANONYMOUS
public:
QQmlComponentAttached(QObject *parent = nullptr);
~QQmlComponentAttached();
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp
index af8deb085c..254b6cc3db 100644
--- a/src/qml/qml/qqmlcontext.cpp
+++ b/src/qml/qml/qqmlcontext.cpp
@@ -550,7 +550,7 @@ QQmlContextData::QQmlContextData()
QQmlContextData::QQmlContextData(QQmlContext *ctxt)
: engine(nullptr), isInternal(false), isJSContext(false),
isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false),
- stronglyReferencedByParent(false), publicContext(ctxt), incubator(nullptr), componentObjectIndex(-1),
+ stronglyReferencedByParent(false), hasExtraObject(false), publicContext(ctxt), incubator(nullptr), componentObjectIndex(-1),
contextObject(nullptr), nextChild(nullptr), prevChild(nullptr),
expressions(nullptr), contextObjects(nullptr), idValues(nullptr), idValueCount(0),
componentAttached(nullptr)
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
index 5f7316b00c..f93393a11b 100644
--- a/src/qml/qml/qqmlcontext_p.h
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -147,11 +147,16 @@ public:
quint32 hasEmittedDestruction:1;
quint32 isRootObjectInCreation:1;
quint32 stronglyReferencedByParent:1;
- quint32 dummy:25;
+ quint32 hasExtraObject:1; // used in QQmlDelegateModelItem::dataForObject to find the corresponding QQmlDelegateModelItem of an object
+ quint32 dummy:24;
QQmlContext *publicContext;
- // The incubator that is constructing this context if any
- QQmlIncubatorPrivate *incubator;
+ union {
+ // The incubator that is constructing this context if any
+ QQmlIncubatorPrivate *incubator;
+ // a pointer to extra data, currently only used in QQmlDelegateModel
+ QObject *extraObject;
+ };
// Compilation unit for contexts that belong to a compiled type.
QQmlRefPointer<QV4::ExecutableCompilationUnit> typeCompilationUnit;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 0fd07ea209..af44d737a2 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -201,33 +201,26 @@ void QQmlEnginePrivate::defineModule()
{
const char uri[] = "QtQml";
- qmlRegisterType<QQmlComponent>(uri, 2, 0, "Component");
- qmlRegisterType<QObject>(uri, 2, 0, "QtObject");
- qmlRegisterType<QQmlBind>(uri, 2, 0, "Binding");
- qmlRegisterType<QQmlBind, 8>(uri, 2, 8, "Binding"); // Only available in >= 2.8
- qmlRegisterType<QQmlBind, 14>(uri, 2, 14, "Binding");
-
- // TODO: We won't need Connections to be a custom type anymore once we can drop the
- // automatic signal handler inference from undeclared properties.
- qmlRegisterCustomType<QQmlConnections>(uri, 2, 0, "Connections", new QQmlConnectionsParser);
- qmlRegisterCustomType<QQmlConnections, 3>(uri, 2, 3, "Connections", new QQmlConnectionsParser); // Only available in QtQml >= 2.3
-
+ qmlRegisterTypesAndRevisions<
+ QObjectForeign,
#if QT_CONFIG(qml_animation)
- qmlRegisterType<QQmlTimer>(uri, 2, 0, "Timer");
+ QQmlTimer,
#endif
-
- qmlRegisterType<QQmlLoggingCategory>(uri, 2, 8, "LoggingCategory"); // Only available in >= 2.8
- qmlRegisterType<QQmlLoggingCategory, 12>(uri, 2, 12, "LoggingCategory"); // Only available in >= 2.12
-
#if QT_CONFIG(qml_locale)
- qmlRegisterUncreatableType<QQmlLocale>(uri, 2, 2, "Locale", QQmlEngine::tr("Locale cannot be instantiated. Use Qt.locale()"));
+ QQmlLocale,
#endif
+ QQmlComponent,
+ QQmlBind,
+ QQmlConnections,
+ QQmlLoggingCategory
+ >(uri, 2);
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void QQmlEnginePrivate::registerQuickTypes()
{
// Don't add anything here. These are only for backwards compatibility.
+ // Also, don't use qmlRegisterTypesAndRevisions as that will auto-add future revisions.
const char uri[] = "QtQuick";
@@ -236,13 +229,17 @@ void QQmlEnginePrivate::registerQuickTypes()
qmlRegisterType<QQmlBind>(uri, 2, 0, "Binding");
qmlRegisterType<QQmlBind, 8>(uri, 2, 8, "Binding");
qmlRegisterCustomType<QQmlConnections>(uri, 2, 0, "Connections", new QQmlConnectionsParser);
+
+ // Connections revision 3 was added in QtQml 2.3, but only in QtQuick 2.7.
qmlRegisterCustomType<QQmlConnections, 3>(uri, 2, 7, "Connections", new QQmlConnectionsParser);
+
#if QT_CONFIG(qml_animation)
qmlRegisterType<QQmlTimer>(uri, 2, 0,"Timer");
#endif
qmlRegisterType<QQmlLoggingCategory>(uri, 2, 8, "LoggingCategory");
qmlRegisterType<QQmlLoggingCategory, 12>(uri, 2, 12, "LoggingCategory");
#if QT_CONFIG(qml_locale)
+ // Locale was added in QtQuick 2.0 and in QtQml 2.2
qmlRegisterUncreatableType<QQmlLocale>(uri, 2, 0, "Locale", QQmlEngine::tr("Locale cannot be instantiated. Use Qt.locale()"));
#endif
}
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 385ae02ce5..5b1b676c89 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -101,6 +101,13 @@ class QQmlProfiler;
class QQmlPropertyCapture;
class QQmlMetaObject;
+struct QObjectForeign {
+ Q_GADGET
+ QML_FOREIGN(QObject)
+ QML_NAMED_ELEMENT(QtObject)
+ Q_CLASSINFO("QML.Root", "QML")
+};
+
// This needs to be declared here so that the pool for it can live in QQmlEnginePrivate.
// The inline method definitions are in qqmljavascriptexpression_p.h
class QQmlJavaScriptExpressionGuard : public QQmlNotifierEndpoint
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index bc06226cbf..f0ef5360b0 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -43,6 +43,7 @@
#include "qqmlexpression_p.h"
#include "qqmlobjectcreator_p.h"
+#include <private/qqmlcomponent_p.h>
void QQmlEnginePrivate::incubate(QQmlIncubator &i, QQmlContextData *forContext)
{
@@ -60,7 +61,7 @@ void QQmlEnginePrivate::incubate(QQmlIncubator &i, QQmlContextData *forContext)
QExplicitlySharedDataPointer<QQmlIncubatorPrivate> parentIncubator;
QQmlContextData *cctxt = forContext;
while (cctxt) {
- if (cctxt->incubator) {
+ if (!cctxt->hasExtraObject && cctxt->incubator) {
parentIncubator = cctxt->incubator;
break;
}
@@ -148,7 +149,8 @@ void QQmlIncubatorPrivate::clear()
}
enginePriv = nullptr;
if (!rootContext.isNull()) {
- rootContext->incubator = nullptr;
+ if (!rootContext->hasExtraObject)
+ rootContext->incubator = nullptr;
rootContext = nullptr;
}
@@ -296,6 +298,20 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i)
tresult = creator->create(subComponentToCreate, /*parent*/nullptr, &i);
if (!tresult)
errors = creator->errors;
+ else {
+ RequiredProperties& requiredProperties = creator->requiredProperties();
+ for (auto it = initialProperties.cbegin(); it != initialProperties.cend(); ++it) {
+ auto component = tresult;
+ auto name = it.key();
+ QQmlProperty prop = QQmlComponentPrivate::removePropertyFromRequired(component, name, requiredProperties);
+ if (!prop.isValid() || !prop.write(it.value())) {
+ QQmlError error{};
+ error.setUrl(compilationUnit->url());
+ error.setDescription(QLatin1String("Could not set property %1").arg(name));
+ errors.push_back(error);
+ }
+ }
+ }
enginePriv->dereferenceScarceResources();
if (watcher.hasRecursed())
@@ -312,8 +328,14 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i)
ddata->indestructible = true;
ddata->explicitIndestructibleSet = true;
ddata->rootObjectInCreation = false;
- if (q)
+ if (q) {
q->setInitialState(result);
+ if (!creator->requiredProperties().empty()) {
+ const auto& unsetRequiredProperties = creator->requiredProperties();
+ for (const auto& unsetRequiredProperty: unsetRequiredProperties)
+ errors << QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
+ }
+ }
}
if (watcher.hasRecursed())
@@ -657,6 +679,36 @@ QObject *QQmlIncubator::object() const
}
/*!
+Return a list of properties which are required but haven't been set yet.
+This list can be modified, so that subclasses which implement special logic
+setInitialProperties can mark properties set there as no longer required.
+
+\sa QQmlIncubator::setInitialProperties
+\since 5.15
+*/
+RequiredProperties &QQmlIncubatorPrivate::requiredProperties()
+{
+ return creator->requiredProperties();
+}
+
+bool QQmlIncubatorPrivate::hadRequiredProperties() const
+{
+ return creator->componentHadRequiredProperties();
+}
+
+/*!
+Stores a mapping from property names to initial values with which the incubated
+component will be initialized
+
+\sa QQmlComponent::setInitialProperties
+\since 5.15
+*/
+void QQmlIncubator::setInitialProperties(const QVariantMap &initialProperties)
+{
+ d->initialProperties = initialProperties;
+}
+
+/*!
Called when the status of the incubator changes. \a status is the new status.
The default implementation does nothing.
diff --git a/src/qml/qml/qqmlincubator.h b/src/qml/qml/qqmlincubator.h
index e68f6e3c45..f075407e73 100644
--- a/src/qml/qml/qqmlincubator.h
+++ b/src/qml/qml/qqmlincubator.h
@@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE
class QQmlEngine;
+class QQmlPropertyData;
+class QVariant;
+using QVariantMap = QMap<QString, QVariant>;
class QQmlIncubatorPrivate;
class Q_QML_EXPORT QQmlIncubator
@@ -84,6 +87,8 @@ public:
QObject *object() const;
+ void setInitialProperties(const QVariantMap &initialProperties);
+
protected:
virtual void statusChanged(Status);
virtual void setInitialState(QObject *);
diff --git a/src/qml/qml/qqmlincubator_p.h b/src/qml/qml/qqmlincubator_p.h
index 57ec8249cb..aadb147bd5 100644
--- a/src/qml/qml/qqmlincubator_p.h
+++ b/src/qml/qml/qqmlincubator_p.h
@@ -61,8 +61,12 @@
QT_BEGIN_NAMESPACE
+class QQmlPropertyData;
+struct RequiredPropertyInfo;
+using RequiredProperties = QHash<QQmlPropertyData*, RequiredPropertyInfo>;
+
class QQmlIncubator;
-class QQmlIncubatorPrivate : public QQmlEnginePrivate::Incubator
+class Q_QML_PRIVATE_EXPORT QQmlIncubatorPrivate : public QQmlEnginePrivate::Incubator
{
public:
QQmlIncubatorPrivate(QQmlIncubator *q, QQmlIncubator::IncubationMode m);
@@ -97,11 +101,14 @@ public:
QIntrusiveList<QIPBase, &QIPBase::nextWaitingFor> waitingFor;
QRecursionNode recursion;
+ QVariantMap initialProperties;
void clear();
void forceCompletion(QQmlInstantiationInterrupt &i);
void incubate(QQmlInstantiationInterrupt &i);
+ RequiredProperties &requiredProperties();
+ bool hadRequiredProperties() const;
};
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 859c36e11b..10e0dfcc38 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -94,6 +94,9 @@ private:
class Q_QML_PRIVATE_EXPORT QQmlLocale
{
Q_GADGET
+ QML_NAMED_ELEMENT(Locale)
+ QML_UNCREATABLE("Locale cannot be instantiated. Use Qt.locale().")
+ QML_ADDED_IN_MINOR_VERSION(2)
public:
~QQmlLocale();
diff --git a/src/qml/qml/qqmlloggingcategory_p.h b/src/qml/qml/qqmlloggingcategory_p.h
index ee5d9af2e7..c7377528b4 100644
--- a/src/qml/qml/qqmlloggingcategory_p.h
+++ b/src/qml/qml/qqmlloggingcategory_p.h
@@ -56,6 +56,7 @@
#include <QtCore/qloggingcategory.h>
#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -66,6 +67,8 @@ class QQmlLoggingCategory : public QObject, public QQmlParserStatus
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(DefaultLogLevel defaultLogLevel READ defaultLogLevel WRITE setDefaultLogLevel REVISION 12)
+ QML_NAMED_ELEMENT(LoggingCategory)
+ QML_ADDED_IN_MINOR_VERSION(8)
public:
enum DefaultLogLevel {
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index c2674b402a..268d58a856 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -154,7 +154,7 @@ static QQmlTypePrivate *createQQmlType(QQmlMetaTypeData *data, const QString &el
d->extraData.cd->propertyValueSourceCast = type.valueSourceCast;
d->extraData.cd->propertyValueInterceptorCast = type.valueInterceptorCast;
d->extraData.cd->extFunc = type.extensionObjectCreate;
- d->extraData.cd->customParser = type.customParser;
+ d->extraData.cd->customParser = reinterpret_cast<QQmlCustomParser *>(type.customParser);
d->extraData.cd->registerEnumClassesUnscoped = true;
if (type.extensionMetaObject)
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index a4270628e8..cf1795aafa 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -93,6 +93,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, const QQmlR
sharedState->allJavaScriptObjects = nullptr;
sharedState->creationContext = creationContext;
sharedState->rootContext = nullptr;
+ sharedState->hadRequiredProperties = false;
if (auto profiler = QQmlEnginePrivate::get(engine)->profiler) {
Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler,
@@ -785,6 +786,23 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings)
const QV4::CompiledData::Binding *binding = _compiledObject->bindingTable();
for (quint32 i = 0; i < _compiledObject->nBindings; ++i, ++binding) {
+ QQmlPropertyData *const property = propertyData.at(i);
+ if (property) {
+ QQmlPropertyData* targetProperty = property;
+ if (targetProperty->isAlias()) {
+ // follow alias
+ auto target = _bindingTarget;
+ QQmlPropertyIndex originalIndex(targetProperty->coreIndex(), _valueTypeProperty ? _valueTypeProperty->coreIndex() : -1);
+ QQmlPropertyIndex propIndex;
+ QQmlPropertyPrivate::findAliasTarget(target, originalIndex, &target, &propIndex);
+ QQmlData *data = QQmlData::get(target);
+ Q_ASSERT(data && data->propertyCache);
+ targetProperty = data->propertyCache->property(propIndex.coreIndex());
+ }
+ sharedState->requiredProperties.remove(targetProperty);
+ }
+
+
if (binding->flags & QV4::CompiledData::Binding::IsCustomParserBinding)
continue;
@@ -796,8 +814,6 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings)
continue;
}
- const QQmlPropertyData *property = propertyData.at(i);
-
if (property && property->isQList()) {
if (property->coreIndex() != currentListPropertyIndex) {
void *argv[1] = { (void*)&_currentList };
@@ -1506,10 +1522,43 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject *
if (_compiledObject->flags & QV4::CompiledData::Object::HasDeferredBindings)
_ddata->deferData(_compiledObjectIndex, compilationUnit, context);
+ for (int propertyIndex = 0; propertyIndex != _compiledObject->propertyCount(); ++propertyIndex) {
+ const QV4::CompiledData::Property* property = _compiledObject->propertiesBegin() + propertyIndex;
+ QQmlPropertyData *propertyData = _propertyCache->property(_propertyCache->propertyOffset() + propertyIndex);
+ if (property->isRequired) {
+ sharedState->hadRequiredProperties = true;
+ sharedState->requiredProperties.insert(propertyData,
+ RequiredPropertyInfo {compilationUnit->stringAt(property->nameIndex), compilationUnit->finalUrl(), property->location, {}});
+ }
+ }
+
if (_compiledObject->nFunctions > 0)
setupFunctions();
setupBindings();
+ for (int aliasIndex = 0; aliasIndex != _compiledObject->aliasCount(); ++aliasIndex) {
+ const QV4::CompiledData::Alias* alias = _compiledObject->aliasesBegin() + aliasIndex;
+ const auto originalAlias = alias;
+ while (alias->aliasToLocalAlias)
+ alias = _compiledObject->aliasesBegin() + alias->localAliasIndex;
+ Q_ASSERT(alias->flags & QV4::CompiledData::Alias::Resolved);
+ if (!context->idValues->wasSet())
+ continue;
+ QObject *target = context->idValues[alias->targetObjectId].data();
+ if (!target)
+ continue;
+ QQmlData *targetDData = QQmlData::get(target, /*create*/false);
+ if (!targetDData)
+ continue;
+ int coreIndex = QQmlPropertyIndex::fromEncoded(alias->encodedMetaPropertyIndex).coreIndex();
+ QQmlPropertyData *const targetProperty = targetDData->propertyCache->property(coreIndex);
+ if (!targetProperty)
+ continue;
+ auto it = sharedState->requiredProperties.find(targetProperty);
+ if (it != sharedState->requiredProperties.end())
+ it->aliasesToRequired.push_back(AliasToRequiredInfo {compilationUnit->stringAt(originalAlias->nameIndex), compilationUnit->finalUrl()});
+ }
+
qSwap(_vmeMetaObject, vmeMetaObject);
qSwap(_bindingTarget, bindingTarget);
qSwap(_ddata, declarativeData);
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index ecdbcc56dd..59e236c855 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -66,6 +66,28 @@ class QQmlAbstractBinding;
class QQmlInstantiationInterrupt;
class QQmlIncubatorPrivate;
+struct AliasToRequiredInfo {
+ QString propertyName;
+ QUrl fileUrl;
+};
+
+/*!
+\internal
+This struct contains information solely used for displaying error messages
+\variable aliasesToRequired allows us to give the user a way to know which (aliasing) properties
+can be set to set the required property
+\sa QQmlComponentPrivate::unsetRequiredPropertyToQQmlError
+*/
+struct RequiredPropertyInfo
+{
+ QString propertyName;
+ QUrl fileUrl;
+ QV4::CompiledData::Location location;
+ QVector<AliasToRequiredInfo> aliasesToRequired;
+};
+
+using RequiredProperties = QHash<QQmlPropertyData*, RequiredPropertyInfo>;
+
struct QQmlObjectCreatorSharedState : public QSharedData
{
QQmlContextData *rootContext;
@@ -78,6 +100,8 @@ struct QQmlObjectCreatorSharedState : public QSharedData
QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks;
QQmlVmeProfiler profiler;
QRecursionNode recursionNode;
+ RequiredProperties requiredProperties;
+ bool hadRequiredProperties;
};
class Q_QML_PRIVATE_EXPORT QQmlObjectCreator
@@ -102,6 +126,9 @@ public:
QQmlContextData *parentContextData() const { return parentContext.contextData(); }
QFiniteStack<QPointer<QObject> > &allCreatedObjects() { return sharedState->allCreatedObjects; }
+ RequiredProperties &requiredProperties() {return sharedState->requiredProperties;}
+ bool componentHadRequiredProperties() const {return sharedState->hadRequiredProperties;}
+
private:
QQmlObjectCreator(QQmlContextData *contextData, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, QQmlObjectCreatorSharedState *inheritedSharedState);
diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h
index bfd3611fb8..27dac71571 100644
--- a/src/qml/qml/qqmlprivate.h
+++ b/src/qml/qml/qqmlprivate.h
@@ -52,18 +52,43 @@
//
#include <functional>
+#include <type_traits>
#include <QtQml/qtqmlglobal.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqmllist.h>
+#include <QtQml/qqmlpropertyvaluesource.h>
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
#include <QtCore/qurl.h>
#include <QPointer>
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qdebug.h>
+
+#define QML_GETTYPENAMES \
+ const char *className = T::staticMetaObject.className(); \
+ const int nameLen = int(strlen(className)); \
+ QVarLengthArray<char,48> pointerName(nameLen+2); \
+ memcpy(pointerName.data(), className, size_t(nameLen)); \
+ pointerName[nameLen] = '*'; \
+ pointerName[nameLen+1] = '\0'; \
+ const int listLen = int(strlen("QQmlListProperty<")); \
+ QVarLengthArray<char,64> listName(listLen + nameLen + 2); \
+ memcpy(listName.data(), "QQmlListProperty<", size_t(listLen)); \
+ memcpy(listName.data()+listLen, className, size_t(nameLen)); \
+ listName[listLen+nameLen] = '>'; \
+ listName[listLen+nameLen+1] = '\0';
+
QT_BEGIN_NAMESPACE
+class QQmlPropertyValueInterceptor;
+
namespace QQmlPrivate {
struct CachedQmlUnit;
+template<typename A>
+using QQmlAttachedPropertiesFunc = A *(*)(QObject *);
}
namespace QV4 {
@@ -78,7 +103,7 @@ struct Document;
typedef void (*IRLoaderFunction)(Document *, const QQmlPrivate::CachedQmlUnit *);
}
-typedef QObject *(*QQmlAttachedPropertiesFunc)(QObject *);
+using QQmlAttachedPropertiesFunc = QQmlPrivate::QQmlAttachedPropertiesFunc<QObject>;
inline uint qHash(QQmlAttachedPropertiesFunc func, uint seed = 0)
{
@@ -99,6 +124,13 @@ class QJSValue;
class QJSEngine;
class QQmlEngine;
class QQmlCustomParser;
+
+template<class T>
+QQmlCustomParser *qmlCreateCustomParser()
+{
+ return nullptr;
+}
+
namespace QQmlPrivate
{
void Q_QML_EXPORT qdeclarativeelement_destructor(QObject *);
@@ -124,11 +156,62 @@ namespace QQmlPrivate
};
template<typename T>
+ constexpr bool isConstructible()
+ {
+ return std::is_default_constructible<T>::value && std::is_base_of<QObject, T>::value;
+ }
+
+ template<typename T>
void createInto(void *memory) { new (memory) QQmlElement<T>; }
template<typename T>
+ QObject *createSingletonInstance(QQmlEngine *, QJSEngine *) { return new T; }
+
+ template<typename T>
QObject *createParent(QObject *p) { return new T(p); }
+ using CreateIntoFunction = void (*)(void *);
+ using CreateSingletonFunction = QObject *(*)(QQmlEngine *, QJSEngine *);
+ using CreateParentFunction = QObject *(*)(QObject *);
+
+ template<typename T, bool Constructible = isConstructible<T>()>
+ struct Constructors;
+
+ template<typename T>
+ struct Constructors<T, true>
+ {
+ static constexpr CreateIntoFunction createInto
+ = QQmlPrivate::createInto<T>;
+ static constexpr CreateSingletonFunction createSingletonInstance
+ = QQmlPrivate::createSingletonInstance<T>;
+ };
+
+ template<typename T>
+ struct Constructors<T, false>
+ {
+ static constexpr CreateIntoFunction createInto = nullptr;
+ static constexpr CreateSingletonFunction createSingletonInstance = nullptr;
+ };
+
+ template<typename T, bool IsVoid = std::is_void<T>::value>
+ struct ExtendedType;
+
+ // void means "not an extended type"
+ template<typename T>
+ struct ExtendedType<T, true>
+ {
+ static constexpr const CreateParentFunction createParent = nullptr;
+ static constexpr const QMetaObject *staticMetaObject = nullptr;
+ };
+
+ // If it's not void, we actually want an error if the ctor or the metaobject is missing.
+ template<typename T>
+ struct ExtendedType<T, false>
+ {
+ static constexpr const CreateParentFunction createParent = QQmlPrivate::createParent<T>;
+ static constexpr const QMetaObject *staticMetaObject = &T::staticMetaObject;
+ };
+
template<class From, class To, int N>
struct StaticCastSelectorClass
{
@@ -156,66 +239,103 @@ namespace QQmlPrivate
}
};
- template <typename T>
- struct has_attachedPropertiesMember
+ template<typename...>
+ using QmlVoidT = void;
+
+ // You can prevent subclasses from using the same attached type by specialzing this.
+ // This is reserved for internal types, though.
+ template<class T, class A>
+ struct OverridableAttachedType
{
- static bool const value = QQmlTypeInfo<T>::hasAttachedProperties;
+ using Type = A;
};
- template <typename T, bool hasMember>
- class has_attachedPropertiesMethod
+ template<class T, class = QmlVoidT<>, bool OldStyle = QQmlTypeInfo<T>::hasAttachedProperties>
+ struct QmlAttached
{
- public:
- typedef int yes_type;
- typedef char no_type;
-
- template<typename ReturnType>
- static yes_type checkType(ReturnType *(*)(QObject *));
- static no_type checkType(...);
-
- static bool const value = sizeof(checkType(&T::qmlAttachedProperties)) == sizeof(yes_type);
+ using Type = void;
+ using Func = QQmlAttachedPropertiesFunc<QObject>;
+ static const QMetaObject *staticMetaObject() { return nullptr; }
+ static Func attachedPropertiesFunc() { return nullptr; }
};
- template <typename T>
- class has_attachedPropertiesMethod<T, false>
+ // Defined inline via QML_ATTACHED
+ template<class T>
+ struct QmlAttached<T, QmlVoidT<typename OverridableAttachedType<T, typename T::QmlAttachedType>::Type>, false>
{
- public:
- static bool const value = false;
+ // Normal attached properties
+ template <typename Parent, typename Attached>
+ struct Properties
+ {
+ using Func = QQmlAttachedPropertiesFunc<Attached>;
+ static const QMetaObject *staticMetaObject() { return &Attached::staticMetaObject; }
+ static Func attachedPropertiesFunc() { return Parent::qmlAttachedProperties; }
+ };
+
+ // Disabled via OverridableAttachedType
+ template<typename Parent>
+ struct Properties<Parent, void>
+ {
+ using Func = QQmlAttachedPropertiesFunc<QObject>;
+ static const QMetaObject *staticMetaObject() { return nullptr; };
+ static Func attachedPropertiesFunc() { return nullptr; };
+ };
+
+ using Type = typename OverridableAttachedType<T, typename T::QmlAttachedType>::Type;
+ using Func = typename Properties<T, Type>::Func;
+
+ static const QMetaObject *staticMetaObject()
+ {
+ return Properties<T, Type>::staticMetaObject();
+ }
+
+ static Func attachedPropertiesFunc()
+ {
+ return Properties<T, Type>::attachedPropertiesFunc();
+ }
};
- template<typename T, int N>
- class AttachedPropertySelector
+ // Separately defined via QQmlTypeInfo
+ template<class T>
+ struct QmlAttached<T, QmlVoidT<decltype(T::qmlAttachedProperties)>, true>
{
- public:
- static inline QQmlAttachedPropertiesFunc func() { return nullptr; }
- static inline const QMetaObject *metaObject() { return nullptr; }
+ using Type = typename std::remove_pointer<decltype(T::qmlAttachedProperties(nullptr))>::type;
+ using Func = QQmlAttachedPropertiesFunc<Type>;
+
+ static const QMetaObject *staticMetaObject() { return &Type::staticMetaObject; }
+ static Func attachedPropertiesFunc() { return T::qmlAttachedProperties; }
};
- template<typename T>
- class AttachedPropertySelector<T, 1>
+
+ // This is necessary because both the type containing a default template parameter and the type
+ // instantiating the template need to have access to the default template parameter type. In
+ // this case that's T::QmlAttachedType. The QML_FOREIGN macro needs to befriend specific other
+ // types. Therefore we need some kind of "accessor". Because of compiler bugs in gcc and clang,
+ // we cannot befriend attachedPropertiesFunc() directly. Wrapping the actual access into another
+ // struct "fixes" that. For convenience we still want the free standing functions in addition.
+ template<class T>
+ struct QmlAttachedAccessor
{
- template<typename ReturnType>
- static inline const QMetaObject *attachedPropertiesMetaObject(ReturnType *(*)(QObject *)) {
- return &ReturnType::staticMetaObject;
- }
- public:
- static inline QQmlAttachedPropertiesFunc func() {
- return QQmlAttachedPropertiesFunc(&T::qmlAttachedProperties);
+ static QQmlAttachedPropertiesFunc<QObject> attachedPropertiesFunc()
+ {
+ return QQmlAttachedPropertiesFunc<QObject>(QmlAttached<T>::attachedPropertiesFunc());
}
- static inline const QMetaObject *metaObject() {
- return attachedPropertiesMetaObject(&T::qmlAttachedProperties);
+
+ static const QMetaObject *staticMetaObject()
+ {
+ return QmlAttached<T>::staticMetaObject();
}
};
template<typename T>
- inline QQmlAttachedPropertiesFunc attachedPropertiesFunc()
+ inline QQmlAttachedPropertiesFunc<QObject> attachedPropertiesFunc()
{
- return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::func();
+ return QmlAttachedAccessor<T>::attachedPropertiesFunc();
}
template<typename T>
inline const QMetaObject *attachedPropertiesMetaObject()
{
- return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::metaObject();
+ return QmlAttachedAccessor<T>::staticMetaObject();
}
enum AutoParentResult { Parented, IncompatibleObject, IncompatibleParent };
@@ -236,7 +356,7 @@ namespace QQmlPrivate
const char *elementName;
const QMetaObject *metaObject;
- QQmlAttachedPropertiesFunc attachedPropertiesFunction;
+ QQmlAttachedPropertiesFunc<QObject> attachedPropertiesFunction;
const QMetaObject *attachedPropertiesMetaObject;
int parserStatusCast;
@@ -247,10 +367,38 @@ namespace QQmlPrivate
const QMetaObject *extensionMetaObject;
QQmlCustomParser *customParser;
+
int revision;
// If this is extended ensure "version" is bumped!!!
};
+ struct RegisterTypeAndRevisions {
+ int version;
+
+ int typeId;
+ int listId;
+ int objectSize;
+ void (*create)(void *);
+
+ const char *uri;
+ int versionMajor;
+
+ const QMetaObject *metaObject;
+ const QMetaObject *classInfoMetaObject;
+
+ QQmlAttachedPropertiesFunc<QObject> attachedPropertiesFunction;
+ const QMetaObject *attachedPropertiesMetaObject;
+
+ int parserStatusCast;
+ int valueSourceCast;
+ int valueInterceptorCast;
+
+ QObject *(*extensionObjectCreate)(QObject *);
+ const QMetaObject *extensionMetaObject;
+
+ QQmlCustomParser *(*customParserFactory)();
+ };
+
struct RegisterInterface {
int version;
@@ -283,6 +431,19 @@ namespace QQmlPrivate
// If this is extended ensure "version" is bumped!!!
};
+ struct RegisterSingletonTypeAndRevisions {
+ int version;
+ const char *uri;
+ int versionMajor;
+
+ QJSValue (*scriptApi)(QQmlEngine *, QJSEngine *);
+ const QMetaObject *instanceMetaObject;
+ const QMetaObject *classInfoMetaObject;
+
+ int typeId;
+ std::function<QObject*(QQmlEngine *, QJSEngine *)> generalizedQobjectApi; // new in version 3
+ };
+
struct RegisterCompositeType {
QUrl url;
const char *uri;
@@ -318,7 +479,9 @@ namespace QQmlPrivate
SingletonRegistration = 3,
CompositeRegistration = 4,
CompositeSingletonRegistration = 5,
- QmlUnitCacheHookRegistration = 6
+ QmlUnitCacheHookRegistration = 6,
+ TypeAndRevisionsRegistration = 7,
+ SingletonAndRevisionsRegistration = 8
};
int Q_QML_EXPORT qmlregister(RegistrationType, void *);
@@ -330,7 +493,151 @@ namespace QQmlPrivate
QPointer<QObject> m_object;
bool alreadyCalled = false;
};
-}
+
+ static int indexOfOwnClassInfo(const QMetaObject *metaObject, const char *key)
+ {
+ if (!metaObject || !key)
+ return -1;
+
+ const int offset = metaObject->classInfoOffset();
+ for (int i = metaObject->classInfoCount() + offset - 1; i >= offset; --i)
+ if (qstrcmp(key, metaObject->classInfo(i).name()) == 0) {
+ return i;
+ }
+ return -1;
+ }
+
+ inline const char *classInfo(const QMetaObject *metaObject, const char *key)
+ {
+ return metaObject->classInfo(indexOfOwnClassInfo(metaObject, key)).value();
+ }
+
+ inline int intClassInfo(const QMetaObject *metaObject, const char *key, int defaultValue = 0)
+ {
+ const int index = indexOfOwnClassInfo(metaObject, key);
+ return (index == -1) ? defaultValue
+ : QByteArray(metaObject->classInfo(index).value()).toInt();
+ }
+
+ inline bool boolClassInfo(const QMetaObject *metaObject, const char *key,
+ bool defaultValue = false)
+ {
+ const int index = indexOfOwnClassInfo(metaObject, key);
+ return (index == -1) ? defaultValue
+ : (QByteArray(metaObject->classInfo(index).value()) == "true");
+ }
+
+ inline const char *classElementName(const QMetaObject *metaObject)
+ {
+ const char *elementName = classInfo(metaObject, "QML.Element");
+ if (qstrcmp(elementName, "auto") == 0)
+ return metaObject->className();
+ if (qstrcmp(elementName, "anonymous") == 0)
+ return nullptr;
+
+ if (!elementName || elementName[0] < 'A' || elementName[0] > 'Z') {
+ qWarning() << "Missing or unusable QML.Element class info \"" << elementName << "\""
+ << "for" << metaObject->className();
+ }
+
+ return elementName;
+ }
+
+ template<class T, class = QmlVoidT<>>
+ struct QmlExtended
+ {
+ using Type = void;
+ };
+
+ template<class T>
+ struct QmlExtended<T, QmlVoidT<typename T::QmlExtendedType>>
+ {
+ using Type = typename T::QmlExtendedType;
+ };
+
+ template<class T, class = QmlVoidT<>>
+ struct QmlResolved
+ {
+ using Type = T;
+ };
+
+ template<class T>
+ struct QmlResolved<T, QmlVoidT<typename T::QmlForeignType>>
+ {
+ using Type = typename T::QmlForeignType;
+ };
+
+ template<class T, class = QmlVoidT<>>
+ struct QmlSingleton
+ {
+ static constexpr bool Value = false;
+ };
+
+ template<class T>
+ struct QmlSingleton<T, QmlVoidT<typename T::QmlIsSingleton>>
+ {
+ static constexpr bool Value = bool(T::QmlIsSingleton::yes);
+ };
+
+ template<typename T>
+ void qmlRegisterSingletonAndRevisions(const char *uri, int versionMajor,
+ const QMetaObject *classInfoMetaObject)
+ {
+ QML_GETTYPENAMES
+
+ RegisterSingletonTypeAndRevisions api = {
+ 0,
+
+ uri,
+ versionMajor,
+
+ nullptr,
+
+ &T::staticMetaObject,
+ classInfoMetaObject,
+
+ qRegisterNormalizedMetaType<T *>(pointerName.constData()),
+ Constructors<T>::createSingletonInstance
+ };
+
+ qmlregister(SingletonAndRevisionsRegistration, &api);
+ }
+
+ template<typename T, typename E>
+ void qmlRegisterTypeAndRevisions(const char *uri, int versionMajor,
+ const QMetaObject *classInfoMetaObject)
+ {
+ QML_GETTYPENAMES
+
+ RegisterTypeAndRevisions type = {
+ 0,
+ qRegisterNormalizedMetaType<T *>(pointerName.constData()),
+ qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ int(sizeof(T)),
+ Constructors<T>::createInto,
+
+ uri,
+ versionMajor,
+
+ &T::staticMetaObject,
+ classInfoMetaObject,
+
+ attachedPropertiesFunc<T>(),
+ attachedPropertiesMetaObject<T>(),
+
+ StaticCastSelector<T, QQmlParserStatus>::cast(),
+ StaticCastSelector<T, QQmlPropertyValueSource>::cast(),
+ StaticCastSelector<T, QQmlPropertyValueInterceptor>::cast(),
+
+ ExtendedType<E>::createParent,
+ ExtendedType<E>::staticMetaObject,
+
+ &qmlCreateCustomParser<T>
+ };
+
+ qmlregister(TypeAndRevisionsRegistration, &type);
+ }
+} // namespace QQmlPrivate
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 5f57e0eca1..eff3e94fbd 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -885,7 +885,7 @@ void QQmlPropertyPrivate::setBinding(QQmlAbstractBinding *binding, BindingFlags
QQmlData *data = QQmlData::get(object, true);
if (data->propertyCache) {
QQmlPropertyData *propertyData = data->propertyCache->property(coreIndex);
- Q_ASSERT(propertyData && !propertyData->isAlias());
+ Q_ASSERT(propertyData);
}
#endif
diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp
index 6959b05105..d7361ea2c6 100644
--- a/src/qml/qml/qqmlpropertyvalidator.cpp
+++ b/src/qml/qml/qqmlpropertyvalidator.cpp
@@ -727,7 +727,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateObjectBinding(QQmlPrope
} else if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject && property->isFunction()) {
return noError;
} else if (isPrimitiveType(propType)) {
- auto typeName = QMetaType::typeName(propType);
+ auto typeName = QString::fromUtf8(QMetaType::typeName(propType));
return qQmlCompileError(binding->location, tr("Can not assign value of type \"%1\" to property \"%2\", expecting \"%3\"")
.arg(rhsType())
.arg(propertyName)
diff --git a/src/qml/qml/qqmltypenotavailable_p.h b/src/qml/qml/qqmltypenotavailable_p.h
index 33630bf507..8db5876b10 100644
--- a/src/qml/qml/qqmltypenotavailable_p.h
+++ b/src/qml/qml/qqmltypenotavailable_p.h
@@ -58,6 +58,9 @@ QT_BEGIN_NAMESPACE
class QQmlTypeNotAvailable : public QObject {
Q_OBJECT
+ QML_NAMED_ELEMENT(TypeNotAvailable)
+ QML_UNCREATABLE("Type not available.")
+
public:
QQmlTypeNotAvailable();
};
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index cf53b8cb4a..9c008859da 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -215,6 +215,8 @@ struct QQmlEasingValueType
{
QEasingCurve v;
Q_GADGET
+ QML_NAMED_ELEMENT(Easing)
+ QML_UNCREATABLE("Use the Type enum.")
Q_PROPERTY(QQmlEasingValueType::Type type READ type WRITE setType FINAL)
Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude FINAL)
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index cf6553d129..f23921497c 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -96,29 +96,29 @@ using namespace QV4;
void Heap::QQmlValueTypeWrapper::destroy()
{
- if (gadgetPtr) {
- valueType->metaType.destruct(gadgetPtr);
- ::operator delete(gadgetPtr);
+ if (m_gadgetPtr) {
+ m_valueType->metaType.destruct(m_gadgetPtr);
+ ::operator delete(m_gadgetPtr);
}
- if (_propertyCache)
- _propertyCache->release();
+ if (m_propertyCache)
+ m_propertyCache->release();
Object::destroy();
}
void Heap::QQmlValueTypeWrapper::setValue(const QVariant &value) const
{
- Q_ASSERT(valueType->metaType.id() == value.userType());
- if (gadgetPtr)
- valueType->metaType.destruct(gadgetPtr);
- if (!gadgetPtr)
- gadgetPtr = ::operator new(valueType->metaType.sizeOf());
- valueType->metaType.construct(gadgetPtr, value.constData());
+ Q_ASSERT(valueType()->metaType.id() == value.userType());
+ if (auto *gadget = gadgetPtr())
+ valueType()->metaType.destruct(gadget);
+ if (!gadgetPtr())
+ setGadgetPtr(::operator new(valueType()->metaType.sizeOf()));
+ valueType()->metaType.construct(gadgetPtr(), value.constData());
}
QVariant Heap::QQmlValueTypeWrapper::toVariant() const
{
- Q_ASSERT(gadgetPtr);
- return QVariant(valueType->metaType.id(), gadgetPtr);
+ Q_ASSERT(gadgetPtr());
+ return QVariant(valueType()->metaType.id(), gadgetPtr());
}
@@ -146,13 +146,13 @@ bool QQmlValueTypeReference::readReferenceValue() const
QQmlPropertyCache *cache = nullptr;
if (const QMetaObject *mo = QQmlValueTypeFactory::metaObjectForMetaType(variantReferenceType))
cache = QJSEnginePrivate::get(engine())->cache(mo);
- if (d()->gadgetPtr) {
- d()->valueType->metaType.destruct(d()->gadgetPtr);
- ::operator delete(d()->gadgetPtr);
+ if (d()->gadgetPtr()) {
+ d()->valueType()->metaType.destruct(d()->gadgetPtr());
+ ::operator delete(d()->gadgetPtr());
}
- d()->gadgetPtr =nullptr;
+ d()->setGadgetPtr(nullptr);
d()->setPropertyCache(cache);
- d()->valueType = QQmlValueTypeFactory::valueType(variantReferenceType);
+ d()->setValueType(QQmlValueTypeFactory::valueType(variantReferenceType));
if (!cache)
return false;
} else {
@@ -161,12 +161,12 @@ bool QQmlValueTypeReference::readReferenceValue() const
}
d()->setValue(variantReferenceValue);
} else {
- if (!d()->gadgetPtr) {
- d()->gadgetPtr = ::operator new(d()->valueType->metaType.sizeOf());
- d()->valueType->metaType.construct(d()->gadgetPtr, nullptr);
+ if (!d()->gadgetPtr()) {
+ d()->setGadgetPtr(::operator new(d()->valueType()->metaType.sizeOf()));
+ d()->valueType()->metaType.construct(d()->gadgetPtr(), nullptr);
}
// value-type reference
- void *args[] = { d()->gadgetPtr, nullptr };
+ void *args[] = { d()->gadgetPtr(), nullptr };
QMetaObject::metacall(d()->object, QMetaObject::ReadProperty, d()->property, args);
}
return true;
@@ -192,8 +192,8 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj
r->d()->object = object;
r->d()->property = property;
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
- r->d()->valueType = QQmlValueTypeFactory::valueType(typeId);
- r->d()->gadgetPtr = nullptr;
+ r->d()->setValueType(QQmlValueTypeFactory::valueType(typeId));
+ r->d()->setGadgetPtr(nullptr);
return r->asReturnedValue();
}
@@ -204,8 +204,8 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria
Scoped<QQmlValueTypeWrapper> r(scope, engine->memoryManager->allocate<QQmlValueTypeWrapper>());
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
- r->d()->valueType = QQmlValueTypeFactory::valueType(typeId);
- r->d()->gadgetPtr = nullptr;
+ r->d()->setValueType(QQmlValueTypeFactory::valueType(typeId));
+ r->d()->setGadgetPtr(nullptr);
r->d()->setValue(value);
return r->asReturnedValue();
}
@@ -223,9 +223,9 @@ bool QQmlValueTypeWrapper::toGadget(void *data) const
if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>())
if (!ref->readReferenceValue())
return false;
- const int typeId = d()->valueType->metaType.id();
+ const int typeId = d()->valueType()->metaType.id();
QMetaType::destruct(typeId, data);
- QMetaType::construct(typeId, data, d()->gadgetPtr);
+ QMetaType::construct(typeId, data, d()->gadgetPtr());
return true;
}
@@ -307,7 +307,7 @@ bool QQmlValueTypeWrapper::isEqual(const QVariant& value) const
int QQmlValueTypeWrapper::typeId() const
{
- return d()->valueType->metaType.id();
+ return d()->valueType()->metaType.id();
}
bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
@@ -315,10 +315,10 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
bool destructGadgetOnExit = false;
Q_ALLOCA_DECLARE(void, gadget);
if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>()) {
- if (!d()->gadgetPtr) {
- Q_ALLOCA_ASSIGN(void, gadget, d()->valueType->metaType.sizeOf());
- d()->gadgetPtr = gadget;
- d()->valueType->metaType.construct(d()->gadgetPtr, nullptr);
+ if (!d()->gadgetPtr()) {
+ Q_ALLOCA_ASSIGN(void, gadget, d()->valueType()->metaType.sizeOf());
+ d()->setGadgetPtr(gadget);
+ d()->valueType()->metaType.construct(d()->gadgetPtr(), nullptr);
destructGadgetOnExit = true;
}
if (!ref->readReferenceValue())
@@ -327,12 +327,12 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
int flags = 0;
int status = -1;
- void *a[] = { d()->gadgetPtr, nullptr, &status, &flags };
+ void *a[] = { d()->gadgetPtr(), nullptr, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty, propertyIndex, a);
if (destructGadgetOnExit) {
- d()->valueType->metaType.destruct(d()->gadgetPtr);
- d()->gadgetPtr = nullptr;
+ d()->valueType()->metaType.destruct(d()->gadgetPtr());
+ d()->setGadgetPtr(nullptr);
}
return true;
}
@@ -354,16 +354,16 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con
// Prepare a buffer to pass to QMetaType::convert()
QString convertResult;
convertResult.~QString();
- if (QMetaType::convert(w->d()->gadgetPtr, w->d()->valueType->metaType.id(), &convertResult, QMetaType::QString)) {
+ if (QMetaType::convert(w->d()->gadgetPtr(), w->d()->valueType()->metaType.id(), &convertResult, QMetaType::QString)) {
result = convertResult;
} else {
- result += QString::fromUtf8(QMetaType::typeName(w->d()->valueType->metaType.id()))
+ result += QString::fromUtf8(QMetaType::typeName(w->d()->valueType()->metaType.id()))
+ QLatin1Char('(');
const QMetaObject *mo = w->d()->propertyCache()->metaObject();
const int propCount = mo->propertyCount();
for (int i = 0; i < propCount; ++i) {
if (mo->property(i).isDesignable()) {
- QVariant value = mo->property(i).readOnGadget(w->d()->gadgetPtr);
+ QVariant value = mo->property(i).readOnGadget(w->d()->gadgetPtr());
if (i > 0)
result += QLatin1String(", ");
result += value.toString();
@@ -387,7 +387,7 @@ Q_ALWAYS_INLINE static ReturnedValue getGadgetProperty(ExecutionEngine *engine,
if (property->propType() == metatype) { \
cpptype v; \
void *args[] = { &v, nullptr }; \
- metaObject->d.static_metacall(reinterpret_cast<QObject*>(valueTypeWrapper->gadgetPtr), \
+ metaObject->d.static_metacall(reinterpret_cast<QObject*>(valueTypeWrapper->gadgetPtr()), \
QMetaObject::ReadProperty, index, args); \
return QV4::Encode(constructor(v)); \
}
@@ -412,7 +412,7 @@ Q_ALWAYS_INLINE static ReturnedValue getGadgetProperty(ExecutionEngine *engine,
v = QVariant(property->propType(), static_cast<void *>(nullptr));
args[0] = v.data();
}
- metaObject->d.static_metacall(reinterpret_cast<QObject*>(valueTypeWrapper->gadgetPtr), QMetaObject::ReadProperty,
+ metaObject->d.static_metacall(reinterpret_cast<QObject*>(valueTypeWrapper->gadgetPtr()), QMetaObject::ReadProperty,
index, args);
return engine->fromVariant(v);
#undef VALUE_TYPE_LOAD
@@ -604,7 +604,7 @@ bool QQmlValueTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &v
if (property.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double)
v = v.toInt();
- void *gadget = r->d()->gadgetPtr;
+ void *gadget = r->d()->gadgetPtr();
property.writeOnGadget(gadget, v);
@@ -620,7 +620,7 @@ bool QQmlValueTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &v
} else {
int flags = 0;
int status = -1;
- void *a[] = { r->d()->gadgetPtr, nullptr, &status, &flags };
+ void *a[] = { r->d()->gadgetPtr(), nullptr, &status, &flags };
QMetaObject::metacall(reference->d()->object, QMetaObject::WriteProperty, reference->d()->property, a);
}
}
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index baac129afa..60079aa623 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -69,22 +69,45 @@ namespace Heap {
struct QQmlValueTypeWrapper : Object {
void init() { Object::init(); }
void destroy();
- QQmlPropertyCache *propertyCache() const { return _propertyCache; }
+
+ QQmlPropertyCache *propertyCache() const { return m_propertyCache; }
void setPropertyCache(QQmlPropertyCache *c) {
if (c)
c->addref();
- if (_propertyCache)
- _propertyCache->release();
- _propertyCache = c;
+ if (m_propertyCache)
+ m_propertyCache->release();
+ m_propertyCache = c;
+ }
+
+ void setValueType(QQmlValueType *valueType)
+ {
+ Q_ASSERT(valueType != nullptr);
+ m_valueType = valueType;
+ }
+
+ QQmlValueType *valueType() const
+ {
+ Q_ASSERT(m_valueType != nullptr);
+ return m_valueType;
+ }
+
+ void setGadgetPtr(void *gadgetPtr) const
+ {
+ m_gadgetPtr = gadgetPtr;
+ }
+
+ void *gadgetPtr() const
+ {
+ return m_gadgetPtr;
}
- mutable void *gadgetPtr;
- QQmlValueType *valueType;
void setValue(const QVariant &value) const;
QVariant toVariant() const;
private:
- QQmlPropertyCache *_propertyCache;
+ mutable void *m_gadgetPtr;
+ QQmlValueType *m_valueType;
+ QQmlPropertyCache *m_propertyCache;
};
}
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index abdc686ec2..9b5490b6e5 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -1197,6 +1197,8 @@ bool QQmlVMEMetaObject::aliasTarget(int index, QObject **target, int *coreIndex,
const int aliasId = index - propOffset() - compiledObject->nProperties;
const QV4::CompiledData::Alias *aliasData = &compiledObject->aliasTable()[aliasId];
+ while (aliasData->aliasToLocalAlias)
+ aliasData = &compiledObject->aliasTable()[aliasData->localAliasIndex];
*target = ctxt->idValues[aliasData->targetObjectId].data();
if (!*target)
return false;
diff --git a/src/qml/qmldirparser/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp
index 5bf33d3602..6e925ba515 100644
--- a/src/qml/qmldirparser/qqmldirparser.cpp
+++ b/src/qml/qmldirparser/qqmldirparser.cpp
@@ -73,14 +73,6 @@ static bool parseVersion(const QString &str, int *major, int *minor)
return false;
}
-QQmlDirParser::QQmlDirParser() : _designerSupported(false)
-{
-}
-
-QQmlDirParser::~QQmlDirParser()
-{
-}
-
inline static void scanSpace(const QChar *&ch) {
while (ch->isSpace() && !ch->isNull() && *ch != QLatin1Char('\n'))
++ch;
diff --git a/src/qml/qmldirparser/qqmldirparser_p.h b/src/qml/qmldirparser/qqmldirparser_p.h
index 37ca1ef2ce..c9d77532c8 100644
--- a/src/qml/qmldirparser/qqmldirparser_p.h
+++ b/src/qml/qmldirparser/qqmldirparser_p.h
@@ -64,9 +64,6 @@ class QQmlEngine;
class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlDirParser
{
public:
- QQmlDirParser();
- ~QQmlDirParser();
-
bool parse(const QString &source);
bool hasError() const;
@@ -87,7 +84,7 @@ public:
struct Plugin
{
- Plugin() {}
+ Plugin() = default;
Plugin(const QString &name, const QString &path)
: name(name), path(path)
@@ -101,7 +98,7 @@ public:
struct Component
{
- Component() {}
+ Component() = default;
Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
: typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
@@ -120,7 +117,7 @@ public:
struct Script
{
- Script() {}
+ Script() = default;
Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion)
: nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion)
@@ -143,7 +140,7 @@ public:
struct TypeInfo
{
- TypeInfo() {}
+ TypeInfo() = default;
TypeInfo(const QString &fileName)
: fileName(fileName) {}
@@ -166,14 +163,14 @@ private:
QStringList _imports;
QList<Script> _scripts;
QList<Plugin> _plugins;
- bool _designerSupported;
+ bool _designerSupported = false;
QList<TypeInfo> _typeInfos;
QString _className;
};
-typedef QHash<QString,QQmlDirParser::Component> QQmlDirComponents;
-typedef QList<QQmlDirParser::Script> QQmlDirScripts;
-typedef QList<QQmlDirParser::Plugin> QQmlDirPlugins;
+using QQmlDirComponents = QHash<QString,QQmlDirParser::Component>;
+using QQmlDirScripts = QList<QQmlDirParser::Script>;
+using QQmlDirPlugins = QList<QQmlDirParser::Plugin>;
QDebug &operator<< (QDebug &, const QQmlDirParser::Component &);
QDebug &operator<< (QDebug &, const QQmlDirParser::Script &);
diff --git a/src/qml/types/qqmlbind_p.h b/src/qml/types/qqmlbind_p.h
index ba040d2a0b..a100b1552c 100644
--- a/src/qml/types/qqmlbind_p.h
+++ b/src/qml/types/qqmlbind_p.h
@@ -81,6 +81,7 @@ private:
Q_PROPERTY(RestorationMode restoreMode READ restoreMode WRITE setRestoreMode
NOTIFY restoreModeChanged REVISION 14)
Q_ENUM(RestorationMode)
+ QML_NAMED_ELEMENT(Binding)
public:
QQmlBind(QObject *parent=nullptr);
diff --git a/src/qml/types/qqmlconnections_p.h b/src/qml/types/qqmlconnections_p.h
index 5d28e8e8be..7bf688cf75 100644
--- a/src/qml/types/qqmlconnections_p.h
+++ b/src/qml/types/qqmlconnections_p.h
@@ -71,6 +71,7 @@ class Q_AUTOTEST_EXPORT QQmlConnections : public QObject, public QQmlParserStatu
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged REVISION 3)
Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals)
+ QML_NAMED_ELEMENT(Connections)
public:
QQmlConnections(QObject *parent=nullptr);
@@ -106,6 +107,13 @@ public:
void applyBindings(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
+// TODO: We won't need Connections to be a custom type anymore once we can drop the
+// automatic signal handler inference from undeclared properties.
+template<>
+inline QQmlCustomParser *qmlCreateCustomParser<QQmlConnections>()
+{
+ return new QQmlConnectionsParser;
+}
QT_END_NAMESPACE
diff --git a/src/qml/types/qqmltimer_p.h b/src/qml/types/qqmltimer_p.h
index 0160e97a2f..0cd93e4659 100644
--- a/src/qml/types/qqmltimer_p.h
+++ b/src/qml/types/qqmltimer_p.h
@@ -72,6 +72,7 @@ class Q_QML_PRIVATE_EXPORT QQmlTimer : public QObject, public QQmlParserStatus
Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged)
Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged)
Q_PROPERTY(QObject *parent READ parent CONSTANT)
+ QML_NAMED_ELEMENT(Timer)
public:
QQmlTimer(QObject *parent=nullptr);
diff --git a/src/qmlmodels/qqmldelegatecomponent_p.h b/src/qmlmodels/qqmldelegatecomponent_p.h
index 1d20f0327b..86ad04d2e3 100644
--- a/src/qmlmodels/qqmldelegatecomponent_p.h
+++ b/src/qmlmodels/qqmldelegatecomponent_p.h
@@ -64,6 +64,9 @@ class QQmlAdaptorModel;
class Q_QMLMODELS_PRIVATE_EXPORT QQmlAbstractDelegateComponent : public QQmlComponent
{
Q_OBJECT
+ QML_NAMED_ELEMENT(AbstractDelegateComponent)
+ QML_UNCREATABLE("Cannot create instance of abstract class AbstractDelegateComponent.")
+
public:
QQmlAbstractDelegateComponent(QObject *parent = nullptr);
~QQmlAbstractDelegateComponent() override;
@@ -90,6 +93,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateChoice : public QObject
Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged)
Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
+ QML_NAMED_ELEMENT(DelegateChoice)
public:
QVariant roleValue() const;
void setRoleValue(const QVariant &roleValue);
@@ -126,6 +130,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateChooser : public QQmlAbstractDelega
Q_PROPERTY(QString role READ role WRITE setRole NOTIFY roleChanged)
Q_PROPERTY(QQmlListProperty<QQmlDelegateChoice> choices READ choices CONSTANT)
Q_CLASSINFO("DefaultProperty", "choices")
+ QML_NAMED_ELEMENT(DelegateChooser)
public:
QString role() const { return m_role; }
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index e7868517cd..691b4b3c29 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -48,7 +48,6 @@
#include <private/qqmlchangeset_p.h>
#include <private/qqmlengine_p.h>
#include <private/qqmlcomponent_p.h>
-#include <private/qqmlincubator_p.h>
#include <private/qv4value_p.h>
#include <private/qv4functionobject_p.h>
@@ -887,6 +886,117 @@ static bool isDoneIncubating(QQmlIncubator::Status status)
return status == QQmlIncubator::Ready || status == QQmlIncubator::Error;
}
+PropertyUpdater::PropertyUpdater(QObject *parent) :
+ QObject(parent) {}
+
+void PropertyUpdater::doUpdate()
+{
+ auto sender = QObject::sender();
+ auto mo = sender->metaObject();
+ auto signalIndex = QObject::senderSignalIndex();
+ ++updateCount;
+ // start at 0 instead of propertyOffset to handle properties from parent hierarchy
+ for (auto i = 0; i < mo->propertyCount() + mo->propertyOffset(); ++i) {
+ auto property = mo->property(i);
+ if (property.notifySignal().methodIndex() == signalIndex) {
+ // we synchronize between required properties and model rolenames by name
+ // that's why the QQmlProperty and the metaobject property must have the same name
+ QQmlProperty qmlProp(parent(), QString::fromLatin1(property.name()));
+ qmlProp.write(property.read(QObject::sender()));
+ return;
+ }
+ }
+}
+
+void PropertyUpdater::breakBinding()
+{
+ auto it = senderToConnection.find(QObject::senderSignalIndex());
+ if (it == senderToConnection.end())
+ return;
+ if (updateCount == 0) {
+ QObject::disconnect(*it);
+ QQmlError warning;
+ warning.setUrl(qmlContext(QObject::sender())->baseUrl());
+ auto signalName = QString::fromLatin1(QObject::sender()->metaObject()->method(QObject::senderSignalIndex()).name());
+ signalName.chop(sizeof("changed")-1);
+ QString propName = signalName;
+ propName[0] = propName[0].toLower();
+ warning.setDescription(QString::fromUtf8("Writing to \"%1\" broke the binding to the underlying model").arg(propName));
+ qmlWarning(this, warning);
+ senderToConnection.erase(it);
+ } else {
+ --updateCount;
+ }
+}
+
+void QQDMIncubationTask::initializeRequiredProperties(QQmlDelegateModelItem *modelItemToIncubate, QObject *object)
+{
+ auto incubatorPriv = QQmlIncubatorPrivate::get(this);
+ QQmlData *d = QQmlData::get(object);
+ auto contextData = d ? d->context : nullptr;
+ if (contextData) {
+ contextData->hasExtraObject = true;
+ contextData->extraObject = modelItemToIncubate;
+ }
+ if (incubatorPriv->hadRequiredProperties()) {
+ if (incubatorPriv->requiredProperties().empty())
+ return;
+ RequiredProperties &requiredProperties = incubatorPriv->requiredProperties();
+
+ auto qmlMetaObject = modelItemToIncubate->metaObject();
+ // if a required property was not in the model, it might still be a static property of the
+ // QQmlDelegateModelItem or one of its derived classes this is the case for index, row,
+ // column, model and more
+ // the most derived subclass of QQmlDelegateModelItem is QQmlDMAbstractModelData at depth 2,
+ // so 4 should be plenty
+ QVarLengthArray<const QMetaObject *, 4> mos;
+ // we first check the dynamic meta object for properties originating from the model
+ mos.push_back(qmlMetaObject); // contains abstractitemmodelproperties
+ auto delegateModelItemSubclassMO = qmlMetaObject->superClass();
+ mos.push_back(delegateModelItemSubclassMO);
+
+ while (strcmp(delegateModelItemSubclassMO->className(), modelItemToIncubate->staticMetaObject.className())) {
+ delegateModelItemSubclassMO = delegateModelItemSubclassMO->superClass();
+ mos.push_back(delegateModelItemSubclassMO);
+ }
+ if (proxiedObject)
+ mos.push_back(proxiedObject->metaObject());
+
+ auto updater = new PropertyUpdater(object);
+ for (const QMetaObject *mo : mos) {
+ for (int i = mo->propertyOffset(); i < mo->propertyCount() + mo->propertyOffset(); ++i) {
+ auto prop = mo->property(i);
+ if (!prop.name())
+ continue;
+ auto propName = QString::fromUtf8(prop.name());
+ bool wasInRequired = false;
+ QQmlProperty componentProp = QQmlComponentPrivate::removePropertyFromRequired(
+ object, propName, requiredProperties, &wasInRequired);
+ // only write to property if it was actually requested by the component
+ if (wasInRequired && prop.hasNotifySignal()) {
+ QMetaMethod changeSignal = prop.notifySignal();
+ static QMetaMethod updateSlot = PropertyUpdater::staticMetaObject.method(PropertyUpdater::staticMetaObject.indexOfSlot("doUpdate()"));
+ QMetaObject::Connection conn = QObject::connect(modelItemToIncubate, changeSignal, updater, updateSlot);
+ auto propIdx = object->metaObject()->indexOfProperty(propName.toUtf8());
+ QMetaMethod writeToPropSignal = object->metaObject()->property(propIdx).notifySignal();
+ updater->senderToConnection[writeToPropSignal.methodIndex()] = conn;
+ static QMetaMethod breakBinding = PropertyUpdater::staticMetaObject.method(PropertyUpdater::staticMetaObject.indexOfSlot("breakBinding()"));
+ componentProp.write(prop.read(modelItemToIncubate));
+ // the connection needs to established after the write,
+ // else the signal gets triggered by it and breakBinding will remove the connection
+ QObject::connect(object, writeToPropSignal, updater, breakBinding);
+ }
+ else if (wasInRequired) // we still have to write, even if there is no change signal
+ componentProp.write(prop.read(modelItemToIncubate));
+ }
+ }
+ } else {
+ modelItemToIncubate->contextData->contextObject = modelItemToIncubate;
+ if (proxiedObject)
+ proxyContext->contextObject = proxiedObject;
+ }
+}
+
void QQDMIncubationTask::statusChanged(Status status)
{
if (vdm) {
@@ -987,6 +1097,7 @@ void QQDMIncubationTask::setInitialState(QObject *o)
void QQmlDelegateModelPrivate::setInitialState(QQDMIncubationTask *incubationTask, QObject *o)
{
QQmlDelegateModelItem *cacheItem = incubationTask->incubating;
+ incubationTask->initializeRequiredProperties(incubationTask->incubating, o);
cacheItem->object = o;
if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(cacheItem->object))
@@ -1053,7 +1164,6 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
QQmlContextData *ctxt = new QQmlContextData;
ctxt->setParent(QQmlContextData::get(creationContext ? creationContext : m_context.data()));
- ctxt->contextObject = cacheItem;
cacheItem->contextData = ctxt;
if (m_adaptorModel.hasProxyObject()) {
@@ -1062,7 +1172,8 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
ctxt = new QQmlContextData;
ctxt->setParent(cacheItem->contextData, /*stronglyReferencedByParent*/true);
QObject *proxied = proxy->proxiedObject();
- ctxt->contextObject = proxied;
+ cacheItem->incubationTask->proxiedObject = proxied;
+ cacheItem->incubationTask->proxyContext = ctxt;
// We don't own the proxied object. We need to clear it if it goes away.
QObject::connect(proxied, &QObject::destroyed,
cacheItem, &QQmlDelegateModelItem::childContextObjectDestroyed);
@@ -2166,6 +2277,8 @@ QQmlDelegateModelItem *QQmlDelegateModelItem::dataForObject(QObject *object)
{
QQmlData *d = QQmlData::get(object);
QQmlContextData *context = d ? d->context : nullptr;
+ if (context && context->hasExtraObject)
+ return qobject_cast<QQmlDelegateModelItem *>(context->extraObject);
for (context = context ? context->parent : nullptr; context; context = context->parent) {
if (QQmlDelegateModelItem *cacheItem = qobject_cast<QQmlDelegateModelItem *>(
context->contextObject)) {
diff --git a/src/qmlmodels/qqmldelegatemodel_p.h b/src/qmlmodels/qqmldelegatemodel_p.h
index 21eaef02e0..7492f2b77d 100644
--- a/src/qmlmodels/qqmldelegatemodel_p.h
+++ b/src/qmlmodels/qqmldelegatemodel_p.h
@@ -85,7 +85,11 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModel : public QQmlInstanceModel, p
Q_PROPERTY(QObject *parts READ parts CONSTANT)
Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
+ QML_NAMED_ELEMENT(DelegateModel)
+ QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ATTACHED(QQmlDelegateModelAttached)
Q_INTERFACES(QQmlParserStatus)
+
public:
QQmlDelegateModel();
QQmlDelegateModel(QQmlContext *, QObject *parent=nullptr);
@@ -163,6 +167,8 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModelGroup : public QObject
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(bool includeByDefault READ defaultInclude WRITE setDefaultInclude NOTIFY defaultIncludeChanged)
+ QML_NAMED_ELEMENT(DelegateModelGroup)
+ QML_ADDED_IN_MINOR_VERSION(1)
public:
QQmlDelegateModelGroup(QObject *parent = nullptr);
QQmlDelegateModelGroup(const QString &name, QQmlDelegateModel *model, int compositorType, QObject *parent = nullptr);
@@ -240,7 +246,6 @@ public:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQmlDelegateModel)
-QML_DECLARE_TYPEINFO(QQmlDelegateModel, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(QQmlDelegateModelGroup)
#endif // QQMLDATAMODEL_P_H
diff --git a/src/qmlmodels/qqmldelegatemodel_p_p.h b/src/qmlmodels/qqmldelegatemodel_p_p.h
index 92362b8876..06365a212f 100644
--- a/src/qmlmodels/qqmldelegatemodel_p_p.h
+++ b/src/qmlmodels/qqmldelegatemodel_p_p.h
@@ -201,11 +201,14 @@ public:
, incubating(nullptr)
, vdm(l) {}
+ void initializeRequiredProperties(QQmlDelegateModelItem *modelItemToIncubate, QObject* object);
void statusChanged(Status) override;
void setInitialState(QObject *) override;
QQmlDelegateModelItem *incubating = nullptr;
QQmlDelegateModelPrivate *vdm = nullptr;
+ QQmlContextData *proxyContext = nullptr;
+ QPointer<QObject> proxiedObject = nullptr; // the proxied object might disapear, so we use a QPointer instead of a raw one
int index[QQmlListCompositor::MaximumGroupCount];
};
@@ -445,6 +448,19 @@ private:
const int indexPropertyOffset;
};
+class PropertyUpdater : public QObject
+{
+ Q_OBJECT
+
+public:
+ PropertyUpdater(QObject *parent);
+ QHash<int, QMetaObject::Connection> senderToConnection;
+ int updateCount = 0;
+public Q_SLOTS:
+ void doUpdate();
+ void breakBinding();
+};
+
QT_END_NAMESPACE
#endif
diff --git a/src/qmlmodels/qqmlinstantiator_p.h b/src/qmlmodels/qqmlinstantiator_p.h
index 87accc304f..60b611128d 100644
--- a/src/qmlmodels/qqmlinstantiator_p.h
+++ b/src/qmlmodels/qqmlinstantiator_p.h
@@ -72,6 +72,8 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstantiator : public QObject, public QQmlP
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(QObject *object READ object NOTIFY objectChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
+ QML_NAMED_ELEMENT(Instantiator)
+ QML_ADDED_IN_MINOR_VERSION(14)
public:
QQmlInstantiator(QObject *parent = nullptr);
diff --git a/src/qmlmodels/qqmllistmodel_p.h b/src/qmlmodels/qqmllistmodel_p.h
index 10d67c1c6f..9a4358ac6f 100644
--- a/src/qmlmodels/qqmllistmodel_p.h
+++ b/src/qmlmodels/qqmllistmodel_p.h
@@ -83,6 +83,8 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlListModel : public QAbstractListModel
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(bool dynamicRoles READ dynamicRoles WRITE setDynamicRoles)
Q_PROPERTY(QObject *agent READ agent CONSTANT REVISION(14))
+ QML_NAMED_ELEMENT(ListModel)
+ QML_ADDED_IN_MINOR_VERSION(1)
public:
QQmlListModel(QObject *parent=nullptr);
@@ -171,7 +173,9 @@ private:
// ### FIXME
class QQmlListElement : public QObject
{
-Q_OBJECT
+ Q_OBJECT
+ QML_NAMED_ELEMENT(ListElement)
+ QML_ADDED_IN_MINOR_VERSION(1)
};
class QQmlListModelParser : public QQmlCustomParser
@@ -201,6 +205,12 @@ private:
QString listElementTypeName;
};
+template<>
+inline QQmlCustomParser *qmlCreateCustomParser<QQmlListModel>()
+{
+ return new QQmlListModelParser;
+}
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQmlListModel)
diff --git a/src/qmlmodels/qqmllistmodelworkeragent_p.h b/src/qmlmodels/qqmllistmodelworkeragent_p.h
index 1ef27cea3f..f65909dcec 100644
--- a/src/qmlmodels/qqmllistmodelworkeragent_p.h
+++ b/src/qmlmodels/qqmllistmodelworkeragent_p.h
@@ -56,6 +56,7 @@
#include <QEvent>
#include <QMutex>
#include <QWaitCondition>
+#include <QtQml/qqml.h>
#include <private/qv4engine_p.h>
@@ -71,6 +72,7 @@ class QQmlListModelWorkerAgent : public QObject
Q_OBJECT
Q_PROPERTY(int count READ count)
Q_PROPERTY(QV4::ExecutionEngine *engine READ engine WRITE setEngine NOTIFY engineChanged)
+ QML_ANONYMOUS
public:
QQmlListModelWorkerAgent(QQmlListModel *);
diff --git a/src/qmlmodels/qqmlmodelsmodule.cpp b/src/qmlmodels/qqmlmodelsmodule.cpp
index d569d8e23c..5dbf84b599 100644
--- a/src/qmlmodels/qqmlmodelsmodule.cpp
+++ b/src/qmlmodels/qqmlmodelsmodule.cpp
@@ -40,16 +40,15 @@
#include "qqmlmodelsmodule_p.h"
#include <private/qtqmlmodelsglobal_p.h>
-#if QT_CONFIG(itemmodel)
-#include <QtCore/qitemselectionmodel.h>
-#endif
#if QT_CONFIG(qml_list_model)
#include <private/qqmllistmodel_p.h>
+#include <private/qqmllistmodelworkeragent_p.h>
#endif
#if QT_CONFIG(qml_delegate_model)
#include <private/qqmldelegatemodel_p.h>
#include <private/qqmldelegatecomponent_p.h>
#include <private/qquickpackage_p.h>
+#include <private/qqmlcomponentattached_p.h>
#endif
#if QT_CONFIG(qml_object_model)
#include <private/qqmlobjectmodel_p.h>
@@ -67,6 +66,8 @@ QT_BEGIN_NAMESPACE
void QQmlModelsModule::registerQmlTypes()
{
// Don't add anything here. These are only for backwards compatibility.
+ // Don't convert these to qmlRegisterTypesAndRevisions!
+ // -> the annotations in the headers are for the QtQml.Models module <-
#if QT_CONFIG(qml_object_model)
qmlRegisterType<QQmlInstantiator>("QtQml", 2, 1, "Instantiator"); // Only available in >= 2.1
qmlRegisterAnonymousType<QQmlInstanceModel>("QtQml", 2);
@@ -76,6 +77,8 @@ void QQmlModelsModule::registerQmlTypes()
void QQmlModelsModule::registerQuickTypes()
{
// Don't add anything here. These are only for backwards compatibility.
+ // Don't convert these to qmlRegisterTypesAndRevisions!
+ // -> the annotations in the headers are for the QtQml.Models module <-
const char uri[] = "QtQuick";
@@ -102,22 +105,16 @@ void QQmlModelsModule::defineModule()
const char uri[] = "QtQml.Models";
#if QT_CONFIG(qml_list_model)
- qmlRegisterType<QQmlListElement>(uri, 2, 1, "ListElement");
- qmlRegisterCustomType<QQmlListModel>(uri, 2, 1, "ListModel", new QQmlListModelParser);
+ qmlRegisterTypesAndRevisions<QQmlListElement, QQmlListModel, QQmlListModelWorkerAgent>(uri, 2);
#endif
#if QT_CONFIG(qml_delegate_model)
- qmlRegisterType<QQmlDelegateModel>(uri, 2, 1, "DelegateModel");
- qmlRegisterType<QQmlDelegateModelGroup>(uri, 2, 1, "DelegateModelGroup");
- qmlRegisterType<QQuickPackage>(uri, 2, 14, "Package");
+ qmlRegisterTypesAndRevisions<QQmlDelegateModel, QQmlDelegateModelGroup, QQuickPackage>(uri, 2);
#endif
#if QT_CONFIG(qml_object_model)
- qmlRegisterType<QQmlObjectModel>(uri, 2, 1, "ObjectModel");
- qmlRegisterType<QQmlObjectModel,3>(uri, 2, 3, "ObjectModel");
- qmlRegisterType<QQmlInstantiator>(uri, 2, 14, "Instantiator");
- qmlRegisterAnonymousType<QQmlInstanceModel>(uri, 2);
+ qmlRegisterTypesAndRevisions<QQmlObjectModel, QQmlInstantiator, QQmlInstanceModel>(uri, 2);
#endif
#if QT_CONFIG(itemmodel)
- qmlRegisterType<QItemSelectionModel>(uri, 2, 2, "ItemSelectionModel");
+ qmlRegisterTypesAndRevisions<QItemSelectionModelForeign>(uri, 2);
#endif
}
@@ -126,13 +123,11 @@ void QQmlModelsModule::defineLabsModule()
const char uri[] = "Qt.labs.qmlmodels";
#if QT_CONFIG(qml_delegate_model)
- qmlRegisterUncreatableType<QQmlAbstractDelegateComponent>(uri, 1, 0, "AbstractDelegateComponent", QQmlAbstractDelegateComponent::tr("Cannot create instance of abstract class AbstractDelegateComponent."));
- qmlRegisterType<QQmlDelegateChooser>(uri, 1, 0, "DelegateChooser");
- qmlRegisterType<QQmlDelegateChoice>(uri, 1, 0, "DelegateChoice");
+ qmlRegisterTypesAndRevisions<
+ QQmlAbstractDelegateComponent, QQmlDelegateChooser, QQmlDelegateChoice>(uri, 1);
#endif
#if QT_CONFIG(qml_table_model)
- qmlRegisterType<QQmlTableModel>(uri, 1, 0, "TableModel");
- qmlRegisterType<QQmlTableModelColumn>(uri, 1, 0, "TableModelColumn");
+ qmlRegisterTypesAndRevisions<QQmlTableModel, QQmlTableModelColumn>(uri, 1);
#endif
}
diff --git a/src/qmlmodels/qqmlmodelsmodule_p.h b/src/qmlmodels/qqmlmodelsmodule_p.h
index 7e02578db9..85c87b35a2 100644
--- a/src/qmlmodels/qqmlmodelsmodule_p.h
+++ b/src/qmlmodels/qqmlmodelsmodule_p.h
@@ -51,6 +51,12 @@
// We mean it.
//
+#include <QtQml/qqml.h>
+
+#if QT_CONFIG(itemmodel)
+#include <QtCore/qitemselectionmodel.h>
+#endif
+
#include <private/qtqmlmodelsglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -67,6 +73,16 @@ public:
static void defineLabsModule();
};
+#if QT_CONFIG(itemmodel)
+struct QItemSelectionModelForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QItemSelectionModel)
+ QML_NAMED_ELEMENT(ItemSelectionModel)
+ QML_ADDED_IN_MINOR_VERSION(2)
+};
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/src/qmlmodels/qqmlobjectmodel_p.h b/src/qmlmodels/qqmlobjectmodel_p.h
index 78a5615ae2..0aa818d724 100644
--- a/src/qmlmodels/qqmlobjectmodel_p.h
+++ b/src/qmlmodels/qqmlobjectmodel_p.h
@@ -69,6 +69,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstanceModel : public QObject
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
+ QML_ANONYMOUS
public:
virtual ~QQmlInstanceModel() {}
@@ -113,6 +114,9 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlObjectModel : public QQmlInstanceModel
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged DESIGNABLE false)
Q_CLASSINFO("DefaultProperty", "children")
+ QML_NAMED_ELEMENT(ObjectModel)
+ QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ATTACHED(QQmlObjectModelAttached)
public:
QQmlObjectModel(QObject *parent=nullptr);
@@ -191,6 +195,5 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QQmlInstanceModel)
QML_DECLARE_TYPE(QQmlObjectModel)
-QML_DECLARE_TYPEINFO(QQmlObjectModel, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQMLINSTANCEMODEL_P_H
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
index b244a007e5..9b79df3441 100644
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
@@ -525,8 +525,13 @@ const QAbstractItemModel *QQmlTableInstanceModel::abstractItemModel() const
void QQmlTableInstanceModelIncubationTask::setInitialState(QObject *object)
{
- modelItemToIncubate->object = object;
- emit tableInstanceModel->initItem(modelItemToIncubate->index, object);
+ initializeRequiredProperties(modelItemToIncubate, object);
+ if (QQmlIncubatorPrivate::get(this)->requiredProperties().empty()) {
+ modelItemToIncubate->object = object;
+ emit tableInstanceModel->initItem(modelItemToIncubate->index, object);
+ } else {
+ object->deleteLater();
+ }
}
void QQmlTableInstanceModelIncubationTask::statusChanged(QQmlIncubator::Status status)
diff --git a/src/qmlmodels/qqmltablemodel_p.h b/src/qmlmodels/qqmltablemodel_p.h
index b3c0cc2848..4b667e1073 100644
--- a/src/qmlmodels/qqmltablemodel_p.h
+++ b/src/qmlmodels/qqmltablemodel_p.h
@@ -72,6 +72,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlTableModel : public QAbstractTableModel, pu
Q_PROPERTY(QQmlListProperty<QQmlTableModelColumn> columns READ columns CONSTANT FINAL)
Q_INTERFACES(QQmlParserStatus)
Q_CLASSINFO("DefaultProperty", "columns")
+ QML_NAMED_ELEMENT(TableModel)
public:
QQmlTableModel(QObject *parent = nullptr);
diff --git a/src/qmlmodels/qqmltablemodelcolumn_p.h b/src/qmlmodels/qqmltablemodelcolumn_p.h
index 0b6478ce38..33f32ccb68 100644
--- a/src/qmlmodels/qqmltablemodelcolumn_p.h
+++ b/src/qmlmodels/qqmltablemodelcolumn_p.h
@@ -96,6 +96,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlTableModelColumn : public QObject
Q_PROPERTY(QJSValue sizeHint READ sizeHint WRITE setSizeHint NOTIFY sizeHintChanged FINAL)
Q_PROPERTY(QJSValue setSizeHint READ getSetSizeHint WRITE setSetSizeHint NOTIFY setSizeHintChanged FINAL)
+ QML_NAMED_ELEMENT(TableModelColumn)
public:
QQmlTableModelColumn(QObject *parent = nullptr);
diff --git a/src/qmlmodels/qquickpackage_p.h b/src/qmlmodels/qquickpackage_p.h
index 97f7818fee..97f3bab9bc 100644
--- a/src/qmlmodels/qquickpackage_p.h
+++ b/src/qmlmodels/qquickpackage_p.h
@@ -66,6 +66,9 @@ class Q_AUTOTEST_EXPORT QQuickPackage : public QObject
Q_DECLARE_PRIVATE(QQuickPackage)
Q_CLASSINFO("DefaultProperty", "data")
+ QML_NAMED_ELEMENT(Package)
+ QML_ADDED_IN_MINOR_VERSION(14)
+ QML_ATTACHED(QQuickPackageAttached)
Q_PROPERTY(QQmlListProperty<QObject> data READ data)
public:
@@ -99,6 +102,5 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickPackage)
-QML_DECLARE_TYPEINFO(QQuickPackage, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKPACKAGE_H
diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro
index 0bf05093be..d6e4669769 100644
--- a/src/qmltest/qmltest.pro
+++ b/src/qmltest/qmltest.pro
@@ -18,12 +18,15 @@ qtHaveModule(widgets) {
SOURCES += \
$$PWD/quicktest.cpp \
$$PWD/quicktestevent.cpp \
- $$PWD/quicktestresult.cpp
+ $$PWD/quicktestresult.cpp \
+ $$PWD/quicktestutil.cpp
+
HEADERS += \
$$PWD/quicktestglobal.h \
$$PWD/quicktest.h \
$$PWD/quicktestevent_p.h \
$$PWD/quicktestresult_p.h \
+ $$PWD/quicktestutil_p.h \
$$PWD/qtestoptions_p.h
qtConfig(qml-debug): DEFINES += QT_QML_DEBUG_NO_WARNING
diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h
index 5208c03a82..a3c2e78e58 100644
--- a/src/qmltest/quicktestevent_p.h
+++ b/src/qmltest/quicktestevent_p.h
@@ -54,6 +54,7 @@
#include <QtQuickTest/quicktestglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/QWindow>
+#include <QtQml/qqml.h>
#include <QtTest/qtesttouch.h>
QT_BEGIN_NAMESPACE
@@ -62,6 +63,8 @@ class QuickTestEvent;
class Q_QUICK_TEST_EXPORT QQuickTouchEventSequence : public QObject
{
Q_OBJECT
+ QML_ANONYMOUS
+
public:
explicit QQuickTouchEventSequence(QuickTestEvent *testEvent, QObject *item = nullptr);
public slots:
@@ -80,6 +83,7 @@ class Q_QUICK_TEST_EXPORT QuickTestEvent : public QObject
{
Q_OBJECT
Q_PROPERTY(int defaultMouseDelay READ defaultMouseDelay FINAL)
+ QML_NAMED_ELEMENT(TestEvent)
public:
QuickTestEvent(QObject *parent = nullptr);
~QuickTestEvent() override;
diff --git a/src/qmltest/quicktestresult_p.h b/src/qmltest/quicktestresult_p.h
index 0d229ad713..296e8e5344 100644
--- a/src/qmltest/quicktestresult_p.h
+++ b/src/qmltest/quicktestresult_p.h
@@ -76,6 +76,8 @@ class Q_QUICK_TEST_EXPORT QuickTestResult : public QObject
Q_PROPERTY(int skipCount READ skipCount)
Q_PROPERTY(QStringList functionsToRun READ functionsToRun)
Q_PROPERTY(QStringList tagsToRun READ tagsToRun)
+ QML_NAMED_ELEMENT(TestResult)
+
public:
QuickTestResult(QObject *parent = nullptr);
~QuickTestResult() override;
diff --git a/src/qmltest/quicktestutil.cpp b/src/qmltest/quicktestutil.cpp
new file mode 100644
index 0000000000..682c56400e
--- /dev/null
+++ b/src/qmltest/quicktestutil.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quicktestutil_p.h"
+
+#include <QtQuickTest/private/qtestoptions_p.h>
+#include <QtQml/private/qqmltype_p.h>
+#include <QtQml/private/qqmlmetatype_p.h>
+#include <QtQml/private/qv4engine_p.h>
+#include <QtQml/private/qv4scopedvalue_p.h>
+
+#include <QtGui/qguiapplication.h>
+#include <QtGui/qstylehints.h>
+#include <QtQml/qqmlengine.h>
+
+QT_BEGIN_NAMESPACE
+
+bool QuickTestUtil::printAvailableFunctions() const
+{
+ return QTest::printAvailableFunctions;
+}
+
+int QuickTestUtil::dragThreshold() const
+{
+ return QGuiApplication::styleHints()->startDragDistance();
+}
+
+QJSValue QuickTestUtil::typeName(const QVariant &v) const
+{
+ QString name(v.typeName());
+ if (v.canConvert<QObject*>()) {
+ QQmlType type;
+ const QMetaObject *mo = v.value<QObject*>()->metaObject();
+ while (!type.isValid() && mo) {
+ type = QQmlMetaType::qmlType(mo);
+ mo = mo->superClass();
+ }
+ if (type.isValid()) {
+ name = type.qmlTypeName();
+ }
+ }
+
+ QQmlEngine *engine = qmlEngine(this);
+ QV4::ExecutionEngine *v4 = engine->handle();
+ return QJSValue(v4, v4->newString(name)->asReturnedValue());
+}
+
+bool QuickTestUtil::compare(const QVariant &act, const QVariant &exp) const {
+ return act == exp;
+}
+
+QJSValue QuickTestUtil::callerFile(int frameIndex) const
+{
+ QQmlEngine *engine = qmlEngine(this);
+ QV4::ExecutionEngine *v4 = engine->handle();
+ QV4::Scope scope(v4);
+
+ QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2);
+ return (stack.size() > frameIndex + 1)
+ ? QJSValue(v4, v4->newString(stack.at(frameIndex + 1).source)->asReturnedValue())
+ : QJSValue();
+}
+
+int QuickTestUtil::callerLine(int frameIndex) const
+{
+ QQmlEngine *engine = qmlEngine(this);
+ QV4::ExecutionEngine *v4 = engine->handle();
+
+ QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2);
+ if (stack.size() > frameIndex + 1)
+ return stack.at(frameIndex + 1).line;
+ return -1;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qmltest/quicktestutil_p.h b/src/qmltest/quicktestutil_p.h
new file mode 100644
index 0000000000..74d315df7d
--- /dev/null
+++ b/src/qmltest/quicktestutil_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUICKTESTUTIL_P_H
+#define QUICKTESTUTIL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTest/quicktestglobal.h>
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qjsvalue.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_TEST_EXPORT QuickTestUtil : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool printAvailableFunctions READ printAvailableFunctions NOTIFY printAvailableFunctionsChanged)
+ Q_PROPERTY(int dragThreshold READ dragThreshold NOTIFY dragThresholdChanged)
+ QML_NAMED_ELEMENT(TestUtil)
+public:
+ QuickTestUtil(QObject *parent = nullptr) :QObject(parent) {}
+ ~QuickTestUtil() override {}
+
+ bool printAvailableFunctions() const;
+ int dragThreshold() const;
+
+Q_SIGNALS:
+ void printAvailableFunctionsChanged();
+ void dragThresholdChanged();
+
+public Q_SLOTS:
+
+ QJSValue typeName(const QVariant& v) const;
+ bool compare(const QVariant& act, const QVariant& exp) const;
+
+ QJSValue callerFile(int frameIndex = 0) const;
+ int callerLine(int frameIndex = 0) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QUICKTESTUTIL_P_H
diff --git a/src/qmlworkerscript/qqmlworkerscriptmodule.cpp b/src/qmlworkerscript/qqmlworkerscriptmodule.cpp
index 98e82dbeba..42efe1a8eb 100644
--- a/src/qmlworkerscript/qqmlworkerscriptmodule.cpp
+++ b/src/qmlworkerscript/qqmlworkerscriptmodule.cpp
@@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE
void QQmlWorkerScriptModule::registerQuickTypes()
{
// Don't add anything here. These are only for backwards compatibility.
+ // Also, don't convert to qmlRegisterTypesAndRevisions as that will add future revisions.
const char uri[] = "QtQuick";
qmlRegisterType<QQuickWorkerScript>(uri, 2, 0, "WorkerScript");
}
@@ -56,7 +57,7 @@ void QQmlWorkerScriptModule::registerQuickTypes()
void QQmlWorkerScriptModule::defineModule()
{
const char uri[] = "QtQml.WorkerScript";
- qmlRegisterType<QQuickWorkerScript>(uri, 2, 0, "WorkerScript");
+ qmlRegisterTypesAndRevisions<QQuickWorkerScript>(uri, 2);
}
QT_END_NAMESPACE
diff --git a/src/qmlworkerscript/qquickworkerscript_p.h b/src/qmlworkerscript/qquickworkerscript_p.h
index 87cf2e9754..9b5d3587fb 100644
--- a/src/qmlworkerscript/qquickworkerscript_p.h
+++ b/src/qmlworkerscript/qquickworkerscript_p.h
@@ -87,6 +87,7 @@ class Q_AUTOTEST_EXPORT QQuickWorkerScript : public QObject, public QQmlParserSt
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ QML_NAMED_ELEMENT(WorkerScript);
Q_INTERFACES(QQmlParserStatus)
public:
diff --git a/src/quick/handlers/qquickdragaxis_p.h b/src/quick/handlers/qquickdragaxis_p.h
index a4649d5eb9..ef74902122 100644
--- a/src/quick/handlers/qquickdragaxis_p.h
+++ b/src/quick/handlers/qquickdragaxis_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtQml/qqml.h>
#include <private/qtquickglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -61,6 +62,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickDragAxis : public QObject
Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ QML_NAMED_ELEMENT(DragAxis)
+ QML_ADDED_IN_MINOR_VERSION(12)
+ QML_UNCREATABLE("DragAxis is only available as a grouped property of DragHandler.")
public:
QQuickDragAxis();
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp
index 61b66beff4..492897b68b 100644
--- a/src/quick/handlers/qquickdraghandler.cpp
+++ b/src/quick/handlers/qquickdraghandler.cpp
@@ -39,6 +39,7 @@
#include "qquickdraghandler_p.h"
#include <private/qquickwindow_p.h>
+#include <private/qquickmultipointhandler_p_p.h>
#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -228,7 +229,7 @@ void QQuickDragHandler::handlePointerEventImpl(QQuickPointerEvent *event)
accumulatedDragDelta.setY(0);
}
qreal angle = std::atan2(accumulatedDragDelta.y(), accumulatedDragDelta.x()) * 180 / M_PI;
- bool overThreshold = QQuickWindowPrivate::dragOverThreshold(accumulatedDragDelta);
+ bool overThreshold = d_func()->dragOverThreshold(accumulatedDragDelta);
qCDebug(lcDragHandler) << "movement" << accumulatedDragDelta << "angle" << angle << "of point" << point
<< "pressed @" << point->scenePressPosition() << "over threshold?" << overThreshold;
minAngle = qMin(angle, minAngle);
diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h
index e8f47163ed..22d51c78ec 100644
--- a/src/quick/handlers/qquickdraghandler_p.h
+++ b/src/quick/handlers/qquickdraghandler_p.h
@@ -63,6 +63,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickDragHandler : public QQuickMultiPointHandler
Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged REVISION 14)
+ QML_NAMED_ELEMENT(DragHandler)
+ QML_ADDED_IN_MINOR_VERSION(12)
public:
enum SnapMode {
diff --git a/src/quick/handlers/qquickhoverhandler_p.h b/src/quick/handlers/qquickhoverhandler_p.h
index d8e5fc00a1..e4786bfa53 100644
--- a/src/quick/handlers/qquickhoverhandler_p.h
+++ b/src/quick/handlers/qquickhoverhandler_p.h
@@ -62,6 +62,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickHoverHandler : public QQuickSinglePointHandle
{
Q_OBJECT
Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged)
+ QML_NAMED_ELEMENT(HoverHandler)
+ QML_ADDED_IN_MINOR_VERSION(12)
public:
explicit QQuickHoverHandler(QQuickItem *parent = nullptr);
diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp
index a5a867015c..20ad95b0d7 100644
--- a/src/quick/handlers/qquickpinchhandler.cpp
+++ b/src/quick/handlers/qquickpinchhandler.cpp
@@ -43,6 +43,7 @@
#include <private/qsgadaptationlayer_p.h>
#include <private/qquickitem_p.h>
#include <private/qguiapplication_p.h>
+#include <private/qquickmultipointhandler_p_p.h>
#include <private/qquickwindow_p.h>
#include <QEvent>
#include <QMouseEvent>
@@ -338,8 +339,7 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
const QVector2D currentCentroid(centroid().scenePosition());
const QVector2D pressCentroid(centroid().scenePressPosition());
- QStyleHints *styleHints = QGuiApplication::styleHints();
- const int dragThreshold = styleHints->startDragDistance();
+ const int dragThreshold = QQuickPointerHandler::dragThreshold();
const int dragThresholdSquared = dragThreshold * dragThreshold;
double accumulatedCentroidDistance = 0; // Used to detect scale
@@ -399,7 +399,8 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
point->setAccepted(false); // don't stop propagation
setPassiveGrab(point);
}
- if (QQuickWindowPrivate::dragOverThreshold(point))
+ Q_D(QQuickMultiPointHandler);
+ if (d->dragOverThreshold(point))
++numberOfPointsDraggedOverThreshold;
}
diff --git a/src/quick/handlers/qquickpinchhandler_p.h b/src/quick/handlers/qquickpinchhandler_p.h
index cea794f0c8..708c836acf 100644
--- a/src/quick/handlers/qquickpinchhandler_p.h
+++ b/src/quick/handlers/qquickpinchhandler_p.h
@@ -78,6 +78,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler
#endif
Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
+ QML_NAMED_ELEMENT(PinchHandler)
+ QML_ADDED_IN_MINOR_VERSION(12)
public:
explicit QQuickPinchHandler(QQuickItem *parent = nullptr);
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index 12c06aa179..9d4fae1a71 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -113,6 +113,47 @@ void QQuickPointerHandler::setMargin(qreal pointDistanceThreshold)
}
/*!
+ \qmlproperty int PointerHandler::dragThreshold
+ \since 5.15
+
+ The distance in pixels that the user must drag an event point in order to
+ have it treated as a drag gesture.
+
+ The default value depends on the platform and screen resolution.
+ It can be reset back to the default value by setting it to undefined.
+ The behavior when a drag gesture begins varies in different handlers.
+*/
+int QQuickPointerHandler::dragThreshold() const
+{
+ Q_D(const QQuickPointerHandler);
+ if (d->dragThreshold < 0)
+ return qApp->styleHints()->startDragDistance();
+ return d->dragThreshold;
+}
+
+void QQuickPointerHandler::setDragThreshold(int t)
+{
+ Q_D(QQuickPointerHandler);
+ if (d->dragThreshold == t)
+ return;
+
+ if (t > std::numeric_limits<qint16>::max())
+ qWarning() << "drag threshold cannot exceed" << std::numeric_limits<qint16>::max();
+ d->dragThreshold = qint16(t);
+ emit dragThresholdChanged();
+}
+
+void QQuickPointerHandler::resetDragThreshold()
+{
+ Q_D(QQuickPointerHandler);
+ if (d->dragThreshold < 0)
+ return;
+
+ d->dragThreshold = -1;
+ emit dragThresholdChanged();
+}
+
+/*!
Notification that the grab has changed in some way which is relevant to this handler.
The \a grabber (subject) will be the Input Handler whose state is changing,
or null if the state change regards an Item.
@@ -547,4 +588,32 @@ QQuickPointerHandlerPrivate::QQuickPointerHandlerPrivate()
{
}
+template <typename TEventPoint>
+bool QQuickPointerHandlerPrivate::dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint *p) const
+{
+ Q_Q(const QQuickPointerHandler);
+ QStyleHints *styleHints = qApp->styleHints();
+ bool overThreshold = qAbs(d) > q->dragThreshold();
+ const bool dragVelocityLimitAvailable = (styleHints->startDragVelocity() > 0);
+ if (!overThreshold && dragVelocityLimitAvailable) {
+ qreal velocity = qreal(axis == Qt::XAxis ? p->velocity().x() : p->velocity().y());
+ overThreshold |= qAbs(velocity) > styleHints->startDragVelocity();
+ }
+ return overThreshold;
+}
+
+bool QQuickPointerHandlerPrivate::dragOverThreshold(QVector2D delta) const
+{
+ Q_Q(const QQuickPointerHandler);
+ const float threshold = q->dragThreshold();
+ return qAbs(delta.x()) > threshold || qAbs(delta.y()) > threshold;
+}
+
+bool QQuickPointerHandlerPrivate::dragOverThreshold(const QQuickEventPoint *point) const
+{
+ QPointF delta = point->scenePosition() - point->scenePressPosition();
+ return (dragOverThreshold(delta.x(), Qt::XAxis, point) ||
+ dragOverThreshold(delta.y(), Qt::YAxis, point));
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpointerhandler_p.h b/src/quick/handlers/qquickpointerhandler_p.h
index c600e42491..34ae9ce2c2 100644
--- a/src/quick/handlers/qquickpointerhandler_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p.h
@@ -71,6 +71,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandler : public QObject, public QQmlP
Q_PROPERTY(QQuickItem * parent READ parentItem CONSTANT)
Q_PROPERTY(GrabPermissions grabPermissions READ grabPermissions WRITE setGrabPermissions NOTIFY grabPermissionChanged)
Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged)
+ Q_PROPERTY(int dragThreshold READ dragThreshold WRITE setDragThreshold RESET resetDragThreshold NOTIFY dragThresholdChanged REVISION 15)
+
+ QML_NAMED_ELEMENT(PointerHandler)
+ QML_UNCREATABLE("PointerHandler is an abstract base class.")
+ QML_ADDED_IN_MINOR_VERSION(12)
public:
explicit QQuickPointerHandler(QQuickItem *parent = nullptr);
@@ -110,11 +115,16 @@ public:
qreal margin() const;
void setMargin(qreal pointDistanceThreshold);
+ int dragThreshold() const;
+ void setDragThreshold(int t);
+ void resetDragThreshold();
+
Q_SIGNALS:
void enabledChanged();
void activeChanged();
void targetChanged();
void marginChanged();
+ Q_REVISION(15) void dragThresholdChanged();
void grabChanged(QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point);
void grabPermissionChanged();
void canceled(QQuickEventPoint *point);
diff --git a/src/quick/handlers/qquickpointerhandler_p_p.h b/src/quick/handlers/qquickpointerhandler_p_p.h
index 2ea4905643..5727b1ef55 100644
--- a/src/quick/handlers/qquickpointerhandler_p_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p_p.h
@@ -68,9 +68,16 @@ public:
QQuickPointerHandlerPrivate();
+ template<typename TEventPoint>
+ bool dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint *p) const;
+
+ bool dragOverThreshold(QVector2D delta) const;
+ bool dragOverThreshold(const QQuickEventPoint *point) const;
+
QQuickPointerEvent *currentEvent = nullptr;
QQuickItem *target = nullptr;
qreal m_margin = 0;
+ qint16 dragThreshold = -1; // -1 means use the platform default
uint8_t grabPermissions : 8;
bool enabled : 1;
bool active : 1;
diff --git a/src/quick/handlers/qquickpointhandler_p.h b/src/quick/handlers/qquickpointhandler_p.h
index c197cb4f20..42677540a7 100644
--- a/src/quick/handlers/qquickpointhandler_p.h
+++ b/src/quick/handlers/qquickpointhandler_p.h
@@ -59,6 +59,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointHandler : public QQuickSinglePointHandle
{
Q_OBJECT
Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
+ QML_NAMED_ELEMENT(PointHandler)
+ QML_ADDED_IN_MINOR_VERSION(12)
public:
explicit QQuickPointHandler(QQuickItem *parent = nullptr);
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index 7b26adbe6f..272ebe6b63 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -97,13 +97,6 @@ QQuickTapHandler::QQuickTapHandler(QQuickItem *parent)
}
}
-static bool dragOverThreshold(const QQuickEventPoint *point)
-{
- QPointF delta = point->scenePosition() - point->scenePressPosition();
- return (QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point) ||
- QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point));
-}
-
bool QQuickTapHandler::wantsEventPoint(QQuickEventPoint *point)
{
if (!point->pointerEvent()->asPointerMouseEvent() &&
@@ -115,7 +108,7 @@ bool QQuickTapHandler::wantsEventPoint(QQuickEventPoint *point)
// (e.g. DragHandler) gets a chance to take over.
// Don't forget to emit released in case of a cancel.
bool ret = false;
- bool overThreshold = dragOverThreshold(point);
+ bool overThreshold = d_func()->dragOverThreshold(point);
if (overThreshold) {
m_longPressTimer.stop();
m_holdTimer.invalidate();
diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h
index 56e08590b2..07454bccb8 100644
--- a/src/quick/handlers/qquicktaphandler_p.h
+++ b/src/quick/handlers/qquicktaphandler_p.h
@@ -67,6 +67,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTapHandler : public QQuickSinglePointHandler
Q_PROPERTY(qreal longPressThreshold READ longPressThreshold WRITE setLongPressThreshold NOTIFY longPressThresholdChanged)
Q_PROPERTY(GesturePolicy gesturePolicy READ gesturePolicy WRITE setGesturePolicy NOTIFY gesturePolicyChanged)
+ QML_NAMED_ELEMENT(TapHandler)
+ QML_ADDED_IN_MINOR_VERSION(12)
+
public:
enum GesturePolicy {
DragThreshold,
diff --git a/src/quick/handlers/qquickwheelhandler_p.h b/src/quick/handlers/qquickwheelhandler_p.h
index f8d1c00726..26b052c5b3 100644
--- a/src/quick/handlers/qquickwheelhandler_p.h
+++ b/src/quick/handlers/qquickwheelhandler_p.h
@@ -72,6 +72,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWheelHandler : public QQuickSinglePointHandle
Q_PROPERTY(qreal targetScaleMultiplier READ targetScaleMultiplier WRITE setTargetScaleMultiplier NOTIFY targetScaleMultiplierChanged)
Q_PROPERTY(bool targetTransformAroundCursor READ isTargetTransformAroundCursor WRITE setTargetTransformAroundCursor NOTIFY targetTransformAroundCursorChanged)
+ QML_NAMED_ELEMENT(WheelHandler)
+ QML_ADDED_IN_MINOR_VERSION(14)
+
public:
explicit QQuickWheelHandler(QQuickItem *parent = nullptr);
diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h
index cd2977429b..6575caf806 100644
--- a/src/quick/items/context2d/qquickcanvasitem_p.h
+++ b/src/quick/items/context2d/qquickcanvasitem_p.h
@@ -99,6 +99,7 @@ class QQuickCanvasItem : public QQuickItem
Q_PROPERTY(QRectF canvasWindow READ canvasWindow WRITE setCanvasWindow NOTIFY canvasWindowChanged)
Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
Q_PROPERTY(RenderStrategy renderStrategy READ renderStrategy WRITE setRenderStrategy NOTIFY renderStrategyChanged)
+ QML_NAMED_ELEMENT(Canvas)
public:
enum RenderTarget {
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h
index f4194ef13d..678c1361ba 100644
--- a/src/quick/items/qquickaccessibleattached_p.h
+++ b/src/quick/items/qquickaccessibleattached_p.h
@@ -90,6 +90,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAccessibleAttached : public QObject
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged FINAL)
Q_PROPERTY(bool ignored READ ignored WRITE setIgnored NOTIFY ignoredChanged FINAL)
+ QML_NAMED_ELEMENT(Accessible)
+ QML_UNCREATABLE("Accessible is only available via attached properties.")
+ QML_ATTACHED(QQuickAccessibleAttached)
+
public:
Q_ENUMS(QAccessible::Role QAccessible::Event)
STATE_PROPERTY(checkable)
@@ -237,7 +241,6 @@ public:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickAccessibleAttached)
-QML_DECLARE_TYPEINFO(QQuickAccessibleAttached, QML_HAS_ATTACHED_PROPERTIES)
#endif // accessibility
diff --git a/src/quick/items/qquickanchors_p.h b/src/quick/items/qquickanchors_p.h
index c7995cb7a8..e0276549e9 100644
--- a/src/quick/items/qquickanchors_p.h
+++ b/src/quick/items/qquickanchors_p.h
@@ -84,6 +84,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAnchors : public QObject
Q_PROPERTY(QQuickItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
Q_PROPERTY(QQuickItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
Q_PROPERTY(bool alignWhenCentered READ alignWhenCentered WRITE setAlignWhenCentered NOTIFY centerAlignedChanged)
+ QML_ANONYMOUS
public:
QQuickAnchors(QQuickItem *item, QObject *parent=nullptr);
diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h
index 13eae83350..7f2199fd2a 100644
--- a/src/quick/items/qquickanimatedimage_p.h
+++ b/src/quick/items/qquickanimatedimage_p.h
@@ -74,6 +74,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimatedImage : public QQuickImage
// read-only for AnimatedImage
Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged)
+ QML_NAMED_ELEMENT(AnimatedImage)
public:
QQuickAnimatedImage(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
index d36f908c78..30f64e9def 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -92,6 +92,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimatedSprite : public QQuickItem
Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged)
Q_PROPERTY(bool paused READ paused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged)
+ QML_NAMED_ELEMENT(AnimatedSprite)
public:
explicit QQuickAnimatedSprite(QQuickItem *parent = nullptr);
diff --git a/src/quick/items/qquickborderimage_p.h b/src/quick/items/qquickborderimage_p.h
index 61bd26ba83..515edb33da 100644
--- a/src/quick/items/qquickborderimage_p.h
+++ b/src/quick/items/qquickborderimage_p.h
@@ -67,6 +67,7 @@ class Q_AUTOTEST_EXPORT QQuickBorderImage : public QQuickImageBase
Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged)
// read-only for BorderImage
Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged)
+ QML_NAMED_ELEMENT(BorderImage)
public:
QQuickBorderImage(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index 8fe1929a2c..ff4d9b0fd1 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE
class QQuickDragAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
{
Q_DECLARE_PUBLIC(QQuickDragAttached)
+ QML_ANONYMOUS
+
public:
static QQuickDragAttachedPrivate *get(QQuickDragAttached *attached) {
return static_cast<QQuickDragAttachedPrivate *>(QObjectPrivate::get(attached)); }
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index 094070aa2c..9dbaac18f9 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -172,6 +172,10 @@ class Q_AUTOTEST_EXPORT QQuickDrag : public QObject
Q_PROPERTY(qreal threshold READ threshold WRITE setThreshold NOTIFY thresholdChanged RESET resetThreshold)
//### consider drag and drop
+ QML_NAMED_ELEMENT(Drag)
+ QML_UNCREATABLE("Drag is only available via attached properties.")
+ QML_ATTACHED(QQuickDragAttached)
+
public:
QQuickDrag(QObject *parent=nullptr);
~QQuickDrag();
@@ -254,6 +258,9 @@ class QQuickDragAttached : public QObject
Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions WRITE setSupportedActions NOTIFY supportedActionsChanged)
Q_PROPERTY(Qt::DropAction proposedAction READ proposedAction WRITE setProposedAction NOTIFY proposedActionChanged)
Q_PROPERTY(QQuickDrag::DragType dragType READ dragType WRITE setDragType NOTIFY dragTypeChanged)
+
+ QML_ANONYMOUS
+
public:
QQuickDragAttached(QObject *parent);
~QQuickDragAttached();
@@ -316,6 +323,5 @@ Q_SIGNALS:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickDrag)
-QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES)
#endif
diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h
index 2b2ace2eae..ee2deaa97a 100644
--- a/src/quick/items/qquickdroparea_p.h
+++ b/src/quick/items/qquickdroparea_p.h
@@ -80,6 +80,7 @@ class QQuickDropEvent : public QObject
Q_PROPERTY(QString text READ text)
Q_PROPERTY(QList<QUrl> urls READ urls)
Q_PROPERTY(QStringList formats READ formats)
+ QML_ANONYMOUS
public:
QQuickDropEvent(QQuickDropAreaPrivate *d, QDropEvent *event) : d(d), event(event) {}
@@ -125,6 +126,7 @@ class QQuickDropAreaDrag : public QObject
Q_PROPERTY(qreal x READ x NOTIFY positionChanged)
Q_PROPERTY(qreal y READ y NOTIFY positionChanged)
Q_PROPERTY(QObject *source READ source NOTIFY sourceChanged)
+ QML_ANONYMOUS
public:
QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent = 0);
~QQuickDropAreaDrag();
@@ -151,6 +153,7 @@ class Q_AUTOTEST_EXPORT QQuickDropArea : public QQuickItem
Q_PROPERTY(bool containsDrag READ containsDrag NOTIFY containsDragChanged)
Q_PROPERTY(QStringList keys READ keys WRITE setKeys NOTIFY keysChanged)
Q_PROPERTY(QQuickDropAreaDrag *drag READ drag CONSTANT)
+ QML_NAMED_ELEMENT(DropArea)
public:
QQuickDropArea(QQuickItem *parent=0);
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 1a3737091f..1d2ffefc9d 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -84,6 +84,7 @@ class QQuickKeyEvent : public QObject
Q_PROPERTY(int count READ count CONSTANT)
Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+ QML_ANONYMOUS
public:
QQuickKeyEvent()
@@ -135,6 +136,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseEvent : public QObject
Q_PROPERTY(bool isClick READ isClick CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
Q_PROPERTY(int flags READ flags CONSTANT REVISION 11)
+ QML_ANONYMOUS
public:
QQuickMouseEvent()
@@ -201,6 +203,7 @@ class QQuickWheelEvent : public QObject
Q_PROPERTY(int modifiers READ modifiers CONSTANT)
Q_PROPERTY(bool inverted READ inverted CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+ QML_ANONYMOUS
public:
QQuickWheelEvent()
@@ -245,6 +248,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickCloseEvent : public QObject
{
Q_OBJECT
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+ QML_ANONYMOUS
public:
QQuickCloseEvent() {}
@@ -271,6 +275,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventPoint : public QObject
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
Q_PROPERTY(QObject *exclusiveGrabber READ exclusiveGrabber WRITE setExclusiveGrabber)
+ QML_NAMED_ELEMENT(EventPoint)
+ QML_UNCREATABLE("EventPoint is only available as a member of PointerEvent.")
+ QML_ADDED_IN_MINOR_VERSION(12)
+
public:
enum State {
Pressed = Qt::TouchPointPressed,
@@ -362,6 +370,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventTouchPoint : public QQuickEventPoint
Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters)
Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId)
+ QML_NAMED_ELEMENT(EventTouchPoint)
+ QML_UNCREATABLE("EventTouchPoint is only available as a member of PointerEvent.")
+ QML_ADDED_IN_MINOR_VERSION(12)
+
public:
QQuickEventTouchPoint(QQuickPointerTouchEvent *parent);
@@ -391,6 +403,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerEvent : public QObject
Q_PROPERTY(Qt::MouseButtons button READ button CONSTANT)
Q_PROPERTY(Qt::MouseButtons buttons READ buttons CONSTANT)
+ QML_NAMED_ELEMENT(PointerEvent)
+ QML_UNCREATABLE("PointerEvent is only available as a parameter of several signals in PointerHandler")
+ QML_ADDED_IN_MINOR_VERSION(12)
+
public:
QQuickPointerEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
: QObject(parent)
@@ -482,6 +498,11 @@ protected:
class Q_QUICK_PRIVATE_EXPORT QQuickPointerMouseEvent : public QQuickSinglePointEvent
{
Q_OBJECT
+
+ QML_NAMED_ELEMENT(PointerMouseEvent)
+ QML_UNCREATABLE("PointerMouseEvent is only available as a parameter of several signals in PointerHandler")
+ QML_ADDED_IN_MINOR_VERSION(12)
+
public:
QQuickPointerMouseEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
: QQuickSinglePointEvent(parent, device) { }
@@ -502,6 +523,11 @@ public:
class Q_QUICK_PRIVATE_EXPORT QQuickPointerTouchEvent : public QQuickPointerEvent
{
Q_OBJECT
+
+ QML_NAMED_ELEMENT(PointerTouchEvent)
+ QML_UNCREATABLE("PointerTouchEvent is only available as a parameter of several signals in PointerHandler")
+ QML_ADDED_IN_MINOR_VERSION(12)
+
public:
QQuickPointerTouchEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
: QQuickPointerEvent(parent, device)
@@ -623,6 +649,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerDevice : public QObject
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT)
+ QML_NAMED_ELEMENT(PointerDevice)
+ QML_UNCREATABLE("PointerDevice is only available as a property of PointerEvent.")
+ QML_ADDED_IN_MINOR_VERSION(12)
+
public:
enum DeviceType : qint16 {
UnknownDevice = 0x0000,
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index c54ed5ce71..2d8d4a5e9a 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -114,6 +114,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
Q_PROPERTY(QQmlListProperty<QObject> flickableData READ flickableData)
Q_PROPERTY(QQmlListProperty<QQuickItem> flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
+ QML_NAMED_ELEMENT(Flickable)
public:
QQuickFlickable(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h
index 835c54170f..1ff55dae90 100644
--- a/src/quick/items/qquickflickable_p_p.h
+++ b/src/quick/items/qquickflickable_p_p.h
@@ -284,6 +284,7 @@ class QQuickFlickableVisibleArea : public QObject
Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged)
Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged)
Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged)
+ QML_ANONYMOUS
public:
QQuickFlickableVisibleArea(QQuickFlickable *parent=nullptr);
diff --git a/src/quick/items/qquickflipable_p.h b/src/quick/items/qquickflipable_p.h
index d70cd02d35..42c632a33c 100644
--- a/src/quick/items/qquickflipable_p.h
+++ b/src/quick/items/qquickflipable_p.h
@@ -71,6 +71,7 @@ class Q_AUTOTEST_EXPORT QQuickFlipable : public QQuickItem
Q_PROPERTY(QQuickItem *front READ front WRITE setFront NOTIFY frontChanged)
Q_PROPERTY(QQuickItem *back READ back WRITE setBack NOTIFY backChanged)
Q_PROPERTY(Side side READ side NOTIFY sideChanged)
+ QML_NAMED_ELEMENT(Flipable)
//### flipAxis
//### flipRotation
public:
diff --git a/src/quick/items/qquickfocusscope_p.h b/src/quick/items/qquickfocusscope_p.h
index af750fc127..c32fa93cd9 100644
--- a/src/quick/items/qquickfocusscope_p.h
+++ b/src/quick/items/qquickfocusscope_p.h
@@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE
class Q_AUTOTEST_EXPORT QQuickFocusScope : public QQuickItem
{
Q_OBJECT
+ QML_NAMED_ELEMENT(FocusScope)
public:
QQuickFocusScope(QQuickItem *parent=nullptr);
virtual ~QQuickFocusScope();
diff --git a/src/quick/items/qquickgraphicsinfo_p.h b/src/quick/items/qquickgraphicsinfo_p.h
index f0a18c29cc..066a419c37 100644
--- a/src/quick/items/qquickgraphicsinfo_p.h
+++ b/src/quick/items/qquickgraphicsinfo_p.h
@@ -75,6 +75,11 @@ class QQuickGraphicsInfo : public QObject
Q_PROPERTY(OpenGLContextProfile profile READ profile NOTIFY profileChanged FINAL)
Q_PROPERTY(RenderableType renderableType READ renderableType NOTIFY renderableTypeChanged FINAL)
+ QML_NAMED_ELEMENT(GraphicsInfo)
+ QML_ADDED_IN_MINOR_VERSION(8)
+ QML_UNCREATABLE("GraphicsInfo is only available via attached properties.")
+ QML_ATTACHED(QQuickGraphicsInfo)
+
public:
enum GraphicsApi {
Unknown = QSGRendererInterface::Unknown,
@@ -168,6 +173,4 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPEINFO(QQuickGraphicsInfo, QML_HAS_ATTACHED_PROPERTIES)
-
#endif // QQUICKGRAPHICSINFO_P_H
diff --git a/src/quick/items/qquickgridview_p.h b/src/quick/items/qquickgridview_p.h
index 7daeaf41a1..9072e5f269 100644
--- a/src/quick/items/qquickgridview_p.h
+++ b/src/quick/items/qquickgridview_p.h
@@ -73,6 +73,8 @@ class Q_AUTOTEST_EXPORT QQuickGridView : public QQuickItemView
Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
Q_CLASSINFO("DefaultProperty", "data")
+ QML_NAMED_ELEMENT(GridView)
+ QML_ATTACHED(QQuickGridViewAttached)
public:
enum Flow {
@@ -136,6 +138,5 @@ public:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickGridView)
-QML_DECLARE_TYPEINFO(QQuickGridView, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKGRIDVIEW_P_H
diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h
index 257cde5313..f7e652cdcc 100644
--- a/src/quick/items/qquickimage_p.h
+++ b/src/quick/items/qquickimage_p.h
@@ -68,6 +68,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickImage : public QQuickImageBase
Q_PROPERTY(VAlignment verticalAlignment READ verticalAlignment WRITE setVerticalAlignment NOTIFY verticalAlignmentChanged)
Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged REVISION 3)
Q_PROPERTY(bool autoTransform READ autoTransform WRITE setAutoTransform NOTIFY autoTransformChanged REVISION 5)
+ QML_NAMED_ELEMENT(Image)
public:
QQuickImage(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickimagebase_p.h b/src/quick/items/qquickimagebase_p.h
index 8cd59c8cea..d1d01ad27d 100644
--- a/src/quick/items/qquickimagebase_p.h
+++ b/src/quick/items/qquickimagebase_p.h
@@ -71,6 +71,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickImageBase : public QQuickImplicitSizeItem
Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged REVISION 14)
Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged REVISION 14)
+ QML_NAMED_ELEMENT(ImageBase);
+ QML_ADDED_IN_MINOR_VERSION(14)
+ QML_UNCREATABLE("ImageBase is an abstract base class.")
+
public:
QQuickImageBase(QQuickItem *parent=nullptr);
~QQuickImageBase();
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index 394a5adb8c..8c04ced11b 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -58,6 +58,7 @@ class QQuickTransformPrivate;
class Q_QUICK_EXPORT QQuickTransform : public QObject
{
Q_OBJECT
+ QML_ANONYMOUS
public:
explicit QQuickTransform(QObject *parent = nullptr);
~QQuickTransform() override;
@@ -150,6 +151,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
Q_CLASSINFO("DefaultProperty", "data")
Q_CLASSINFO("qt_QmlJSWrapperFactoryMethod", "_q_createJSWrapper(QV4::ExecutionEngine*)")
+ QML_NAMED_ELEMENT(Item)
public:
enum Flag {
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 3e8feec4bf..7c3325fd90 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -152,6 +152,7 @@ class QQuickItemLayer : public QObject, public QQuickItemChangeListener
Q_PROPERTY(QQmlComponent *effect READ effect WRITE setEffect NOTIFY effectChanged)
Q_PROPERTY(QQuickShaderEffectSource::TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged)
Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged)
+ QML_ANONYMOUS
public:
QQuickItemLayer(QQuickItem *item);
@@ -715,6 +716,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickKeyNavigationAttached : public QObject, publi
Q_PROPERTY(QQuickItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged)
Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
+ QML_NAMED_ELEMENT(KeyNavigation)
+ QML_UNCREATABLE("KeyNavigation is only available via attached properties.")
+ QML_ATTACHED(QQuickKeyNavigationAttached)
+
public:
QQuickKeyNavigationAttached(QObject * = nullptr);
@@ -760,6 +765,10 @@ class QQuickLayoutMirroringAttached : public QObject
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged)
+ QML_NAMED_ELEMENT(LayoutMirroring)
+ QML_UNCREATABLE("LayoutMirroring is only available via attached properties.")
+ QML_ATTACHED(QQuickLayoutMirroringAttached)
+
public:
explicit QQuickLayoutMirroringAttached(QObject *parent = nullptr);
@@ -784,6 +793,11 @@ class QQuickEnterKeyAttached : public QObject
Q_OBJECT
Q_PROPERTY(Qt::EnterKeyType type READ type WRITE setType NOTIFY typeChanged)
+ QML_NAMED_ELEMENT(EnterKey)
+ QML_UNCREATABLE("EnterKey is only available via attached properties")
+ QML_ADDED_IN_MINOR_VERSION(6)
+ QML_ATTACHED(QQuickEnterKeyAttached)
+
public:
explicit QQuickEnterKeyAttached(QObject *parent = nullptr);
@@ -829,6 +843,10 @@ class QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
Q_PROPERTY(QQmlListProperty<QQuickItem> forwardTo READ forwardTo)
Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
+ QML_NAMED_ELEMENT(Keys)
+ QML_UNCREATABLE("Keys is only available via attached properties")
+ QML_ATTACHED(QQuickKeysAttached)
+
public:
QQuickKeysAttached(QObject *parent=nullptr);
~QQuickKeysAttached() override;
@@ -984,12 +1002,8 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickItemLayer)
#endif
QML_DECLARE_TYPE(QQuickKeysAttached)
-QML_DECLARE_TYPEINFO(QQuickKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(QQuickKeyNavigationAttached)
-QML_DECLARE_TYPEINFO(QQuickKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(QQuickLayoutMirroringAttached)
-QML_DECLARE_TYPEINFO(QQuickLayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(QQuickEnterKeyAttached)
-QML_DECLARE_TYPEINFO(QQuickEnterKeyAttached, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKITEM_P_H
diff --git a/src/quick/items/qquickitemanimation_p.h b/src/quick/items/qquickitemanimation_p.h
index b803455f12..28c18c874d 100644
--- a/src/quick/items/qquickitemanimation_p.h
+++ b/src/quick/items/qquickitemanimation_p.h
@@ -66,6 +66,7 @@ class Q_AUTOTEST_EXPORT QQuickParentAnimation : public QQuickAnimationGroup
Q_PROPERTY(QQuickItem *target READ target WRITE setTargetObject NOTIFY targetChanged)
Q_PROPERTY(QQuickItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged)
Q_PROPERTY(QQuickItem *via READ via WRITE setVia NOTIFY viaChanged)
+ QML_NAMED_ELEMENT(ParentAnimation)
public:
QQuickParentAnimation(QObject *parent=nullptr);
@@ -100,6 +101,7 @@ class Q_AUTOTEST_EXPORT QQuickAnchorAnimation : public QQuickAbstractAnimation
Q_PROPERTY(QQmlListProperty<QQuickItem> targets READ targets)
Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
+ QML_NAMED_ELEMENT(AnchorAnimation)
public:
QQuickAnchorAnimation(QObject *parent=nullptr);
@@ -143,6 +145,7 @@ class Q_AUTOTEST_EXPORT QQuickPathAnimation : public QQuickAbstractAnimation
Q_PROPERTY(int orientationEntryDuration READ orientationEntryDuration WRITE setOrientationEntryDuration NOTIFY orientationEntryDurationChanged)
Q_PROPERTY(int orientationExitDuration READ orientationExitDuration WRITE setOrientationExitDuration NOTIFY orientationExitDurationChanged)
Q_PROPERTY(qreal endRotation READ endRotation WRITE setEndRotation NOTIFY endRotationChanged)
+ QML_NAMED_ELEMENT(PathAnimation)
public:
QQuickPathAnimation(QObject *parent=nullptr);
diff --git a/src/quick/items/qquickitemgrabresult.h b/src/quick/items/qquickitemgrabresult.h
index 3dc10e2d75..c92a8c52f4 100644
--- a/src/quick/items/qquickitemgrabresult.h
+++ b/src/quick/items/qquickitemgrabresult.h
@@ -45,6 +45,7 @@
#include <QtCore/QUrl>
#include <QtGui/QImage>
#include <QtQml/QJSValue>
+#include <QtQml/qqml.h>
#include <QtQuick/qtquickglobal.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,8 @@ class Q_QUICK_EXPORT QQuickItemGrabResult : public QObject
Q_PROPERTY(QImage image READ image CONSTANT)
Q_PROPERTY(QUrl url READ url CONSTANT)
+ QML_ANONYMOUS
+
public:
QImage image() const;
QUrl url() const;
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 7bc6eefe0a..d65a5cf6ba 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -175,330 +175,218 @@ static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject
return QQmlPrivate::IncompatibleObject;
}
-static void qt_quickitems_defineModule(const char *uri, int major, int minor)
+static void qt_quickitems_defineModule()
{
+ const char *uri = "QtQuick";
+ const int major = 2;
+
QQmlPrivate::RegisterAutoParent autoparent = { 0, &qquickitem_autoParent };
QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent);
- // Register the latest version, even if there are no new types or new revisions for existing types yet.
- qmlRegisterModule(uri, 2, QT_VERSION_MINOR);
-
-#if !QT_CONFIG(quick_animatedimage)
- qmlRegisterTypeNotAvailable(uri,major,minor,"AnimatedImage", QCoreApplication::translate("QQuickAnimatedImage","Qt was built without support for QMovie"));
-#else
- qmlRegisterType<QQuickAnimatedImage>(uri,major,minor,"AnimatedImage");
-#endif
- qmlRegisterType<QQuickBorderImage>(uri,major,minor,"BorderImage");
- qmlRegisterType<QQuickFlickable>(uri,major,minor,"Flickable");
-#if QT_CONFIG(quick_flipable)
- qmlRegisterType<QQuickFlipable>(uri,major,minor,"Flipable");
-#endif
-// qmlRegisterType<QQuickFocusPanel>(uri,major,minor,"FocusPanel");
- qmlRegisterType<QQuickFocusScope>(uri,major,minor,"FocusScope");
- qmlRegisterType<QQuickGradient>(uri,major,minor,"Gradient");
- qmlRegisterType<QQuickGradientStop>(uri,major,minor,"GradientStop");
-#if QT_CONFIG(quick_positioners)
- qmlRegisterType<QQuickColumn>(uri,major,minor,"Column");
- qmlRegisterType<QQuickFlow>(uri,major,minor,"Flow");
- qmlRegisterType<QQuickGrid>(uri,major,minor,"Grid");
- qmlRegisterUncreatableType<QQuickBasePositioner>(uri,major,minor,"Positioner",
- QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
- qmlRegisterType<QQuickRow>(uri,major,minor,"Row");
-#endif
-#if QT_CONFIG(quick_gridview)
- qmlRegisterType<QQuickGridView>(uri,major,minor,"GridView");
-#endif
- qmlRegisterType<QQuickImage>(uri,major,minor,"Image");
- qmlRegisterType<QQuickItem>(uri,major,minor,"Item");
-#if QT_CONFIG(quick_listview)
- qmlRegisterType<QQuickListView>(uri,major,minor,"ListView");
- qmlRegisterType<QQuickViewSection>(uri,major,minor,"ViewSection");
-#endif
- qmlRegisterType<QQuickLoader>(uri,major,minor,"Loader");
- qmlRegisterType<QQuickMouseArea>(uri,major,minor,"MouseArea");
-#if QT_CONFIG(quick_path)
- qmlRegisterType<QQuickPath>(uri,major,minor,"Path");
- qmlRegisterType<QQuickPathAttribute>(uri,major,minor,"PathAttribute");
- qmlRegisterType<QQuickPathCubic>(uri,major,minor,"PathCubic");
- qmlRegisterType<QQuickPathLine>(uri,major,minor,"PathLine");
- qmlRegisterType<QQuickPathPercent>(uri,major,minor,"PathPercent");
- qmlRegisterType<QQuickPathQuad>(uri,major,minor,"PathQuad");
- qmlRegisterType<QQuickPathCatmullRomCurve>("QtQuick",2,0,"PathCurve");
- qmlRegisterType<QQuickPathArc>("QtQuick",2,0,"PathArc");
- qmlRegisterType<QQuickPathSvg>("QtQuick",2,0,"PathSvg");
- qmlRegisterType<QQuickPath, 14>(uri, 2, 14, "Path");
- qmlRegisterType<QQuickPathPolyline>("QtQuick", 2, 14, "PathPolyline");
- qmlRegisterType<QQuickPathMultiline>("QtQuick", 2, 14, "PathMultiline");
-#endif
-#if QT_CONFIG(quick_pathview)
- qmlRegisterType<QQuickPathView>(uri,major,minor,"PathView");
-#endif
- qmlRegisterType<QQuickRectangle>(uri,major,minor,"Rectangle");
-#if QT_CONFIG(quick_repeater)
- qmlRegisterType<QQuickRepeater>(uri,major,minor,"Repeater");
-#endif
- qmlRegisterType<QQuickTranslate>(uri,major,minor,"Translate");
- qmlRegisterType<QQuickRotation>(uri,major,minor,"Rotation");
- qmlRegisterType<QQuickScale>(uri,major,minor,"Scale");
- qmlRegisterType<QQuickMatrix4x4>(uri,2,3,"Matrix4x4");
- qmlRegisterType<QQuickText>(uri,major,minor,"Text");
- qmlRegisterType<QQuickTextEdit>(uri,major,minor,"TextEdit");
- qmlRegisterType<QQuickTextEdit,1>(uri,2,1,"TextEdit");
- qmlRegisterType<QQuickTextInput>(uri,major,minor,"TextInput");
- qmlRegisterType<QQuickTextInput,2>(uri,2,2,"TextInput");
- qmlRegisterType<QQuickTextInput,4>(uri,2,4,"TextInput");
- qmlRegisterAnonymousType<QQuickItemGrabResult>(uri, major);
-#if QT_CONFIG(quick_shadereffect)
- qmlRegisterAnonymousType<QQuickItemLayer>(uri, major);
-#endif
- qmlRegisterAnonymousType<QQuickAnchors>(uri, major);
- qmlRegisterAnonymousType<QQuickKeyEvent>(uri, major);
- qmlRegisterAnonymousType<QQuickMouseEvent>(uri, major);
- qmlRegisterAnonymousType<QQuickWheelEvent>(uri, major);
- qmlRegisterAnonymousType<QQuickCloseEvent>(uri, major);
- qmlRegisterAnonymousType<QQuickTransform>(uri, major);
-#if QT_CONFIG(quick_path)
- qmlRegisterAnonymousType<QQuickPathElement>(uri, major);
- qmlRegisterAnonymousType<QQuickCurve>(uri, major);
-#endif
- qmlRegisterAnonymousType<QQuickScaleGrid>(uri, major);
- qmlRegisterAnonymousType<QQuickTextLine>(uri, major);
- qmlRegisterAnonymousType<QQuickPen>(uri, major);
- qmlRegisterAnonymousType<QQuickFlickableVisibleArea>(uri, major);
qRegisterMetaType<QQuickAnchorLine>("QQuickAnchorLine");
+ qRegisterMetaType<QPointingDeviceUniqueId>("QPointingDeviceUniqueId");
+ qRegisterMetaType<QQuickHandlerPoint>();
- qmlRegisterAnonymousType<QQuickTextDocument>(uri, major);
-
-
- qmlRegisterUncreatableType<QQuickKeyNavigationAttached>(uri,major,minor,"KeyNavigation",QQuickKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
- qmlRegisterUncreatableType<QQuickKeysAttached>(uri,major,minor,"Keys",QQuickKeysAttached::tr("Keys is only available via attached properties"));
- qmlRegisterUncreatableType<QQuickLayoutMirroringAttached>(uri,major,minor,"LayoutMirroring", QQuickLayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties"));
-#if QT_CONFIG(quick_viewtransitions)
- qmlRegisterUncreatableType<QQuickViewTransitionAttached>(uri,major,minor,"ViewTransition",QQuickViewTransitionAttached::tr("ViewTransition is only available via attached properties"));
-#endif
+ // Register the latest version, even if there are no new types or new revisions for existing types yet.
+ qmlRegisterModule(uri, major, QT_VERSION_MINOR);
+
+ // Core QtQuick types
+ qmlRegisterTypesAndRevisions<
+ QPointingDeviceUniqueIdForeign,
+ QQuickAnchorAnimation,
+ QQuickAnchorChanges,
+ QQuickAnchors,
+ QQuickAnchorSet,
+ QQuickBorderImage,
+ QQuickEnterKeyAttached,
+ QQuickEventPoint,
+ QQuickEventTouchPoint,
+ QQuickFlickable,
+ QQuickFlickableVisibleArea,
+ QQuickFocusScope,
+ QQuickGradient,
+ QQuickGradientStop,
+ QQuickGraphicsInfo,
+ QQuickImage,
+ QQuickImageBase,
+ QQuickItem,
+ QQuickItemGrabResult,
+ QQuickKeyNavigationAttached,
+ QQuickKeysAttached,
+ QQuickLayoutMirroringAttached,
+ QQuickLoader,
+ QQuickMatrix4x4,
+ QQuickMouseArea,
+ QQuickMultiPointTouchArea,
+ QQuickPaintedItem,
+ QQuickParentAnimation,
+ QQuickParentChange,
+ QQuickPen,
+ QQuickPinch,
+ QQuickPinchArea,
+ QQuickPointerDevice,
+ QQuickRectangle,
+ QQuickRotation,
+ QQuickScale,
+ QQuickScaleGrid,
+ QQuickTouchPoint,
+ QQuickTransform,
+ QQuickTranslate
+ >(uri, major);
+
+ // text-related types
+ qmlRegisterTypesAndRevisions<
+ QQuickText,
+ QQuickTextDocument,
+ QQuickTextEdit,
+ QQuickTextInput,
+ QQuickTextLine
+ >(uri, major);
+
+ // events
+ qmlRegisterTypesAndRevisions<
+ QQuickCloseEvent,
+ QQuickGrabGestureEvent,
+ QQuickKeyEvent,
+ QQuickMouseEvent,
+ QQuickPinchEvent,
+ QQuickPointerEvent,
+ QQuickPointerMouseEvent,
+ QQuickPointerTouchEvent,
+ QQuickWheelEvent
+ >(uri, major);
- qmlRegisterType<QQuickPinchArea>(uri,major,minor,"PinchArea");
- qmlRegisterType<QQuickPinch>(uri,major,minor,"Pinch");
- qmlRegisterAnonymousType<QQuickPinchEvent>(uri, major);
+ // Input Handlers are part of QtQuick, not a separate module, since 5.12
+ qmlRegisterTypesAndRevisions<
+ QQuickDragHandler,
+ QQuickHoverHandler,
+ QQuickPinchHandler,
+ QQuickPointerHandler,
+ QQuickPointHandler,
+ QQuickTapHandler
+ >(uri, major);
-#if QT_CONFIG(quick_shadereffect)
- qmlRegisterType<QQuickShaderEffectSource>("QtQuick", 2, 0, "ShaderEffectSource");
- qmlRegisterUncreatableType<QQuickShaderEffectMesh>("QtQuick", 2, 0, "ShaderEffectMesh", QQuickShaderEffectMesh::tr("Cannot create instance of abstract class ShaderEffectMesh."));
- qmlRegisterType<QQuickGridMesh>("QtQuick", 2, 0, "GridMesh");
- qmlRegisterType<QQuickShaderEffect>("QtQuick", 2, 0, "ShaderEffect");
+#if QT_CONFIG(accessibility)
+ qmlRegisterTypesAndRevisions<QQuickAccessibleAttached>(uri, major);
#endif
- qmlRegisterUncreatableType<QQuickPaintedItem>("QtQuick", 2, 0, "PaintedItem", QQuickPaintedItem::tr("Cannot create instance of abstract class PaintedItem"));
-
-#if QT_CONFIG(quick_canvas)
- qmlRegisterType<QQuickCanvasItem>("QtQuick", 2, 0, "Canvas");
+#if QT_CONFIG(opengl)
+ qmlRegisterTypesAndRevisions<QQuickOpenGLInfo>(uri, major);
#endif
-#if QT_CONFIG(quick_sprite)
- qmlRegisterType<QQuickSprite>("QtQuick", 2, 0, "Sprite");
- qmlRegisterType<QQuickAnimatedSprite>("QtQuick", 2, 0, "AnimatedSprite");
- qmlRegisterType<QQuickSpriteSequence>("QtQuick", 2, 0, "SpriteSequence");
+#if QT_CONFIG(quick_animatedimage)
+ qmlRegisterTypesAndRevisions<QQuickAnimatedImage>(uri, major);
+#else
+ qmlRegisterTypeNotAvailable(
+ uri, major, 15, "AnimatedImage",
+ QCoreApplication::translate("QQuickAnimatedImage",
+ "Qt was built without support for QMovie"));
#endif
- qmlRegisterType<QQuickParentChange>(uri, major, minor,"ParentChange");
- qmlRegisterType<QQuickAnchorChanges>(uri, major, minor,"AnchorChanges");
- qmlRegisterAnonymousType<QQuickAnchorSet>(uri, major);
- qmlRegisterType<QQuickAnchorAnimation>(uri, major, minor,"AnchorAnimation");
- qmlRegisterType<QQuickParentAnimation>(uri, major, minor,"ParentAnimation");
-#if QT_CONFIG(quick_path)
- qmlRegisterType<QQuickPathAnimation>("QtQuick",2,0,"PathAnimation");
- qmlRegisterType<QQuickPathInterpolator>("QtQuick",2,0,"PathInterpolator");
+#if QT_CONFIG(quick_canvas)
+ qmlRegisterTypesAndRevisions<QQuickCanvasItem>(uri, major);
#endif
#if QT_CONFIG(quick_draganddrop)
- qmlRegisterType<QQuickDropArea>("QtQuick", 2, 0, "DropArea");
- qmlRegisterAnonymousType<QQuickDropEvent>(uri, 2);
- qmlRegisterAnonymousType<QQuickDropAreaDrag>(uri, 2);
- qmlRegisterUncreatableType<QQuickDrag>("QtQuick", 2, 0, "Drag", QQuickDragAttached::tr("Drag is only available via attached properties"));
-#endif
-
- qmlRegisterType<QQuickMultiPointTouchArea>("QtQuick", 2, 0, "MultiPointTouchArea");
- qmlRegisterType<QQuickTouchPoint>("QtQuick", 2, 0, "TouchPoint");
- qmlRegisterUncreatableType<QQuickGrabGestureEvent>(uri,major,minor, "GestureEvent",
- QQuickMouseEvent::tr("GestureEvent is only available in the context of handling the gestureStarted signal from MultiPointTouchArea"));
-
-#if QT_CONFIG(accessibility)
- qmlRegisterUncreatableType<QQuickAccessibleAttached>("QtQuick", 2, 0, "Accessible",QQuickAccessibleAttached::tr("Accessible is only available via attached properties"));
-#endif
-
- qmlRegisterType<QQuickItem, 1>(uri, 2, 1,"Item");
-#if QT_CONFIG(quick_positioners)
- qmlRegisterType<QQuickGrid, 1>(uri, 2, 1, "Grid");
-#endif
-#if QT_CONFIG(quick_itemview)
- const char *itemViewName = "ItemView";
- const QString itemViewMessage = QQuickItemView::tr("ItemView is an abstract base class");
- qmlRegisterUncreatableType<QQuickItemView, 1>(uri, 2, 1, itemViewName, itemViewMessage);
- qmlRegisterUncreatableType<QQuickItemView, 3>(uri, 2, 3, itemViewName, itemViewMessage);
+ qmlRegisterTypesAndRevisions<
+ QQuickDropEvent,
+ QQuickDrag,
+ QQuickDropArea,
+ QQuickDropAreaDrag,
+ QQuickDragAttached,
+ QQuickDragAxis
+ >(uri, major);
#endif
-#if QT_CONFIG(quick_listview)
- qmlRegisterType<QQuickListView, 1>(uri, 2, 1, "ListView");
-#endif
-#if QT_CONFIG(quick_gridview)
- qmlRegisterType<QQuickGridView, 1>(uri, 2, 1, "GridView");
-#endif
- qmlRegisterType<QQuickTextEdit, 1>(uri, 2, 1, "TextEdit");
-
- qmlRegisterType<QQuickText, 2>(uri, 2, 2, "Text");
- qmlRegisterType<QQuickTextEdit, 2>(uri, 2, 2, "TextEdit");
-
- qmlRegisterType<QQuickText, 3>(uri, 2, 3, "Text");
- qmlRegisterType<QQuickTextEdit, 3>(uri, 2, 3, "TextEdit");
- qmlRegisterType<QQuickImage, 3>(uri, 2, 3,"Image");
- qmlRegisterType<QQuickItem, 4>(uri, 2, 4, "Item");
-#if QT_CONFIG(quick_listview)
- qmlRegisterType<QQuickListView, 4>(uri, 2, 4, "ListView");
-#endif
- qmlRegisterType<QQuickMouseArea, 4>(uri, 2, 4, "MouseArea");
-#if QT_CONFIG(quick_shadereffect)
- qmlRegisterType<QQuickShaderEffect, 4>(uri, 2, 4, "ShaderEffect");
-#endif
-
-#if QT_CONFIG(opengl)
- qmlRegisterUncreatableType<QQuickOpenGLInfo>(uri, 2, 4,"OpenGLInfo", QQuickOpenGLInfo::tr("OpenGLInfo is only available via attached properties"));
+#if QT_CONFIG(quick_flipable)
+ qmlRegisterTypesAndRevisions<QQuickFlipable>(uri, major);
#endif
- qmlRegisterType<QQuickPinchArea, 5>(uri, 2, 5,"PinchArea");
- qmlRegisterType<QQuickImage, 5>(uri, 2, 5,"Image");
- qmlRegisterType<QQuickMouseArea, 5>(uri, 2, 5, "MouseArea");
- qmlRegisterType<QQuickText, 6>(uri, 2, 6, "Text");
- qmlRegisterType<QQuickTextEdit, 6>(uri, 2, 6, "TextEdit");
- qmlRegisterType<QQuickTextInput, 6>(uri, 2, 6, "TextInput");
#if QT_CONFIG(quick_positioners)
- qmlRegisterUncreatableType<QQuickBasePositioner, 6>(uri, 2, 6, "Positioner",
- QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
- qmlRegisterType<QQuickColumn, 6>(uri, 2, 6, "Column");
- qmlRegisterType<QQuickRow, 6>(uri, 2, 6, "Row");
- qmlRegisterType<QQuickGrid, 6>(uri, 2, 6, "Grid");
- qmlRegisterType<QQuickFlow, 6>(uri, 2, 6, "Flow");
-#endif
- qmlRegisterUncreatableType<QQuickEnterKeyAttached, 6>(uri, 2, 6, "EnterKey",
- QQuickEnterKeyAttached::tr("EnterKey is only available via attached properties"));
-#if QT_CONFIG(quick_shadereffect)
- qmlRegisterType<QQuickShaderEffectSource, 6>(uri, 2, 6, "ShaderEffectSource");
+ qmlRegisterTypesAndRevisions<
+ QQuickBasePositioner,
+ QQuickColumn,
+ QQuickFlow,
+ QQuickGrid,
+ QQuickRow
+ >(uri, major);
#endif
- qmlRegisterType<QQuickItem, 7>(uri, 2, 7, "Item");
-#if QT_CONFIG(quick_listview)
- qmlRegisterType<QQuickListView, 7>(uri, 2, 7, "ListView");
-#endif
#if QT_CONFIG(quick_gridview)
- qmlRegisterType<QQuickGridView, 7>(uri, 2, 7, "GridView");
-#endif
- qmlRegisterType<QQuickTextInput, 7>(uri, 2, 7, "TextInput");
- qmlRegisterType<QQuickTextEdit, 7>(uri, 2, 7, "TextEdit");
-#if QT_CONFIG(quick_pathview)
- qmlRegisterType<QQuickPathView, 7>(uri, 2, 7, "PathView");
+ qmlRegisterTypesAndRevisions<QQuickGridView>(uri, major);
#endif
+
#if QT_CONFIG(quick_itemview)
- qmlRegisterUncreatableType<QQuickItemView, 7>(uri, 2, 7, itemViewName, itemViewMessage);
+ qmlRegisterTypesAndRevisions<QQuickItemView>(uri, major);
#endif
- qmlRegisterUncreatableType<QQuickMouseEvent, 7>(uri, 2, 7, nullptr, QQuickMouseEvent::tr("MouseEvent is only available within handlers in MouseArea"));
-
- qmlRegisterUncreatableType<QQuickGraphicsInfo>(uri, 2, 8,"GraphicsInfo", QQuickGraphicsInfo::tr("GraphicsInfo is only available via attached properties"));
-#if QT_CONFIG(quick_shadereffect)
- qmlRegisterType<QQuickBorderImageMesh>("QtQuick", 2, 8, "BorderImageMesh");
+#if QT_CONFIG(quick_listview)
+ qmlRegisterTypesAndRevisions<
+ QQuickViewSection,
+ QQuickListView
+ >(uri, major);
#endif
- qmlRegisterType<QQuickFlickable, 9>(uri, 2, 9, "Flickable");
- qmlRegisterType<QQuickMouseArea, 9>(uri, 2, 9, "MouseArea");
-
#if QT_CONFIG(quick_path)
- qmlRegisterType<QQuickPathArc, 9>(uri, 2, 9, "PathArc");
- qmlRegisterType<QQuickPathMove>(uri, 2, 9, "PathMove");
+ qmlRegisterTypesAndRevisions<
+ QQuickCurve,
+ QQuickPath,
+ QQuickPathAngleArc,
+ QQuickPathAnimation,
+ QQuickPathArc,
+ QQuickPathAttribute,
+ QQuickPathCatmullRomCurve,
+ QQuickPathCubic,
+ QQuickPathElement,
+ QQuickPathInterpolator,
+ QQuickPathLine,
+ QQuickPathMove,
+ QQuickPathMultiline,
+ QQuickPathPercent,
+ QQuickPathPolyline,
+ QQuickPathQuad,
+ QQuickPathSvg
+ >(uri, major);
#endif
- qmlRegisterType<QQuickText, 9>(uri, 2, 9, "Text");
- qmlRegisterType<QQuickTextInput, 9>(uri, 2, 9, "TextInput");
- qmlRegisterType<QQuickTouchPoint>(uri, 2, 9, "TouchPoint");
- qRegisterMetaType<QPointingDeviceUniqueId>("QPointingDeviceUniqueId");
- qmlRegisterUncreatableType<QPointingDeviceUniqueId>(uri, 2, 9, "PointingDeviceUniqueId", QQuickTouchPoint::tr("PointingDeviceUniqueId is only available via read-only properties"));
-#if QT_CONFIG(quick_positioners)
- qmlRegisterUncreatableType<QQuickBasePositioner, 9>(uri, 2, 9, "Positioner",
- QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
+#if QT_CONFIG(quick_pathview)
+ qmlRegisterTypesAndRevisions<QQuickPathView>(uri, major);
#endif
-#if QT_CONFIG(quick_shadereffect)
- qmlRegisterType<QQuickShaderEffectSource, 9>(uri, 2, 9, "ShaderEffectSource");
+#if QT_CONFIG(quick_repeater)
+ qmlRegisterTypesAndRevisions<QQuickRepeater>(uri, major);
#endif
- qmlRegisterType<QQuickFlickable, 10>(uri, 2, 10, "Flickable");
- qmlRegisterType<QQuickTextEdit, 10>(uri, 2, 10, "TextEdit");
- qmlRegisterType<QQuickText, 10>(uri, 2, 10, "Text");
-
-#if QT_CONFIG(quick_path)
- qmlRegisterType<QQuickPathAngleArc>(uri, 2, 11, "PathAngleArc");
+#if QT_CONFIG(quick_shadereffect)
+ qmlRegisterTypesAndRevisions<
+ QQuickBorderImageMesh,
+ QQuickGridMesh,
+ QQuickItemLayer,
+ QQuickShaderEffect,
+ QQuickShaderEffectMesh,
+ QQuickShaderEffectSource
+ >(uri, major);
#endif
-#if QT_CONFIG(quick_animatedimage)
- qmlRegisterType<QQuickAnimatedImage, 11>(uri, 2, 11,"AnimatedImage");
-#endif
- qmlRegisterType<QQuickItem, 11>(uri, 2, 11,"Item");
- qmlRegisterType<QQuickFlickable, 12>(uri, 2, 12, "Flickable");
-
- // classes related to Input Handlers which are newly exposed since 5.12
- qmlRegisterUncreatableType<QQuickPointerEvent>(uri, 2, 12, "PointerEvent",
- QQuickPointerHandler::tr("PointerEvent is only available as a parameter of several signals in PointerHandler"));
- qmlRegisterUncreatableType<QQuickPointerMouseEvent>(uri, 2, 12, "PointerMouseEvent",
- QQuickPointerHandler::tr("PointerMouseEvent is only available as a parameter of several signals in PointerHandler"));
- qmlRegisterUncreatableType<QQuickPointerTouchEvent>(uri, 2, 12, "PointerTouchEvent",
- QQuickPointerHandler::tr("PointerTouchEvent is only available as a parameter of several signals in PointerHandler"));
- qmlRegisterUncreatableType<QQuickEventPoint>(uri, 2, 12, "EventPoint",
- QQuickPointerHandler::tr("EventPoint is only available as a member of PointerEvent"));
- qmlRegisterUncreatableType<QQuickEventTouchPoint>(uri, 2, 12, "EventTouchPoint",
- QQuickPointerHandler::tr("EventTouchPoint is only available as a member of PointerEvent"));
- qmlRegisterUncreatableType<QQuickPointerDevice>(uri, 2, 12, "PointerDevice",
- QQuickPointerHandler::tr("PointerDevice is only available as a property of PointerEvent"));
-
- // Input Handlers are part of QtQuick, not a separate module, since 5.12
- qmlRegisterUncreatableType<QQuickPointerHandler>(uri, 2, 12, "PointerHandler",
- QQuickPointerHandler::tr("PointerHandler is an abstract base class"));
- qmlRegisterType<QQuickPointHandler>(uri, 2, 12, "PointHandler");
- qmlRegisterType<QQuickDragHandler>(uri, 2, 12, "DragHandler");
- qmlRegisterUncreatableType<QQuickDragAxis>(uri, 2, 12, "DragAxis",
- QQuickDragHandler::tr("DragAxis is only available as a grouped property of DragHandler"));
- qmlRegisterType<QQuickHoverHandler>(uri, 2, 12, "HoverHandler");
- qmlRegisterType<QQuickPinchHandler>(uri, 2, 12, "PinchHandler");
- qmlRegisterType<QQuickTapHandler>(uri, 2, 12, "TapHandler");
- qRegisterMetaType<QQuickHandlerPoint>();
-
- // The rest of the 5.12 revisions
#if QT_CONFIG(quick_sprite)
- qmlRegisterType<QQuickAnimatedSprite, 12>("QtQuick", 2, 12, "AnimatedSprite");
+ qmlRegisterTypesAndRevisions<
+ QQuickAnimatedSprite,
+ QQuickSprite,
+ QQuickSpriteSequence
+ >(uri, major);
#endif
- qmlRegisterType<QQuickGradient, 12>(uri, 2, 12, "Gradient");
- qmlRegisterType<QQuickFlickable, 12>(uri, 2, 12, "Flickable");
- qmlRegisterType<QQuickText, 12>(uri, 2, 12, "Text");
+
#if QT_CONFIG(quick_tableview)
- qmlRegisterType<QQuickTableView>(uri, 2, 12, "TableView");
+ qmlRegisterTypesAndRevisions<QQuickTableView>(uri, major);
#endif
-#if QT_CONFIG(quick_itemview)
- qmlRegisterUncreatableType<QQuickItemView, 13>(uri, 2, 13, itemViewName, itemViewMessage);
-#endif
-#if QT_CONFIG(quick_pathview)
- qmlRegisterType<QQuickPathView, 13>(uri, 2, 13, "PathView");
-#endif
-#if QT_CONFIG(quick_gridview)
- qmlRegisterType<QQuickGridView, 13>(uri, 2, 13, "GridView");
-#endif
-#if QT_CONFIG(quick_tableview)
- qmlRegisterType<QQuickTableView, 14>(uri, 2, 14, "TableView");
+#if QT_CONFIG(quick_viewtransitions)
+ qmlRegisterTypesAndRevisions<QQuickViewTransitionAttached>(uri, major);
#endif
+
#if QT_CONFIG(wheelevent)
- qmlRegisterType<QQuickWheelHandler>(uri, 2, 14, "WheelHandler");
+ qmlRegisterTypesAndRevisions<QQuickWheelHandler>(uri, major);
#endif
- qmlRegisterUncreatableType<QQuickImageBase, 14>(uri, 2, 14, "ImageBase",
- QQuickPointerHandler::tr("ImageBase is an abstract base class"));
- qmlRegisterType<QQuickImage, 14>(uri, 2, 14, "Image");
- qmlRegisterType<QQuickDragHandler, 14>(uri, 2, 14, "DragHandler");
}
static void initResources()
@@ -511,12 +399,7 @@ QT_BEGIN_NAMESPACE
void QQuickItemsModule::defineModule()
{
initResources();
-
- QByteArray name = "QtQuick";
- int majorVersion = 2;
- int minorVersion = 0;
-
- qt_quickitems_defineModule(name, majorVersion, minorVersion);
+ qt_quickitems_defineModule();
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickitemsmodule_p.h b/src/quick/items/qquickitemsmodule_p.h
index cd79efe256..6ceb0d56e6 100644
--- a/src/quick/items/qquickitemsmodule_p.h
+++ b/src/quick/items/qquickitemsmodule_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/qevent.h>
#include <qqml.h>
QT_BEGIN_NAMESPACE
@@ -61,6 +62,15 @@ public:
static void defineModule();
};
+struct QPointingDeviceUniqueIdForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QPointingDeviceUniqueId)
+ QML_NAMED_ELEMENT(PointingDeviceUniqueId)
+ QML_ADDED_IN_MINOR_VERSION(9)
+ QML_UNCREATABLE("PointingDeviceUniqueId is only available via read-only properties.")
+};
+
QT_END_NAMESPACE
#endif // QQUICKITEMSMODULE_P_H
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index 66e09f9ed1..6bc00411f0 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -110,6 +110,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickItemView : public QQuickFlickable
Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged RESET resetPreferredHighlightEnd)
Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
+ QML_NAMED_ELEMENT(ItemView)
+ QML_UNCREATABLE("ItemView is an abstract base class.")
+ QML_ADDED_IN_MINOR_VERSION(1)
+
public:
// this holds all layout enum values so they can be referred to by other enums
// to ensure consistent values - e.g. QML references to GridView.TopToBottom flow
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h
index 0c7a9cad75..5f4e74171e 100644
--- a/src/quick/items/qquickitemviewtransition_p.h
+++ b/src/quick/items/qquickitemviewtransition_p.h
@@ -194,6 +194,10 @@ class QQuickViewTransitionAttached : public QObject
Q_PROPERTY(QList<int> targetIndexes READ targetIndexes NOTIFY targetIndexesChanged)
Q_PROPERTY(QQmlListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged)
+ QML_NAMED_ELEMENT(ViewTransition)
+ QML_UNCREATABLE("ViewTransition is only available via attached properties.")
+ QML_ATTACHED(QQuickViewTransitionAttached)
+
public:
QQuickViewTransitionAttached(QObject *parent);
@@ -227,6 +231,5 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickViewTransitionAttached)
-QML_DECLARE_TYPEINFO(QQuickViewTransitionAttached, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKITEMVIEWTRANSITION_P_P_H
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 8b70ffd0d7..725d35f325 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -49,6 +49,7 @@
#include <QtCore/qmath.h>
#include <private/qquicksmoothedanimation_p_p.h>
+#include <private/qqmlcomponent_p.h>
#include "qplatformdefs.h"
QT_BEGIN_NAMESPACE
@@ -190,6 +191,8 @@ public:
}
friend class QQuickViewSection;
+
+ static void setSectionHelper(QQmlContext *context, QQuickItem *sectionItem, const QString &section);
};
//----------------------------------------------------------------------------
@@ -992,14 +995,20 @@ QQuickItem * QQuickListViewPrivate::getSectionItem(const QString &section)
sectionCache[i] = nullptr;
sectionItem->setVisible(true);
QQmlContext *context = QQmlEngine::contextForObject(sectionItem)->parentContext();
- context->setContextProperty(QLatin1String("section"), section);
+ setSectionHelper(context, sectionItem, section);
} else {
QQmlContext *creationContext = sectionCriteria->delegate()->creationContext();
QQmlContext *context = new QQmlContext(
creationContext ? creationContext : qmlContext(q));
- context->setContextProperty(QLatin1String("section"), section);
- QObject *nobj = sectionCriteria->delegate()->beginCreate(context);
+ QQmlComponent* delegate = sectionCriteria->delegate();
+ QQmlComponentPrivate* delegatePriv = QQmlComponentPrivate::get(delegate);
+ QObject *nobj = delegate->beginCreate(context);
if (nobj) {
+ if (delegatePriv->hadRequiredProperties()) {
+ delegate->setInitialProperties(nobj, {{"section", section}});
+ } else {
+ context->setContextProperty(QLatin1String("section"), section);
+ }
QQml_setParent_noEvent(context, nobj);
sectionItem = qobject_cast<QQuickItem *>(nobj);
if (!sectionItem) {
@@ -1069,7 +1078,7 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem)
listItem->setPosition(pos);
} else {
QQmlContext *context = QQmlEngine::contextForObject(listItem->section())->parentContext();
- context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
+ setSectionHelper(context, listItem->section(), listItem->attached->m_section);
}
} else if (listItem->section()) {
qreal pos = listItem->position();
@@ -1125,7 +1134,7 @@ void QQuickListViewPrivate::updateStickySections()
currentSectionItem = getSectionItem(currentSection);
} else if (QString::compare(currentStickySection, currentSection, Qt::CaseInsensitive)) {
QQmlContext *context = QQmlEngine::contextForObject(currentSectionItem)->parentContext();
- context->setContextProperty(QLatin1String("section"), currentSection);
+ setSectionHelper(context, currentSectionItem, currentSection);
}
currentStickySection = currentSection;
if (!currentSectionItem)
@@ -1159,7 +1168,7 @@ void QQuickListViewPrivate::updateStickySections()
nextSectionItem = getSectionItem(nextSection);
} else if (QString::compare(nextStickySection, nextSection, Qt::CaseInsensitive)) {
QQmlContext *context = QQmlEngine::contextForObject(nextSectionItem)->parentContext();
- context->setContextProperty(QLatin1String("section"), nextSection);
+ setSectionHelper(context, nextSectionItem, nextSection);
}
nextStickySection = nextSection;
if (!nextSectionItem)
@@ -1754,6 +1763,14 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
}
}
+void QQuickListViewPrivate::setSectionHelper(QQmlContext *context, QQuickItem *sectionItem, const QString &section)
+{
+ if (context->contextProperty(QLatin1String("section")).isValid())
+ context->setContextProperty(QLatin1String("section"), section);
+ else
+ sectionItem->setProperty("section", section);
+}
+
//----------------------------------------------------------------------------
/*!
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index f2bab9e018..1c72a10190 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -70,6 +70,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickViewSection : public QObject
Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged)
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int labelPositioning READ labelPositioning WRITE setLabelPositioning NOTIFY labelPositioningChanged)
+ QML_NAMED_ELEMENT(ViewSection)
public:
QQuickViewSection(QQuickListView *parent=nullptr);
@@ -130,6 +131,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickListView : public QQuickItemView
Q_PROPERTY(FooterPositioning footerPositioning READ footerPositioning WRITE setFooterPositioning NOTIFY footerPositioningChanged REVISION 4)
Q_CLASSINFO("DefaultProperty", "data")
+ QML_NAMED_ELEMENT(ListView)
+ QML_ATTACHED(QQuickListViewAttached)
public:
QQuickListView(QQuickItem *parent=nullptr);
@@ -216,7 +219,6 @@ public:
QT_END_NAMESPACE
-QML_DECLARE_TYPEINFO(QQuickListView, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(QQuickListView)
QML_DECLARE_TYPE(QQuickViewSection)
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index d0e29c204e..819a3a73e3 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -45,6 +45,7 @@
#include <private/qqmlglobal_p.h>
#include <private/qqmlcomponent_p.h>
+#include <private/qqmlincubator_p.h>
QT_BEGIN_NAMESPACE
@@ -664,7 +665,8 @@ void QQuickLoaderPrivate::setInitialState(QObject *obj)
QV4::Scope scope(v4);
QV4::ScopedValue ipv(scope, initialPropertyValues.value());
QV4::Scoped<QV4::QmlContext> qmlContext(scope, qmlCallingContext.value());
- d->initializeObjectWithInitialProperties(qmlContext, ipv, obj);
+ auto incubatorPriv = QQmlIncubatorPrivate::get(incubator);
+ d->initializeObjectWithInitialProperties(qmlContext, ipv, obj, incubatorPriv->requiredProperties());
}
void QQuickLoaderIncubator::statusChanged(Status status)
diff --git a/src/quick/items/qquickloader_p.h b/src/quick/items/qquickloader_p.h
index de1dfa9da5..2d560fb856 100644
--- a/src/quick/items/qquickloader_p.h
+++ b/src/quick/items/qquickloader_p.h
@@ -67,6 +67,7 @@ class Q_AUTOTEST_EXPORT QQuickLoader : public QQuickImplicitSizeItem
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
+ QML_NAMED_ELEMENT(Loader)
public:
QQuickLoader(QQuickItem *parent = nullptr);
diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h
index 0e01fa7915..3d4d113215 100644
--- a/src/quick/items/qquickmousearea_p.h
+++ b/src/quick/items/qquickmousearea_p.h
@@ -85,6 +85,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem
#endif
Q_PROPERTY(bool containsPress READ containsPress NOTIFY containsPressChanged REVISION 4)
Q_PROPERTY(int pressAndHoldInterval READ pressAndHoldInterval WRITE setPressAndHoldInterval NOTIFY pressAndHoldIntervalChanged RESET resetPressAndHoldInterval REVISION 9)
+ QML_NAMED_ELEMENT(MouseArea)
public:
QQuickMouseArea(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index 634ea1c2e2..7506be10a1 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -83,6 +83,7 @@ class Q_AUTOTEST_EXPORT QQuickTouchPoint : public QObject
Q_PROPERTY(qreal previousY READ previousY NOTIFY previousYChanged)
Q_PROPERTY(qreal sceneX READ sceneX NOTIFY sceneXChanged)
Q_PROPERTY(qreal sceneY READ sceneY NOTIFY sceneYChanged)
+ QML_NAMED_ELEMENT(TouchPoint)
public:
QQuickTouchPoint(bool qmlDefined = true)
@@ -187,6 +188,9 @@ class QQuickGrabGestureEvent : public QObject
Q_OBJECT
Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints CONSTANT)
Q_PROPERTY(qreal dragThreshold READ dragThreshold CONSTANT)
+ QML_NAMED_ELEMENT(GestureEvent)
+ QML_UNCREATABLE("GestureEvent is only available in the context of handling the gestureStarted signal from MultiPointTouchArea.")
+
public:
QQuickGrabGestureEvent() : _dragThreshold(QGuiApplication::styleHints()->startDragDistance()) {}
@@ -213,6 +217,7 @@ class Q_AUTOTEST_EXPORT QQuickMultiPointTouchArea : public QQuickItem
Q_PROPERTY(int minimumTouchPoints READ minimumTouchPoints WRITE setMinimumTouchPoints NOTIFY minimumTouchPointsChanged)
Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints WRITE setMaximumTouchPoints NOTIFY maximumTouchPointsChanged)
Q_PROPERTY(bool mouseEnabled READ mouseEnabled WRITE setMouseEnabled NOTIFY mouseEnabledChanged)
+ QML_NAMED_ELEMENT(MultiPointTouchArea)
public:
QQuickMultiPointTouchArea(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickopenglinfo_p.h b/src/quick/items/qquickopenglinfo_p.h
index 86683d5348..b733d205e3 100644
--- a/src/quick/items/qquickopenglinfo_p.h
+++ b/src/quick/items/qquickopenglinfo_p.h
@@ -70,6 +70,11 @@ class QQuickOpenGLInfo : public QObject
Q_PROPERTY(ContextProfile profile READ profile NOTIFY profileChanged FINAL)
Q_PROPERTY(RenderableType renderableType READ renderableType NOTIFY renderableTypeChanged FINAL)
+ QML_NAMED_ELEMENT(OpenGLInfo)
+ QML_UNCREATABLE("OpenGLInfo is only available via attached properties.")
+ QML_ADDED_IN_MINOR_VERSION(4)
+ QML_ATTACHED(QQuickOpenGLInfo)
+
public:
QQuickOpenGLInfo(QQuickItem *item = 0);
@@ -116,6 +121,4 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPEINFO(QQuickOpenGLInfo, QML_HAS_ATTACHED_PROPERTIES)
-
#endif // QQUICKOPENGLINFO_P_H
diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h
index ddc1fd99d9..4821a409be 100644
--- a/src/quick/items/qquickpainteditem.h
+++ b/src/quick/items/qquickpainteditem.h
@@ -56,6 +56,9 @@ class Q_QUICK_EXPORT QQuickPaintedItem : public QQuickItem
Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged)
+ QML_NAMED_ELEMENT(PaintedItem)
+ QML_UNCREATABLE("Cannot create instance of abstract class PaintedItem.")
+
public:
explicit QQuickPaintedItem(QQuickItem *parent = nullptr);
~QQuickPaintedItem() override;
diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h
index 66be7fa6ff..c12358e4f6 100644
--- a/src/quick/items/qquickpathview_p.h
+++ b/src/quick/items/qquickpathview_p.h
@@ -100,6 +100,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathView : public QQuickItem
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection NOTIFY movementDirectionChanged REVISION 7)
Q_PROPERTY(int cacheItemCount READ cacheItemCount WRITE setCacheItemCount NOTIFY cacheItemCountChanged)
+ QML_NAMED_ELEMENT(PathView)
+ QML_ATTACHED(QQuickPathViewAttached)
public:
QQuickPathView(QQuickItem *parent = nullptr);
@@ -299,6 +301,5 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickPathView)
-QML_DECLARE_TYPEINFO(QQuickPathView, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKPATHVIEW_P_H
diff --git a/src/quick/items/qquickpincharea_p.h b/src/quick/items/qquickpincharea_p.h
index cf21555823..d7f814cc8a 100644
--- a/src/quick/items/qquickpincharea_p.h
+++ b/src/quick/items/qquickpincharea_p.h
@@ -70,6 +70,7 @@ class Q_AUTOTEST_EXPORT QQuickPinch : public QObject
Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
+ QML_NAMED_ELEMENT(Pinch)
public:
QQuickPinch();
@@ -210,6 +211,7 @@ class Q_AUTOTEST_EXPORT QQuickPinchEvent : public QObject
Q_PROPERTY(QPointF startPoint2 READ startPoint2)
Q_PROPERTY(int pointCount READ pointCount)
Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
+ QML_ANONYMOUS
public:
QQuickPinchEvent(QPointF c, qreal s, qreal a, qreal r)
@@ -268,6 +270,7 @@ class Q_AUTOTEST_EXPORT QQuickPinchArea : public QQuickItem
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QQuickPinch *pinch READ pinch CONSTANT)
+ QML_NAMED_ELEMENT(PinchArea)
public:
QQuickPinchArea(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h
index 94a737e1f1..b924cb9c12 100644
--- a/src/quick/items/qquickpositioners_p.h
+++ b/src/quick/items/qquickpositioners_p.h
@@ -112,6 +112,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBasePositioner : public QQuickImplicitSizeIte
Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6)
Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6)
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
+
+ QML_NAMED_ELEMENT(Positioner)
+ QML_UNCREATABLE("Positioner is an abstract type that is only available as an attached property.")
+ QML_ATTACHED(QQuickPositionerAttached)
+
public:
enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
@@ -230,6 +235,7 @@ private:
class Q_AUTOTEST_EXPORT QQuickColumn : public QQuickBasePositioner
{
Q_OBJECT
+ QML_NAMED_ELEMENT(Column)
public:
QQuickColumn(QQuickItem *parent=nullptr);
@@ -246,6 +252,8 @@ class Q_AUTOTEST_EXPORT QQuickRow: public QQuickBasePositioner
Q_OBJECT
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
+ QML_NAMED_ELEMENT(Row)
+
public:
QQuickRow(QQuickItem *parent=nullptr);
@@ -279,6 +287,7 @@ class Q_AUTOTEST_EXPORT QQuickGrid : public QQuickBasePositioner
Q_PROPERTY(HAlignment horizontalItemAlignment READ hItemAlign WRITE setHItemAlign NOTIFY horizontalAlignmentChanged REVISION 1)
Q_PROPERTY(HAlignment effectiveHorizontalItemAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged REVISION 1)
Q_PROPERTY(VAlignment verticalItemAlignment READ vItemAlign WRITE setVItemAlign NOTIFY verticalAlignmentChanged REVISION 1)
+ QML_NAMED_ELEMENT(Grid)
public:
QQuickGrid(QQuickItem *parent=nullptr);
@@ -359,6 +368,7 @@ class Q_AUTOTEST_EXPORT QQuickFlow: public QQuickBasePositioner
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
+ QML_NAMED_ELEMENT(Flow)
public:
QQuickFlow(QQuickItem *parent=nullptr);
@@ -395,6 +405,5 @@ QML_DECLARE_TYPE(QQuickGrid)
QML_DECLARE_TYPE(QQuickFlow)
QML_DECLARE_TYPE(QQuickBasePositioner)
-QML_DECLARE_TYPEINFO(QQuickBasePositioner, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKPOSITIONERS_P_H
diff --git a/src/quick/items/qquickrectangle_p.h b/src/quick/items/qquickrectangle_p.h
index d56a03d22d..934300b63b 100644
--- a/src/quick/items/qquickrectangle_p.h
+++ b/src/quick/items/qquickrectangle_p.h
@@ -66,6 +66,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPen : public QObject
Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY penChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY penChanged)
+ QML_ANONYMOUS
public:
QQuickPen(QObject *parent=nullptr);
@@ -96,6 +97,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickGradientStop : public QObject
Q_PROPERTY(qreal position READ position WRITE setPosition)
Q_PROPERTY(QColor color READ color WRITE setColor)
+ QML_NAMED_ELEMENT(GradientStop)
public:
QQuickGradientStop(QObject *parent=nullptr);
@@ -121,6 +123,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickGradient : public QObject
Q_PROPERTY(QQmlListProperty<QQuickGradientStop> stops READ stops)
Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged REVISION 12)
Q_CLASSINFO("DefaultProperty", "stops")
+ QML_NAMED_ELEMENT(Gradient)
Q_ENUMS(QGradient::Preset)
public:
@@ -161,6 +164,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRectangle : public QQuickItem
Q_PROPERTY(QJSValue gradient READ gradient WRITE setGradient RESET resetGradient)
Q_PROPERTY(QQuickPen * border READ border CONSTANT)
Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
+ QML_NAMED_ELEMENT(Rectangle)
public:
QQuickRectangle(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickrepeater_p.h b/src/quick/items/qquickrepeater_p.h
index dbe3cd0c55..20984fa23e 100644
--- a/src/quick/items/qquickrepeater_p.h
+++ b/src/quick/items/qquickrepeater_p.h
@@ -70,6 +70,7 @@ class Q_AUTOTEST_EXPORT QQuickRepeater : public QQuickItem
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
+ QML_NAMED_ELEMENT(Repeater)
public:
QQuickRepeater(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickscalegrid_p_p.h b/src/quick/items/qquickscalegrid_p_p.h
index f5187a8eea..56b0ee86ab 100644
--- a/src/quick/items/qquickscalegrid_p_p.h
+++ b/src/quick/items/qquickscalegrid_p_p.h
@@ -69,6 +69,7 @@ class Q_AUTOTEST_EXPORT QQuickScaleGrid : public QObject
Q_PROPERTY(int top READ top WRITE setTop NOTIFY topBorderChanged)
Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightBorderChanged)
Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomBorderChanged)
+ QML_ANONYMOUS
public:
QQuickScaleGrid(QObject *parent=nullptr);
diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h
index 10e524e4a0..9d9f9a1567 100644
--- a/src/quick/items/qquickscreen_p.h
+++ b/src/quick/items/qquickscreen_p.h
@@ -86,6 +86,10 @@ class Q_AUTOTEST_EXPORT QQuickScreenInfo : public QObject
Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION 3)
Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION 3)
+ QML_NAMED_ELEMENT(ScreenInfo)
+ QML_ADDED_IN_MINOR_VERSION(3)
+ QML_UNCREATABLE("ScreenInfo can only be used via the attached property.")
+
public:
QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr);
@@ -161,13 +165,16 @@ private:
class Q_AUTOTEST_EXPORT QQuickScreen : public QObject
{
Q_OBJECT
+ QML_NAMED_ELEMENT(Screen)
+ QML_UNCREATABLE("Screen can only be used via the attached property.")
+ QML_ATTACHED(QQuickScreenAttached)
+
public:
static QQuickScreenAttached *qmlAttachedProperties(QObject *object){ return new QQuickScreenAttached(object); }
};
QT_END_NAMESPACE
-QML_DECLARE_TYPEINFO(QQuickScreen, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(QQuickScreenInfo)
#endif
diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h
index 6e2f35882b..c14907092c 100644
--- a/src/quick/items/qquickshadereffect_p.h
+++ b/src/quick/items/qquickshadereffect_p.h
@@ -75,6 +75,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffect : public QQuickItem
Q_PROPERTY(QString log READ log NOTIFY logChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(bool supportsAtlasTextures READ supportsAtlasTextures WRITE setSupportsAtlasTextures NOTIFY supportsAtlasTexturesChanged REVISION 4)
+ QML_NAMED_ELEMENT(ShaderEffect)
public:
enum CullMode {
diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h
index 79e05a5f9f..710d37c275 100644
--- a/src/quick/items/qquickshadereffectmesh_p.h
+++ b/src/quick/items/qquickshadereffectmesh_p.h
@@ -49,6 +49,7 @@ QT_REQUIRE_CONFIG(quick_shadereffect);
#include <QtCore/qsize.h>
#include <QtCore/qvector.h>
#include <QtCore/qbytearray.h>
+#include <QtQml/qqml.h>
#ifndef QQUICKSHADEREFFECTMESH_P_H
#define QQUICKSHADEREFFECTMESH_P_H
@@ -75,6 +76,10 @@ class QRectF;
class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectMesh : public QObject
{
Q_OBJECT
+
+ QML_NAMED_ELEMENT(ShaderEffectMesh)
+ QML_UNCREATABLE("Cannot create instance of abstract class ShaderEffectMesh.")
+
public:
QQuickShaderEffectMesh(QObject *parent = nullptr);
virtual bool validateAttributes(const QVector<QByteArray> &attributes, int *posIndex) = 0;
@@ -96,6 +101,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickGridMesh : public QQuickShaderEffectMesh
{
Q_OBJECT
Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
+ QML_NAMED_ELEMENT(GridMesh)
public:
QQuickGridMesh(QObject *parent = nullptr);
bool validateAttributes(const QVector<QByteArray> &attributes, int *posIndex) override;
@@ -123,6 +129,10 @@ class QQuickBorderImageMesh : public QQuickShaderEffectMesh
Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged)
Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged)
Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged)
+
+ QML_NAMED_ELEMENT(BorderImageMesh)
+ QML_ADDED_IN_MINOR_VERSION(8)
+
public:
QQuickBorderImageMesh(QObject *parent = nullptr);
diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h
index d612d1179f..c0a1ccab78 100644
--- a/src/quick/items/qquickshadereffectsource_p.h
+++ b/src/quick/items/qquickshadereffectsource_p.h
@@ -89,6 +89,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectSource : public QQuickItem, publi
Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged)
Q_PROPERTY(TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged REVISION 6)
Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged REVISION 9)
+ QML_NAMED_ELEMENT(ShaderEffectSource)
public:
enum WrapMode {
diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h
index fab9e75190..98e5b82db8 100644
--- a/src/quick/items/qquicksprite_p.h
+++ b/src/quick/items/qquicksprite_p.h
@@ -86,6 +86,7 @@ class Q_QUICK_EXPORT QQuickSprite : public QQuickStochasticState
Q_PROPERTY(qreal frameRateVariation READ frameRateVariation WRITE setFrameRateVariation NOTIFY frameRateVariationChanged)
Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration)
Q_PROPERTY(int frameDurationVariation READ frameDurationVariation WRITE setFrameDurationVariation NOTIFY frameDurationVariationChanged)
+ QML_NAMED_ELEMENT(Sprite)
public:
explicit QQuickSprite(QObject *parent = nullptr);
diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h
index 12c80d6a27..8361f7832a 100644
--- a/src/quick/items/qquickspritesequence_p.h
+++ b/src/quick/items/qquickspritesequence_p.h
@@ -74,6 +74,7 @@ class Q_AUTOTEST_EXPORT QQuickSpriteSequence : public QQuickItem
//###try to share similar spriteEngines for less overhead?
Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
Q_CLASSINFO("DefaultProperty", "sprites")
+ QML_NAMED_ELEMENT(SpriteSequence)
public:
explicit QQuickSpriteSequence(QQuickItem *parent = nullptr);
diff --git a/src/quick/items/qquickstateoperations_p.h b/src/quick/items/qquickstateoperations_p.h
index 357366bc60..d451dc6f77 100644
--- a/src/quick/items/qquickstateoperations_p.h
+++ b/src/quick/items/qquickstateoperations_p.h
@@ -74,6 +74,7 @@ class Q_AUTOTEST_EXPORT QQuickParentChange : public QQuickStateOperation, public
Q_PROPERTY(QQmlScriptString height READ height WRITE setHeight)
Q_PROPERTY(QQmlScriptString scale READ scale WRITE setScale)
Q_PROPERTY(QQmlScriptString rotation READ rotation WRITE setRotation)
+ QML_NAMED_ELEMENT(ParentChange)
public:
QQuickParentChange(QObject *parent=nullptr);
~QQuickParentChange();
@@ -136,6 +137,7 @@ class Q_AUTOTEST_EXPORT QQuickAnchorSet : public QObject
Q_PROPERTY(QQmlScriptString bottom READ bottom WRITE setBottom RESET resetBottom)
Q_PROPERTY(QQmlScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
Q_PROPERTY(QQmlScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline)
+ QML_ANONYMOUS
public:
QQuickAnchorSet(QObject *parent=nullptr);
@@ -185,6 +187,7 @@ class Q_AUTOTEST_EXPORT QQuickAnchorChanges : public QQuickStateOperation, publi
Q_PROPERTY(QQuickItem *target READ object WRITE setObject)
Q_PROPERTY(QQuickAnchorSet *anchors READ anchors CONSTANT)
+ QML_NAMED_ELEMENT(AnchorChanges)
public:
QQuickAnchorChanges(QObject *parent=nullptr);
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
index a5f727d7a4..5ef73a816f 100644
--- a/src/quick/items/qquicktableview_p.h
+++ b/src/quick/items/qquicktableview_p.h
@@ -82,6 +82,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable
Q_PROPERTY(QQuickTableView *syncView READ syncView WRITE setSyncView NOTIFY syncViewChanged REVISION 14)
Q_PROPERTY(Qt::Orientations syncDirection READ syncDirection WRITE setSyncDirection NOTIFY syncDirectionChanged REVISION 14)
+ QML_NAMED_ELEMENT(TableView)
+ QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ATTACHED(QQuickTableViewAttached)
+
public:
QQuickTableView(QQuickItem *parent = nullptr);
~QQuickTableView() override;
@@ -186,6 +190,5 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickTableView)
-QML_DECLARE_TYPEINFO(QQuickTableView, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKTABLEVIEW_P_H
diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h
index 45f387cb12..394ea25b83 100644
--- a/src/quick/items/qquicktext_p.h
+++ b/src/quick/items/qquicktext_p.h
@@ -100,6 +100,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickText : public QQuickImplicitSizeItem
Q_PROPERTY(QJSValue fontInfo READ fontInfo NOTIFY fontInfoChanged REVISION 9)
Q_PROPERTY(QSizeF advance READ advance NOTIFY contentSizeChanged REVISION 10)
+ QML_NAMED_ELEMENT(Text)
public:
QQuickText(QQuickItem *parent=nullptr);
@@ -329,6 +330,7 @@ class QQuickTextLine : public QObject
Q_PROPERTY(qreal height READ height WRITE setHeight)
Q_PROPERTY(qreal x READ x WRITE setX)
Q_PROPERTY(qreal y READ y WRITE setY)
+ QML_ANONYMOUS
public:
QQuickTextLine();
diff --git a/src/quick/items/qquicktextdocument.h b/src/quick/items/qquicktextdocument.h
index affa0ab4d6..bf9162755c 100644
--- a/src/quick/items/qquicktextdocument.h
+++ b/src/quick/items/qquicktextdocument.h
@@ -49,6 +49,7 @@ class QQuickTextDocumentPrivate;
class Q_QUICK_EXPORT QQuickTextDocument : public QObject
{
Q_OBJECT
+ QML_ANONYMOUS
public:
QQuickTextDocument(QQuickItem *parent);
diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h
index 2d1b6c7f9c..227d8cbf51 100644
--- a/src/quick/items/qquicktextedit_p.h
+++ b/src/quick/items/qquicktextedit_p.h
@@ -112,6 +112,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION 7)
Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance NOTIFY tabStopDistanceChanged REVISION 10)
+ QML_NAMED_ELEMENT(TextEdit)
public:
QQuickTextEdit(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h
index c10b06d02a..9f7b82b168 100644
--- a/src/quick/items/qquicktextinput_p.h
+++ b/src/quick/items/qquicktextinput_p.h
@@ -113,6 +113,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTextInput : public QQuickImplicitSizeItem
Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6)
Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6)
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
+ QML_NAMED_ELEMENT(TextInput)
public:
QQuickTextInput(QQuickItem * parent=nullptr);
diff --git a/src/quick/items/qquicktranslate_p.h b/src/quick/items/qquicktranslate_p.h
index b6ea43342c..aeda6ca589 100644
--- a/src/quick/items/qquicktranslate_p.h
+++ b/src/quick/items/qquicktranslate_p.h
@@ -64,6 +64,7 @@ class Q_AUTOTEST_EXPORT QQuickTranslate : public QQuickTransform
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
+ QML_NAMED_ELEMENT(Translate)
public:
QQuickTranslate(QObject *parent = nullptr);
@@ -95,6 +96,7 @@ class Q_AUTOTEST_EXPORT QQuickScale : public QQuickTransform
Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY xScaleChanged)
Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY yScaleChanged)
Q_PROPERTY(qreal zScale READ zScale WRITE setZScale NOTIFY zScaleChanged)
+ QML_NAMED_ELEMENT(Scale)
public:
QQuickScale(QObject *parent = nullptr);
~QQuickScale();
@@ -132,6 +134,7 @@ class Q_AUTOTEST_EXPORT QQuickRotation : public QQuickTransform
Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged)
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged)
+ QML_NAMED_ELEMENT(Rotation)
public:
QQuickRotation(QObject *parent = nullptr);
~QQuickRotation();
@@ -163,6 +166,8 @@ class Q_AUTOTEST_EXPORT QQuickMatrix4x4 : public QQuickTransform
Q_OBJECT
Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged)
+ QML_NAMED_ELEMENT(Matrix4x4)
+ QML_ADDED_IN_MINOR_VERSION(3)
public:
QQuickMatrix4x4(QObject *parent = nullptr);
~QQuickMatrix4x4();
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 64d7232354..3885700af8 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -3124,6 +3124,18 @@ bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent
return overThreshold;
}
+bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold)
+{
+ QStyleHints *styleHints = qApp->styleHints();
+ bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance());
+ const bool dragVelocityLimitAvailable = (styleHints->startDragVelocity() > 0);
+ if (!overThreshold && dragVelocityLimitAvailable) {
+ qreal velocity = axis == Qt::XAxis ? tp->velocity().x() : tp->velocity().y();
+ overThreshold |= qAbs(velocity) > styleHints->startDragVelocity();
+ }
+ return overThreshold;
+}
+
bool QQuickWindowPrivate::dragOverThreshold(QVector2D delta)
{
int threshold = qApp->styleHints()->startDragDistance();
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index 56d50cec2a..bec1ace2a6 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -76,6 +76,9 @@ class Q_QUICK_EXPORT QQuickWindow : public QWindow
Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT)
Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged REVISION 1)
Q_CLASSINFO("DefaultProperty", "data")
+ QML_NAMED_ELEMENT(Window)
+ QML_ADDED_IN_MINOR_VERSION(0)
+ QML_REMOVED_IN_MINOR_VERSION(1)
Q_DECLARE_PRIVATE(QQuickWindow)
public:
enum CreateTextureOption {
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 7d1767c40e..432ed99a53 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -288,25 +288,7 @@ public:
static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1);
- template <typename TEventPoint>
- static bool dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint *p, int startDragThreshold = -1)
- {
- QStyleHints *styleHints = qApp->styleHints();
- bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance());
- const bool dragVelocityLimitAvailable = (styleHints->startDragVelocity() > 0);
- if (!overThreshold && dragVelocityLimitAvailable) {
- qreal velocity = axis == Qt::XAxis ? p->velocity().x() : p->velocity().y();
- overThreshold |= qAbs(velocity) > styleHints->startDragVelocity();
- }
- return overThreshold;
- }
-
- static bool dragOverThreshold(const QQuickEventPoint *point)
- {
- QPointF delta = point->scenePosition() - point->scenePressPosition();
- return (QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point) ||
- QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point));
- }
+ static bool dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold = -1);
static bool dragOverThreshold(QVector2D delta);
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index 4b2b8f498d..0f952d194c 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -199,22 +199,13 @@ void QQuickWindowModule::defineModule()
{
const char uri[] = "QtQuick.Window";
- qmlRegisterType<QQuickWindow>(uri, 2, 0, "Window");
+ // Cannot automatically register these. They are from QtGui.
qmlRegisterRevision<QWindow,1>(uri, 2, 1);
qmlRegisterRevision<QWindow,2>(uri, 2, 2);
- qmlRegisterRevision<QQuickWindow,1>(uri, 2, 1);//Type moved to a subclass, but also has new members
- qmlRegisterRevision<QQuickWindow,2>(uri, 2, 2);
- qmlRegisterType<QQuickWindowQmlImpl>(uri, 2, 1, "Window");
- qmlRegisterType<QQuickWindowQmlImpl,2>(uri, 2, 2, "Window");
- qmlRegisterType<QQuickWindowQmlImpl,3>(uri, 2, 3, "Window");
- qmlRegisterUncreatableType<QQuickScreen>(uri, 2, 0, "Screen", QStringLiteral("Screen can only be used via the attached property."));
- qmlRegisterUncreatableType<QQuickScreen,3>(uri, 2, 3, "Screen", QStringLiteral("Screen can only be used via the attached property."));
- qmlRegisterUncreatableType<QQuickScreenInfo,3>(uri, 2, 3, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
- qmlRegisterUncreatableType<QQuickScreenInfo,10>(uri, 2, 10, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
qmlRegisterRevision<QWindow,13>(uri, 2, 13);
- qmlRegisterRevision<QQuickWindow,13>(uri, 2, 13);
- qmlRegisterType<QQuickWindowQmlImpl,13>(uri, 2, 13, "Window");
- qmlRegisterRevision<QQuickWindow,14>(uri, 2, 14);
+
+ qmlRegisterTypesAndRevisions<QQuickWindow, QQuickWindowQmlImpl,
+ QQuickScreen, QQuickScreenInfo>(uri, 2);
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h
index 1dcf1a1021..1769e5aeb4 100644
--- a/src/quick/items/qquickwindowmodule_p.h
+++ b/src/quick/items/qquickwindowmodule_p.h
@@ -68,6 +68,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWindowQmlImpl : public QQuickWindow, public Q
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged REVISION 3)
+ QML_NAMED_ELEMENT(Window)
+ QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ATTACHED(QQuickWindowAttached)
public:
QQuickWindowQmlImpl(QWindow *parent = nullptr);
@@ -106,6 +109,5 @@ public:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickWindowQmlImpl)
-QML_DECLARE_TYPEINFO(QQuickWindowQmlImpl, QML_HAS_ATTACHED_PROPERTIES)
#endif
diff --git a/src/quick/qtquick2.cpp b/src/quick/qtquick2.cpp
index 7a04c2146c..527742ab8a 100644
--- a/src/quick/qtquick2.cpp
+++ b/src/quick/qtquick2.cpp
@@ -185,8 +185,6 @@ void QQmlQtQuick2Module::defineModule()
QQuickUtilModule::defineModule();
QQuickItemsModule::defineModule();
- qmlRegisterUncreatableType<QQuickApplication>("QtQuick",2,0,"Application", QQuickApplication::tr("Application is an abstract class"));
-
QQuickValueTypes::registerValueTypes();
#if QT_CONFIG(accessibility)
diff --git a/src/quick/util/qquickanimation_p.h b/src/quick/util/qquickanimation_p.h
index 746cb938bd..45f1635c91 100644
--- a/src/quick/util/qquickanimation_p.h
+++ b/src/quick/util/qquickanimation_p.h
@@ -80,6 +80,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAbstractAnimation : public QObject, public QQ
Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged)
Q_CLASSINFO("DefaultMethod", "start()")
+ QML_NAMED_ELEMENT(Animation)
+ QML_UNCREATABLE("Animation is an abstract class")
+
public:
enum ThreadingModel {
GuiThread,
@@ -165,6 +168,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPauseAnimation : public QQuickAbstractAnimati
Q_DECLARE_PRIVATE(QQuickPauseAnimation)
Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ QML_NAMED_ELEMENT(PauseAnimation)
public:
QQuickPauseAnimation(QObject *parent=nullptr);
@@ -191,6 +195,7 @@ class QQuickScriptAction : public QQuickAbstractAnimation
Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
+ QML_NAMED_ELEMENT(ScriptAction)
public:
QQuickScriptAction(QObject *parent=nullptr);
@@ -221,6 +226,7 @@ class QQuickPropertyAction : public QQuickAbstractAnimation
Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+ QML_NAMED_ELEMENT(PropertyAction)
public:
QQuickPropertyAction(QObject *parent=nullptr);
@@ -269,6 +275,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPropertyAnimation : public QQuickAbstractAnim
Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
+ QML_NAMED_ELEMENT(PropertyAnimation)
public:
QQuickPropertyAnimation(QObject *parent=nullptr);
@@ -324,6 +331,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickColorAnimation : public QQuickPropertyAnimati
Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
Q_PROPERTY(QColor from READ from WRITE setFrom)
Q_PROPERTY(QColor to READ to WRITE setTo)
+ QML_NAMED_ELEMENT(ColorAnimation)
public:
QQuickColorAnimation(QObject *parent=nullptr);
@@ -343,6 +351,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickNumberAnimation : public QQuickPropertyAnimat
Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
+ QML_NAMED_ELEMENT(NumberAnimation)
public:
QQuickNumberAnimation(QObject *parent=nullptr);
@@ -368,6 +377,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickVector3dAnimation : public QQuickPropertyAnim
Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged)
Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged)
+ QML_NAMED_ELEMENT(Vector3dAnimation)
public:
QQuickVector3dAnimation(QObject *parent=nullptr);
@@ -389,6 +399,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimation : public QQuickPropertyAnim
Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
+ QML_NAMED_ELEMENT(RotationAnimation)
public:
QQuickRotationAnimation(QObject *parent=nullptr);
@@ -433,6 +444,7 @@ class QQuickSequentialAnimation : public QQuickAnimationGroup
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickAnimationGroup)
+ QML_NAMED_ELEMENT(SequentialAnimation)
public:
QQuickSequentialAnimation(QObject *parent=nullptr);
@@ -450,6 +462,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGro
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickAnimationGroup)
+ QML_NAMED_ELEMENT(ParallelAnimation)
public:
QQuickParallelAnimation(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickanimationcontroller_p.h b/src/quick/util/qquickanimationcontroller_p.h
index d9ce377060..da6df6038a 100644
--- a/src/quick/util/qquickanimationcontroller_p.h
+++ b/src/quick/util/qquickanimationcontroller_p.h
@@ -64,6 +64,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimationController : public QObject, public QQmlP
Q_DECLARE_PRIVATE(QQuickAnimationController)
Q_CLASSINFO("DefaultProperty", "animation")
+ QML_NAMED_ELEMENT(AnimationController)
Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged)
diff --git a/src/quick/util/qquickanimator_p.h b/src/quick/util/qquickanimator_p.h
index 511cecda7f..9f7aaafcb0 100644
--- a/src/quick/util/qquickanimator_p.h
+++ b/src/quick/util/qquickanimator_p.h
@@ -69,6 +69,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAnimator : public QQuickAbstractAnimation
Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ QML_NAMED_ELEMENT(Animator)
+ QML_ADDED_IN_MINOR_VERSION(2)
+ QML_UNCREATABLE("Animator is an abstract class")
+
public:
QQuickItem *targetItem() const;
void setTargetItem(QQuickItem *target);
@@ -109,6 +113,8 @@ class QQuickScaleAnimatorPrivate;
class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimator : public QQuickAnimator
{
Q_OBJECT
+ QML_NAMED_ELEMENT(ScaleAnimator)
+ QML_ADDED_IN_MINOR_VERSION(2)
public:
QQuickScaleAnimator(QObject *parent = nullptr);
protected:
@@ -119,6 +125,8 @@ protected:
class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator
{
Q_OBJECT
+ QML_NAMED_ELEMENT(XAnimator)
+ QML_ADDED_IN_MINOR_VERSION(2)
public:
QQuickXAnimator(QObject *parent = nullptr);
protected:
@@ -129,6 +137,8 @@ protected:
class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator
{
Q_OBJECT
+ QML_NAMED_ELEMENT(YAnimator)
+ QML_ADDED_IN_MINOR_VERSION(2)
public:
QQuickYAnimator(QObject *parent = nullptr);
protected:
@@ -139,6 +149,8 @@ protected:
class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator
{
Q_OBJECT
+ QML_NAMED_ELEMENT(OpacityAnimator)
+ QML_ADDED_IN_MINOR_VERSION(2)
public:
QQuickOpacityAnimator(QObject *parent = nullptr);
protected:
@@ -152,6 +164,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimator : public QQuickAnimator
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickRotationAnimator)
Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
+ QML_NAMED_ELEMENT(RotationAnimator)
+ QML_ADDED_IN_MINOR_VERSION(2)
public:
enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
@@ -177,6 +191,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickUniformAnimator)
Q_PROPERTY(QString uniform READ uniform WRITE setUniform NOTIFY uniformChanged)
+ QML_NAMED_ELEMENT(UniformAnimator)
+ QML_ADDED_IN_MINOR_VERSION(2)
public:
QQuickUniformAnimator(QObject *parent = nullptr);
diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h
index 66a33489e4..b0eb6fa604 100644
--- a/src/quick/util/qquickapplication_p.h
+++ b/src/quick/util/qquickapplication_p.h
@@ -71,6 +71,9 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
Q_PROPERTY(QQmlListProperty<QQuickScreenInfo> screens READ screens NOTIFY screensChanged)
+ QML_NAMED_ELEMENT(Application)
+ QML_UNCREATABLE("Application is an abstract class.")
+
public:
explicit QQuickApplication(QObject *parent = nullptr);
virtual ~QQuickApplication();
diff --git a/src/quick/util/qquickbehavior_p.h b/src/quick/util/qquickbehavior_p.h
index 80a51d77af..fa9cf6d6bc 100644
--- a/src/quick/util/qquickbehavior_p.h
+++ b/src/quick/util/qquickbehavior_p.h
@@ -71,6 +71,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBehavior : public QObject, public QQmlPropert
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QVariant targetValue READ targetValue NOTIFY targetValueChanged REVISION 13)
Q_CLASSINFO("DeferredPropertyNames", "animation")
+ QML_NAMED_ELEMENT(Behavior)
public:
QQuickBehavior(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickfontloader_p.h b/src/quick/util/qquickfontloader_p.h
index 8d277f7cf7..e849c52a35 100644
--- a/src/quick/util/qquickfontloader_p.h
+++ b/src/quick/util/qquickfontloader_p.h
@@ -67,6 +67,7 @@ class Q_AUTOTEST_EXPORT QQuickFontLoader : public QObject
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ QML_NAMED_ELEMENT(FontLoader)
public:
enum Status { Null = 0, Ready, Loading, Error };
diff --git a/src/quick/util/qquickfontmetrics_p.h b/src/quick/util/qquickfontmetrics_p.h
index db2b7b6796..ee6d679649 100644
--- a/src/quick/util/qquickfontmetrics_p.h
+++ b/src/quick/util/qquickfontmetrics_p.h
@@ -79,6 +79,8 @@ class Q_AUTOTEST_EXPORT QQuickFontMetrics : public QObject
Q_PROPERTY(qreal overlinePosition READ overlinePosition NOTIFY fontChanged)
Q_PROPERTY(qreal strikeOutPosition READ strikeOutPosition NOTIFY fontChanged)
Q_PROPERTY(qreal lineWidth READ lineWidth NOTIFY fontChanged)
+ QML_NAMED_ELEMENT(FontMetrics)
+ QML_ADDED_IN_MINOR_VERSION(4)
public:
explicit QQuickFontMetrics(QObject *parent = nullptr);
~QQuickFontMetrics();
diff --git a/src/quick/util/qquickforeignutils_p.h b/src/quick/util/qquickforeignutils_p.h
new file mode 100644
index 0000000000..7e51bc4f82
--- /dev/null
+++ b/src/quick/util/qquickforeignutils_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTQUICKFOREIGN_P_H
+#define QTQUICKFOREIGN_P_H
+
+#include <qtquickglobal_p.h>
+
+#if QT_CONFIG(im)
+#include <QtGui/qinputmethod.h>
+#endif
+#if QT_CONFIG(validator)
+#include <QtGui/qvalidator.h>
+#endif
+#if QT_CONFIG(shortcut)
+#include <QtGui/qkeysequence.h>
+#endif
+
+#include <QtQml/qqml.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+#if QT_CONFIG(validator)
+struct QValidatorForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QValidator)
+ QML_ANONYMOUS
+};
+
+struct QRegExpValidatorForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QRegExpValidator)
+ QML_NAMED_ELEMENT(RegExpValidator)
+};
+
+#if QT_CONFIG(regularexpression)
+struct QRegularExpressionValidatorForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QRegularExpressionValidator)
+ QML_NAMED_ELEMENT(RegularExpressionValidator)
+ QML_ADDED_IN_MINOR_VERSION(14)
+};
+#endif // QT_CONFIG(regularexpression)
+
+#endif // QT_CONFIG(validator)
+
+#if QT_CONFIG(im)
+struct QInputMethodForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QInputMethod)
+ QML_NAMED_ELEMENT(InputMethod)
+ QML_UNCREATABLE("InputMethod is an abstract class.")
+};
+#endif // QT_CONFIG(im)
+
+#if QT_CONFIG(shortcut)
+struct QKeySequenceForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QKeySequence)
+ QML_NAMED_ELEMENT(StandardKey)
+ QML_ADDED_IN_MINOR_VERSION(2)
+ QML_UNCREATABLE("Cannot create an instance of StandardKey.")
+};
+#endif // QT_CONFIG(shortcut)
+
+QT_END_NAMESPACE
+
+#endif // QTQUICKFOREIGN_P_H
diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h
index 5987ae8f35..ca0495a90d 100644
--- a/src/quick/util/qquickpath_p.h
+++ b/src/quick/util/qquickpath_p.h
@@ -77,6 +77,7 @@ struct QQuickPathData
class Q_QUICK_PRIVATE_EXPORT QQuickPathElement : public QObject
{
Q_OBJECT
+ QML_ANONYMOUS
public:
QQuickPathElement(QObject *parent=nullptr) : QObject(parent) {}
Q_SIGNALS:
@@ -89,6 +90,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAttribute : public QQuickPathElement
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
+ QML_NAMED_ELEMENT(PathAttribute)
public:
QQuickPathAttribute(QObject *parent=nullptr) : QQuickPathElement(parent) {}
@@ -116,6 +118,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickCurve : public QQuickPathElement
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
Q_PROPERTY(qreal relativeX READ relativeX WRITE setRelativeX NOTIFY relativeXChanged)
Q_PROPERTY(qreal relativeY READ relativeY WRITE setRelativeY NOTIFY relativeYChanged)
+ QML_ANONYMOUS
public:
QQuickCurve(QObject *parent=nullptr) : QQuickPathElement(parent) {}
@@ -153,6 +156,7 @@ private:
class Q_QUICK_PRIVATE_EXPORT QQuickPathLine : public QQuickCurve
{
Q_OBJECT
+ QML_NAMED_ELEMENT(PathLine)
public:
QQuickPathLine(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -162,6 +166,8 @@ public:
class Q_QUICK_PRIVATE_EXPORT QQuickPathMove : public QQuickCurve
{
Q_OBJECT
+ QML_NAMED_ELEMENT(PathMove)
+ QML_ADDED_IN_MINOR_VERSION(9)
public:
QQuickPathMove(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -176,6 +182,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve
Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY controlYChanged)
Q_PROPERTY(qreal relativeControlX READ relativeControlX WRITE setRelativeControlX NOTIFY relativeControlXChanged)
Q_PROPERTY(qreal relativeControlY READ relativeControlY WRITE setRelativeControlY NOTIFY relativeControlYChanged)
+
+ QML_NAMED_ELEMENT(PathQuad)
public:
QQuickPathQuad(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -220,6 +228,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCubic : public QQuickCurve
Q_PROPERTY(qreal relativeControl1Y READ relativeControl1Y WRITE setRelativeControl1Y NOTIFY relativeControl1YChanged)
Q_PROPERTY(qreal relativeControl2X READ relativeControl2X WRITE setRelativeControl2X NOTIFY relativeControl2XChanged)
Q_PROPERTY(qreal relativeControl2Y READ relativeControl2Y WRITE setRelativeControl2Y NOTIFY relativeControl2YChanged)
+ QML_NAMED_ELEMENT(PathCubic)
public:
QQuickPathCubic(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -277,6 +286,7 @@ private:
class Q_QUICK_PRIVATE_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve
{
Q_OBJECT
+ QML_NAMED_ELEMENT(PathCurve)
public:
QQuickPathCatmullRomCurve(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -291,6 +301,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathArc : public QQuickCurve
Q_PROPERTY(bool useLargeArc READ useLargeArc WRITE setUseLargeArc NOTIFY useLargeArcChanged)
Q_PROPERTY(ArcDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
Q_PROPERTY(qreal xAxisRotation READ xAxisRotation WRITE setXAxisRotation NOTIFY xAxisRotationChanged REVISION 9)
+ QML_NAMED_ELEMENT(PathArc)
public:
QQuickPathArc(QObject *parent=nullptr)
@@ -342,6 +353,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAngleArc : public QQuickCurve
Q_PROPERTY(qreal sweepAngle READ sweepAngle WRITE setSweepAngle NOTIFY sweepAngleChanged)
Q_PROPERTY(bool moveToStart READ moveToStart WRITE setMoveToStart NOTIFY moveToStartChanged)
+ QML_NAMED_ELEMENT(PathAngleArc)
+ QML_ADDED_IN_MINOR_VERSION(11)
+
public:
QQuickPathAngleArc(QObject *parent=nullptr)
: QQuickCurve(parent) {}
@@ -392,6 +406,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve
{
Q_OBJECT
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
+ QML_NAMED_ELEMENT(PathSvg)
public:
QQuickPathSvg(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -411,6 +426,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPercent : public QQuickPathElement
{
Q_OBJECT
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
+ QML_NAMED_ELEMENT(PathPercent)
public:
QQuickPathPercent(QObject *parent=nullptr) : QQuickPathElement(parent) {}
@@ -429,6 +445,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPolyline : public QQuickCurve
Q_OBJECT
Q_PROPERTY(QPointF start READ start NOTIFY startChanged)
Q_PROPERTY(QVariant path READ path WRITE setPath NOTIFY pathChanged)
+ QML_NAMED_ELEMENT(PathPolyline)
+ QML_ADDED_IN_MINOR_VERSION(14)
public:
QQuickPathPolyline(QObject *parent=nullptr);
@@ -451,6 +469,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathMultiline : public QQuickCurve
Q_OBJECT
Q_PROPERTY(QPointF start READ start NOTIFY startChanged)
Q_PROPERTY(QVariant paths READ paths WRITE setPaths NOTIFY pathsChanged)
+ QML_NAMED_ELEMENT(PathMultiline)
+ QML_ADDED_IN_MINOR_VERSION(14)
public:
QQuickPathMultiline(QObject *parent=nullptr);
@@ -493,6 +513,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPath : public QObject, public QQmlParserStatu
Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION 14)
Q_CLASSINFO("DefaultProperty", "pathElements")
+ QML_NAMED_ELEMENT(Path)
Q_INTERFACES(QQmlParserStatus)
public:
QQuickPath(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickpathinterpolator_p.h b/src/quick/util/qquickpathinterpolator_p.h
index 60a9ff2e22..440ea06841 100644
--- a/src/quick/util/qquickpathinterpolator_p.h
+++ b/src/quick/util/qquickpathinterpolator_p.h
@@ -69,6 +69,7 @@ class Q_AUTOTEST_EXPORT QQuickPathInterpolator : public QObject
Q_PROPERTY(qreal x READ x NOTIFY xChanged)
Q_PROPERTY(qreal y READ y NOTIFY yChanged)
Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged)
+ QML_NAMED_ELEMENT(PathInterpolator)
public:
explicit QQuickPathInterpolator(QObject *parent = nullptr);
diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h
index 82a6ebffac..27a00420af 100644
--- a/src/quick/util/qquickpropertychanges_p.h
+++ b/src/quick/util/qquickpropertychanges_p.h
@@ -65,6 +65,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPropertyChanges : public QQuickStateOperation
Q_PROPERTY(QObject *target READ object WRITE setObject)
Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
+ QML_NAMED_ELEMENT(PropertyChanges)
+
public:
QQuickPropertyChanges();
~QQuickPropertyChanges();
@@ -107,6 +109,11 @@ public:
void applyBindings(QObject *obj, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
+template<>
+inline QQmlCustomParser *qmlCreateCustomParser<QQuickPropertyChanges>()
+{
+ return new QQuickPropertyChangesParser;
+}
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h
index 712cca7696..0e66a38e75 100644
--- a/src/quick/util/qquickshortcut_p.h
+++ b/src/quick/util/qquickshortcut_p.h
@@ -56,6 +56,7 @@
#include <QtCore/qvariant.h>
#include <QtGui/qkeysequence.h>
#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -72,6 +73,8 @@ class QQuickShortcut : public QObject, public QQmlParserStatus
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext NOTIFY contextChanged FINAL)
+ QML_NAMED_ELEMENT(Shortcut)
+ QML_ADDED_IN_MINOR_VERSION(5)
public:
explicit QQuickShortcut(QObject *parent = nullptr);
diff --git a/src/quick/util/qquicksmoothedanimation_p.h b/src/quick/util/qquicksmoothedanimation_p.h
index 7bceba387c..d7e637446d 100644
--- a/src/quick/util/qquicksmoothedanimation_p.h
+++ b/src/quick/util/qquicksmoothedanimation_p.h
@@ -68,6 +68,7 @@ class Q_AUTOTEST_EXPORT QQuickSmoothedAnimation : public QQuickNumberAnimation
Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
+ QML_NAMED_ELEMENT(SmoothedAnimation)
public:
enum ReversingMode { Eased, Immediate, Sync };
diff --git a/src/quick/util/qquickspringanimation_p.h b/src/quick/util/qquickspringanimation_p.h
index 2014a4311a..771b746622 100644
--- a/src/quick/util/qquickspringanimation_p.h
+++ b/src/quick/util/qquickspringanimation_p.h
@@ -71,6 +71,7 @@ class Q_AUTOTEST_EXPORT QQuickSpringAnimation : public QQuickNumberAnimation
Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
+ QML_NAMED_ELEMENT(SpringAnimation)
public:
QQuickSpringAnimation(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickstate_p.h b/src/quick/util/qquickstate_p.h
index 576ba9834c..af49bb1c2f 100644
--- a/src/quick/util/qquickstate_p.h
+++ b/src/quick/util/qquickstate_p.h
@@ -125,6 +125,7 @@ class QQuickStateOperationPrivate;
class Q_QUICK_PRIVATE_EXPORT QQuickStateOperation : public QObject
{
Q_OBJECT
+ QML_ANONYMOUS
public:
QQuickStateOperation(QObject *parent = nullptr)
: QObject(parent) {}
@@ -157,6 +158,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickState : public QObject
Q_PROPERTY(QQmlListProperty<QQuickStateOperation> changes READ changes)
Q_CLASSINFO("DefaultProperty", "changes")
Q_CLASSINFO("DeferredPropertyNames", "changes")
+ QML_NAMED_ELEMENT(State)
public:
QQuickState(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickstatechangescript_p.h b/src/quick/util/qquickstatechangescript_p.h
index ff509a7cf5..931baaca4e 100644
--- a/src/quick/util/qquickstatechangescript_p.h
+++ b/src/quick/util/qquickstatechangescript_p.h
@@ -64,6 +64,7 @@ class Q_AUTOTEST_EXPORT QQuickStateChangeScript : public QQuickStateOperation, p
Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
Q_PROPERTY(QString name READ name WRITE setName)
+ QML_NAMED_ELEMENT(StateChangeScript)
public:
QQuickStateChangeScript(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickstategroup_p.h b/src/quick/util/qquickstategroup_p.h
index 7235066d99..11a0c5f442 100644
--- a/src/quick/util/qquickstategroup_p.h
+++ b/src/quick/util/qquickstategroup_p.h
@@ -65,6 +65,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateGroup : public QObject, public QQmlParse
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(QQmlListProperty<QQuickState> states READ statesProperty DESIGNABLE false)
Q_PROPERTY(QQmlListProperty<QQuickTransition> transitions READ transitionsProperty DESIGNABLE false)
+ QML_NAMED_ELEMENT(StateGroup)
public:
QQuickStateGroup(QObject * = nullptr);
diff --git a/src/quick/util/qquicksystempalette_p.h b/src/quick/util/qquicksystempalette_p.h
index 9a3a520ed1..c6d9fc2604 100644
--- a/src/quick/util/qquicksystempalette_p.h
+++ b/src/quick/util/qquicksystempalette_p.h
@@ -79,6 +79,7 @@ class Q_AUTOTEST_EXPORT QQuickSystemPalette : public QObject
Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
+ QML_NAMED_ELEMENT(SystemPalette)
public:
QQuickSystemPalette(QObject *parent=nullptr);
diff --git a/src/quick/util/qquicktextmetrics_p.h b/src/quick/util/qquicktextmetrics_p.h
index 4fb6741996..a1d64e3d0a 100644
--- a/src/quick/util/qquicktextmetrics_p.h
+++ b/src/quick/util/qquicktextmetrics_p.h
@@ -74,6 +74,8 @@ class Q_AUTOTEST_EXPORT QQuickTextMetrics : public QObject
Q_PROPERTY(QString elidedText READ elidedText NOTIFY metricsChanged FINAL)
Q_PROPERTY(Qt::TextElideMode elide READ elide WRITE setElide NOTIFY elideChanged FINAL)
Q_PROPERTY(qreal elideWidth READ elideWidth WRITE setElideWidth NOTIFY elideWidthChanged FINAL)
+ QML_NAMED_ELEMENT(TextMetrics)
+ QML_ADDED_IN_MINOR_VERSION(4)
public:
explicit QQuickTextMetrics(QObject *parent = 0);
diff --git a/src/quick/util/qquicktransition_p.h b/src/quick/util/qquicktransition_p.h
index c7d06b8832..6e45143126 100644
--- a/src/quick/util/qquicktransition_p.h
+++ b/src/quick/util/qquicktransition_p.h
@@ -103,6 +103,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTransition : public QObject
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_CLASSINFO("DefaultProperty", "animations")
Q_CLASSINFO("DeferredPropertyNames", "animations")
+ QML_NAMED_ELEMENT(Transition)
public:
QQuickTransition(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index 93b6599506..650a8c7e81 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -40,6 +40,7 @@
#include "qquickutilmodule_p.h"
#include "qquickanimation_p.h"
#include "qquickanimation_p_p.h"
+#include "qquickapplication_p.h"
#include "qquickbehavior_p.h"
#include "qquicksmoothedanimation_p.h"
#include "qquickfontloader_p.h"
@@ -58,12 +59,11 @@
#include "qquickshortcut_p.h"
#endif
#include "qquickvalidator_p.h"
+#include "qquickforeignutils_p.h"
#include <qqmlinfo.h>
#include <private/qqmltypenotavailable_p.h>
#include <private/qquickanimationcontroller_p.h>
#include <QtCore/qcoreapplication.h>
-#include <QtGui/QInputMethod>
-#include <QtGui/QKeySequence>
#if QT_CONFIG(shortcut)
Q_DECLARE_METATYPE(QKeySequence::StandardKey)
@@ -71,73 +71,61 @@ Q_DECLARE_METATYPE(QKeySequence::StandardKey)
void QQuickUtilModule::defineModule()
{
-#if QT_CONFIG(im)
- qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputMethod",
- QInputMethod::tr("InputMethod is an abstract class"));
+#if QT_CONFIG(shortcut)
+ qRegisterMetaType<QKeySequence::StandardKey>();
#endif
- qmlRegisterUncreatableType<QQuickAbstractAnimation>("QtQuick",2,0,"Animation",QQuickAbstractAnimation::tr("Animation is an abstract class"));
-
- qmlRegisterType<QQuickBehavior>("QtQuick",2,0,"Behavior");
- qmlRegisterType<QQuickColorAnimation>("QtQuick",2,0,"ColorAnimation");
- qmlRegisterType<QQuickSmoothedAnimation>("QtQuick",2,0,"SmoothedAnimation");
- qmlRegisterType<QQuickFontLoader>("QtQuick",2,0,"FontLoader");
- qmlRegisterType<QQuickNumberAnimation>("QtQuick",2,0,"NumberAnimation");
- qmlRegisterType<QQuickParallelAnimation>("QtQuick",2,0,"ParallelAnimation");
- qmlRegisterType<QQuickPauseAnimation>("QtQuick",2,0,"PauseAnimation");
- qmlRegisterType<QQuickPropertyAction>("QtQuick",2,0,"PropertyAction");
- qmlRegisterType<QQuickPropertyAnimation>("QtQuick",2,0,"PropertyAnimation");
- qmlRegisterType<QQuickRotationAnimation>("QtQuick",2,0,"RotationAnimation");
- qmlRegisterType<QQuickScriptAction>("QtQuick",2,0,"ScriptAction");
- qmlRegisterType<QQuickSequentialAnimation>("QtQuick",2,0,"SequentialAnimation");
- qmlRegisterType<QQuickSpringAnimation>("QtQuick",2,0,"SpringAnimation");
- qmlRegisterType<QQuickAnimationController>("QtQuick",2,0,"AnimationController");
- qmlRegisterType<QQuickStateChangeScript>("QtQuick",2,0,"StateChangeScript");
- qmlRegisterType<QQuickStateGroup>("QtQuick",2,0,"StateGroup");
- qmlRegisterType<QQuickState>("QtQuick",2,0,"State");
- qmlRegisterType<QQuickSystemPalette>("QtQuick",2,0,"SystemPalette");
- qmlRegisterType<QQuickTransition>("QtQuick",2,0,"Transition");
- qmlRegisterType<QQuickVector3dAnimation>("QtQuick",2,0,"Vector3dAnimation");
+ qmlRegisterTypesAndRevisions<
#if QT_CONFIG(validator)
- qmlRegisterAnonymousType<QValidator>("QtQuick", 2);
- qmlRegisterType<QQuickIntValidator>("QtQuick",2,0,"IntValidator");
- qmlRegisterType<QQuickDoubleValidator>("QtQuick",2,0,"DoubleValidator");
- qmlRegisterType<QRegExpValidator>("QtQuick",2,0,"RegExpValidator");
+ QValidatorForeign,
+ QQuickIntValidator,
+ QQuickDoubleValidator,
+ QRegExpValidatorForeign,
#if QT_CONFIG(regularexpression)
- qmlRegisterType<QRegularExpressionValidator>("QtQuick", 2, 14, "RegularExpressionValidator");
-#endif
-#endif
-
- qmlRegisterUncreatableType<QQuickAnimator>("QtQuick", 2, 2, "Animator", QQuickAbstractAnimation::tr("Animator is an abstract class"));
- qmlRegisterType<QQuickXAnimator>("QtQuick", 2, 2, "XAnimator");
- qmlRegisterType<QQuickYAnimator>("QtQuick", 2, 2, "YAnimator");
- qmlRegisterType<QQuickScaleAnimator>("QtQuick", 2, 2, "ScaleAnimator");
- qmlRegisterType<QQuickRotationAnimator>("QtQuick", 2, 2, "RotationAnimator");
- qmlRegisterType<QQuickOpacityAnimator>("QtQuick", 2, 2, "OpacityAnimator");
+ QRegularExpressionValidatorForeign,
+#endif // QT_CONFIG(regularexpression)
+#endif // QT_CONFIG(validator)
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
- qmlRegisterType<QQuickUniformAnimator>("QtQuick", 2, 2, "UniformAnimator");
+ QQuickUniformAnimator,
#endif
- qmlRegisterAnonymousType<QQuickStateOperation>("QtQuick", 2);
-
- qmlRegisterCustomType<QQuickPropertyChanges>("QtQuick",2,0,"PropertyChanges", new QQuickPropertyChangesParser);
-
#if QT_CONFIG(shortcut)
- qRegisterMetaType<QKeySequence::StandardKey>();
- qmlRegisterUncreatableType<QKeySequence, 2>("QtQuick", 2, 2, "StandardKey", QStringLiteral("Cannot create an instance of StandardKey."));
+ QQuickShortcut,
+ QKeySequenceForeign,
#endif
-
- qmlRegisterType<QQuickFontMetrics>("QtQuick", 2, 4, "FontMetrics");
- qmlRegisterType<QQuickTextMetrics>("QtQuick", 2, 4, "TextMetrics");
-
-#if QT_CONFIG(shortcut)
- qmlRegisterType<QQuickShortcut>("QtQuick", 2, 5, "Shortcut");
- qmlRegisterType<QQuickShortcut,6>("QtQuick", 2, 6, "Shortcut");
-
- qmlRegisterType<QQuickShortcut,9>("QtQuick", 2, 9, "Shortcut");
+#if QT_CONFIG(im)
+ QInputMethodForeign,
#endif
-
- qmlRegisterUncreatableType<QQuickAbstractAnimation, 12>("QtQuick", 2, 12, "Animation",
- QQuickAbstractAnimation::tr("Animation is an abstract class"));
- // 5.13
- qmlRegisterType<QQuickBehavior, 13>("QtQuick", 2, 13, "Behavior");
+ QQuickAbstractAnimation,
+ QQuickBehavior,
+ QQuickColorAnimation,
+ QQuickSmoothedAnimation,
+ QQuickFontLoader,
+ QQuickNumberAnimation,
+ QQuickParallelAnimation,
+ QQuickPauseAnimation,
+ QQuickPropertyAction,
+ QQuickPropertyAnimation,
+ QQuickRotationAnimation,
+ QQuickScriptAction,
+ QQuickSequentialAnimation,
+ QQuickSpringAnimation,
+ QQuickAnimationController,
+ QQuickStateChangeScript,
+ QQuickStateGroup,
+ QQuickState,
+ QQuickSystemPalette,
+ QQuickTransition,
+ QQuickVector3dAnimation,
+ QQuickAnimator,
+ QQuickXAnimator,
+ QQuickYAnimator,
+ QQuickScaleAnimator,
+ QQuickRotationAnimator,
+ QQuickOpacityAnimator,
+ QQuickStateOperation,
+ QQuickPropertyChanges,
+ QQuickFontMetrics,
+ QQuickTextMetrics,
+ QQuickApplication
+ >("QtQuick", 2);
}
diff --git a/src/quick/util/qquickvalidator_p.h b/src/quick/util/qquickvalidator_p.h
index 9212efa044..a0dc2cd5ba 100644
--- a/src/quick/util/qquickvalidator_p.h
+++ b/src/quick/util/qquickvalidator_p.h
@@ -61,6 +61,7 @@ class Q_AUTOTEST_EXPORT QQuickIntValidator : public QIntValidator
{
Q_OBJECT
Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged)
+ QML_NAMED_ELEMENT(IntValidator)
public:
QQuickIntValidator(QObject *parent = nullptr);
@@ -76,6 +77,7 @@ class Q_AUTOTEST_EXPORT QQuickDoubleValidator : public QDoubleValidator
{
Q_OBJECT
Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged)
+ QML_NAMED_ELEMENT(DoubleValidator)
public:
QQuickDoubleValidator(QObject *parent = nullptr);
diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h
index 5a9af970e8..25fac72a38 100644
--- a/src/quick/util/qquickvaluetypes_p.h
+++ b/src/quick/util/qquickvaluetypes_p.h
@@ -326,6 +326,9 @@ class QQuickFontValueType
Q_PROPERTY(bool kerning READ kerning WRITE setKerning FINAL)
Q_PROPERTY(bool preferShaping READ preferShaping WRITE setPreferShaping FINAL)
+ QML_NAMED_ELEMENT(Font)
+ QML_UNCREATABLE("Element is not creatable.")
+
public:
enum FontWeight { Thin = QFont::Thin,
ExtraLight = QFont::ExtraLight,
diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri
index 63d995e34c..3a1addfcd4 100644
--- a/src/quick/util/util.pri
+++ b/src/quick/util/util.pri
@@ -15,7 +15,6 @@ SOURCES += \
$$PWD/qquicktimeline.cpp \
$$PWD/qquickpixmapcache.cpp \
$$PWD/qquickbehavior.cpp \
- $$PWD/qquickboundaryrule.cpp \
$$PWD/qquickfontloader.cpp \
$$PWD/qquickstyledtext.cpp \
$$PWD/qquickimageprovider.cpp \
@@ -51,7 +50,6 @@ HEADERS += \
$$PWD/qquicktimeline_p_p.h \
$$PWD/qquickpixmapcache_p.h \
$$PWD/qquickbehavior_p.h \
- $$PWD/qquickboundaryrule_p.h \
$$PWD/qquickfontloader_p.h \
$$PWD/qquickstyledtext_p.h \
$$PWD/qquickimageprovider.h \
@@ -65,7 +63,8 @@ HEADERS += \
$$PWD/qquickprofiler_p.h \
$$PWD/qquickfontmetrics_p.h \
$$PWD/qquicktextmetrics_p.h \
- $$PWD/qquickvalidator_p.h
+ $$PWD/qquickvalidator_p.h \
+ $$PWD/qquickforeignutils_p.h
qtConfig(shortcut) {
SOURCES += \
diff --git a/src/quickshapes/qquickshape_p.h b/src/quickshapes/qquickshape_p.h
index 7066ea0709..cadc65f7cd 100644
--- a/src/quickshapes/qquickshape_p.h
+++ b/src/quickshapes/qquickshape_p.h
@@ -69,6 +69,9 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeGradient : public QQuickGradient
Q_PROPERTY(SpreadMode spread READ spread WRITE setSpread NOTIFY spreadChanged)
Q_CLASSINFO("DefaultProperty", "stops")
+ QML_NAMED_ELEMENT(ShapeGradient)
+ QML_UNCREATABLE("ShapeGradient is an abstract base class.");
+
public:
enum SpreadMode {
PadSpread,
@@ -97,6 +100,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeLinearGradient : public QQuickShap
Q_PROPERTY(qreal x2 READ x2 WRITE setX2 NOTIFY x2Changed)
Q_PROPERTY(qreal y2 READ y2 WRITE setY2 NOTIFY y2Changed)
Q_CLASSINFO("DefaultProperty", "stops")
+ QML_NAMED_ELEMENT(LinearGradient)
public:
QQuickShapeLinearGradient(QObject *parent = nullptr);
@@ -131,6 +135,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeRadialGradient : public QQuickShap
Q_PROPERTY(qreal focalY READ focalY WRITE setFocalY NOTIFY focalYChanged)
Q_PROPERTY(qreal focalRadius READ focalRadius WRITE setFocalRadius NOTIFY focalRadiusChanged)
Q_CLASSINFO("DefaultProperty", "stops")
+ QML_NAMED_ELEMENT(RadialGradient)
public:
QQuickShapeRadialGradient(QObject *parent = nullptr);
@@ -175,6 +180,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeConicalGradient : public QQuickSha
Q_PROPERTY(qreal centerY READ centerY WRITE setCenterY NOTIFY centerYChanged)
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
Q_CLASSINFO("DefaultProperty", "stops")
+ QML_NAMED_ELEMENT(ConicalGradient)
public:
QQuickShapeConicalGradient(QObject *parent = nullptr);
@@ -214,6 +220,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapePath : public QQuickPath
Q_PROPERTY(QVector<qreal> dashPattern READ dashPattern WRITE setDashPattern NOTIFY dashPatternChanged)
Q_PROPERTY(QQuickShapeGradient *fillGradient READ fillGradient WRITE setFillGradient RESET resetFillGradient)
Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION 14)
+ QML_NAMED_ELEMENT(ShapePath)
public:
enum FillRule {
@@ -308,6 +315,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShape : public QQuickItem
Q_PROPERTY(ContainsMode containsMode READ containsMode WRITE setContainsMode NOTIFY containsModeChanged REVISION 11)
Q_PROPERTY(QQmlListProperty<QObject> data READ data)
Q_CLASSINFO("DefaultProperty", "data")
+ QML_NAMED_ELEMENT(Shape)
public:
enum RendererType {