aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsglistview.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-07-27 18:30:05 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-28 07:12:34 +0200
commite2b5681b1adab83555c7307b05f508d796a1152b (patch)
treec19df1b0e1ab62a3694b53371803ff76a054fd3c /src/declarative/items/qsglistview.cpp
parent14496b18a67982ee25ed43aed6b6bcd7d6fa23ee (diff)
Fix moving of multiple items, and moving items backwards
To fix backward movements, all backward movements are now flipped into forward movements (as is done in ListModel implemenation). Movement of multiple items wasn't working as views weren't removing the right indexes in these cases. Task-number: QTBUG-19208 Change-Id: I9866ddabc241c066bb77329a6761d500d79aaf61 Reviewed-on: http://codereview.qt.nokia.com/2262 Reviewed-by: Bea Lam <bea.lam@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/declarative/items/qsglistview.cpp')
-rw-r--r--src/declarative/items/qsglistview.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/declarative/items/qsglistview.cpp b/src/declarative/items/qsglistview.cpp
index 7fbfe3c68d..37b027cd36 100644
--- a/src/declarative/items/qsglistview.cpp
+++ b/src/declarative/items/qsglistview.cpp
@@ -1813,11 +1813,13 @@ void QSGListView::itemsMoved(int from, int to, int count)
}
d->moveReason = QSGListViewPrivate::Other;
- FxViewItem *firstVisible = d->firstVisibleItem();
- QHash<int,FxViewItem*> moved;
- int moveBy = 0;
bool movingBackwards = from > to;
+ d->adjustMoveParameters(&from, &to, &count);
+
+ QHash<int,FxViewItem*> moved;
+ int moveBy = 0;
+ FxViewItem *firstVisible = d->firstVisibleItem();
int firstItemIndex = firstVisible ? firstVisible->index : -1;
// if visibleItems.first() is above the content start pos, and the items
@@ -1845,21 +1847,20 @@ void QSGListView::itemsMoved(int from, int to, int count)
}
}
- int remaining = count;
+ int movedCount = 0;
int endIndex = d->visibleIndex;
it = d->visibleItems.begin();
while (it != d->visibleItems.end()) {
FxViewItem *item = *it;
- if (remaining && item->index >= to && item->index < to + count) {
+ if (movedCount < count && item->index >= to && item->index < to + count) {
// place items in the target position, reusing any existing items
- FxViewItem *movedItem = moved.take(item->index);
+ int targetIndex = item->index + movedCount;
+ FxViewItem *movedItem = moved.take(targetIndex);
if (!movedItem)
- movedItem = d->createItem(item->index);
- if (item->index <= firstVisible->index)
- moveBy -= movedItem->size();
+ movedItem = d->createItem(targetIndex);
it = d->visibleItems.insert(it, movedItem);
++it;
- --remaining;
+ ++movedCount;
} else {
if (item->index != -1) {
if (item->index >= to) {