aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-03-15 11:58:58 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-21 01:10:41 +0100
commit37cd29b2ff024f27f84ef6214ff5403603d522f2 (patch)
tree88dd0d32f024195ed068dd87663e3b07bb6d798b /src/qml
parentfd8028514550da7594736a10f1d20bab1576bcfd (diff)
Support (registered) non-local enums for signal/slot params in QML.
It's now possible to detect whether a registered type is an enum, allowing registered non-local enums to be used as parameters in signals and slots from QML/C++. Author: Glenn Watson <glenn.watson@nokia.com> Task-number: QTBUG-20639 Change-Id: I8c439f2dcc7bfd8ec31914b0c86cd3a1de3c038c Reviewed-by: Chris Adams <christopher.adams@nokia.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp5
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp8
2 files changed, 10 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 3200aaea3a..5cc603224a 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -227,7 +227,10 @@ QQmlBoundSignalParameters::QQmlBoundSignalParameters(const QMetaMethod &method,
prop.setWritable(false);
} else {
QByteArray propType = type;
- if (t >= QVariant::UserType || t == QVariant::Invalid) {
+ if ((QMetaType::typeFlags(t) & QMetaType::IsEnumeration) == QMetaType::IsEnumeration) {
+ t = QVariant::Int;
+ propType = "int";
+ } else if (t == QVariant::Invalid) {
QByteArray scope;
QByteArray name;
int scopeIdx = propType.lastIndexOf("::");
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 93c6aa1f00..9ff79a1956 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -734,7 +734,9 @@ int *QQmlPropertyCache::methodParameterTypes(QObject *object, int index,
for (int ii = 0; ii < argTypeNames.count(); ++ii) {
int type = QMetaType::type(argTypeNames.at(ii));
- if (type == QVariant::Invalid)
+ if ((QMetaType::typeFlags(type) & QMetaType::IsEnumeration) == QMetaType::IsEnumeration)
+ type = QVariant::Int;
+ else if (type == QVariant::Invalid)
type = EnumType(object->metaObject(), argTypeNames.at(ii));
if (type == QVariant::Invalid) {
if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii);
@@ -757,7 +759,9 @@ int *QQmlPropertyCache::methodParameterTypes(QObject *object, int index,
for (int ii = 0; ii < argTypeNames.count(); ++ii) {
int type = QMetaType::type(argTypeNames.at(ii));
- if (type == QVariant::Invalid)
+ if ((QMetaType::typeFlags(type) & QMetaType::IsEnumeration) == QMetaType::IsEnumeration)
+ type = QVariant::Int;
+ else if (type == QVariant::Invalid)
type = EnumType(object->metaObject(), argTypeNames.at(ii));
if (type == QVariant::Invalid) {
if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii);