| 179 | } |
| 180 | |
| 181 | static QSize viewItemTextSize(const QStyleOptionViewItem *option) |
| 182 | { |
| 183 | QStyle *style = option->widget ? option->widget->style() : QApplication::style(); |
| 184 | QTextOption textOption; |
| 185 | textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); |
| 186 | QTextLayout textLayout; |
| 187 | textLayout.setTextOption(textOption); |
| 188 | textLayout.setFont(option->font); |
| 189 | textLayout.setText(option->text); |
| 190 | const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, option, option->widget) + 1; |
| 191 | QRect bounds(0, 0, 100 - 2 * textMargin, 600); |
| 192 | qreal height = 0, widthUsed = 0; |
| 193 | viewItemTextLayout(textLayout, bounds.width(), height, widthUsed); |
| 194 | const QSize size(qCeil(widthUsed), qCeil(height)); |
| 195 | return QSize(size.width() + 2 * textMargin, size.height()); |
| 196 | } |
| 197 | |
| 198 | void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, |
| 199 | const QModelIndex &index) const |
no test coverage detected