summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-10-28 04:45:57 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-10-28 04:45:57 (GMT)
commitc394f166af47fed34652685531ca1811c7f7568b (patch)
tree7cab164ec5effa73dd9bae45a3d05657b4c58de1 /src/declarative
parent072b70c9521d507b0a4cdae379f2874d0e49d6df (diff)
downloadQt-c394f166af47fed34652685531ca1811c7f7568b.zip
Qt-c394f166af47fed34652685531ca1811c7f7568b.tar.gz
Qt-c394f166af47fed34652685531ca1811c7f7568b.tar.bz2
Setting the currentIndex should cancel a flick.
Task-number: QT-2383
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfxflickable.cpp9
-rw-r--r--src/declarative/fx/qfxflickable.h1
-rw-r--r--src/declarative/fx/qfxgridview.cpp6
-rw-r--r--src/declarative/fx/qfxlistview.cpp6
4 files changed, 18 insertions, 4 deletions
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 659193d..0fb8474 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -889,6 +889,14 @@ void QFxFlickable::viewportMoved()
}
}
+void QFxFlickable::cancelFlick()
+{
+ Q_D(QFxFlickable);
+ d->timeline.reset(d->_moveX);
+ d->timeline.reset(d->_moveY);
+ movementEnding();
+}
+
void QFxFlickablePrivate::data_removeAt(int)
{
// ###
@@ -1257,6 +1265,7 @@ void QFxFlickable::movementEnding()
emit flickEnded();
}
d->horizontalVelocity.setValue(0);
+ d->verticalVelocity.setValue(0);
}
void QFxFlickablePrivate::updateVelocity()
diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h
index 4c80e8f..3db4ca7 100644
--- a/src/declarative/fx/qfxflickable.h
+++ b/src/declarative/fx/qfxflickable.h
@@ -183,6 +183,7 @@ protected:
bool xflick() const;
bool yflick() const;
+ void cancelFlick();
protected:
QFxFlickable(QFxFlickablePrivate &dd, QFxItem *parent);
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 0b2a935..c07258d 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -857,10 +857,12 @@ int QFxGridView::currentIndex() const
void QFxGridView::setCurrentIndex(int index)
{
Q_D(QFxGridView);
- if (d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0)
+ if (d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
+ cancelFlick();
d->updateCurrent(index);
- else
+ } else {
d->currentIndex = index;
+ }
}
QFxItem *QFxGridView::currentItem()
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 1f1b97b..49c2d11 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -1172,10 +1172,12 @@ void QFxListView::setCurrentIndex(int index)
{
Q_D(QFxListView);
d->moveReason = QFxListViewPrivate::Other;
- if (d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0)
+ if (d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
+ cancelFlick();
d->updateCurrent(index);
- else
+ } else {
d->currentIndex = index;
+ }
}
QFxItem *QFxListView::currentItem()