Account for the sort indicator being placed above the text on Vista
In WindowsVista style and later the sort indicator is placed above the text as opposed to alongside it. Therefore the extra space given is moved to the common style allowing styles that have it placed differently to easily ensure it is not included. Task-number: QTBUG-19915 Change-Id: Ic21fcc1d95f4c3cc2eb9c465e1c8afb9b805389a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
92c6bfa0b2
commit
f7af9fb632
@ -2762,15 +2762,9 @@ QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const
|
||||
opt.icon = qvariant_cast<QIcon>(variant);
|
||||
if (opt.icon.isNull())
|
||||
opt.icon = qvariant_cast<QPixmap>(variant);
|
||||
QSize size = style()->sizeFromContents(QStyle::CT_HeaderSection, &opt, QSize(), this);
|
||||
if (isSortIndicatorShown()) {
|
||||
int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, &opt, this);
|
||||
if (d->orientation == Qt::Horizontal)
|
||||
size.rwidth() += size.height() + margin;
|
||||
else
|
||||
size.rheight() += size.width() + margin;
|
||||
}
|
||||
return size;
|
||||
if (isSortIndicatorShown())
|
||||
opt.sortIndicator = QStyleOptionHeader::SortDown;
|
||||
return style()->sizeFromContents(QStyle::CT_HeaderSection, &opt, QSize(), this);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -4783,6 +4783,13 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
||||
sz.setHeight(margin + qMax(iconSize, txt.height()) + margin);
|
||||
sz.setWidth((nullIcon ? 0 : margin) + iconSize
|
||||
+ (hdr->text.isNull() ? 0 : margin) + txt.width() + margin);
|
||||
if (hdr->sortIndicator != QStyleOptionHeader::None) {
|
||||
int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, hdr, widget);
|
||||
if (hdr->orientation == Qt::Horizontal)
|
||||
sz.rwidth() += sz.height() + margin;
|
||||
else
|
||||
sz.rheight() += sz.width() + margin;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CT_TabWidget:
|
||||
|
@ -1970,6 +1970,19 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption
|
||||
sz -= QSize(2*border, 2*border);
|
||||
}
|
||||
return sz;
|
||||
case CT_HeaderSection:
|
||||
{
|
||||
// When there is a sort indicator it adds to the width but it is shown
|
||||
// above the text natively and not on the side
|
||||
if (QStyleOptionHeader *hdr = qstyleoption_cast<QStyleOptionHeader *>(const_cast<QStyleOption *>(option))) {
|
||||
QStyleOptionHeader::SortIndicator sortInd = hdr->sortIndicator;
|
||||
hdr->sortIndicator = QStyleOptionHeader::None;
|
||||
sz = QWindowsXPStyle::sizeFromContents(type, hdr, size, widget);
|
||||
hdr->sortIndicator = sortInd;
|
||||
return sz;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user