diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-01-28 15:53:51 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-01-29 08:43:41 +0100 |
commit | eff73ee3197723eb1f5b35ec39bb496a40ab5343 (patch) | |
tree | d93caaa0c0b681566cb4383db095578c8c5f5438 /src | |
parent | 92c87fec98f0b9e86e74c1660a2962d4aa16964c (diff) |
Expose getter and setter names of C++ classes in qmltypes files
This simply exports the name which are already available in the json
files generated by moc. We do not consider whether the methods are
non-private for now. MEMBER is not supported either, but might be added
if the need actually arises.
Fixes: QTBUG-90711
Change-Id: If3ee18c8ce60499676a7ee22df569cba0912e22f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/tooling/Property.qml | 2 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljstypedescriptionreader.cpp | 3 | ||||
-rw-r--r-- | src/qmltyperegistrar/qmltypescreator.cpp | 6 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/imports/tooling/Property.qml b/src/imports/tooling/Property.qml index 7c335a1dc9..de76df55b3 100644 --- a/src/imports/tooling/Property.qml +++ b/src/imports/tooling/Property.qml @@ -46,4 +46,6 @@ Member { property bool isList: false property int revision: 0 property string bindable + property string read + property string write } diff --git a/src/qmlcompiler/qqmljstypedescriptionreader.cpp b/src/qmlcompiler/qqmljstypedescriptionreader.cpp index b3ef6092a0..3457b6ec15 100644 --- a/src/qmlcompiler/qqmljstypedescriptionreader.cpp +++ b/src/qmlcompiler/qqmljstypedescriptionreader.cpp @@ -347,6 +347,9 @@ void QQmlJSTypeDescriptionReader::readProperty(UiObjectDefinition *ast, const QQ property.setRevision(readIntBinding(script)); } else if (id == QLatin1String("bindable")) { property.setBindable(readStringBinding(script)); + } else if (id == QLatin1String("read") || id == QLatin1String("write")) { + // QQmlJSMetaProperty currently does not make use of the getter and setter name + continue; } else { addWarning(script->firstSourceLocation(), tr("Expected only type, name, revision, isPointer, isReadonly, bindable, and" diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp index b5a3cd749c..4dafdc4490 100644 --- a/src/qmltyperegistrar/qmltypescreator.cpp +++ b/src/qmltyperegistrar/qmltypescreator.cpp @@ -178,6 +178,12 @@ void QmlTypesCreator::writeProperties(const QJsonArray &properties, QSet<QString if (bindable != obj.constEnd()) m_qml.writeScriptBinding(QLatin1String("bindable"), enquote(bindable->toString())); writeType(obj, QLatin1String("type"), !obj.contains(QLatin1String("write")), true); + const auto read = obj.constFind(QLatin1String("read")); + if (read != obj.constEnd()) + m_qml.writeScriptBinding(QLatin1String("read"), enquote(read->toString())); + const auto write = obj.constFind(QLatin1String("write")); + if (write != obj.constEnd()) + m_qml.writeScriptBinding(QLatin1String("write"), enquote(write->toString())); m_qml.writeEndObject(); const QString notify = obj[QLatin1String("notify")].toString(); |