aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicklistview.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-11-25 15:20:22 +0100
committerMitch Curtis <mitch.curtis@theqtcompany.com>2015-12-08 09:40:41 +0000
commitd1fbfbbab7f78e0a1050acce3540c02660a0d68f (patch)
tree9326407c3374dddc083fdc3dc58fe6ef43a58039 /src/quick/items/qquicklistview.cpp
parentd9763f2565445ada2d11bde3c1f46b5217b17dab (diff)
ListView: add keyNavigationEnabled property
It is useful for applications that need to selectively enable or disable mouse and keyboard interaction. [ChangeLog][QtQuick][ListView] added keyNavigationEnabled property to allow mouse and keyboard interaction to be selectively enabled/disabled. Change-Id: I1cdb73e7be105bcc5c131e3cf2ae242dc66e8a65 Task-number: QTBUG-17051 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquicklistview.cpp')
-rw-r--r--src/quick/items/qquicklistview.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 8384d5b58c..59ecc0b893 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -2174,6 +2174,24 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation)
By default, key navigation is not wrapped.
*/
+/*!
+ \qmlproperty bool QtQuick::ListView::keyNavigationEnabled
+ \since 5.7
+
+ This property holds whether the key navigation of the list is enabled.
+
+ If this is \c true, the user can navigate the view with a keyboard.
+ It is useful for applications that need to selectively enable or
+ disable mouse and keyboard interaction.
+
+ By default, the value of this property is bound to
+ \l {Flickable::}{interactive} to ensure behavior compatibility for
+ existing applications. When explicitly set, it will cease to be bound to
+ the interactive property.
+
+ \sa \l {Flickable::}{interactive}
+*/
+
/*!
\qmlproperty int QtQuick::ListView::cacheBuffer
@@ -2952,7 +2970,8 @@ void QQuickListView::viewportMoved(Qt::Orientations orient)
void QQuickListView::keyPressEvent(QKeyEvent *event)
{
Q_D(QQuickListView);
- if (d->model && d->model->count() && d->interactive) {
+ if (d->model && d->model->count() && ((d->interactive && !d->explicitKeyNavigationEnabled)
+ || (d->explicitKeyNavigationEnabled && d->keyNavigationEnabled))) {
if ((d->orient == QQuickListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Left)
|| (d->orient == QQuickListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Right)
|| (d->orient == QQuickListView::Vertical && !d->isBottomToTop() && event->key() == Qt::Key_Up)