]> git.sur5r.net Git - minitube/blobdiff - src/playlistitemdelegate.cpp
Imported Upstream version 2.4
[minitube] / src / playlistitemdelegate.cpp
index 295eba8e403ea5c98498e3f6e055137528a70cd7..717c7e57d64cbe7ee82a8318bd552d645a8bb41d 100644 (file)
@@ -22,7 +22,7 @@ $END_LICENSE */
 #include "playlistmodel.h"
 #include "fontutils.h"
 #include "downloaditem.h"
-#include "utils.h"
+#include "iconutils.h"
 #include "videodefinition.h"
 #include "video.h"
 
@@ -131,7 +131,8 @@ void PlaylistItemDelegate::paintBody( QPainter* painter,
         painter->drawPixmap(playIcon.rect(), playIcon);
 
     // time
-    drawTime(painter, video->formattedDuration(), line);
+    if (video->duration() > 0)
+        drawTime(painter, video->formattedDuration(), line);
 
     // separator
     painter->setPen(option.palette.color(QPalette::Midlight));
@@ -142,13 +143,13 @@ void PlaylistItemDelegate::paintBody( QPainter* painter,
 
     if (line.width() > THUMB_WIDTH + 60) {
 
-        if (isActive) painter->setFont(boldFont);
+        // if (isActive) painter->setFont(boldFont);
 
         // text color
         if (isSelected)
-            painter->setPen(QPen(option.palette.brush(QPalette::HighlightedText), 0));
+            painter->setPen(QPen(option.palette.highlightedText(), 0));
         else
-            painter->setPen(QPen(option.palette.brush(QPalette::Text), 0));
+            painter->setPen(QPen(option.palette.text(), 0));
 
         // title
         QString videoTitle = video->title();
@@ -190,9 +191,9 @@ void PlaylistItemDelegate::paintBody( QPainter* painter,
                 if (authorHovered)
                     painter->setPen(QPen(option.palette.brush(QPalette::Highlight), 0));
                 else
-                    painter->setPen(QPen(option.palette.brush(QPalette::Mid), 0));
+                    painter->setOpacity(.5);
             }
-            QString authorString = video->author();
+            QString authorString = video->channelTitle();
             textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
             stringSize = QSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, authorString ) );
             QRect authorTextBox(textLoc , stringSize);
@@ -226,7 +227,7 @@ void PlaylistItemDelegate::paintBody( QPainter* painter,
 
     } else {
 
-        bool isHovered = option.state & QStyle::State_MouseOver;
+        const bool isHovered = index.data(HoveredItemRole).toBool();
         if (!isActive && isHovered) {
             painter->setFont(smallerFont);
             painter->setPen(Qt::white);
@@ -380,7 +381,7 @@ void PlaylistItemDelegate::paintDownloadInfo( QPainter* painter,
     if (status != Finished && status != Failed && status != Idle) {
         if (downloadButtonHovered) message = tr("Stop downloading");
         painter->save();
-        QIcon closeIcon = Utils::icon("window-close");
+        QIcon closeIcon = IconUtils::icon("window-close");
         painter->drawPixmap(downloadButtonRect(line), closeIcon.pixmap(16, 16, iconMode));
         painter->restore();
     }
@@ -393,7 +394,7 @@ void PlaylistItemDelegate::paintDownloadInfo( QPainter* painter,
             message = tr("Open parent folder");
 #endif
         painter->save();
-        QIcon searchIcon = Utils::icon("system-search");
+        QIcon searchIcon = IconUtils::icon("system-search");
         painter->drawPixmap(downloadButtonRect(line), searchIcon.pixmap(16, 16, iconMode));
         painter->restore();
     }
@@ -401,7 +402,7 @@ void PlaylistItemDelegate::paintDownloadInfo( QPainter* painter,
     else if (status == Failed || status == Idle) {
         if (downloadButtonHovered) message = tr("Restart downloading");
         painter->save();
-        QIcon searchIcon = Utils::icon("view-refresh");
+        QIcon searchIcon = IconUtils::icon("view-refresh");
         painter->drawPixmap(downloadButtonRect(line), searchIcon.pixmap(16, 16, iconMode));
         painter->restore();
     }