diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-06-03 15:28:51 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-06-04 17:02:55 +0200 |
commit | 11a11d1280b1634628b9c4a92a0fc420ee8a3a81 (patch) | |
tree | b48d9608ef3f08123cdeea605068342131b32b44 /src/qml/types/qqmllistmodel.cpp | |
parent | 52e07d564b65ed6ce26955a676c7692ad67686c1 (diff) | |
parent | fea26bb2941c3f24c4a5f3ad5efc1b85e0123ff3 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
The merge conflict is about the removal of "d1" from the register
set on ARM, but that was already done in dev in commit ddb33ee9ba9e1344caa9be5dbf4b534c3ede692e
The change in src/quick/scenegraph/coreapi/qsgrenderer.cpp with commit 2414f1675eab163b22dcc4e8ded80ed04d06369b
was reverted to what it was before, per Laszlo's advice.
Conflicts:
src/qml/jit/qv4isel_masm.cpp
Change-Id: I7bce546c5cdee01e37853a476d82279d4e72948b
Diffstat (limited to 'src/qml/types/qqmllistmodel.cpp')
-rw-r--r-- | src/qml/types/qqmllistmodel.cpp | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 1b074efd56..a0148715ce 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -1694,13 +1694,20 @@ void QQmlListModel::emitItemsChanged(int index, int count, const QVector<int> &r } } +void QQmlListModel::emitItemsAboutToBeRemoved(int index, int count) +{ + if (count <= 0 || !m_mainThread) + return; + + beginRemoveRows(QModelIndex(), index, index + count - 1); +} + void QQmlListModel::emitItemsRemoved(int index, int count) { if (count <= 0) return; if (m_mainThread) { - beginRemoveRows(QModelIndex(), index, index + count - 1); endRemoveRows(); emit countChanged(); } else { @@ -1711,13 +1718,20 @@ void QQmlListModel::emitItemsRemoved(int index, int count) } } +void QQmlListModel::emitItemsAboutToBeInserted(int index, int count) +{ + if (count <= 0 || !m_mainThread) + return; + + beginInsertRows(QModelIndex(), index, index + count - 1); +} + void QQmlListModel::emitItemsInserted(int index, int count) { if (count <= 0) return; if (m_mainThread) { - beginInsertRows(QModelIndex(), index, index + count - 1); endInsertRows(); emit countChanged(); } else { @@ -1726,13 +1740,20 @@ void QQmlListModel::emitItemsInserted(int index, int count) } } +void QQmlListModel::emitItemsAboutToBeMoved(int from, int to, int n) +{ + if (n <= 0 || !m_mainThread) + return; + + beginMoveRows(QModelIndex(), from, from + n - 1, QModelIndex(), to > from ? to + n : to); +} + void QQmlListModel::emitItemsMoved(int from, int to, int n) { if (n <= 0) return; if (m_mainThread) { - beginMoveRows(QModelIndex(), from, from + n - 1, QModelIndex(), to > from ? to + n : to); endMoveRows(); } else { int uid = m_dynamicRoles ? getUid() : m_listModel->getUid(); @@ -1872,6 +1893,8 @@ void QQmlListModel::clear() { int cleared = count(); + emitItemsAboutToBeRemoved(0, cleared); + if (m_dynamicRoles) { for (int i=0 ; i < m_modelObjects.count() ; ++i) delete m_modelObjects[i]; @@ -1904,6 +1927,8 @@ void QQmlListModel::remove(QQmlV4Function *args) return; } + emitItemsAboutToBeRemoved(index, removeCount); + if (m_dynamicRoles) { for (int i=0 ; i < removeCount ; ++i) delete m_modelObjects[index+i]; @@ -1952,6 +1977,7 @@ void QQmlListModel::insert(QQmlV4Function *args) QV4::ScopedObject argObject(scope); int objectArrayLength = objectArray->getLength(); + emitItemsAboutToBeInserted(index, objectArrayLength); for (int i=0 ; i < objectArrayLength ; ++i) { argObject = objectArray->getIndexed(i); @@ -1963,6 +1989,8 @@ void QQmlListModel::insert(QQmlV4Function *args) } emitItemsInserted(index, objectArrayLength); } else if (argObject) { + emitItemsAboutToBeInserted(index, 1); + if (m_dynamicRoles) { m_modelObjects.insert(index, DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this)); } else { @@ -2001,6 +2029,8 @@ void QQmlListModel::move(int from, int to, int n) return; } + emitItemsAboutToBeMoved(from, to, n); + if (m_dynamicRoles) { int realFrom = from; @@ -2056,6 +2086,8 @@ void QQmlListModel::append(QQmlV4Function *args) int objectArrayLength = objectArray->getLength(); int index = count(); + emitItemsAboutToBeInserted(index, objectArrayLength); + for (int i=0 ; i < objectArrayLength ; ++i) { argObject = objectArray->getIndexed(i); @@ -2072,9 +2104,12 @@ void QQmlListModel::append(QQmlV4Function *args) if (m_dynamicRoles) { index = m_modelObjects.count(); + emitItemsAboutToBeInserted(index, 1); m_modelObjects.append(DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this)); } else { - index = m_listModel->append(argObject, args->engine()); + index = m_listModel->elementCount(); + emitItemsAboutToBeInserted(index, 1); + m_listModel->append(argObject, args->engine()); } emitItemsInserted(index, 1); @@ -2169,6 +2204,7 @@ void QQmlListModel::set(int index, const QQmlV4Handle &handle) if (index == count()) { + emitItemsAboutToBeInserted(index, 1); if (m_dynamicRoles) { m_modelObjects.append(DynamicRoleModelNode::create(engine()->variantMapFromJS(object), this)); |