]> git.sur5r.net Git - minitube/commitdiff
Video definition indicator while downloading videos
authorFlavio <flavio@odisseo.local>
Wed, 25 Jul 2012 14:25:33 +0000 (16:25 +0200)
committerFlavio <flavio@odisseo.local>
Wed, 25 Jul 2012 14:25:33 +0000 (16:25 +0200)
src/playlist/PrettyItemDelegate.cpp
src/videodefinition.cpp
src/videodefinition.h

index 6cdac51014805cdb6efc823740a9419996ee9f28..846650f141c11ec5fc008cbb634be5226d174ea1 100644 (file)
@@ -3,6 +3,7 @@
 #include "../fontutils.h"
 #include "../downloaditem.h"
 #include "../iconloader/qticonloader.h"
+#include "../videodefinition.h"
 
 #include <QFontMetricsF>
 #include <QPainter>
@@ -133,9 +134,9 @@ void PrettyItemDelegate::paintBody( QPainter* painter,
 
     // published date
     QString publishedString = video->published().date().toString(Qt::DefaultLocaleShortDate);
-    QSizeF publishedStringSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, publishedString ) );
+    QSizeF stringSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, publishedString ) );
     QPointF textLoc(PADDING+THUMB_WIDTH, PADDING*2 + textBox.height());
-    QRectF publishedTextBox( textLoc , publishedStringSize);
+    QRectF publishedTextBox(textLoc , stringSize);
     painter->drawText(publishedTextBox, Qt::AlignLeft | Qt::AlignTop, publishedString);
 
     // author
@@ -156,9 +157,9 @@ void PrettyItemDelegate::paintBody( QPainter* painter,
             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);
+    textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
+    stringSize = QSizeF(QFontMetrics(painter->font()).size( Qt::TextSingleLine, authorString ) );
+    QRectF authorTextBox(textLoc , stringSize);
     authorRects.insert(index.row(), authorTextBox.toRect());
     painter->drawText(authorTextBox, Qt::AlignLeft | Qt::AlignTop, authorString);
     painter->restore();
@@ -168,13 +169,23 @@ void PrettyItemDelegate::paintBody( QPainter* painter,
         painter->save();
         QLocale locale;
         QString viewCountString = tr("%1 views").arg(locale.toString(video->viewCount()));
-        QSizeF viewCountStringSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, viewCountString ) );
-        textLoc.setX(textLoc.x() + authorStringSize.width() + PADDING);
-        QRectF viewCountTextBox( textLoc , viewCountStringSize);
+        textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
+        stringSize = QSizeF(QFontMetrics(painter->font()).size( Qt::TextSingleLine, viewCountString ) );
+        QRectF viewCountTextBox(textLoc , stringSize);
         painter->drawText(viewCountTextBox, Qt::AlignLeft | Qt::AlignBottom, viewCountString);
         painter->restore();
     }
 
+    if (downloadInfo) {
+        painter->save();
+        QString definitionString = VideoDefinition::getDefinitionName(video->getDefinitionCode());
+        textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
+        stringSize = QSizeF(QFontMetrics(painter->font()).size( Qt::TextSingleLine, definitionString ) );
+        QRectF viewCountTextBox(textLoc , stringSize);
+        painter->drawText(viewCountTextBox, Qt::AlignLeft | Qt::AlignBottom, definitionString);
+        painter->restore();
+    }
+
     /*
     QLinearGradient myGradient;
     QPen myPen;
index c2180e2d24b39f2cfc2136b30c3dea95541a054f..341b881fe3276a45017a9671ce8f750d5d5d7aca 100644 (file)
@@ -23,3 +23,7 @@ QHash<QString, int> VideoDefinition::getDefinitions() {
 int VideoDefinition::getDefinitionCode(QString name) {
     return VideoDefinition::getDefinitions().value(name);
 }
+
+QString VideoDefinition::getDefinitionName(int code) {
+    return getDefinitions().key(code);
+}
index 8e2e4c0075765f921147e1a79247a7cf64d128cc..dadc992f31619f69652225a4d12cd9fe33e4b362 100644 (file)
@@ -10,6 +10,7 @@ public:
     static QList<int> getDefinitionCodes();
     static QHash<QString, int> getDefinitions();
     static int getDefinitionCode(QString name);
+    static QString getDefinitionName(int code);
 
 };