diff options
Diffstat (limited to 'src/qml/types/qqmllistmodel.cpp')
-rw-r--r-- | src/qml/types/qqmllistmodel.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 2b4e906617..d72d2e9487 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -361,7 +361,7 @@ int ListModel::appendElement() void ListModel::insertElement(int index) { newElement(index); - updateCacheIndices(); + updateCacheIndices(index); } void ListModel::move(int from, int to, int n) @@ -383,7 +383,7 @@ void ListModel::move(int from, int to, int n) for (int i=0 ; i < store.count() ; ++i) elements[from+i] = store[i]; - updateCacheIndices(); + updateCacheIndices(from, to + n); } void ListModel::newElement(int index) @@ -392,9 +392,14 @@ void ListModel::newElement(int index) elements.insert(index, e); } -void ListModel::updateCacheIndices() +void ListModel::updateCacheIndices(int start, int end) { - for (int i=0 ; i < elements.count() ; ++i) { + int count = elements.count(); + + if (end < 0 || end > count) + end = count; + + for (int i = start; i < end; ++i) { ListElement *e = elements.at(i); if (ModelNodeMetaObject *mo = e->objectCache()) mo->m_elementIndex = i; @@ -571,7 +576,7 @@ QVector<std::function<void()>> ListModel::remove(int index, int count) }); } elements.remove(index, count); - updateCacheIndices(); + updateCacheIndices(index); return toDestroy; } @@ -1332,7 +1337,7 @@ void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCo namespace QV4 { -void ModelObject::put(Managed *m, String *name, const Value &value) +bool ModelObject::put(Managed *m, String *name, const Value &value) { ModelObject *that = static_cast<ModelObject*>(m); @@ -1346,6 +1351,7 @@ void ModelObject::put(Managed *m, String *name, const Value &value) ModelNodeMetaObject *mo = ModelNodeMetaObject::get(that->object()); if (mo->initialized()) mo->emitPropertyNotification(name->toQString().toUtf8()); + return true; } ReturnedValue ModelObject::get(const Managed *m, String *name, bool *hasProperty) @@ -1984,12 +1990,12 @@ void QQmlListModel::setDynamicRoles(bool enableDynamicRoles) if (m_mainThread && m_agent == 0) { if (enableDynamicRoles) { if (m_layout->roleCount()) - qmlWarning(this) << tr("unable to enable dynamic roles as this model is not empty!"); + qmlWarning(this) << tr("unable to enable dynamic roles as this model is not empty"); else m_dynamicRoles = true; } else { if (m_roles.count()) { - qmlWarning(this) << tr("unable to enable static roles as this model is not empty!"); + qmlWarning(this) << tr("unable to enable static roles as this model is not empty"); } else { m_dynamicRoles = false; } |