summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativegridview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-07-06 05:04:15 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-07-06 05:11:33 (GMT)
commitc09f58965e772064ca952892f2e7969082f03855 (patch)
tree2edbb77c5505be81aa8cae18df33bb097e08cb46 /src/declarative/graphicsitems/qdeclarativegridview.cpp
parentb43f46fdc4fede579b512624c03df5c19893288a (diff)
downloadQt-c09f58965e772064ca952892f2e7969082f03855.zip
Qt-c09f58965e772064ca952892f2e7969082f03855.tar.gz
Qt-c09f58965e772064ca952892f2e7969082f03855.tar.bz2
Changing currentIndex shouldn't cancel a flick unnecessarily.
If the new currentIndex is in view, then there is no need to cancel a flick that is in progress. Task-number: QTBUG-11405
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativegridview.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index cb99129..3efb9ad 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -1216,6 +1216,11 @@ void QDeclarativeGridView::setModel(const QVariant &model)
} else {
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
d->updateCurrent(d->currentIndex);
+ if (d->highlight && d->currentItem) {
+ d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos());
+ d->updateTrackedItem();
+ }
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
}
}
connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
@@ -1274,6 +1279,11 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate)
refill();
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
d->updateCurrent(d->currentIndex);
+ if (d->highlight && d->currentItem) {
+ d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos());
+ d->updateTrackedItem();
+ }
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
}
emit delegateChanged();
}
@@ -1300,7 +1310,6 @@ void QDeclarativeGridView::setCurrentIndex(int index)
return;
if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
- cancelFlick();
d->updateCurrent(index);
} else if (index != d->currentIndex) {
d->currentIndex = index;
@@ -2158,7 +2167,7 @@ void QDeclarativeGridView::componentComplete()
d->updateCurrent(0);
else
d->updateCurrent(d->currentIndex);
- if (d->highlight) {
+ if (d->highlight && d->currentItem) {
d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos());
d->updateTrackedItem();
}
@@ -2172,20 +2181,17 @@ void QDeclarativeGridView::trackedPositionChanged()
Q_D(QDeclarativeGridView);
if (!d->trackedItem || !d->currentItem)
return;
- if (!d->flickingHorizontally && !d->flickingVertically && !d->movingHorizontally && !d->movingVertically
- && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) {
+ if (d->moveReason == QDeclarativeGridViewPrivate::SetIndex) {
const qreal trackedPos = d->trackedItem->rowPos();
const qreal viewPos = d->position();
+ qreal pos = viewPos;
if (d->haveHighlightRange) {
if (d->highlightRange == StrictlyEnforceRange) {
- qreal pos = viewPos;
if (trackedPos > pos + d->highlightRangeEnd - d->rowSize())
pos = trackedPos - d->highlightRangeEnd + d->rowSize();
if (trackedPos < pos + d->highlightRangeStart)
pos = trackedPos - d->highlightRangeStart;
- d->setPosition(pos);
} else {
- qreal pos = viewPos;
if (trackedPos < d->startPosition() + d->highlightRangeStart) {
pos = d->startPosition();
} else if (d->trackedItem->endRowPos() > d->endPosition() - d->size() + d->highlightRangeEnd) {
@@ -2199,14 +2205,12 @@ void QDeclarativeGridView::trackedPositionChanged()
pos = trackedPos - d->highlightRangeEnd + d->rowSize();
}
}
- d->setPosition(pos);
}
} else {
if (trackedPos < viewPos && d->currentItem->rowPos() < viewPos) {
- d->setPosition(d->currentItem->rowPos() < trackedPos ? trackedPos : d->currentItem->rowPos());
+ pos = d->currentItem->rowPos() < trackedPos ? trackedPos : d->currentItem->rowPos();
} else if (d->trackedItem->endRowPos() > viewPos + d->size()
&& d->currentItem->endRowPos() > viewPos + d->size()) {
- qreal pos;
if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) {
pos = d->trackedItem->endRowPos() - d->size();
if (d->rowSize() > d->size())
@@ -2216,9 +2220,12 @@ void QDeclarativeGridView::trackedPositionChanged()
if (d->rowSize() > d->size())
pos = d->currentItem->rowPos();
}
- d->setPosition(pos);
}
}
+ if (viewPos != pos) {
+ cancelFlick();
+ d->setPosition(pos);
+ }
}
}
@@ -2563,6 +2570,12 @@ void QDeclarativeGridView::modelReset()
refill();
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
d->updateCurrent(d->currentIndex);
+ if (d->highlight && d->currentItem) {
+ d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos());
+ d->updateTrackedItem();
+ }
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+
emit countChanged();
}