]> git.sur5r.net Git - minitube/commitdiff
paint channel and views even if there's not enough space
authorFlavio Tordini <flavio.tordini@gmail.com>
Wed, 16 Sep 2015 14:31:22 +0000 (16:31 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Wed, 16 Sep 2015 14:31:22 +0000 (16:31 +0200)
src/playlistitemdelegate.cpp

index e3383f6c47e4d9c1ad7bfddb9c29e2ac5e525ae2..4a83605ad1c28b23592bbc6886ef46a603b7505f 100644 (file)
@@ -177,55 +177,47 @@ void PlaylistItemDelegate::paintBody( QPainter* painter,
         QRect publishedTextBox(textLoc , stringSize);
         painter->drawText(publishedTextBox, Qt::AlignLeft | Qt::AlignTop, publishedString);
 
-        if (line.width() > publishedTextBox.x() + publishedTextBox.width()*2) {
-
-            // 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();
-            }
+        // 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) {
-                if (authorHovered)
-                    painter->setPen(QPen(option.palette.brush(QPalette::Highlight), 0));
-                else
-                    painter->setOpacity(.5);
-            }
-            const QString &authorString = video->channelTitle();
-            textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
-            stringSize = QSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, authorString ) );
-            QRect authorTextBox(textLoc , stringSize);
-            authorRects.insert(index.row(), authorTextBox);
-            painter->drawText(authorTextBox, Qt::AlignLeft | Qt::AlignTop, authorString);
-            painter->restore();
-
-            if (line.width() > authorTextBox.x() + 50) {
-
-                // view count
-                if (video->viewCount() >= 0) {
-                    QLocale locale;
-                    QString viewCountString = tr("%1 views").arg(locale.toString(video->viewCount()));
-                    textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
-                    stringSize = QSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, viewCountString ) );
-                    QRect viewCountTextBox(textLoc , stringSize);
-                    painter->drawText(viewCountTextBox, Qt::AlignLeft | Qt::AlignBottom, viewCountString);
-                }
-
-                if (downloadInfo) {
-                    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);
-                    painter->drawText(viewCountTextBox, Qt::AlignLeft | Qt::AlignBottom, definitionString);
-                }
+        painter->save();
+        painter->setFont(smallerBoldFont);
+        if (!isSelected) {
+            if (authorHovered)
+                painter->setPen(QPen(option.palette.brush(QPalette::Highlight), 0));
+            else
+                painter->setOpacity(.5);
+        }
+        const QString &authorString = video->channelTitle();
+        textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
+        stringSize = QSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, authorString ) );
+        QRect authorTextBox(textLoc , stringSize);
+        authorRects.insert(index.row(), authorTextBox);
+        painter->drawText(authorTextBox, Qt::AlignLeft | Qt::AlignTop, authorString);
+        painter->restore();
 
-            }
+        // view count
+        if (video->viewCount() >= 0) {
+            QLocale locale;
+            QString viewCountString = tr("%1 views").arg(locale.toString(video->viewCount()));
+            textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
+            stringSize = QSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, viewCountString ) );
+            QRect viewCountTextBox(textLoc , stringSize);
+            painter->drawText(viewCountTextBox, Qt::AlignLeft | Qt::AlignBottom, viewCountString);
+        }
 
+        if (downloadInfo) {
+            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);
+            painter->drawText(viewCountTextBox, Qt::AlignLeft | Qt::AlignBottom, definitionString);
         }
 
     } else {