diff options
author | Bea Lam <bea.lam@nokia.com> | 2012-03-27 14:34:58 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-27 09:46:00 +0200 |
commit | 19977e9686a482a8189d928d8a45b282cb4287ba (patch) | |
tree | e8c0b43cba87e92762e23ad894baf4134f8130e8 /src/quick/items/qquickitemview.cpp | |
parent | ce9c98c15bc4f84583bb7e07739dbca9e633d1c8 (diff) |
Buffer changes received during layout()
Otherwise, changes received by a view during layout() may
override the changes that are currently being processed.
Change-Id: Iabc4db682f85ceb7d04c3f7442fb6c98ebdb94f1
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'src/quick/items/qquickitemview.cpp')
-rw-r--r-- | src/quick/items/qquickitemview.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 0d95500860..209d30aa74 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -186,6 +186,18 @@ void QQuickItemViewChangeSet::applyChanges(const QQuickChangeSet &changeSet) } } +void QQuickItemViewChangeSet::applyBufferedChanges(const QQuickItemViewChangeSet &other) +{ + if (!other.hasPendingChanges()) + return; + + pendingChanges.apply(other.pendingChanges); + itemCount = other.itemCount; + newCurrentIndex = other.newCurrentIndex; + currentChanged = other.currentChanged; + currentRemoved = other.currentRemoved; +} + void QQuickItemViewChangeSet::prepare(int currentIndex, int count) { if (active) @@ -1044,8 +1056,17 @@ void QQuickItemView::modelUpdated(const QQuickChangeSet &changeSet, bool reset) polish(); } } else { - d->currentChanges.prepare(d->currentIndex, d->itemCount); - d->currentChanges.applyChanges(changeSet); + if (d->disableLayout) { + d->bufferedChanges.prepare(d->currentIndex, d->itemCount); + d->bufferedChanges.applyChanges(changeSet); + } else { + if (d->bufferedChanges.hasPendingChanges()) { + d->currentChanges.applyBufferedChanges(d->bufferedChanges); + d->bufferedChanges.reset(); + } + d->currentChanges.prepare(d->currentIndex, d->itemCount); + d->currentChanges.applyChanges(changeSet); + } polish(); } } @@ -1756,11 +1777,16 @@ void QQuickItemViewPrivate::layout() bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult, ChangeResult *totalRemovalResult) { Q_Q(QQuickItemView); - if (!q->isComponentComplete() || (!currentChanges.hasPendingChanges() && !runDelayedRemoveTransition) || disableLayout) + if (!q->isComponentComplete() || (!currentChanges.hasPendingChanges() && !bufferedChanges.hasPendingChanges() && !runDelayedRemoveTransition) || disableLayout) return false; disableLayout = true; + if (bufferedChanges.hasPendingChanges()) { + currentChanges.applyBufferedChanges(bufferedChanges); + bufferedChanges.reset(); + } + updateUnrequestedIndexes(); moveReason = QQuickItemViewPrivate::Other; |