aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltyperegistrar
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-05-14 16:11:14 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-05-19 11:46:37 +0200
commit4b46972be3c34c1b5506ba7d8c97f4520e2c17d6 (patch)
tree49fdcfb5561a1e892bc602e420e295764cb0cd9b /src/qmltyperegistrar
parentd6c98f192922b3ceab5eb65e651a7f0588b482e9 (diff)
Add a ParentProperty classinfo and use that to find parents
This is more robust than just going by the "parent" name. Task-number: QTBUG-93662 Change-Id: If099733de6ad0f3bb7cb75b8915789f66b554f85 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmltyperegistrar')
-rw-r--r--src/qmltyperegistrar/qmltypesclassdescription.cpp7
-rw-r--r--src/qmltyperegistrar/qmltypesclassdescription.h1
-rw-r--r--src/qmltyperegistrar/qmltypescreator.cpp3
3 files changed, 11 insertions, 0 deletions
diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp
index 4eb65adea8..bf6c0ca5ed 100644
--- a/src/qmltyperegistrar/qmltypesclassdescription.cpp
+++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp
@@ -114,6 +114,8 @@ void QmlTypesClassDescription::collectLocalAnonymous(
const QJsonObject obj = classInfo.toObject();
if (obj[QStringLiteral("name")].toString() == QStringLiteral("DefaultProperty"))
defaultProp = obj[QStringLiteral("value")].toString();
+ if (obj[QStringLiteral("name")].toString() == QStringLiteral("ParentProperty"))
+ parentProp = obj[QStringLiteral("value")].toString();
}
collectInterfaces(classDef);
@@ -138,6 +140,9 @@ void QmlTypesClassDescription::collect(
if (name == QLatin1String("DefaultProperty")) {
if (mode != RelatedType && defaultProp.isEmpty())
defaultProp = value;
+ } else if (name == QLatin1String("ParentProperty")) {
+ if (mode != RelatedType && parentProp.isEmpty())
+ parentProp = value;
} else if (name == QLatin1String("QML.AddedInVersion")) {
const QTypeRevision revision = QTypeRevision::fromEncodedVersion(value.toInt());
if (mode == TopLevel) {
@@ -198,6 +203,8 @@ void QmlTypesClassDescription::collect(
const QString foreignValue = obj[QLatin1String("value")].toString();
if (defaultProp.isEmpty() && foreignName == QLatin1String("DefaultProperty")) {
defaultProp = foreignValue;
+ } else if (parentProp.isEmpty() && foreignName == QLatin1String("ParentProperty")) {
+ parentProp = foreignValue;
} else if (foreignName == QLatin1String("QML.Attached")) {
attachedType = foreignValue;
collectRelated(foreignValue, types, foreign, defaultRevision);
diff --git a/src/qmltyperegistrar/qmltypesclassdescription.h b/src/qmltyperegistrar/qmltypesclassdescription.h
index 42eeaafee4..1e043fb925 100644
--- a/src/qmltyperegistrar/qmltypesclassdescription.h
+++ b/src/qmltyperegistrar/qmltypesclassdescription.h
@@ -42,6 +42,7 @@ struct QmlTypesClassDescription
QString className;
QString elementName;
QString defaultProp;
+ QString parentProp;
QString superClass;
QString attachedType;
QString extensionType;
diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp
index 1d72207c06..a47e22c264 100644
--- a/src/qmltyperegistrar/qmltypescreator.cpp
+++ b/src/qmltyperegistrar/qmltypescreator.cpp
@@ -55,6 +55,9 @@ void QmlTypesCreator::writeClassProperties(const QmlTypesClassDescription &colle
if (!collector.defaultProp.isEmpty())
m_qml.writeScriptBinding(QLatin1String("defaultProperty"), enquote(collector.defaultProp));
+ if (!collector.parentProp.isEmpty())
+ m_qml.writeScriptBinding(QLatin1String("parentProperty"), enquote(collector.parentProp));
+
if (!collector.superClass.isEmpty())
m_qml.writeScriptBinding(QLatin1String("prototype"), enquote(collector.superClass));