summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-09 01:41:18 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-09 01:41:18 (GMT)
commit5405740678314389e6e5477a3ed76819a60aeb37 (patch)
treecb1110f200bdd4ff6976d61ca438a5585b953b95
parentbb07e7d2f4f3e8940ebcc12334b4b723e450d374 (diff)
downloadQt-5405740678314389e6e5477a3ed76819a60aeb37.zip
Qt-5405740678314389e6e5477a3ed76819a60aeb37.tar.gz
Qt-5405740678314389e6e5477a3ed76819a60aeb37.tar.bz2
Ensure GridView content position is stable when moving items.
Task-number: QTBUG-9697
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp5
2 files changed, 7 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index f832f12..9be025a 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -2166,6 +2166,8 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count)
if (!movedItem)
movedItem = d->createItem(item->index);
it = d->visibleItems.insert(it, movedItem);
+ if (it == d->visibleItems.begin() && firstItem)
+ movedItem->setPosition(firstItem->colPos(), firstItem->rowPos());
++it;
--remaining;
} else {
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index dd594774..7add9c6 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -578,6 +578,11 @@ void tst_QDeclarativeGridView::moved()
QCOMPARE(number->text(), model.number(i));
}
+ // ensure content position is stable
+ gridview->setContentY(0);
+ model.moveItem(10, 0);
+ QVERIFY(gridview->contentY() == 0);
+
delete canvas;
}