Correct wordwrapped text handling in QListView icon mode
Currently a QListView with wordwrapping activated will wrap the text only to the width of the icon even if the grid size is bigger. With this patch the option rect is now updated to match the grid size if valid and the style uses it to determine the correct size when wrapping [ChangeLog][QtWidgets][QTBUG-4714] Use the grid size for wordwrapping when available in icon mode Task-number: QTBUG-4714 Change-Id: I2cb63809d3ee8bd262f38bc11de91df9ff5cf237 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
7fab8eb56b
commit
a761be2fb2
@ -915,6 +915,11 @@ QStyleOptionViewItem QListView::viewOptions() const
|
||||
} else {
|
||||
option.decorationPosition = QStyleOptionViewItem::Left;
|
||||
}
|
||||
|
||||
if (d->gridSize().isValid()) {
|
||||
option.rect.setSize(d->gridSize());
|
||||
}
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
|
@ -838,7 +838,10 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int
|
||||
break;
|
||||
case QStyleOptionViewItem::Top:
|
||||
case QStyleOptionViewItem::Bottom:
|
||||
bounds.setWidth(wrapText ? option->decorationSize.width() : QFIXED_MAX);
|
||||
if (wrapText)
|
||||
bounds.setWidth(bounds.isValid() ? bounds.width() - 2 * textMargin : option->decorationSize.width());
|
||||
else
|
||||
bounds.setWidth(QFIXED_MAX);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user