aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2013-09-23 16:30:40 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-19 01:36:30 +0100
commit854272ecf9f26e77ddd8e3b7015cb8fe278183a5 (patch)
treeb212a3055c38e6c1a8be3c22d82938ea6e23955d /src
parenta34eddbf7a68360ead218b2f5a9215e6b1ae88ec (diff)
Fix positioning of item when first cacheBuffer item is removed.
When items prior to the first visible item are removed from the instantiated items list the first item is moved forward by the size of the item removed so it position remains correct relative to the visible items. But if the removed item is the first instanitated item then it's size shouldn't contribute to the offset as the next instatiated item is already offset by its size. Task-number: QTBUG-33619 Change-Id: I05c33f505e2856afa08cd9cd89d8eae97c20679d Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickitemview.cpp7
-rw-r--r--src/quick/items/qquickitemview_p_p.h1
-rw-r--r--src/quick/items/qquicklistview.cpp7
3 files changed, 14 insertions, 1 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index d9ff024d9f..d7b984788e 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -2065,7 +2065,7 @@ void QQuickItemViewPrivate::removeItem(FxViewItem *item, const QQmlChangeSet::Re
{
if (removeResult->visiblePos.isValid()) {
if (item->position() < removeResult->visiblePos)
- removeResult->sizeChangesBeforeVisiblePos += item->size();
+ updateSizeChangesBeforeVisiblePos(item, removeResult);
else
removeResult->sizeChangesAfterVisiblePos += item->size();
}
@@ -2080,6 +2080,11 @@ void QQuickItemViewPrivate::removeItem(FxViewItem *item, const QQmlChangeSet::Re
removeResult->changedFirstItem = true;
}
+void QQuickItemViewPrivate::updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult)
+{
+ removeResult->sizeChangesBeforeVisiblePos += item->size();
+}
+
void QQuickItemViewPrivate::repositionFirstItem(FxViewItem *prevVisibleItemsFirst,
qreal prevVisibleItemsFirstPos,
FxViewItem *prevFirstVisible,
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index c528fa3b2c..e0f08fd50f 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -211,6 +211,7 @@ public:
bool applyModelChanges(ChangeResult *insertionResult, ChangeResult *removalResult);
bool applyRemovalChange(const QQmlChangeSet::Remove &removal, ChangeResult *changeResult, int *removedCount);
void removeItem(FxViewItem *item, const QQmlChangeSet::Remove &removal, ChangeResult *removeResult);
+ virtual void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult);
void repositionFirstItem(FxViewItem *prevVisibleItemsFirst, qreal prevVisibleItemsFirstPos,
FxViewItem *prevFirstVisible, ChangeResult *insertionResult, ChangeResult *removalResult);
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 424b5ac385..1b46d79326 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -98,6 +98,7 @@ public:
virtual void repositionPackageItemAt(QQuickItem *item, int index);
virtual void resetFirstItemPosition(qreal pos = 0.0);
virtual void adjustFirstItem(qreal forwards, qreal backwards, int);
+ virtual void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult);
virtual void createHighlight();
virtual void updateHighlight();
@@ -846,6 +847,12 @@ void QQuickListViewPrivate::adjustFirstItem(qreal forwards, qreal backwards, int
static_cast<FxListItemSG*>(visibleItems.first())->setPosition(visibleItems.first()->position() + diff);
}
+void QQuickListViewPrivate::updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult)
+{
+ if (item != visibleItems.first())
+ QQuickItemViewPrivate::updateSizeChangesBeforeVisiblePos(item, removeResult);
+}
+
void QQuickListViewPrivate::createHighlight()
{
Q_Q(QQuickListView);