From 020664da2db7086b81864a7f9658cf783b2ec83b Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 23 Oct 2014 10:30:39 +0200 Subject: Auto-scroll while selecting entire rows/columns did not work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you press and hold a section in a header view you can extend the selection to more rows by moving the mouse. This worked fine until you moved the mouse outside the geometry of the header view. The expected behavior was then to scroll the view (this is what happens with extended selections on regular table cells). [ChangeLog][QtWidgets][QHeaderView] Auto-scroll the view when making extended row/column selections. Change-Id: Ic65aa34d370e74054b2123ab57edb1add0e8adb9 Task-number: QTBUG-21201 Reviewed-by: Thorbjørn Lund Martsum (cherry picked from qtbase/f9408317e70bc2e635a2f9baeff35d1c06227734) --- src/gui/itemviews/qheaderview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 36b77a7e61..6555521bde 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -2210,7 +2210,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) { Q_D(QHeaderView); int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); - if (pos < 0) + if (pos < 0 && d->state != QHeaderViewPrivate::SelectSections) return; if (e->buttons() == Qt::NoButton) { #if !defined(Q_WS_MAC) @@ -2263,7 +2263,9 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) return; } case QHeaderViewPrivate::SelectSections: { - int logical = logicalIndexAt(pos); + int logical = logicalIndexAt(qMax(-d->offset, pos)); + if (logical == -1 && pos > 0) + logical = d->lastVisibleVisualIndex(); if (logical == d->pressed) return; // nothing to do else if (d->pressed != -1) -- cgit v1.2.3