| 159 | } |
| 160 | |
| 161 | static QSize viewItemTextSize(const QStyleOptionViewItem *option) |
| 162 | { |
| 163 | QStyle *style = option->widget ? option->widget->style() : QApplication::style(); |
| 164 | QTextOption textOption; |
| 165 | textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); |
| 166 | QTextLayout textLayout; |
| 167 | textLayout.setTextOption(textOption); |
| 168 | textLayout.setFont(option->font); |
| 169 | textLayout.setText(option->text); |
| 170 | const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, option, option->widget) + 1; |
| 171 | QRect bounds(0, 0, 100 - 2 * textMargin, 600); |
| 172 | qreal height = 0, widthUsed = 0; |
| 173 | viewItemTextLayout(textLayout, bounds.width(), height, widthUsed); |
| 174 | const QSize size(qCeil(widthUsed), qCeil(height)); |
| 175 | return QSize(size.width() + 2 * textMargin, size.height()); |
| 176 | } |
| 177 | |
| 178 | void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, |
| 179 | const QModelIndex &index) const |
no test coverage detected