1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-25 02:09:48 +01:00

* Use new API in RelatedArtistsContext.

This commit is contained in:
Christian Muehlhaeuser 2012-05-27 19:21:16 +02:00
parent 9af174a198
commit 49a4dddd88
2 changed files with 12 additions and 52 deletions

View File

@ -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 );
}

View File

@ -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;
};