X-Git-Url: https://git.sur5r.net/?p=minitube;a=blobdiff_plain;f=src%2Fplaylist%2FPrettyItemDelegate.cpp;h=6cdac51014805cdb6efc823740a9419996ee9f28;hp=8194771c84cef04a5cb0c1476372cbab90ad8a5d;hb=3c8c537559e6bef5f019196b0989e95863ddd3ee;hpb=57c25e20a8f10a98a18dbc2b64ce55cf87d4fd7c diff --git a/src/playlist/PrettyItemDelegate.cpp b/src/playlist/PrettyItemDelegate.cpp index 8194771..6cdac51 100644 --- a/src/playlist/PrettyItemDelegate.cpp +++ b/src/playlist/PrettyItemDelegate.cpp @@ -6,11 +6,15 @@ #include #include +#include const qreal PrettyItemDelegate::THUMB_HEIGHT = 90.0; const qreal PrettyItemDelegate::THUMB_WIDTH = 120.0; const qreal PrettyItemDelegate::PADDING = 10.0; +QRect lastAuthorRect; +QHash authorRects; + PrettyItemDelegate::PrettyItemDelegate(QObject* parent, bool downloadInfo) : QStyledItemDelegate(parent), downloadInfo(downloadInfo) { @@ -135,14 +139,27 @@ void PrettyItemDelegate::paintBody( QPainter* painter, painter->drawText(publishedTextBox, Qt::AlignLeft | Qt::AlignTop, publishedString); // author + bool authorHovered = false; + bool authorPressed = false; + const bool isHovered = index.data(HoveredItemRole).toBool(); + if (isHovered) { + authorHovered = index.data(AuthorHoveredRole).toBool(); + authorPressed = index.data(AuthorPressedRole).toBool(); + } + painter->save(); painter->setFont(smallerBoldFont); - if (!isSelected && !isActive) - painter->setPen(QPen(option.palette.brush(QPalette::Mid), 0)); + if (!isSelected) { + if (authorHovered) + painter->setPen(QPen(option.palette.brush(QPalette::Highlight), 0)); + else + painter->setPen(QPen(option.palette.brush(QPalette::Mid), 0)); + } QString authorString = video->author(); QSizeF authorStringSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, authorString ) ); textLoc.setX(textLoc.x() + publishedStringSize.width() + PADDING); QRectF authorTextBox( textLoc , authorStringSize); + authorRects.insert(index.row(), authorTextBox.toRect()); painter->drawText(authorTextBox, Qt::AlignLeft | Qt::AlignTop, authorString); painter->restore(); @@ -358,3 +375,7 @@ QRect PrettyItemDelegate::downloadButtonRect(QRect line) const { 16, 16); } + +QRect PrettyItemDelegate::authorRect(const QModelIndex& index) const { + return authorRects.value(index.row()); +}