diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-27 16:15:38 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-30 08:05:48 +0200 |
commit | e57c2c8a0adef8949f69195573d149237814bed1 (patch) | |
tree | 12e15bc037183967cde5278dd1c08d5c2e969977 /src/qml/types | |
parent | 0e36db9f1179d1bdf0710494e98ff7aee1a2d836 (diff) |
remove more uses of QV4::Value
Change-Id: I11b0b2b7626297e2c98dc77784574da4b59ba8cf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmllistmodel.cpp | 28 | ||||
-rw-r--r-- | src/qml/types/qqmllistmodel_p_p.h | 4 |
2 files changed, 17 insertions, 15 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index e16c8d819a..f5e0e70035 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -606,7 +606,7 @@ int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const Q return roleIndex; } -int ListModel::setExistingProperty(int elementIndex, const QString &key, const QV4::Value &data, QV8Engine *eng) +int ListModel::setExistingProperty(int elementIndex, const QString &key, const QV4::ValueRef data, QV8Engine *eng) { int roleIndex = -1; @@ -1162,7 +1162,7 @@ int ListElement::setVariantProperty(const ListLayout::Role &role, const QVariant return roleIndex; } -int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV8Engine *eng) +int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::ValueRef d, QV8Engine *eng) { // Check if this key exists yet int roleIndex = -1; @@ -1170,12 +1170,13 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d QV4::Scope scope(QV8Engine::getV4(eng)); // Add the value now - if (QV4::String *s = d.asString()) { - QString qstr = s->toQString(); + if (d->asString()) { + QString qstr = d->toQString(); roleIndex = setStringProperty(role, qstr); - } else if (d.isNumber()) { - roleIndex = setDoubleProperty(role, d.asDouble()); - } else if (QV4::ArrayObject *a = d.asArrayObject()) { + } else if (d->isNumber()) { + roleIndex = setDoubleProperty(role, d->asDouble()); + } else if (d->asArrayObject()) { + QV4::ScopedArrayObject a(scope, d); if (role.type == ListLayout::Role::List) { QV4::Scope scope(a->engine()); QV4::Scoped<QV4::Object> o(scope); @@ -1190,12 +1191,13 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d } else { qmlInfo(0) << QString::fromLatin1("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(role.name).arg(roleTypeName(role.type)).arg(roleTypeName(ListLayout::Role::List)); } - } else if (d.isBoolean()) { - roleIndex = setBoolProperty(role, d.booleanValue()); - } else if (QV4::DateObject *dd = d.asDateObject()) { - QDateTime dt = dd->toQDateTime();; + } else if (d->isBoolean()) { + roleIndex = setBoolProperty(role, d->booleanValue()); + } else if (d->asDateObject()) { + QV4::Scoped<QV4::DateObject> dd(scope, d); + QDateTime dt = dd->toQDateTime(); roleIndex = setDateTimeProperty(role, dt); - } else if (d.isObject()) { + } else if (d->isObject()) { QV4::ScopedObject o(scope, d); QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>(); if (role.type == ListLayout::Role::QObject && wrapper) { @@ -1204,7 +1206,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d } else if (role.type == ListLayout::Role::VariantMap) { roleIndex = setVariantMapProperty(role, o, eng); } - } else if (d.isUndefined() || d.isNull()) { + } else if (d->isNullOrUndefined()) { clearProperty(role); } diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index d74299780d..3b15af2d23 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -253,7 +253,7 @@ private: int setVariantProperty(const ListLayout::Role &role, const QVariant &d); - int setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV8Engine *eng); + int setJsProperty(const ListLayout::Role &role, const QV4::ValueRef d, QV8Engine *eng); int setStringProperty(const ListLayout::Role &role, const QString &s); int setDoubleProperty(const ListLayout::Role &role, double n); @@ -308,7 +308,7 @@ public: void destroy(); int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data); - int setExistingProperty(int uid, const QString &key, const QV4::Value &data, QV8Engine *eng); + int setExistingProperty(int uid, const QString &key, const QV4::ValueRef data, QV8Engine *eng); QVariant getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV8Engine *eng); ListModel *getListProperty(int elementIndex, const ListLayout::Role &role); |