mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Use new API in RelatedArtistsContext.
This commit is contained in:
@@ -30,7 +30,6 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
RelatedArtistsContext::RelatedArtistsContext()
|
RelatedArtistsContext::RelatedArtistsContext()
|
||||||
: ContextPage()
|
: ContextPage()
|
||||||
, m_infoId( uuid() )
|
|
||||||
{
|
{
|
||||||
m_relatedView = new ArtistView();
|
m_relatedView = new ArtistView();
|
||||||
m_relatedView->setGuid( "RelatedArtistsContext" );
|
m_relatedView->setGuid( "RelatedArtistsContext" );
|
||||||
@@ -70,18 +69,17 @@ RelatedArtistsContext::setArtist( const Tomahawk::artist_ptr& artist )
|
|||||||
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
|
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( !m_artist.isNull() )
|
||||||
|
{
|
||||||
|
disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) );
|
||||||
|
}
|
||||||
|
|
||||||
m_artist = artist;
|
m_artist = artist;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash artistInfo;
|
connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) );
|
||||||
artistInfo["artist"] = artist->name();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
m_relatedModel->clear();
|
||||||
requestData.caller = m_infoId;
|
onSimilarArtistsLoaded();
|
||||||
requestData.customData = QVariantMap();
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
|
||||||
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistSimilars;
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,45 +104,10 @@ RelatedArtistsContext::setAlbum( const Tomahawk::album_ptr& album )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RelatedArtistsContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
RelatedArtistsContext::onSimilarArtistsLoaded()
|
||||||
{
|
{
|
||||||
if ( requestData.caller != m_infoId )
|
foreach ( const artist_ptr& artist, m_artist->similarArtists() )
|
||||||
return;
|
|
||||||
|
|
||||||
InfoSystem::InfoStringHash trackInfo;
|
|
||||||
trackInfo = requestData.input.value< InfoSystem::InfoStringHash >();
|
|
||||||
|
|
||||||
if ( output.canConvert< QVariantMap >() )
|
|
||||||
{
|
{
|
||||||
if ( trackInfo["artist"] != m_artist->name() )
|
m_relatedModel->addArtists( artist );
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RelatedArtistsContext::infoSystemFinished( QString target )
|
|
||||||
{
|
|
||||||
Q_UNUSED( target );
|
|
||||||
}
|
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
#include "Album.h"
|
#include "Album.h"
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
#include "context/ContextPage.h"
|
#include "context/ContextPage.h"
|
||||||
#include "infosystem/InfoSystem.h"
|
|
||||||
|
|
||||||
class TreeModel;
|
class TreeModel;
|
||||||
class ArtistView;
|
class ArtistView;
|
||||||
@@ -56,8 +55,7 @@ public slots:
|
|||||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void onSimilarArtistsLoaded();
|
||||||
void infoSystemFinished( QString target );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ArtistView* m_relatedView;
|
ArtistView* m_relatedView;
|
||||||
@@ -65,7 +63,6 @@ private:
|
|||||||
|
|
||||||
QGraphicsProxyWidget* m_proxy;
|
QGraphicsProxyWidget* m_proxy;
|
||||||
|
|
||||||
QString m_infoId;
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
Tomahawk::artist_ptr m_artist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user