aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitemview_p_p.h
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2012-01-05 09:59:30 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-09 07:14:31 +0100
commit6b6d99c1a218f1c46ae0151a01575de6092ba9a7 (patch)
treed68e19b73691d4119f13358b29ca17cbd084c80b /src/quick/items/qquickitemview_p_p.h
parent95e720d1b63312e50be3df467973d098c4527b7d (diff)
Fix positioning issues and change content y repositioning behaviour
Refactor the code for re-positioning the visibleItems.first() in QSGItemView::applyModelChanges() and fix various positioning issues. The positioning behaviour for removing items at the start of the view has changed. This action will no longer cause the content y to move down; previously the content y would always move down unless another item was moving backwards to the first visible position. This will make it easier to implement built-in removal transitions for the views, since removed items cannot be animated if the content y jumps down past them. Additionally, moving items from before a GridView should not cause the top item in the view to move upwards and out of the view. This also adds additional remove tests and fixes the tst_QQuickGridView::moved() test which wasn't waiting for the polish event after setting the content y, which caused some of the tests to pass even though their test data was wrong. Change-Id: Idad11a73a18f88208e73a52111ed839458e05f2d Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/quick/items/qquickitemview_p_p.h')
-rw-r--r--src/quick/items/qquickitemview_p_p.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index cfceca670a..a81aa6f54d 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -99,12 +99,13 @@ class QQuickItemViewPrivate : public QQuickFlickablePrivate
public:
QQuickItemViewPrivate();
- struct InsertionsResult {
- QList<FxViewItem *> addedItems;
- QList<FxViewItem *> movedBackwards;
- qreal sizeAddedBeforeVisible;
+ struct ChangeResult {
+ QDeclarativeNullableValue<qreal> visiblePos;
+ qreal sizeChangesBeforeVisiblePos;
+ qreal sizeChangesAfterVisiblePos;
- InsertionsResult() : sizeAddedBeforeVisible(0) {}
+ ChangeResult(const QDeclarativeNullableValue<qreal> &p)
+ : visiblePos(p), sizeChangesBeforeVisiblePos(0), sizeChangesAfterVisiblePos(0) {}
};
enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
@@ -145,6 +146,7 @@ public:
void positionViewAtIndex(int index, int mode);
void applyPendingChanges();
bool applyModelChanges();
+ bool applyRemovalChange(const QDeclarativeChangeSet::Remove &removal, ChangeResult *changeResult, int *removedCount);
void checkVisible() const;
@@ -236,11 +238,12 @@ protected:
virtual void repositionPackageItemAt(QQuickItem *item, int index) = 0;
virtual void resetItemPosition(FxViewItem *item, FxViewItem *toItem) = 0;
virtual void resetFirstItemPosition() = 0;
- virtual void moveItemBy(FxViewItem *item, qreal forwards, qreal backwards) = 0;
+ virtual void adjustFirstItem(qreal forwards, qreal backwards) = 0;
virtual void layoutVisibleItems() = 0;
virtual void changedVisibleIndex(int newIndex) = 0;
- virtual bool applyInsertionChange(const QDeclarativeChangeSet::Insert &, FxViewItem *, InsertionsResult *) = 0;
+ virtual bool applyInsertionChange(const QDeclarativeChangeSet::Insert &insert, ChangeResult *changeResult, bool *newVisibleItemsFirst, QList<FxViewItem *> *newItems) = 0;
+
virtual bool needsRefillForAddedOrRemovedIndex(int) const { return false; }
virtual void initializeViewItem(FxViewItem *) {}