40 QStyleOptionViewItem options = option;
41 initStyleOption(&options, index);
42 if (!hasHtml(options.text)) {
43 QStyledItemDelegate::paint(painter, option, index);
49 doc.setHtml(options.text);
53 const QWidget* widget = option.widget;
54 QStyle* style = widget ? widget->style() : QApplication::style();
55 style->drawControl(QStyle::CE_ItemViewItem, &options, painter, widget);
58 QSize iconSize = options.icon.actualSize(options.rect.size());
59 painter->translate(options.rect.left() + iconSize.width(), options.rect.top());
60 QRect clip(0, 0, options.rect.width() + iconSize.width(), options.rect.height());
62 painter->setClipRect(clip);
63 QAbstractTextDocumentLayout::PaintContext ctx;
66 QPalette::ColorGroup cg =
67 options.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
68 if (cg == QPalette::Normal && !(options.state & QStyle::State_Active))
69 cg = QPalette::Inactive;
70 ctx.palette.setColor(QPalette::Text, option.palette.color(cg, QPalette::Text));
73 doc.documentLayout()->draw(painter, ctx);