]> git.sur5r.net Git - minitube/blobdiff - src/channelitemdelegate.cpp
Upload 2.9-1 to unstable
[minitube] / src / channelitemdelegate.cpp
index b06e8612c1ad59e78e2b7db68704653178ebdc84..664efc460072e2d8c6530ed0ee19b2f95f7c4d58 100644 (file)
@@ -20,13 +20,14 @@ $END_LICENSE */
 
 #include "channelitemdelegate.h"
 #include "channelmodel.h"
-#include "ytuser.h"
+#include "ytchannel.h"
 #include "fontutils.h"
 #include "channelaggregator.h"
 #include "painterutils.h"
+#include "iconutils.h"
 
-static const int ITEM_WIDTH = 128;
-static const int ITEM_HEIGHT = 128;
+static const int ITEM_WIDTH = 150;
+static const int ITEM_HEIGHT = 150;
 static const int THUMB_WIDTH = 88;
 static const int THUMB_HEIGHT = 88;
 
@@ -56,12 +57,13 @@ void ChannelItemDelegate::paint( QPainter* painter,
 void ChannelItemDelegate::paintAggregate(QPainter* painter,
                                           const QStyleOptionViewItem& option,
                                           const QModelIndex& index) const {
+    Q_UNUSED(index);
     painter->save();
 
     painter->translate(option.rect.topLeft());
     const QRect line(0, 0, option.rect.width(), option.rect.height());
 
-    static const QPixmap thumbnail = QPixmap(":/images/channels.png");
+    static const QPixmap thumbnail = IconUtils::pixmap(":/images/channels.png");
 
     QString name = tr("All Videos");
 
@@ -73,12 +75,13 @@ void ChannelItemDelegate::paintAggregate(QPainter* painter,
 void ChannelItemDelegate::paintUnwatched(QPainter* painter,
                                           const QStyleOptionViewItem& option,
                                           const QModelIndex& index) const {
+    Q_UNUSED(index);
     painter->save();
 
     painter->translate(option.rect.topLeft());
     const QRect line(0, 0, option.rect.width(), option.rect.height());
 
-    static const QPixmap thumbnail = QPixmap(":/images/unwatched.png");
+    static const QPixmap thumbnail = IconUtils::pixmap(":/images/unwatched.png");
 
     QString name = tr("Unwatched Videos");
 
@@ -94,10 +97,8 @@ void ChannelItemDelegate::paintUnwatched(QPainter* painter,
 void ChannelItemDelegate::paintChannel(QPainter* painter,
                                         const QStyleOptionViewItem& option,
                                         const QModelIndex& index) const {
-    const QVariant dataObject = index.data(ChannelModel::DataObjectRole);
-    const YTUserPointer channelPointer = dataObject.value<YTUserPointer>();
-    YTUser *user = channelPointer.data();
-    if (!user) return;
+    YTChannel *channel = index.data(ChannelModel::DataObjectRole).value<YTChannelPointer>().data();
+    if (!channel) return;
 
     painter->save();
 
@@ -108,17 +109,17 @@ void ChannelItemDelegate::paintChannel(QPainter* painter,
     // const bool isHovered = index.data(ChannelsModel::HoveredItemRole ).toBool();
     // const bool isSelected = option.state & QStyle::State_Selected;
 
-    QPixmap thumbnail = user->getThumbnail();
+    QPixmap thumbnail = channel->getThumbnail();
     if (thumbnail.isNull()) {
-        user->loadThumbnail();
+        channel->loadThumbnail();
         painter->restore();
         return;
     }
 
-    QString name = user->getDisplayName();
+    QString name = channel->getDisplayName();
     drawItem(painter, line, thumbnail, name);
 
-    int notifyCount = user->getNotifyCount();
+    int notifyCount = channel->getNotifyCount();
     if (notifyCount > 0)
         paintBadge(painter, line, QString::number(notifyCount));