From c507e2f33eb0b77bcc447c6bc96bea19fa1684ca Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 15 Dec 2023 20:41:09 +0100 Subject: [PATCH] QHeaderView: rename private 'offset' to avoid clash with QAIVP::offset() QAIVP has a function named 'offset()' which is hidden by QHVP::offset variable. Therefore rename the QHVP::offset to headerOffset Pick-to: 6.5 Change-Id: Iadb18b8f18197925daa72af243483a044c1d94e7 Reviewed-by: Axel Spoerl (cherry picked from commit 15884aba8fc697ce3c2b9b5f7dea14093f037f03) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 13198306c8a64cc4a1d17f028aac744437c773b7) --- src/widgets/itemviews/qheaderview.cpp | 24 ++++++++++++------------ src/widgets/itemviews/qheaderview_p.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 8914b9a67e9..c2e0d52ff5f 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -418,7 +418,7 @@ Qt::Orientation QHeaderView::orientation() const int QHeaderView::offset() const { Q_D(const QHeaderView); - return d->offset; + return d->headerOffset; } /*! @@ -432,10 +432,10 @@ int QHeaderView::offset() const void QHeaderView::setOffset(int newOffset) { Q_D(QHeaderView); - if (d->offset == (int)newOffset) + if (d->headerOffset == newOffset) return; - int ndelta = d->offset - newOffset; - d->offset = newOffset; + int ndelta = d->headerOffset - newOffset; + d->headerOffset = newOffset; if (d->orientation == Qt::Horizontal) d->viewport->scroll(isRightToLeft() ? -ndelta : ndelta, 0); else @@ -591,7 +591,7 @@ int QHeaderView::visualIndexAt(int position) const if (d->reverse()) vposition = d->viewport->width() - vposition - 1; - vposition += d->offset; + vposition += d->headerOffset; if (vposition > d->length) return -1; @@ -681,7 +681,7 @@ int QHeaderView::sectionViewportPosition(int logicalIndex) const int position = sectionPosition(logicalIndex); if (position < 0) return position; // the section was hidden - int offsetPosition = position - d->offset; + int offsetPosition = position - d->headerOffset; if (d->reverse()) return d->viewport->width() - (offsetPosition + sectionSize(logicalIndex)); return offsetPosition; @@ -2520,9 +2520,9 @@ void QHeaderView::paintEvent(QPaintEvent *e) for (int a = 0, i = 0; i < d->sectionItems.count(); ++i) { QColor color((i & 4 ? 255 : 0), (i & 2 ? 255 : 0), (i & 1 ? 255 : 0)); if (d->orientation == Qt::Horizontal) - painter.fillRect(a - d->offset, 0, d->sectionItems.at(i).size, 4, color); + painter.fillRect(a - d->headerOffset, 0, d->sectionItems.at(i).size, 4, color); else - painter.fillRect(0, a - d->offset, 4, d->sectionItems.at(i).size, color); + painter.fillRect(0, a - d->headerOffset, 4, d->sectionItems.at(i).size, color); a += d->sectionItems.at(i).size; } @@ -2624,7 +2624,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) if (visual == 0 && logicalIndex(0) == 0 && !d->allowUserMoveOfSection0) return; - const int posThreshold = d->headerSectionPosition(visual) - d->offset + d->headerSectionSize(visual) / 2; + const int posThreshold = d->headerSectionPosition(visual) - d->headerOffset + d->headerSectionSize(visual) / 2; const int checkPos = d->reverse() ? d->viewport->width() - pos : pos; int moving = visualIndex(d->section); int oldTarget = d->target; @@ -2648,7 +2648,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) return; } case QHeaderViewPrivate::SelectSections: { - int logical = logicalIndexAt(qMax(-d->offset, pos)); + int logical = logicalIndexAt(qMax(-d->headerOffset, pos)); if (logical == -1 && pos > 0) logical = logicalIndex(d->lastVisibleVisualIndex()); if (logical == d->pressed) @@ -3070,7 +3070,7 @@ int QHeaderView::horizontalOffset() const { Q_D(const QHeaderView); if (d->orientation == Qt::Horizontal) - return d->offset; + return d->headerOffset; return 0; } @@ -3085,7 +3085,7 @@ int QHeaderView::verticalOffset() const { Q_D(const QHeaderView); if (d->orientation == Qt::Vertical) - return d->offset; + return d->headerOffset; return 0; } diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index f921fe6982a..4b633c21004 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -37,7 +37,7 @@ public: QHeaderViewPrivate() : state(NoState), - offset(0), + headerOffset(0), sortIndicatorOrder(Qt::DescendingOrder), sortIndicatorSection(0), sortIndicatorShown(false), @@ -219,7 +219,7 @@ public: enum State { NoState, ResizeSection, MoveSection, SelectSections, NoClear } state; - int offset; + int headerOffset; Qt::Orientation orientation; Qt::SortOrder sortIndicatorOrder; int sortIndicatorSection;