summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-18 07:20:59 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-18 07:20:59 (GMT)
commit27a94129261c47629d3cf0b6493e46306fb42cad (patch)
tree2cbebf26d83c496c0482814e44b4d7a445403b3a /src
parent4630cca1d2c5fa0553f46cec3566b88e91215070 (diff)
downloadQt-27a94129261c47629d3cf0b6493e46306fb42cad.zip
Qt-27a94129261c47629d3cf0b6493e46306fb42cad.tar.gz
Qt-27a94129261c47629d3cf0b6493e46306fb42cad.tar.bz2
Ensure visibleIndex and currentIndex are updated on itemsMoved().
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index ee711b4..0edf590 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -1656,9 +1656,32 @@ void QmlGraphicsGridView::itemsMoved(int from, int to, int count)
++endIndex;
}
+ // update visibleIndex
+ for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
+ // Fix current index
+ if (d->currentIndex >= 0 && d->currentItem) {
+ int oldCurrent = d->currentIndex;
+ d->currentIndex = d->model->indexOf(d->currentItem->item, this);
+ if (oldCurrent != d->currentIndex) {
+ d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
+ }
+ }
+
// Whatever moved items remain are no longer visible items.
- while (moved.count())
- d->releaseItem(moved.take(moved.begin().key()));
+ while (moved.count()) {
+ int idx = moved.begin().key();
+ FxGridItem *item = moved.take(idx);
+ if (item->item == d->currentItem->item)
+ item->setPosition(d->colPosAt(idx), d->rowPosAt(idx));
+ d->releaseItem(item);
+ }
d->layout(removedBeforeVisible);
}