Revert "clean up library view"

This reverts commit 97cbf556a0.
This commit is contained in:
Arnaud Bienner 2015-09-21 00:23:30 +02:00
parent bfe5042132
commit 774aeaaf11
1 changed files with 14 additions and 35 deletions

View File

@ -62,8 +62,6 @@ void LibraryItemDelegate::paint(QPainter* painter,
QString text(index.data().toString());
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
painter->setRenderHint(QPainter::HighQualityAntialiasing);
QRect text_rect(opt.rect);
@ -91,42 +89,23 @@ void LibraryItemDelegate::paint(QPainter* painter,
painter->drawPixmap(icon_rect, pixmap);
} else {
text_rect.setLeft(text_rect.right() - (text_rect.height() + 10));
text_rect.setWidth(text_rect.height());
}
QRect highlight_rect;
QFont norm_font(opt.font);
QColor highlight_color(opt.palette.color(QPalette::Text));
highlight_color.setAlpha(200);
QBrush brush(highlight_color, Qt::SolidPattern);
painter->setPen(QColor(0, 0, 0, 0));
painter->setBrush(brush);
// Draw text highlight fill
if (text.length() == 1) {
highlight_rect = text_rect;
highlight_rect.setWidth(text_rect.width() - 1);
highlight_rect.setHeight(text_rect.height() - 1);
highlight_rect.setLeft(text_rect.left() + 1);
highlight_rect.setTop(text_rect.top() + 1);
painter->drawEllipse(highlight_rect);
} else {
QFontMetrics fm(norm_font);
text_rect.setLeft(text_rect.right() - (fm.width(text) + 22));
text_rect.setWidth(fm.width(text) + 12);
highlight_rect = text_rect;
highlight_rect.setWidth(text_rect.width() - 1);
highlight_rect.setHeight(text_rect.height() - 1);
highlight_rect.setLeft(text_rect.left() + 1);
highlight_rect.setTop(text_rect.top() + 1);
painter->fillRect(highlight_rect, brush);
text_rect.setLeft(text_rect.left() + 30);
}
// Draw the text
painter->setPen(opt.palette.color(QPalette::Window));
painter->setFont(norm_font);
painter->drawText(text_rect, text, Qt::AlignVCenter | Qt::AlignHCenter);
QFont bold_font(opt.font);
bold_font.setBold(true);
painter->setPen(opt.palette.color(QPalette::Text));
painter->setFont(bold_font);
painter->drawText(text_rect, text);
// Draw the line under the item
QPen line_pen(opt.palette.color(QPalette::Dark));
line_pen.setWidth(2);
painter->setPen(line_pen);
painter->drawLine(opt.rect.bottomLeft(), opt.rect.bottomRight());
painter->restore();
} else {