Style sheets: Include margin while calculating QHeaderview section size

Align with QCommonstyle QHeaderview section size calculation.

Change-Id: I4c11e1881f48850ace3bdbb3c96f999cc298c91e
Task-number: QTBUG-56457
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Peng Wu 2016-10-10 16:16:24 +03:00 committed by Christian Ehrlicher
parent 070aec28e6
commit e555c03a42

View File

@ -4983,11 +4983,13 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
if (!subRule.hasGeometry()) { if (!subRule.hasGeometry()) {
QSize nativeContentsSize; QSize nativeContentsSize;
bool nullIcon = hdr->icon.isNull(); bool nullIcon = hdr->icon.isNull();
const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w);
int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w);
const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text)
: hdr->fontMetrics.size(0, hdr->text); : hdr->fontMetrics.size(0, hdr->text);
nativeContentsSize.setHeight(qMax(iconSize, txt.height())); nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin);
nativeContentsSize.setWidth(iconSize + txt.width()); nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize
+ (hdr->text.isNull() ? 0 : margin) + txt.width() + margin);
sz = sz.expandedTo(nativeContentsSize); sz = sz.expandedTo(nativeContentsSize);
} }
return subRule.size(sz); return subRule.size(sz);