]> git.sur5r.net Git - minitube/blobdiff - src/playlistitemdelegate.cpp
Change VideoDefinition class interface.
[minitube] / src / playlistitemdelegate.cpp
index f0de4b47c98dae7e1a1f9c53bc1aa3cb91432524..d29d973fc30d664a40f2b00c6ce47cca50eb3c67 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,7 +143,7 @@ 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)
@@ -192,7 +193,7 @@ void PlaylistItemDelegate::paintBody( QPainter* painter,
                 else
                     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);
@@ -213,7 +214,7 @@ void PlaylistItemDelegate::paintBody( QPainter* painter,
                 }
 
                 if (downloadInfo) {
-                    QString definitionString = VideoDefinition::getDefinitionName(video->getDefinitionCode());
+                    const QString definitionString = VideoDefinition::getDefinitionFor(video->getDefinitionCode()).getName();
                     textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
                     stringSize = QSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, definitionString ) );
                     QRect viewCountTextBox(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();
     }