summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-02-23 08:34:41 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-02-23 08:35:43 (GMT)
commit48161233af2a6071bc0ba99e546da98f705b8281 (patch)
treea3d72a9ef84e2394937263299c39483e6307669a /src/declarative
parent9701facad44f8e435f0efe6417ffb7d17d5712e7 (diff)
downloadQt-48161233af2a6071bc0ba99e546da98f705b8281.zip
Qt-48161233af2a6071bc0ba99e546da98f705b8281.tar.gz
Qt-48161233af2a6071bc0ba99e546da98f705b8281.tar.bz2
String to enum conversion in value types
Assigning a string to a value type enum property from a binding was not working as QmlMetaProperty didn't realise the property was of enum type.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp8
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp10
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h3
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp22
-rw-r--r--src/declarative/qml/qmlpropertycache_p.h7
5 files changed, 38 insertions, 12 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 10b6e4f..4508964 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -2609,7 +2609,13 @@ int QmlCompiler::genContextCache()
int QmlCompiler::genValueTypeData(QmlParser::Property *valueTypeProp,
QmlParser::Property *prop)
{
- return output->indexForByteArray(QmlMetaPropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index, valueTypeProp->index, valueTypeProp->type));
+ QByteArray data =
+ QmlMetaPropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index,
+ QmlEnginePrivate::get(engine)->valueTypes[prop->type]->metaObject(),
+ valueTypeProp->index);
+// valueTypeProp->index, valueTypeProp->type);
+
+ return output->indexForByteArray(data);
}
int QmlCompiler::genPropertyData(QmlParser::Property *prop)
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index ac619ec..d731393 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -777,6 +777,7 @@ bool QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value,
writeBack->read(object, core.coreIndex);
QmlPropertyCache::Data data = core;
+ data.flags = valueType.flags;
data.coreIndex = valueType.valueTypeCoreIdx;
data.propType = valueType.valueTypePropType;
rv = write(writeBack, data, value, context, flags);
@@ -1082,15 +1083,20 @@ struct ValueTypeSerializedData : public SerializedData {
};
QByteArray QmlMetaPropertyPrivate::saveValueType(const QMetaObject *metaObject, int index,
- int subIndex, int subType)
+ const QMetaObject *subObject, int subIndex)
{
+ QMetaProperty prop = metaObject->property(index);
+ QMetaProperty subProp = subObject->property(subIndex);
+
ValueTypeSerializedData sd;
sd.type = QmlMetaProperty::ValueTypeProperty;
sd.core.load(metaObject->property(index));
+ sd.valueType.flags = QmlPropertyCache::Data::flagsForProperty(subProp);
sd.valueType.valueTypeCoreIdx = subIndex;
- sd.valueType.valueTypePropType = subType;
+ sd.valueType.valueTypePropType = subProp.userType();
QByteArray rv((const char *)&sd, sizeof(sd));
+
return rv;
}
diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h
index b99e5be..9236bd3 100644
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ b/src/declarative/qml/qmlmetaproperty_p.h
@@ -111,7 +111,8 @@ public:
static QmlAbstractBinding *setBinding(QObject *, const QmlPropertyCache::Data &, QmlAbstractBinding *,
QmlMetaProperty::WriteFlags flags = QmlMetaProperty::DontRemoveBinding);
- static QByteArray saveValueType(const QMetaObject *, int, int, int);
+ static QByteArray saveValueType(const QMetaObject *, int,
+ const QMetaObject *, int);
static QByteArray saveProperty(const QMetaObject *, int);
static QmlMetaProperty restore(const QByteArray &, QObject *, QmlContext * = 0);
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
index 2d087b6..81f8e51 100644
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ b/src/declarative/qml/qmlpropertycache.cpp
@@ -49,13 +49,11 @@ Q_DECLARE_METATYPE(QScriptValue);
QT_BEGIN_NAMESPACE
-void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
+QmlPropertyCache::Data::Flags QmlPropertyCache::Data::flagsForProperty(const QMetaProperty &p, QmlEngine *engine)
{
- propType = p.userType();
- if (QVariant::Type(propType) == QVariant::LastType)
- propType = qMetaTypeId<QVariant>();
- coreIndex = p.propertyIndex();
- notifyIndex = p.notifySignalIndex();
+ int propType = p.userType();
+
+ Flags flags;
if (p.isConstant())
flags |= Data::IsConstant;
@@ -78,6 +76,18 @@ void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
else if (cat == QmlMetaType::List)
flags |= Data::IsQList;
}
+
+ return flags;
+}
+
+void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
+{
+ propType = p.userType();
+ if (QVariant::Type(propType) == QVariant::LastType)
+ propType = qMetaTypeId<QVariant>();
+ coreIndex = p.propertyIndex();
+ notifyIndex = p.notifySignalIndex();
+ flags = flagsForProperty(p, engine);
}
void QmlPropertyCache::Data::load(const QMetaMethod &m)
diff --git a/src/declarative/qml/qmlpropertycache_p.h b/src/declarative/qml/qmlpropertycache_p.h
index 18eea80..4a98b88 100644
--- a/src/declarative/qml/qmlpropertycache_p.h
+++ b/src/declarative/qml/qmlpropertycache_p.h
@@ -104,6 +104,7 @@ public:
int coreIndex;
int notifyIndex;
+ static Flags flagsForProperty(const QMetaProperty &, QmlEngine *engine = 0);
void load(const QMetaProperty &, QmlEngine *engine = 0);
void load(const QMetaMethod &);
QString name(QObject *);
@@ -113,6 +114,7 @@ public:
struct ValueTypeData {
inline ValueTypeData();
inline bool operator==(const ValueTypeData &);
+ Data::Flags flags; // flags on the value type wrapper
int valueTypeCoreIdx; // The prop index of the access property on the value type wrapper
int valueTypePropType; // The QVariant::Type of access property on the value type wrapper
};
@@ -173,13 +175,14 @@ QmlPropertyCache::property(const QScriptDeclarativeClass::Identifier &id) const
}
QmlPropertyCache::ValueTypeData::ValueTypeData()
-: valueTypeCoreIdx(-1), valueTypePropType(0)
+: flags(QmlPropertyCache::Data::NoFlags), valueTypeCoreIdx(-1), valueTypePropType(0)
{
}
bool QmlPropertyCache::ValueTypeData::operator==(const ValueTypeData &o)
{
- return valueTypeCoreIdx == o.valueTypeCoreIdx &&
+ return flags == o.flags &&
+ valueTypeCoreIdx == o.valueTypeCoreIdx &&
valueTypePropType == o.valueTypePropType;
}