QCommonStylePrivate::viewItemSize: fix text height calculation
QCommonStylePrivate::viewItemSize did not adjust the width when the item had a decoration or a checkbox. This lead to a too big width used for the layouting and therefore sometimes the calculated height was too small. Task-number: QTBUG-30116 Change-Id: I4468daa9820b9a8aa00fe959ab9b73fec23cc24e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
ec7e870e70
commit
ef60435d2f
|
|
@ -971,6 +971,9 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
|
|||
option.rect.setHeight(height);
|
||||
option.rect.setX(q->columnViewportPosition(index.column()));
|
||||
option.rect.setWidth(q->columnWidth(index.column()));
|
||||
// 1px less space when grid is shown (see drawCell)
|
||||
if (showGrid)
|
||||
option.rect.setWidth(option.rect.width() - 1);
|
||||
}
|
||||
hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).height());
|
||||
return hint;
|
||||
|
|
|
|||
|
|
@ -889,6 +889,13 @@ 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);
|
||||
}
|
||||
|
||||
const int lineWidth = bounds.width();
|
||||
const QSizeF size = viewItemTextLayout(textLayout, lineWidth);
|
||||
return QSize(qCeil(size.width()) + 2 * textMargin, qCeil(size.height()));
|
||||
|
|
|
|||
Loading…
Reference in New Issue