diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-02-20 09:57:06 +0100 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-02-22 16:21:09 +0100 |
| commit | a142873d1cc85c5be50b0479063da36c0f10dc66 (patch) | |
| tree | a57708f79cd6de3ef045a27ce36cd76eed82df8e /tests/auto/qml/qmlcppcodegen/data | |
| parent | 1dad3c22d62e0bbe737a1e76fe44b451ca7f33b3 (diff) | |
QmlCompiler: Implement get lookup of variantMap properties
This patch adds support for get lookups of QVariantMap properties.
Setting or modifying is not supported and will reject.
Also, QQmlJSRegisterContent::JavaScriptObjectProperty was
renamed to QQmlJSRegisterContent::GenericObjectProperty
Tests were added to TestQmllint::cleanQmlCode() and
tst_QmlCppCodegen::variantMapLookup().
Pick-to: 6.5
Fixes: QTBUG-105545
Change-Id: I653ee4e7de1fb1514e1e563a92cfc28633268a7e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h | 17 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml | 11 |
3 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index a2a5224014..fdd1456af0 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -18,6 +18,7 @@ set(cpp_sources state.h theme.cpp theme.h timelinetheme.cpp timelinetheme.h + variantMapLookup.h wrapwithvariant.h withlength.h ) @@ -200,6 +201,7 @@ set(qml_files valueTypeProperty.qml valueTypeReference.qml variantlist.qml + variantMapLookup.qml versionmismatch.qml voidfunction.qml dummy_imports.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h new file mode 100644 index 0000000000..61d38228b0 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h @@ -0,0 +1,17 @@ +#pragma once +#include <QObject> +#include <QVariantMap> +#include <QtQml/qqmlregistration.h> + +class VariantMapLookupFoo : public QObject +{ + Q_OBJECT + QML_ELEMENT + Q_PROPERTY(QVariantMap data READ data CONSTANT) + +public: + VariantMapLookupFoo(QObject *parent = nullptr) : QObject(parent) { } + +private: + QVariantMap data() const { return { { "value", 42 } }; } +}; diff --git a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml new file mode 100644 index 0000000000..4e56cb9448 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml @@ -0,0 +1,11 @@ +pragma Strict +import TestTypes +import QtQuick + +Item { + property int i: moo.data.value + + VariantMapLookupFoo { + id: moo + } +} |
