From 32a454fbc451107bebc3068f0a41e6c5683d8689 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 3 Apr 2015 17:21:04 +0200 Subject: [PATCH] Can't access score via Result anymore. --- src/libtomahawk-playdarapi/Api_v1_5.cpp | 2 +- src/libtomahawk/Pipeline.cpp | 3 +-- src/libtomahawk/Query_p.h | 2 ++ src/libtomahawk/audio/AudioEngine.cpp | 2 +- src/libtomahawk/database/DatabaseCommand_AllTracks.cpp | 1 - src/libtomahawk/database/DatabaseCommand_Resolve.cpp | 2 +- src/libtomahawk/database/DatabaseImpl.cpp | 3 --- src/libtomahawk/playlist/ColumnItemDelegate.cpp | 2 +- src/libtomahawk/playlist/PlayableModel.cpp | 8 +------- src/libtomahawk/playlist/PlayableProxyModel.cpp | 4 ++-- src/libtomahawk/resolvers/ScriptAccount.cpp | 2 +- src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp | 1 - src/libtomahawk/utils/TomahawkUtilsGui.cpp | 2 +- src/libtomahawk/viewpages/SearchViewPage.cpp | 4 ++-- 14 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/libtomahawk-playdarapi/Api_v1_5.cpp b/src/libtomahawk-playdarapi/Api_v1_5.cpp index d7bff50ae..b8e43e162 100644 --- a/src/libtomahawk-playdarapi/Api_v1_5.cpp +++ b/src/libtomahawk-playdarapi/Api_v1_5.cpp @@ -105,7 +105,7 @@ Api_v1_5::playback( QxtWebRequestEvent* event, const QString& command ) } else { trackInfo.insert( "resolvedBy", "" ); } - trackInfo.insert( "score", currentTrack->score() ); +//FIXME? trackInfo.insert( "score", currentTrack->score() ); trackInfo.insert( "album", currentTrack->track()->album() ); trackInfo.insert( "albumpos", currentTrack->track()->albumpos() ); trackInfo.insert( "artist", currentTrack->track()->artist() ); diff --git a/src/libtomahawk/Pipeline.cpp b/src/libtomahawk/Pipeline.cpp index f170fb5cb..4d3496f5d 100644 --- a/src/libtomahawk/Pipeline.cpp +++ b/src/libtomahawk/Pipeline.cpp @@ -387,8 +387,7 @@ Pipeline::addResultsToQuery( const query_ptr& query, const QList< result_ptr >& QList< result_ptr > cleanResults; foreach ( const result_ptr& r, results ) { - r->setScore( query->howSimilar( r ) ); - if ( !query->isFullTextQuery() && r->score() < MINSCORE ) + if ( !query->isFullTextQuery() && query->howSimilar( r ) < MINSCORE ) continue; cleanResults << r; diff --git a/src/libtomahawk/Query_p.h b/src/libtomahawk/Query_p.h index ef00b9efd..635c8bbc6 100644 --- a/src/libtomahawk/Query_p.h +++ b/src/libtomahawk/Query_p.h @@ -39,6 +39,8 @@ private: QList< Tomahawk::artist_ptr > artists; QList< Tomahawk::album_ptr > albums; QList< Tomahawk::result_ptr > results; + + float score; bool solved; bool playable; bool resolveFinished; diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index f2ccf0167..0f6e88822 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -866,7 +866,7 @@ AudioEngine::play( const QUrl& url ) result->setMimetype( tags["mimetype"].toString() ); } - result->setScore( 1.0 ); +// result->setScore( 1.0 ); result->setResolvedByCollection( SourceList::instance()->getLocal()->collections().first(), false ); // Tomahawk::query_ptr qry = Tomahawk::Query::get( t ); diff --git a/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp b/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp index 866f5153a..e1767020c 100644 --- a/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp +++ b/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp @@ -161,7 +161,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi ) result->setBitrate( bitrate ); result->setModificationTime( modificationTime ); result->setMimetype( mimetype ); - result->setScore( 1.0f ); result->setResolvedByCollection( s->dbCollection(), false ); ql << Tomahawk::Query::getFixed( t, result ); diff --git a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp index 80ccfd20f..d6223d604 100644 --- a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp +++ b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp @@ -283,7 +283,7 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib ) { if ( trackPairs.at( k ).first == (int)track->trackId() ) { - result->setScore( trackPairs.at( k ).second ); + //FIXME: result->setScore( trackPairs.at( k ).second ); break; } } diff --git a/src/libtomahawk/database/DatabaseImpl.cpp b/src/libtomahawk/database/DatabaseImpl.cpp index 1ca1de283..447b8e977 100644 --- a/src/libtomahawk/database/DatabaseImpl.cpp +++ b/src/libtomahawk/database/DatabaseImpl.cpp @@ -323,7 +323,6 @@ Tomahawk::DatabaseImpl::file( int fid ) r->setMimetype( query.value( 4 ).toString() ); r->setBitrate( query.value( 6 ).toUInt() ); r->setResolvedByCollection( s->dbCollection() ); - r->setScore( 1.0 ); r->setFileId( fid ); } @@ -642,7 +641,6 @@ Tomahawk::DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery ) // Return http resulthint directly res = Tomahawk::Result::get( url, track ); res->setRID( uuid() ); - res->setScore( 1.0 ); const QUrl u = QUrl::fromUserInput( url ); res->setFriendlySource( u.host() ); @@ -722,7 +720,6 @@ Tomahawk::DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery ) res->setSize( query.value( 2 ).toUInt() ); res->setMimetype( query.value( 4 ).toString() ); res->setBitrate( query.value( 6 ).toInt() ); - res->setScore( 1.0 ); res->setRID( uuid() ); res->setResolvedByCollection( s->dbCollection() ); } diff --git a/src/libtomahawk/playlist/ColumnItemDelegate.cpp b/src/libtomahawk/playlist/ColumnItemDelegate.cpp index 109331bb1..b38a2ded4 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() && item->result()->isOnline() ? item->result()->score() : 0.0; + float opacity = item->query() && item->result()->isOnline() ? item->query()->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/PlayableModel.cpp b/src/libtomahawk/playlist/PlayableModel.cpp index 71e2b4e0c..732aad5c2 100644 --- a/src/libtomahawk/playlist/PlayableModel.cpp +++ b/src/libtomahawk/playlist/PlayableModel.cpp @@ -286,13 +286,7 @@ PlayableModel::queryData( const query_ptr& query, int column, int role ) const case Score: { - float score; - if ( query->results().first()->isOnline() ) - score = query->results().first()->score(); - else - score = 0.0; - - return scoreText( score ); + return scoreText( query->score() ); break; } diff --git a/src/libtomahawk/playlist/PlayableProxyModel.cpp b/src/libtomahawk/playlist/PlayableProxyModel.cpp index eb238a560..1ea7cb728 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModel.cpp @@ -470,7 +470,7 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T mtime1 = r->modificationTime(); size1 = r->size(); year1 = r->track()->year(); - score1 = r->score(); + score1 = q1->score(); origin1 = r->friendlySource().toLower(); } if ( !q2->results().isEmpty() ) @@ -480,7 +480,7 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T mtime2 = r->modificationTime(); size2 = r->size(); year2 = r->track()->year(); - score2 = r->score(); + score2 = q2->score(); origin2 = r->friendlySource().toLower(); } diff --git a/src/libtomahawk/resolvers/ScriptAccount.cpp b/src/libtomahawk/resolvers/ScriptAccount.cpp index 3d4ca231b..248c78ef3 100644 --- a/src/libtomahawk/resolvers/ScriptAccount.cpp +++ b/src/libtomahawk/resolvers/ScriptAccount.cpp @@ -294,7 +294,7 @@ ScriptAccount::parseResultVariantList( const QVariantList& reslist ) rp->setRID( uuid() ); rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() ); rp->setLinkUrl( m.value( "linkUrl" ).toString() ); - rp->setScore( m.value( "score" ).toFloat() ); +//FIXME? rp->setScore( m.value( "score" ).toFloat() ); rp->setChecked( m.value( "checked" ).toBool() ); //FIXME diff --git a/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp b/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp index 0315fc04e..85e8398ab 100644 --- a/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp +++ b/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp @@ -122,7 +122,6 @@ ScriptCommand_AllTracks::onTracksJobDone( const QVariantMap& result ) QList< Tomahawk::query_ptr > queries; foreach ( const Tomahawk::result_ptr& result, t ) { - result->setScore( 1.0 ); result->setResolvedByCollection( m_collection ); queries.append( result->toQuery() ); } diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.cpp b/src/libtomahawk/utils/TomahawkUtilsGui.cpp index 81c413dcd..95841c91d 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.cpp +++ b/src/libtomahawk/utils/TomahawkUtilsGui.cpp @@ -835,7 +835,7 @@ prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, Pl { float opacity = 0.0; if ( item->query() && !item->query()->results().isEmpty() && item->query()->results().first()->isOnline() ) - opacity = item->query()->results().first()->score(); + opacity = item->query()->score(); opacity = qMax( (float)0.3, opacity ); QColor textColor = alphaBlend( option->palette.color( QPalette::Text ), option->palette.color( QPalette::BrightText ), opacity ); diff --git a/src/libtomahawk/viewpages/SearchViewPage.cpp b/src/libtomahawk/viewpages/SearchViewPage.cpp index d1247eb53..00ee9c031 100644 --- a/src/libtomahawk/viewpages/SearchViewPage.cpp +++ b/src/libtomahawk/viewpages/SearchViewPage.cpp @@ -324,7 +324,7 @@ SearchWidget::onResultsFound( const QList& results ) if ( !found ) { - m_results.insert( query, result->score() ); + m_results.insert( query, /*FIXME*/ query->score() ); queries << query; } @@ -344,7 +344,7 @@ SearchWidget::onResultsFound( const QList& results ) PlayableItem* item = m_resultsModel->itemFromIndex( m_resultsModel->index( i, 0, QModelIndex() ) ); if ( item && item->query() && item->query()->numResults( true ) ) { - if ( item->query()->results().first()->score() < q->results().first()->score() ) + if ( item->query()->score() < q->score() ) { m_resultsModel->insertQuery( q, i ); done = true;