From 3d5ffa7102e3373942a6b889386bc77a9c957be0 Mon Sep 17 00:00:00 2001 From: Filip Piechocki Date: Tue, 2 Apr 2013 12:48:22 +0200 Subject: [PATCH] Fix for Positioner attached property Modified Positioner attached properties update - original code was trying to update visible and not visible items by looking only at the positionedItems array, which was wrong as that array contains only visible items. Hidden ones are stored in unpositionedItems array so second loop was added to affect these items also. Task-number: QTBUG-30477 Change-Id: If03abb76f4da708884a7e2cf6ade83c09eca45bf Reviewed-by: Alan Alpert --- src/quick/items/qquickpositioners.cpp | 44 +++++++++++++++++++++++--------- 1 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp index 4a74c0b..d8dc0f1 100644 --- a/src/quick/items/qquickpositioners.cpp +++ b/src/quick/items/qquickpositioners.cpp @@ -452,7 +452,6 @@ void QQuickBasePositioner::updateAttachedProperties(QQuickPositionerAttached *sp QQuickPositionerAttached *prevLastProperty = 0; QQuickPositionerAttached *lastProperty = 0; - int visibleItemIndex = 0; for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (!child.item) @@ -468,28 +467,47 @@ void QQuickBasePositioner::updateAttachedProperties(QQuickPositionerAttached *sp property = static_cast(qmlAttachedPropertiesObject(child.item, false)); } - if (child.isVisible) { - if (property) { - property->setIndex(visibleItemIndex); - property->setIsFirstItem(visibleItemIndex == 0); + if (property) { + property->setIndex(ii); + property->setIsFirstItem(ii == 0); - if (property->isLastItem()) + if (property->isLastItem()) { + if (prevLastProperty) + prevLastProperty->setIsLastItem(false); // there can be only one last property prevLastProperty = property; } - - lastProperty = property; - ++visibleItemIndex; - } else if (property) { - property->setIndex(-1); - property->setIsFirstItem(false); - property->setIsLastItem(false); } + + lastProperty = property; } if (prevLastProperty && prevLastProperty != lastProperty) prevLastProperty->setIsLastItem(false); if (lastProperty) lastProperty->setIsLastItem(true); + + // clear attached properties for unpositioned items + for (int ii = 0; ii < unpositionedItems.count(); ++ii) { + const PositionedItem &child = unpositionedItems.at(ii); + if (!child.item) + continue; + + QQuickPositionerAttached *property = 0; + + if (specificProperty) { + if (specificPropertyOwner == child.item) { + property = specificProperty; + } + } else { + property = static_cast(qmlAttachedPropertiesObject(child.item, false)); + } + + if (property) { + property->setIndex(-1); + property->setIsFirstItem(false); + property->setIsLastItem(false); + } + } } /*! -- 1.7.2.5