| 1273 | } |
| 1274 | |
| 1275 | void RichTextViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, |
| 1276 | const QModelIndex &index) const |
| 1277 | { |
| 1278 | if(index.isValid()) |
| 1279 | { |
| 1280 | QVariant v = index.data(); |
| 1281 | |
| 1282 | if(RichResourceTextCheck(v)) |
| 1283 | { |
| 1284 | // draw the item without text, so we get the proper background/selection/etc. |
| 1285 | // we'd like to be able to use the parent delegate's paint here, but either it calls to |
| 1286 | // QStyledItemDelegate which will re-fetch the text (bleh), or it calls to the manual |
| 1287 | // delegate which could do anything. So for this case we just use the style and skip the |
| 1288 | // delegate and hope it works out. |
| 1289 | QStyleOptionViewItem opt = option; |
| 1290 | QStyledItemDelegate::initStyleOption(&opt, index); |
| 1291 | opt.text.clear(); |
| 1292 | m_widget->style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, m_widget); |
| 1293 | |
| 1294 | painter->save(); |
| 1295 | |
| 1296 | QRect rect = opt.rect; |
| 1297 | if(!opt.icon.isNull()) |
| 1298 | { |
| 1299 | QIcon::Mode mode; |
| 1300 | if((opt.state & QStyle::State_Enabled) == 0) |
| 1301 | mode = QIcon::Disabled; |
| 1302 | else if(opt.state & QStyle::State_Selected) |
| 1303 | mode = QIcon::Selected; |
| 1304 | else |
| 1305 | mode = QIcon::Normal; |
| 1306 | QIcon::State state = opt.state & QStyle::State_Open ? QIcon::On : QIcon::Off; |
| 1307 | rect.setX(rect.x() + opt.icon.actualSize(opt.decorationSize, mode, state).width() + 4); |
| 1308 | } |
| 1309 | |
| 1310 | RichResourceTextPaint(m_widget, painter, rect, opt.font, opt.palette, opt.state, |
| 1311 | m_widget->viewport()->mapFromGlobal(QCursor::pos()), v); |
| 1312 | |
| 1313 | painter->restore(); |
| 1314 | return; |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | return ForwardingDelegate::paint(painter, option, index); |
| 1319 | } |
| 1320 | |
| 1321 | QSize RichTextViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const |
| 1322 | { |
nothing calls this directly
no test coverage detected