summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmllistscriptclass.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-01-28 05:54:33 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-01-28 05:54:33 (GMT)
commit5f1d7d1e73edd1c2ff3e1ad244100fdbc3495458 (patch)
tree55d084dfdd94a1d1bf7e5732a7eb732b83a3cb30 /src/declarative/qml/qmllistscriptclass.cpp
parent044c93a48213e325f486c3076837a2a7cebbe9aa (diff)
downloadQt-5f1d7d1e73edd1c2ff3e1ad244100fdbc3495458.zip
Qt-5f1d7d1e73edd1c2ff3e1ad244100fdbc3495458.tar.gz
Qt-5f1d7d1e73edd1c2ff3e1ad244100fdbc3495458.tar.bz2
Convert lists to variants on assignment.
QTBUG-5675
Diffstat (limited to 'src/declarative/qml/qmllistscriptclass.cpp')
-rw-r--r--src/declarative/qml/qmllistscriptclass.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp
index 441c410..d4cdc6e 100644
--- a/src/declarative/qml/qmllistscriptclass.cpp
+++ b/src/declarative/qml/qmllistscriptclass.cpp
@@ -49,7 +49,8 @@ QT_BEGIN_NAMESPACE
struct ListData : public QScriptDeclarativeClass::Object {
QmlGuard<QObject> object;
int propertyIdx;
- QmlListScriptClass::ListType type;
+ QmlListScriptClass::ListCategory type;
+ int propertyType;
};
QmlListScriptClass::QmlListScriptClass(QmlEngine *e)
@@ -65,7 +66,7 @@ QmlListScriptClass::~QmlListScriptClass()
{
}
-QScriptValue QmlListScriptClass::newList(QObject *object, int propId, ListType type)
+QScriptValue QmlListScriptClass::newList(QObject *object, int propId, ListCategory type, int propType)
{
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
@@ -76,6 +77,7 @@ QScriptValue QmlListScriptClass::newList(QObject *object, int propId, ListType t
data->object = object;
data->propertyIdx = propId;
data->type = type;
+ data->propertyType = propType;
return newObject(scriptEngine, this, data);
}
@@ -144,5 +146,28 @@ QmlListScriptClass::ScriptValue QmlListScriptClass::property(Object *obj, const
}
}
+QVariant QmlListScriptClass::toVariant(Object *obj, bool *ok)
+{
+ ListData *data = (ListData *)obj;
+
+ if (!data->object) {
+ if (ok) *ok = false;
+ return QVariant();
+ }
+
+ void *list = 0;
+ void *args[] = { &list, 0 };
+ QMetaObject::metacall(data->object, QMetaObject::ReadProperty,
+ data->propertyIdx, args);
+
+ if (!list) {
+ if (ok) *ok = false;
+ return QVariant();
+ }
+
+ if (ok) *ok = true;
+ return QVariant(data->propertyType, &list);
+}
+
QT_END_NAMESPACE