diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-22 15:34:57 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-02 19:29:25 +0000 |
commit | 98263a01373f5b225d64da216537165ae27d7ff1 (patch) | |
tree | 60980c16c6cc6f6658355bcd428245819b4b732a /src/qml/types | |
parent | d21ef386ece52490d428daacb8f7f4658e9f78e5 (diff) |
Unify put and putIndexed
Pass an Identifier through those virtual methods to unify
the string and integer based versions.
Also add the receiver that's required in ES7
Change-Id: I4e7f01b4c97cc80bcb3c485f6343f28213dc9e6b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmllistmodel.cpp | 11 | ||||
-rw-r--r-- | src/qml/types/qqmllistmodel_p_p.h | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 41c52e742c..a8f4708ff6 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -1564,24 +1564,23 @@ void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCo namespace QV4 { -bool ModelObject::put(Managed *m, StringOrSymbol *n, const Value &value) +bool ModelObject::put(Managed *m, Identifier id, const Value &value, Value *receiver) { - if (n->isSymbol()) - return Object::put(m, n, value); - String *name = static_cast<String *>(n); + if (!id.isString()) + return Object::put(m, id, value, receiver); + QString propName = id.toQString(); ModelObject *that = static_cast<ModelObject*>(m); ExecutionEngine *eng = that->engine(); const int elementIndex = that->d()->elementIndex(); - const QString propName = name->toQString(); int roleIndex = that->d()->m_model->m_listModel->setExistingProperty(elementIndex, propName, value, eng); if (roleIndex != -1) that->d()->m_model->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex)); ModelNodeMetaObject *mo = ModelNodeMetaObject::get(that->object()); if (mo->initialized()) - mo->emitPropertyNotification(name->toQString().toUtf8()); + mo->emitPropertyNotification(propName.toUtf8()); return true; } diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index 75eeaeed0c..a271d9b4d2 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -173,7 +173,7 @@ struct ModelObject : public QObjectWrapper { struct ModelObject : public QObjectWrapper { - static bool put(Managed *m, StringOrSymbol *name, const Value& value); + static bool put(Managed *m, Identifier id, const Value& value, Value *receiver); static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); |