summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-04-05 16:55:18 +1000
committerBea Lam <bea.lam@nokia.com>2011-04-12 11:07:49 +1000
commitf2219ce983098fc14655d8f3bb8a7fee2c9abe4d (patch)
treef8efd2e3eab7ff4ee868985fa7cdeb3fad0f0f1e /src
parent6ec7695eaa02c923b90d72e3918b9ab50da63e41 (diff)
downloadqt4-tools-f2219ce983098fc14655d8f3bb8a7fee2c9abe4d.tar.gz
Allow enum values to be used as signal parameters
The fix does not work for enums declared outside of the class that emits the signal, since in this case it is not possible to access the metaobject of the class that declared the enum. However the fix makes a special case for the Qt namespace to allow enums in this namespace to be used. Task-number: QTBUG-15983 Change-Id: I6f72255b07010311a20fe068bd97c7db7b294d9b Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index 28dfea965e..47a15cb0ce 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -225,9 +225,35 @@ QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMeta
QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*");
prop.setWritable(false);
} else {
+ QByteArray propType = type;
+ if (t >= QVariant::UserType || t == QVariant::Invalid) {
+ //copy of QDeclarativeObjectScriptClass::enumType()
+ QByteArray scope;
+ QByteArray name;
+ int scopeIdx = propType.lastIndexOf("::");
+ if (scopeIdx != -1) {
+ scope = propType.left(scopeIdx);
+ name = propType.mid(scopeIdx + 2);
+ } else {
+ name = propType;
+ }
+ const QMetaObject *meta;
+ if (scope == "Qt")
+ meta = &QObject::staticQtMetaObject;
+ else
+ meta = parent->parent()->metaObject(); //### assumes parent->parent()
+ for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = meta->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) {
+ t = QVariant::Int;
+ propType = "int";
+ break;
+ }
+ }
+ }
if (QDeclarativeMetaType::canCopy(t)) {
types[ii] = t;
- QMetaPropertyBuilder prop = mob.addProperty(name, type);
+ QMetaPropertyBuilder prop = mob.addProperty(name, propType);
prop.setWritable(false);
} else {
types[ii] = 0x80000000 | t;