MCPcopy Create free account
hub / github.com/KDE/kdevelop / sizeHint

Method sizeHint

kdevplatform/outputview/outputdelegate.cpp:90–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90QSize 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"

Callers

nothing calls this directly

Calls 3

sizeHintFunction · 0.85
modifyStyleOptionsMethod · 0.80
styleMethod · 0.80

Tested by

no test coverage detected