summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 544cc5ef95..3ee3e856bc 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -879,9 +879,16 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int
QRect bounds = option->rect;
switch (option->decorationPosition) {
case QStyleOptionViewItem::Left:
- case QStyleOptionViewItem::Right:
- bounds.setWidth(wrapText && bounds.isValid() ? bounds.width() - 2 * textMargin : QFIXED_MAX);
+ case QStyleOptionViewItem::Right: {
+ if (wrapText && bounds.isValid()) {
+ int width = bounds.width() - 2 * textMargin;
+ if (option->features & QStyleOptionViewItem::HasDecoration)
+ width -= option->decorationSize.width() + 2 * textMargin;
+ bounds.setWidth(width);
+ } else
+ bounds.setWidth(QFIXED_MAX);
break;
+ }
case QStyleOptionViewItem::Top:
case QStyleOptionViewItem::Bottom:
if (wrapText)
@@ -893,12 +900,8 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int
break;
}
- if (wrapText) {
- if (option->features & QStyleOptionViewItem::HasCheckIndicator)
- bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth) - 2 * textMargin);
- if (option->features & QStyleOptionViewItem::HasDecoration)
- bounds.setWidth(bounds.width() - option->decorationSize.width() - 2 * textMargin);
- }
+ if (wrapText && option->features & QStyleOptionViewItem::HasCheckIndicator)
+ bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth) - 2 * textMargin);
const int lineWidth = bounds.width();
const QSizeF size = viewItemTextLayout(textLayout, lineWidth);