aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp19
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h1
2 files changed, 20 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);
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index e755694335..99c1af6cbf 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -461,6 +461,7 @@ public:
bool generateFromQml(const QString &code, const QString &url, Document *output);
static bool isSignalPropertyName(const QString &name);
+ static QString signalNameFromSignalPropertyName(const QString &signalPropertyName);
using QQmlJS::AST::Visitor::visit;
using QQmlJS::AST::Visitor::endVisit;