From 04fc2234562507a071e214635e6fe7dc63eda95b Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 12 Jul 2012 13:15:41 +1000 Subject: [PATCH] Fix item positioning with multiple removes before the visible area. The index of the previous first visible item needs to be adjusted when items are removed before it in order to comparable against later changes. Change-Id: I3c72abb4dfc9c2ccc9b299dda186ecdc3994a735 Reviewed-by: Bea Lam --- src/quick/items/qquickitemview.cpp | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 34a8cf5..a9022bd 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -1871,11 +1871,12 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult visibleAffected = true; if (!visibleAffected && needsRefillForAddedOrRemovedIndex(removals[i].index)) visibleAffected = true; - if (prevFirstVisibleIndex >= 0 && removals[i].index < prevFirstVisibleIndex) { - if (removals[i].index + removals[i].count < prevFirstVisibleIndex) + const int correctedFirstVisibleIndex = prevFirstVisibleIndex - removalResult.countChangeBeforeVisible; + if (correctedFirstVisibleIndex >= 0 && removals[i].index < correctedFirstVisibleIndex) { + if (removals[i].index + removals[i].count < correctedFirstVisibleIndex) removalResult.countChangeBeforeVisible += removals[i].count; else - removalResult.countChangeBeforeVisible += (prevFirstVisibleIndex - removals[i].index); + removalResult.countChangeBeforeVisible += (correctedFirstVisibleIndex - removals[i].index); } } if (runDelayedRemoveTransition) { -- 1.7.2.5