| 88 | } |
| 89 | |
| 90 | QSize OutputDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const |
| 91 | { |
| 92 | Q_D(const OutputDelegate); |
| 93 | |
| 94 | if (!option.features.testFlag(QStyleOptionViewItem::WrapText)) { |
| 95 | return QItemDelegate::sizeHint(option, index); |
| 96 | } |
| 97 | |
| 98 | // Pass item view's contents rect (adjusted) to QItemDelegate::sizeHint() when word wrapping is enabled. |
| 99 | // QItemDelegate::sizeHint() honors the width of opt.rect but overwrites its height to fit the item's text. |
| 100 | // When opt.rect is not replaced, enabling word wrapping has no effect: each item remains single-line. |
| 101 | |
| 102 | QStyleOptionViewItem opt = d->modifyStyleOptions(option, index); |
| 103 | QRect contentsRect = opt.widget->contentsRect(); |
| 104 | // Narrow the rect by the width of a vertical scroll bar to prevent even minuscule horizontal scrolling. |
| 105 | contentsRect.setWidth(contentsRect.width() - opt.widget->style()->pixelMetric(QStyle::PM_ScrollBarExtent)); |
| 106 | opt.rect = contentsRect; |
| 107 | |
| 108 | return QItemDelegate::sizeHint(opt, index); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | #include "moc_outputdelegate.cpp" |
nothing calls this directly
no test coverage detected