ItemViews/css: Honor size for sort indicator only when there is one
When using css the size for the sort indicator is not honored correctly and therefore the header view text overlaps the sort inidcator. This patch reduces the available with for the text when (and only when) there is a sort indicator shown), also for the size hint. Fixes: QTBUG-115486 Pick-to: 6.6 6.5 Change-Id: Ic865bceaf98cd303490d821ecfb033abb8d6ba2a Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>bb10
parent
ab5d3a2958
commit
230ff021a1
|
|
@ -4127,11 +4127,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
|||
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
|
||||
if (hasStyleRule(w, PseudoElement_HeaderViewUpArrow)
|
||||
|| hasStyleRule(w, PseudoElement_HeaderViewDownArrow)) {
|
||||
const QRect arrowRect = subElementRect(SE_HeaderArrow, opt, w);
|
||||
if (hdr.orientation == Qt::Horizontal)
|
||||
hdr.rect.setWidth(hdr.rect.width() - arrowRect.width());
|
||||
else
|
||||
hdr.rect.setHeight(hdr.rect.height() - arrowRect.height());
|
||||
if (hdr.sortIndicator != QStyleOptionHeader::None) {
|
||||
const QRect arrowRect = subElementRect(SE_HeaderArrow, opt, w);
|
||||
if (hdr.orientation == Qt::Horizontal)
|
||||
hdr.rect.setWidth(hdr.rect.width() - arrowRect.width());
|
||||
else
|
||||
hdr.rect.setHeight(hdr.rect.height() - arrowRect.height());
|
||||
}
|
||||
}
|
||||
subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
|
||||
if (subRule.hasFont) {
|
||||
|
|
@ -6224,8 +6226,22 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
|
|||
|
||||
case SE_HeaderLabel: {
|
||||
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
|
||||
if (subRule.hasBox() || !subRule.hasNativeBorder())
|
||||
return subRule.contentsRect(opt->rect);
|
||||
if (subRule.hasBox() || !subRule.hasNativeBorder()) {
|
||||
auto r = subRule.contentsRect(opt->rect);
|
||||
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
|
||||
// Subtract width needed for arrow, if there is one
|
||||
if (header->sortIndicator != QStyleOptionHeader::None) {
|
||||
const auto arrowRect = subElementRect(SE_HeaderArrow, opt, w);
|
||||
if (arrowRect.isValid()) {
|
||||
if (opt->state & State_Horizontal)
|
||||
r.setWidth(r.width() - arrowRect.width());
|
||||
else
|
||||
r.setHeight(r.height() - arrowRect.height());
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue