From 49a4dddd880968819887dafdee969cfd1a50258f Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 27 May 2012 19:21:16 +0200 Subject: [PATCH] * Use new API in RelatedArtistsContext. --- .../context/pages/RelatedArtistsContext.cpp | 59 ++++--------------- .../context/pages/RelatedArtistsContext.h | 5 +- 2 files changed, 12 insertions(+), 52 deletions(-) diff --git a/src/libtomahawk/context/pages/RelatedArtistsContext.cpp b/src/libtomahawk/context/pages/RelatedArtistsContext.cpp index 23f54d2f4..41ab75a2f 100644 --- a/src/libtomahawk/context/pages/RelatedArtistsContext.cpp +++ b/src/libtomahawk/context/pages/RelatedArtistsContext.cpp @@ -30,7 +30,6 @@ using namespace Tomahawk; RelatedArtistsContext::RelatedArtistsContext() : ContextPage() - , m_infoId( uuid() ) { m_relatedView = new ArtistView(); m_relatedView->setGuid( "RelatedArtistsContext" ); @@ -70,18 +69,17 @@ RelatedArtistsContext::setArtist( const Tomahawk::artist_ptr& artist ) if ( !m_artist.isNull() && m_artist->name() == artist->name() ) return; + if ( !m_artist.isNull() ) + { + disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) ); + } + m_artist = artist; - Tomahawk::InfoSystem::InfoStringHash artistInfo; - artistInfo["artist"] = artist->name(); + connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) ); - Tomahawk::InfoSystem::InfoRequestData requestData; - requestData.caller = m_infoId; - requestData.customData = QVariantMap(); - requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo ); - - requestData.type = Tomahawk::InfoSystem::InfoArtistSimilars; - Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData ); + m_relatedModel->clear(); + onSimilarArtistsLoaded(); } @@ -106,45 +104,10 @@ RelatedArtistsContext::setAlbum( const Tomahawk::album_ptr& album ) void -RelatedArtistsContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ) +RelatedArtistsContext::onSimilarArtistsLoaded() { - if ( requestData.caller != m_infoId ) - return; - - InfoSystem::InfoStringHash trackInfo; - trackInfo = requestData.input.value< InfoSystem::InfoStringHash >(); - - if ( output.canConvert< QVariantMap >() ) + foreach ( const artist_ptr& artist, m_artist->similarArtists() ) { - if ( trackInfo["artist"] != m_artist->name() ) - { - qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_artist->name(); - return; - } - } - - QVariantMap returnedData = output.value< QVariantMap >(); - switch ( requestData.type ) - { - case InfoSystem::InfoArtistSimilars: - { - m_relatedModel->clear(); - const QStringList artists = returnedData["artists"].toStringList(); - foreach ( const QString& artist, artists ) - { - m_relatedModel->addArtists( Artist::get( artist ) ); - } - break; - } - - default: - return; + m_relatedModel->addArtists( artist ); } } - - -void -RelatedArtistsContext::infoSystemFinished( QString target ) -{ - Q_UNUSED( target ); -} diff --git a/src/libtomahawk/context/pages/RelatedArtistsContext.h b/src/libtomahawk/context/pages/RelatedArtistsContext.h index 53d3c9a5e..c87b25630 100644 --- a/src/libtomahawk/context/pages/RelatedArtistsContext.h +++ b/src/libtomahawk/context/pages/RelatedArtistsContext.h @@ -28,7 +28,6 @@ #include "Album.h" #include "Query.h" #include "context/ContextPage.h" -#include "infosystem/InfoSystem.h" class TreeModel; class ArtistView; @@ -56,8 +55,7 @@ public slots: virtual void setQuery( const Tomahawk::query_ptr& query ); private slots: - void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ); - void infoSystemFinished( QString target ); + void onSimilarArtistsLoaded(); private: ArtistView* m_relatedView; @@ -65,7 +63,6 @@ private: QGraphicsProxyWidget* m_proxy; - QString m_infoId; Tomahawk::artist_ptr m_artist; };