summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/fx/qfxlistview.cpp35
-rw-r--r--src/declarative/fx/qfxlistview.h7
2 files changed, 34 insertions, 8 deletions
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 5de9bf3..3584892 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -1339,13 +1339,19 @@ qreal QFxListView::maxXExtent() const
void QFxListView::keyPressEvent(QKeyEvent *event)
{
Q_D(QFxListView);
+ QFxFlickable::keyPressEvent(event);
+ if (event->isAccepted())
+ return;
+
if (d->model && d->model->count() && d->interactive) {
if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Left)
|| (d->orient == Qt::Vertical && event->key() == Qt::Key_Up)) {
if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) {
d->moveReason = QFxListViewPrivate::Key;
- int index = currentIndex()-1;
- d->updateCurrent(index >= 0 ? index : d->model->count()-1);
+ decrementCurrentIndex();
+ event->accept();
+ return;
+ } else if (d->wrap) {
event->accept();
return;
}
@@ -1353,8 +1359,10 @@ void QFxListView::keyPressEvent(QKeyEvent *event)
|| (d->orient == Qt::Vertical && event->key() == Qt::Key_Down)) {
if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) {
d->moveReason = QFxListViewPrivate::Key;
- int index = currentIndex()+1;
- d->updateCurrent(index < d->model->count() ? index : 0);
+ incrementCurrentIndex();
+ event->accept();
+ return;
+ } else if (d->wrap) {
event->accept();
return;
}
@@ -1362,7 +1370,24 @@ void QFxListView::keyPressEvent(QKeyEvent *event)
}
d->moveReason = QFxListViewPrivate::Other;
event->ignore();
- QFxFlickable::keyPressEvent(event);
+}
+
+void QFxListView::incrementCurrentIndex()
+{
+ Q_D(QFxListView);
+ if (currentIndex() < d->model->count() - 1 || d->wrap) {
+ int index = currentIndex()+1;
+ d->updateCurrent(index < d->model->count() ? index : 0);
+ }
+}
+
+void QFxListView::decrementCurrentIndex()
+{
+ Q_D(QFxListView);
+ if (currentIndex() > 0 || d->wrap) {
+ int index = currentIndex()-1;
+ d->updateCurrent(index >= 0 ? index : d->model->count()-1);
+ }
}
void QFxListView::componentComplete()
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index cc3d910..fc15967 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -50,9 +50,6 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-//### incrementCurrentIndex(), decrementCurrentIndex() slots
-//### default Keys.OnUp/DownPressed handler
-
class QFxVisualModel;
class QFxListViewAttached;
@@ -131,6 +128,10 @@ public:
static QFxListViewAttached *qmlAttachedProperties(QObject *);
+public Q_SLOTS:
+ void incrementCurrentIndex();
+ void decrementCurrentIndex();
+
Q_SIGNALS:
void countChanged();
void spacingChanged();