From cc1a604c704f848927b3fa0a97b0a50b0b79d2a4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 21 Aug 2019 18:34:21 +0200 Subject: Specify parameters of type registration in class declarations Using this technique we can automatically register all necessary revisions and minor versions of a type, using the metaobject system. This greatly reduces the potential for mistakes and resulting incompatibilities between versions of imports. We assume that for each type we need to register all revisions of its super types and its attached type, and that the revisions match. That is, if you import version X of type A, you will also get version X of its attached type and of any super types. As we previously didn't take these dependencies into account when manually registering the types, a number of extra revisions are now registered for some types. Potentially, we can now generate the qmltypes files at compile time, using moc. Change-Id: I7abb8a5c39f5e63ad1a0cb41a783f2c91909491b Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp | 2 +- examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h | 1 + examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp | 2 +- examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h | 2 +- examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp | 2 +- examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h | 1 + .../qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp | 4 +--- .../tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h | 2 +- .../tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h | 1 + examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp | 3 +-- .../qml/tutorials/extending-qml/chapter5-listproperties/piechart.h | 1 + .../qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h | 1 + .../tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp | 3 +-- .../qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h | 1 + .../qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h | 1 + 15 files changed, 15 insertions(+), 12 deletions(-) (limited to 'examples/qml/tutorials') diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp index fbff60c0e6..af50cc14f2 100644 --- a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h index 005a706db6..687f8e2b4d 100644 --- a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h @@ -59,6 +59,7 @@ class PieChart : public QQuickPaintedItem Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QColor color READ color WRITE setColor) + QML_ELEMENT public: PieChart(QQuickItem *parent = 0); diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp index fbff60c0e6..af50cc14f2 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h index 36bfa3ada0..271afbf653 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h @@ -60,7 +60,7 @@ class PieChart : public QQuickPaintedItem Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QColor color READ color WRITE setColor) - + QML_ELEMENT //![1] public: //![1] diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp index fbff60c0e6..af50cc14f2 100644 --- a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h index 9de2baa82e..58b1339298 100644 --- a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h @@ -59,6 +59,7 @@ class PieChart : public QQuickPaintedItem //![0] Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) + QML_ELEMENT //![1] Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp index 82355d0438..7c5d1a6885 100644 --- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp @@ -59,10 +59,8 @@ int main(int argc, char *argv[]) //![0] QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); - //![1] - qmlRegisterType("Charts", 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions("Charts", 1); //![1] QQuickView view; diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h index 6cd09a9293..b762ce1c49 100644 --- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h @@ -61,7 +61,7 @@ class PieChart : public QQuickItem Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) //![0] Q_PROPERTY(QString name READ name WRITE setName) - + QML_ELEMENT //![1] public: //![1] diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h index 10ab4d34b6..6e64917851 100644 --- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h +++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h @@ -58,6 +58,7 @@ class PieSlice : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor) + QML_ELEMENT public: PieSlice(QQuickItem *parent = 0); diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp index 8aa6fef018..70ef103e4d 100644 --- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp @@ -57,8 +57,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); - qmlRegisterType("Charts", 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h index 9b3390b902..236fa6796f 100644 --- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h @@ -61,6 +61,7 @@ class PieChart : public QQuickItem Q_PROPERTY(QQmlListProperty slices READ slices) //![0] Q_PROPERTY(QString name READ name WRITE setName) + QML_ELEMENT //![1] public: diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h index f8f7f7c36a..0b290851f0 100644 --- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h +++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h @@ -60,6 +60,7 @@ class PieSlice : public QQuickPaintedItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + QML_ELEMENT //![0] public: diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp index ce8b95b6b6..74d382ec57 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp @@ -55,8 +55,7 @@ void ChartsPlugin::registerTypes(const char *uri) { - qmlRegisterType(uri, 1, 0, "PieChart"); - qmlRegisterType(uri, 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions(uri, 1); } //![0] diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h index cd67bdf34a..e6b768b274 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h @@ -59,6 +59,7 @@ class PieChart : public QQuickItem Q_OBJECT Q_PROPERTY(QQmlListProperty slices READ slices) Q_PROPERTY(QString name READ name WRITE setName) + QML_ELEMENT public: PieChart(QQuickItem *parent = 0); diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h index 71cc20a369..091870bd51 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h @@ -59,6 +59,7 @@ class PieSlice : public QQuickPaintedItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + QML_ELEMENT public: PieSlice(QQuickItem *parent = 0); -- cgit v1.2.3