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.5 Change-Id: Ic865bceaf98cd303490d821ecfb033abb8d6ba2a Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 230ff021a14816519b175d02d3400541ddd2abad) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
770d4ad14f
commit
0af27bf836
@ -4127,12 +4127,14 @@ 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)) {
|
||||
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) {
|
||||
QFont oldFont = p->font();
|
||||
@ -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…
x
Reference in New Issue
Block a user