diff options
author | Bea Lam <bea.lam@nokia.com> | 2011-11-18 12:04:56 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-22 06:14:56 +0100 |
commit | d2d4024afb4e7a93c0d09e474f73ad274e23d78a (patch) | |
tree | 9a1fb36922f740cb16e1b8d8d5a070b2e7ac73db /src | |
parent | 18e89379f8db9b656885739daef5d24aa24fb92c (diff) |
Fix inserting before the visible area into cache buffer
Items being inserted after the visible index must be created, even if
they aren't in view (e.g. are in the cache buffer) otherwise they will
not appear at the correct index in the visibleItems list.
Task-number: QTBUG-22772
Change-Id: I235dc766a6abf4988872bb70aa40cdc767df8c96
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qquickgridview.cpp | 4 | ||||
-rw-r--r-- | src/declarative/items/qquicklistview.cpp | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/declarative/items/qquickgridview.cpp b/src/declarative/items/qquickgridview.cpp index f50c362dfd..51131ab742 100644 --- a/src/declarative/items/qquickgridview.cpp +++ b/src/declarative/items/qquickgridview.cpp @@ -1802,9 +1802,11 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In int from = tempPos - buffer; while (i >= 0) { - if (rowPos > from) { + if (rowPos > from && insertionIdx < visibleIndex) { + // item won't be visible, just note the size for repositioning insertResult->sizeAddedBeforeVisible += rowSize(); } else { + // item is before first visible e.g. in cache buffer FxViewItem *item = 0; if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i)))) { if (item->index > modelIndex + i) diff --git a/src/declarative/items/qquicklistview.cpp b/src/declarative/items/qquicklistview.cpp index 4fd4e97da5..60164d51c5 100644 --- a/src/declarative/items/qquicklistview.cpp +++ b/src/declarative/items/qquicklistview.cpp @@ -2384,10 +2384,12 @@ bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In int from = tempPos - buffer; for (i = count-1; i >= 0; --i) { - if (pos > from) { - insertResult->sizeAddedBeforeVisible += averageSize; - pos -= averageSize; + if (pos > from && insertionIdx < visibleIndex) { + // item won't be visible, just note the size for repositioning + insertResult->sizeAddedBeforeVisible += averageSize + spacing; + pos -= averageSize + spacing; } else { + // item is before first visible e.g. in cache buffer FxViewItem *item = 0; if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i)))) { if (item->index > modelIndex + i) |