From a79b6633de96c89508b17a991c3be401204bc6bb Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 20 Jun 2013 10:01:57 +0200 Subject: [PATCH] * Respect results' online state when displaying. --- src/libtomahawk/playlist/ColumnItemDelegate.cpp | 2 +- src/libtomahawk/playlist/PlayableProxyModel.cpp | 8 ++++---- src/libtomahawk/playlist/TreeItemDelegate.cpp | 2 +- src/libtomahawk/utils/TomahawkUtilsGui.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libtomahawk/playlist/ColumnItemDelegate.cpp b/src/libtomahawk/playlist/ColumnItemDelegate.cpp index 0a54379be..9f47c906e 100644 --- a/src/libtomahawk/playlist/ColumnItemDelegate.cpp +++ b/src/libtomahawk/playlist/ColumnItemDelegate.cpp @@ -103,7 +103,7 @@ ColumnItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option } else if ( !item->result().isNull() || !item->query().isNull() ) { - float opacity = item->result().isNull() ? 0.0 : item->result()->score(); + float opacity = item->result() && item->result()->isOnline() ? item->result()->score() : 0.0; opacity = qMax( (float)0.3, opacity ); QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity ); diff --git a/src/libtomahawk/playlist/PlayableProxyModel.cpp b/src/libtomahawk/playlist/PlayableProxyModel.cpp index af1d291fe..0db565111 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModel.cpp @@ -321,25 +321,25 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T if ( q1->numResults() ) { - const Tomahawk::result_ptr& r = q1->results().at( 0 ); + Tomahawk::result_ptr r = q1->results().first(); bitrate1 = r->bitrate(); duration1 = r->track()->duration(); mtime1 = r->modificationTime(); size1 = r->size(); year1 = r->track()->year(); - score1 = r->score(); + score1 = r->isOnline() ? r->score() : 0.0; origin1 = r->friendlySource().toLower(); id1 = (qint64)&r; } if ( q2->numResults() ) { - const Tomahawk::result_ptr& r = q2->results().at( 0 ); + Tomahawk::result_ptr r = q2->results().first(); bitrate2 = r->bitrate(); duration2 = r->track()->duration(); mtime2 = r->modificationTime(); size2 = r->size(); year2 = r->track()->year(); - score2 = r->score(); + score2 = r->isOnline() ? r->score() : 0.0; origin2 = r->friendlySource().toLower(); id2 = (qint64)&r; } diff --git a/src/libtomahawk/playlist/TreeItemDelegate.cpp b/src/libtomahawk/playlist/TreeItemDelegate.cpp index b980985be..7cbebf26f 100644 --- a/src/libtomahawk/playlist/TreeItemDelegate.cpp +++ b/src/libtomahawk/playlist/TreeItemDelegate.cpp @@ -105,7 +105,7 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, } else if ( !item->result().isNull() || !item->query().isNull() ) { - float opacity = item->result().isNull() ? 0.0 : item->result()->score(); + float opacity = item->result() && item->result()->isOnline() ? item->result()->score() : 0.0; opacity = qMax( (float)0.3, opacity ); QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity ); diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.cpp b/src/libtomahawk/utils/TomahawkUtilsGui.cpp index a08a4deb7..57636517c 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.cpp +++ b/src/libtomahawk/utils/TomahawkUtilsGui.cpp @@ -758,7 +758,7 @@ prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, Pl else { float opacity = 0.0; - if ( !item->query()->results().isEmpty() ) + if ( !item->query()->results().isEmpty() && item->query()->results().first()->isOnline() ) opacity = item->query()->results().first()->score(); opacity = qMax( (float)0.3, opacity );