| 95 | } |
| 96 | |
| 97 | QSize QuickItemDelegate::sizeHint(const QStyleOptionViewItem &option, |
| 98 | const QModelIndex &index) const |
| 99 | { |
| 100 | Q_UNUSED(option); |
| 101 | |
| 102 | // this gets us the cached value for empty cells |
| 103 | const auto sh = index.data(Qt::SizeHintRole); |
| 104 | if (sh.isValid()) |
| 105 | return sh.toSize(); |
| 106 | |
| 107 | QSize textSize = m_view->fontMetrics().size(Qt::TextSingleLine, index.data(Qt::DisplayRole).toString()); |
| 108 | |
| 109 | QSize decorationSize; |
| 110 | if (index.column() == 0) { |
| 111 | int flags = index.data(QuickItemModelRole::ItemFlags).value<int>(); |
| 112 | |
| 113 | int icons = 1; |
| 114 | if ((flags & QuickItemModelRole::OutOfView) && (~flags & QuickItemModelRole::Invisible)) |
| 115 | icons++; |
| 116 | |
| 117 | if (flags & (QuickItemModelRole::HasFocus | QuickItemModelRole::HasActiveFocus)) |
| 118 | icons++; |
| 119 | |
| 120 | decorationSize = QSize(icons * 20, 16); |
| 121 | } |
| 122 | |
| 123 | return { textSize.width() + decorationSize.width() + 5, |
| 124 | qMax(textSize.height(), decorationSize.height()) }; |
| 125 | } |
| 126 | |
| 127 | void QuickItemDelegate::setTextColor(const QVariant &textColor, const QPersistentModelIndex &index) |
| 128 | { |
no test coverage detected