QmlJSOutline: Show the type icons again in the outline

They got kicked out when I added a custom style delegate.
This commit is contained in:
Kai Koehne
2010-08-10 16:23:28 +02:00
parent fcd4680761
commit 757b314631

View File

@@ -40,22 +40,24 @@ void QmlJSOutlineItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
QStyle *style = QApplication::style(); QStyle *style = QApplication::style();
// paint type name style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
QRect typeRect = style->itemTextRect(opt.fontMetrics, opt.rect, Qt::AlignLeft, true, typeString);
if (!annotationString.isEmpty()) {
QPalette::ColorRole textColorRole = QPalette::Text; QPalette::ColorRole textColorRole = QPalette::Text;
if (option.state & QStyle::State_Selected) { if (option.state & QStyle::State_Selected) {
textColorRole = QPalette::HighlightedText; textColorRole = QPalette::HighlightedText;
} }
style->drawItemText(painter, typeRect, Qt::AlignLeft, opt.palette, true, typeString, textColorRole); // calculate sizes of icon, type.
QPixmap iconPixmap = opt.icon.pixmap(opt.rect.size());
// paint annotation (e.g. id) QRect iconRect = style->itemPixmapRect(opt.rect, Qt::AlignLeft, iconPixmap);
if (!annotationString.isEmpty()) { QRect typeRect = style->itemTextRect(opt.fontMetrics, opt.rect, Qt::AlignLeft, true, typeString);
QRect annotationRect = style->itemTextRect(opt.fontMetrics, opt.rect, Qt::AlignLeft, true, QRect annotationRect = style->itemTextRect(opt.fontMetrics, opt.rect, Qt::AlignLeft | Qt::AlignBottom, true,
annotationString); annotationString);
static int space = opt.fontMetrics.width(" "); static int space = opt.fontMetrics.width(" ");
annotationRect.adjust(typeRect.width() + space, 0, typeRect.width() + space, 0); annotationRect.adjust(iconRect.width() + typeRect.width() + space, 0,
iconRect.width() + typeRect.width() + space, 0);
QPalette disabledPalette(opt.palette); QPalette disabledPalette(opt.palette);
disabledPalette.setCurrentColorGroup(QPalette::Disabled); disabledPalette.setCurrentColorGroup(QPalette::Disabled);