From: Andrew den Exter Date: Thu, 12 Jul 2012 03:15:41 +0000 (+1000) Subject: Fix item positioning with multiple removes before the visible area. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=04fc2234562507a071e214635e6fe7dc63eda95b;p=konrad%2Fqtdeclarative.git 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 --- 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) {