From: Flavio Date: Wed, 25 Jul 2012 14:25:33 +0000 (+0200) Subject: Video definition indicator while downloading videos X-Git-Tag: 1.9~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c1ad3584ab8fa6b899102f3aa3e47b6c3c599a53;p=minitube Video definition indicator while downloading videos --- diff --git a/src/playlist/PrettyItemDelegate.cpp b/src/playlist/PrettyItemDelegate.cpp index 6cdac51..846650f 100644 --- a/src/playlist/PrettyItemDelegate.cpp +++ b/src/playlist/PrettyItemDelegate.cpp @@ -3,6 +3,7 @@ #include "../fontutils.h" #include "../downloaditem.h" #include "../iconloader/qticonloader.h" +#include "../videodefinition.h" #include #include @@ -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; diff --git a/src/videodefinition.cpp b/src/videodefinition.cpp index c2180e2..341b881 100644 --- a/src/videodefinition.cpp +++ b/src/videodefinition.cpp @@ -23,3 +23,7 @@ QHash VideoDefinition::getDefinitions() { int VideoDefinition::getDefinitionCode(QString name) { return VideoDefinition::getDefinitions().value(name); } + +QString VideoDefinition::getDefinitionName(int code) { + return getDefinitions().key(code); +} diff --git a/src/videodefinition.h b/src/videodefinition.h index 8e2e4c0..dadc992 100644 --- a/src/videodefinition.h +++ b/src/videodefinition.h @@ -10,6 +10,7 @@ public: static QList getDefinitionCodes(); static QHash getDefinitions(); static int getDefinitionCode(QString name); + static QString getDefinitionName(int code); };