diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-06-04 10:36:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-06-04 11:00:55 +0200 |
commit | 1dbbecda8b4e34196d07ecfea65de87b0bd8b83a (patch) | |
tree | a3e027c397ad5d44d5acdb624d245b2b1d6d416a /src/qml/types/qqmllistmodel.cpp | |
parent | 734f65f151ccd491a2dd79fe511a7822016cf52b (diff) |
Simplify the object iterator API
We were really missing methods to get both the key and the value
in one go.
Change-Id: I996bde79265f45312e68fcc6bdce76704385ea5b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/types/qqmllistmodel.cpp')
-rw-r--r-- | src/qml/types/qqmllistmodel.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 4bb057756b..f016a9ab22 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -418,16 +418,11 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles, QV4::ExecutionEngine *v4 = object->engine(); QV4::ObjectIterator it(object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly); while (1) { - QV4::String *name; - uint index; - QV4::PropertyAttributes attrs; - QV4::Property *p = it.next(&name, &index, &attrs); - if (!p) + QV4::Value propertyValue; + QV4::Value propertyName = it.nextPropertyNameAsString(&propertyValue); + if (propertyName.isNull()) break; - QV4::Value propertyName = QV4::Value::fromString(name ? name : v4->newString(QString::number(index))); - QV4::Value propertyValue = object->getValue(v4->current, p, attrs); - // Check if this key exists yet int roleIndex = -1; @@ -489,16 +484,11 @@ void ListModel::set(int elementIndex, QV4::Object *object, QV8Engine *eng) QV4::ExecutionEngine *v4 = object->engine(); QV4::ObjectIterator it(object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly); while (1) { - QV4::String *name; - uint index; - QV4::PropertyAttributes attrs; - QV4::Property *p = it.next(&name, &index, &attrs); - if (!p) + QV4::Value propertyValue; + QV4::Value propertyName = it.nextPropertyNameAsString(&propertyValue); + if (propertyName.isNull()) break; - QV4::Value propertyName = QV4::Value::fromString(name ? name : v4->newString(QString::number(index))); - QV4::Value propertyValue = object->getValue(v4->current, p, attrs); - // Add the value now if (QV4::String *s = propertyValue.asString()) { const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String); |