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 <oliver.eftevaag@qt.io>
This commit is contained in:
parent
4e74fa8119
commit
787b4c1506
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user