From 130a8e7917012e9a87a753adcb3513e780e2fe96 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 23 Dec 2012 20:50:13 +0100 Subject: [PATCH] * Use a textual score representation instead of the bar. --- src/libtomahawk/playlist/PlayableModel.cpp | 19 +++++++++++++++++-- .../playlist/PlaylistItemDelegate.cpp | 12 ++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/libtomahawk/playlist/PlayableModel.cpp b/src/libtomahawk/playlist/PlayableModel.cpp index a5ab9943d..b77530bea 100644 --- a/src/libtomahawk/playlist/PlayableModel.cpp +++ b/src/libtomahawk/playlist/PlayableModel.cpp @@ -47,7 +47,7 @@ PlayableModel::PlayableModel( QObject* parent, bool loading ) connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection ); m_header << tr( "Artist" ) << tr( "Title" ) << tr( "Composer" ) << tr( "Album" ) << tr( "Track" ) << tr( "Duration" ) - << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" ) << tr( "Score" ) << tr( "Name" ); + << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" ) << tr( "Accuracy" ) << tr( "Name" ); } @@ -235,8 +235,22 @@ PlayableModel::queryData( const query_ptr& query, int column, int role ) const break; case Score: - return query->results().first()->score(); + { + float score = query->results().first()->score(); + if ( score == 1.0 ) + return tr( "Perfect match" ); + if ( score > 0.9 ) + return tr( "Very good match" ); + if ( score > 0.7 ) + return tr( "Good match" ); + if ( score > 0.5 ) + return tr( "Vague match" ); + if ( score > 0.3 ) + return tr( "Bad match" ); + + return tr( "Not available" ); break; + } default: break; @@ -679,6 +693,7 @@ PlayableModel::columnAlignment( int column ) const case Bitrate: case Duration: case Filesize: + case Score: case Year: return Qt::AlignHCenter; break; diff --git a/src/libtomahawk/playlist/PlaylistItemDelegate.cpp b/src/libtomahawk/playlist/PlaylistItemDelegate.cpp index 4da4f82d2..5cf892400 100644 --- a/src/libtomahawk/playlist/PlaylistItemDelegate.cpp +++ b/src/libtomahawk/playlist/PlaylistItemDelegate.cpp @@ -240,11 +240,11 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt painter->save(); - if ( index.column() == PlayableModel::Score ) +/* if ( index.column() == PlayableModel::Score ) { QColor barColor( 167, 183, 211 ); // This matches the sidebar (sourcetreeview.cpp:672) - if ( opt.state & QStyle::State_Selected ) - painter->setPen( opt.palette.brightText().color() ); + if ( opt.state & QStyle::State_Selected && !item->isPlaying() ) + painter->setPen( Qt::white ); else painter->setPen( barColor ); @@ -255,14 +255,14 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt int fillerWidth = (int)( index.data().toFloat() * (float)fillR.width() ); fillR.adjust( 0, 0, -( fillR.width() - fillerWidth ), 0 ); - if ( opt.state & QStyle::State_Selected ) - painter->setBrush( opt.palette.brightText().color() ); + if ( opt.state & QStyle::State_Selected && !item->isPlaying() ) + painter->setBrush( TomahawkUtils::Colors::NOW_PLAYING_ITEM.lighter() ); else painter->setBrush( barColor ); painter->drawRect( fillR ); } - else if ( item->isPlaying() ) + else */ if ( item->isPlaying() ) { QRect r = opt.rect.adjusted( 3, 0, 0, 0 );