summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorAles Erjavec <ales.erjavec@fri.uni-lj.si>2018-07-12 10:55:33 +0200
committerAleš Erjavec <ales.erjavec324@gmail.com>2018-08-02 07:23:36 +0000
commitdb738cbaf1ba7a4886f7869db16dbb9107a8e65e (patch)
tree0b684e665b7fb9eac837e54fe184530a75261e7f /src/widgets
parent780dc2291bc0e114bab8b9ccd8706708f6b47270 (diff)
QCommonStylePrivate::viewItemSize: Fix text width bounds calculation
The width of the icon was subtracted out of the available text area width even when the value of the `decorationPosition` was Top/Bottom. Task-number: QTBUG-69404 Task-number: QTBUG-30116 Change-Id: I501ffc0dab0cff25e525c26adf9bdb060408927b Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets')
-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 7420bfb3f7..3b9186e61a 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);