aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2022-07-29 10:27:50 +0200
committerAndrei Golubev <andrei.golubev@qt.io>2022-07-29 13:24:49 +0000
commitf11ad705e00fee85dd92374282c32a4377dd11ca (patch)
tree7e9164b574e79691732c6b34a57745ad12db8244 /tools
parent93f8443c526c32394d7edcd52c9b08175ea97f3f (diff)
qmltc: Support CONSTANT and RESET property attributes in aliases
As a drive by, propagate CONSTANT attribute through the .qmltypes file and qmlcompiler library Task-number: QTBUG-91956 Change-Id: I5802fa29ddedcdadae3e505efca0c4fb4d6b2593 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmltc/qmltccompiler.cpp15
-rw-r--r--tools/qmltc/qmltcpropertyutils.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp
index 50aef66f04..6309c4f94b 100644
--- a/tools/qmltc/qmltccompiler.cpp
+++ b/tools/qmltc/qmltccompiler.cpp
@@ -762,6 +762,21 @@ void QmltcCompiler::compileAlias(QmltcType &current, const QQmlJSMetaProperty &a
current.endInit.body += notifyEpilogue;
current.endInit.body << u"}"_s;
}
+ if (QString resetName = result.property.reset(); !resetName.isEmpty()) {
+ Q_ASSERT(result.kind == QQmlJSUtils::AliasTarget_Property); // property is invalid otherwise
+ QmltcMethod reset {};
+ reset.returnType = u"void"_s;
+ reset.name = compilationData.reset;
+ reset.body += prologue;
+ reset.body << latestAccessor + u"->" + resetName + u"()" + u";";
+ reset.body += epilogue;
+ reset.userVisible = true;
+ current.functions.emplaceBack(reset);
+ mocLines << u"RESET"_s << reset.name;
+ }
+
+ if (result.property.isConstant())
+ mocLines << u"CONSTANT"_s;
// 4. add moc entry
// Q_PROPERTY(QString text READ text WRITE setText BINDABLE bindableText NOTIFY textChanged)
diff --git a/tools/qmltc/qmltcpropertyutils.h b/tools/qmltc/qmltcpropertyutils.h
index a22565df0f..7f5b1ff2dd 100644
--- a/tools/qmltc/qmltcpropertyutils.h
+++ b/tools/qmltc/qmltcpropertyutils.h
@@ -44,12 +44,14 @@ struct QmltcPropertyData
write = u"set" + nameWithUppercase;
bindable = u"bindable" + nameWithUppercase;
notify = propertyName + u"Changed";
+ reset = u"reset" + nameWithUppercase;
}
QString read;
QString write;
QString bindable;
QString notify;
+ QString reset;
};
QT_END_NAMESPACE