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