aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-19 17:37:54 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-19 18:10:23 +0100
commit1daee0b03050487cfc4b483262ca73e5a24267ff (patch)
tree1976f6da0587135121518035cf332b1e84efb46b /src/qml/compiler/qqmlirbuilder.cpp
parent2707910edb6311c1c50253ef80def9e161ea35f6 (diff)
QML: Make retrieval of a signal name from a handler accessible
We want to do that in other places, too. Pick-to: 6.1 Change-Id: Id42495d239c2dccffa390478c8b57ec1acab7408 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder.cpp')
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index b6bc48c833..c7343e709c 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -501,6 +501,25 @@ bool IRBuilder::isSignalPropertyName(const QString &name)
return false; // consists solely of underscores - invalid.
}
+QString IRBuilder::signalNameFromSignalPropertyName(const QString &signalPropertyName)
+{
+ Q_ASSERT(signalPropertyName.startsWith(QLatin1String("on")));
+ QString signalNameCandidate = signalPropertyName;
+ signalNameCandidate.remove(0, 2);
+
+ // Note that the property name could start with any alpha or '_' or '$' character,
+ // so we need to do the lower-casing of the first alpha character.
+ for (int firstAlphaIndex = 0; firstAlphaIndex < signalNameCandidate.size(); ++firstAlphaIndex) {
+ if (signalNameCandidate.at(firstAlphaIndex).isUpper()) {
+ signalNameCandidate[firstAlphaIndex] = signalNameCandidate.at(firstAlphaIndex).toLower();
+ return signalNameCandidate;
+ }
+ }
+
+ Q_UNREACHABLE();
+ return QString();
+}
+
bool IRBuilder::visit(QQmlJS::AST::UiArrayMemberList *ast)
{
return QQmlJS::AST::Visitor::visit(ast);