Revert "QHeaderView: relayout on resetDefaultSectionSize"
This reverts commit a8df174369cecd90f14dac85bf162353b7cb25d1. Reason for revert: Caused QTBUG-122109 Pick-to: 6.6 6.5 Fixes: QTBUG-122109 Fixes: QTBUG-120699 Change-Id: Iea185c00f35e17d8eb8e8da70dc2d808ea274b04 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit c1921abf65092f4732435a92732c8c11224d31fb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d47c40d51e
commit
6b0cb98478
@ -1529,14 +1529,13 @@ void QHeaderView::setDefaultSectionSize(int size)
|
||||
if (size < 0 || size > maxSizeSection)
|
||||
return;
|
||||
d->setDefaultSectionSize(size);
|
||||
d->customDefaultSectionSize = true;
|
||||
}
|
||||
|
||||
void QHeaderView::resetDefaultSectionSize()
|
||||
{
|
||||
Q_D(QHeaderView);
|
||||
if (d->customDefaultSectionSize) {
|
||||
d->setDefaultSectionSize(d->getDefaultSectionSizeFromStyle());
|
||||
d->updateDefaultSectionSizeFromStyle();
|
||||
d->customDefaultSectionSize = false;
|
||||
}
|
||||
}
|
||||
@ -2388,7 +2387,7 @@ bool QHeaderView::event(QEvent *e)
|
||||
break; }
|
||||
case QEvent::StyleChange:
|
||||
if (!d->customDefaultSectionSize)
|
||||
d->setDefaultSectionSize(d->getDefaultSectionSizeFromStyle());
|
||||
d->updateDefaultSectionSizeFromStyle();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -3855,6 +3854,7 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size)
|
||||
executePostedLayout();
|
||||
invalidateCachedSizeHint();
|
||||
defaultSectionSize = size;
|
||||
customDefaultSectionSize = true;
|
||||
if (state == QHeaderViewPrivate::ResizeSection)
|
||||
preventCursorChangeInSetOffset = true;
|
||||
for (int i = 0; i < sectionItems.size(); ++i) {
|
||||
@ -3875,14 +3875,15 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size)
|
||||
viewport->update();
|
||||
}
|
||||
|
||||
int QHeaderViewPrivate::getDefaultSectionSizeFromStyle() const
|
||||
void QHeaderViewPrivate::updateDefaultSectionSizeFromStyle()
|
||||
{
|
||||
Q_Q(const QHeaderView);
|
||||
return orientation == Qt::Horizontal
|
||||
? q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeHorizontal, nullptr, q)
|
||||
: qMax(q->minimumSectionSize(),
|
||||
q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeVertical, nullptr,
|
||||
q));
|
||||
Q_Q(QHeaderView);
|
||||
if (orientation == Qt::Horizontal) {
|
||||
defaultSectionSize = q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeHorizontal, nullptr, q);
|
||||
} else {
|
||||
defaultSectionSize = qMax(q->minimumSectionSize(),
|
||||
q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeVertical, nullptr, q));
|
||||
}
|
||||
}
|
||||
|
||||
void QHeaderViewPrivate::recalcSectionStartPos() const // linear (but fast)
|
||||
@ -4191,7 +4192,7 @@ bool QHeaderViewPrivate::read(QDataStream &in)
|
||||
if (in.status() == QDataStream::Ok) { // we haven't read past end
|
||||
customDefaultSectionSize = tmpbool;
|
||||
if (!customDefaultSectionSize)
|
||||
defaultSectionSize = getDefaultSectionSizeFromStyle();
|
||||
updateDefaultSectionSizeFromStyle();
|
||||
}
|
||||
|
||||
lastSectionSize = -1;
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
|
||||
inline void setDefaultValues(Qt::Orientation o) {
|
||||
orientation = o;
|
||||
defaultSectionSize = getDefaultSectionSizeFromStyle();
|
||||
updateDefaultSectionSizeFromStyle();
|
||||
defaultAlignment = (o == Qt::Horizontal
|
||||
? Qt::Alignment(Qt::AlignCenter)
|
||||
: Qt::AlignLeft|Qt::AlignVCenter);
|
||||
@ -323,7 +323,7 @@ public:
|
||||
void removeSectionsFromSectionItems(int start, int end);
|
||||
void resizeSectionItem(int visualIndex, int oldSize, int newSize);
|
||||
void setDefaultSectionSize(int size);
|
||||
int getDefaultSectionSizeFromStyle() const;
|
||||
void updateDefaultSectionSizeFromStyle();
|
||||
void recalcSectionStartPos() const; // not really const
|
||||
|
||||
inline int headerLength() const { // for debugging
|
||||
|
@ -4922,6 +4922,7 @@ void tst_QTableView::resetDefaultSectionSize()
|
||||
view.verticalHeader()->resetDefaultSectionSize();
|
||||
view.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
QEXPECT_FAIL("", "Reverted fix for QTBUG-116013 due to QTBUG-122109", Continue);
|
||||
QCOMPARE(view.verticalHeader()->logicalIndexAt(9, 45), 1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user