From 787b4c1506aba7e83d861e178329a18c6ec34322 Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Tue, 13 Jun 2023 12:12:43 +0200 Subject: QHeaderView: use correct mouse position for auto scroll QHeaderView::mouseMoveEvent started autoscroll without propagating the event's mouse position to QAbstractItemViewPrivate::draggedPosition. This data member always containing QPoint() has lead to right drags not causing an autoscroll at all. Left drags with a scroll offset just kept scrolling until the offset was 0. The missing propagation has been added. As a drive by, dead code has been removed and the local variable pos has been constified. Fixes: QTBUG-113573 Pick-to: 6.6 6.5 Change-Id: I7b194dfc71abea6f2bbaaae18270c80eb15afb4d Reviewed-by: Oliver Eftevaag --- src/widgets/itemviews/qheaderview.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 5c0958037a..f6880f2c37 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2579,7 +2579,7 @@ void QHeaderView::mousePressEvent(QMouseEvent *e) void QHeaderView::mouseMoveEvent(QMouseEvent *e) { Q_D(QHeaderView); - int pos = d->orientation == Qt::Horizontal ? e->position().toPoint().x() : e->position().toPoint().y(); + const int pos = d->orientation == Qt::Horizontal ? e->position().toPoint().x() : e->position().toPoint().y(); if (pos < 0 && d->state != QHeaderViewPrivate::SelectSections) return; if (e->buttons() == Qt::NoButton) { @@ -2607,8 +2607,10 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) return; } case QHeaderViewPrivate::MoveSection: { - if (d->shouldAutoScroll(e->position().toPoint())) + if (d->shouldAutoScroll(e->position().toPoint())) { + d->draggedPosition = e->pos(); d->startAutoScroll(); + } if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance() #if QT_CONFIG(label) || !d->sectionIndicator->isHidden() @@ -3805,12 +3807,9 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) if (currentSectionSize <= minimumSize) continue; int newSectionSize = qMax(currentSectionSize - delta, minimumSize); - //qDebug() << "### cascading to" << i << newSectionSize - currentSectionSize << delta; resizeSectionItem(i, currentSectionSize, newSectionSize); saveCascadingSectionSize(i, currentSectionSize); delta = delta - (currentSectionSize - newSectionSize); - //qDebug() << "new delta" << delta; - //if (newSectionSize != minimumSize) if (delta <= 0) break; } @@ -3828,7 +3827,6 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) int newSectionSize = currentSectionSize - delta; resizeSectionItem(i, currentSectionSize, newSectionSize); if (newSectionSize >= originalSectionSize && false) { - //qDebug() << "section" << i << "restored to" << originalSectionSize; cascadingSectionSize.remove(i); // the section is now restored } sectionResized = true; -- cgit v1.2.3