From 6ad3445f1e159d9beea936b66d267dcaacdc5d6c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 3 Dec 2019 15:49:12 +0100 Subject: Don't allow dragging a ListView through a floating header or footer If the header or footer positioning is Overlay or PullBack, the list delegates appear to scroll underneath it. The header or footer can contain interactive content. If a mouse or touch press happens to "fall through" that, it should not be possible to drag the ListView contents from there. [ChangeLog][QtQuick][ListView] ListView no longer allows the user to press on an Overlay or PullBack header or footer and start scrolling, but only on the content delegates. Fixes: QTBUG-74046 Change-Id: I4d06c789286be2691d098aeebb10a57b2a335744 Reviewed-by: Mitch Curtis --- src/quick/items/qquicklistview.cpp | 17 +++++++++++++++++ src/quick/items/qquicklistview_p.h | 2 ++ 2 files changed, 19 insertions(+) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 9206628716..4dbb2b792c 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -3608,6 +3608,23 @@ QQuickListViewAttached *QQuickListView::qmlAttachedProperties(QObject *obj) return new QQuickListViewAttached(obj); } +bool QQuickListView::contains(const QPointF &point) const +{ + bool ret = QQuickItemView::contains(point); + // QTBUG-74046: if a mouse press "falls through" a floating header or footer, don't allow dragging the list from there + if (ret) { + if (auto header = headerItem()) { + if (headerPositioning() != QQuickListView::InlineHeader && header->contains(mapToItem(header, point))) + ret = false; + } + if (auto footer = footerItem()) { + if (footerPositioning() != QQuickListView::InlineFooter && footer->contains(mapToItem(footer, point))) + ret = false; + } + } + return ret; +} + QT_END_NAMESPACE #include "moc_qquicklistview_p.cpp" diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h index 1c72a10190..be21b93155 100644 --- a/src/quick/items/qquicklistview_p.h +++ b/src/quick/items/qquicklistview_p.h @@ -179,6 +179,8 @@ public: static QQuickListViewAttached *qmlAttachedProperties(QObject *); + bool contains(const QPointF &point) const override; + public Q_SLOTS: void incrementCurrentIndex(); void decrementCurrentIndex(); -- cgit v1.2.3