mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 09:19:41 +01:00
* Use new API in TopTracksContext.
This commit is contained in:
parent
13befb9d6f
commit
9af174a198
src/libtomahawk/context/pages
@ -29,7 +29,6 @@ using namespace Tomahawk;
|
||||
|
||||
TopTracksContext::TopTracksContext()
|
||||
: ContextPage()
|
||||
, m_infoId( uuid() )
|
||||
{
|
||||
m_topHitsView = new PlaylistView();
|
||||
m_topHitsView->setGuid( "TopTracksContext" );
|
||||
@ -45,12 +44,6 @@ TopTracksContext::TopTracksContext()
|
||||
|
||||
m_proxy = new QGraphicsProxyWidget();
|
||||
m_proxy->setWidget( m_topHitsView );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
}
|
||||
|
||||
|
||||
@ -67,18 +60,19 @@ TopTracksContext::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( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
||||
this, SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode ) ) );
|
||||
}
|
||||
|
||||
m_artist = artist;
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash artistInfo;
|
||||
artistInfo["artist"] = artist->name();
|
||||
connect( m_artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
||||
SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode ) ) );
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||
requestData.caller = m_infoId;
|
||||
requestData.customData = QVariantMap();
|
||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
||||
|
||||
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||
m_topHitsModel->clear();
|
||||
onTracksFound( m_artist->tracks(), Mixed );
|
||||
}
|
||||
|
||||
|
||||
@ -103,51 +97,11 @@ TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
|
||||
|
||||
void
|
||||
TopTracksContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
TopTracksContext::onTracksFound( const QList<Tomahawk::query_ptr>& queries, ModelMode mode )
|
||||
{
|
||||
if ( requestData.caller != m_infoId )
|
||||
return;
|
||||
Q_UNUSED( mode );
|
||||
|
||||
InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo = requestData.input.value< InfoSystem::InfoStringHash >();
|
||||
|
||||
if ( output.canConvert< QVariantMap >() )
|
||||
{
|
||||
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::InfoArtistSongs:
|
||||
{
|
||||
m_topHitsModel->clear();
|
||||
const QStringList tracks = returnedData["tracks"].toStringList();
|
||||
|
||||
int i = 0;
|
||||
foreach ( const QString& track, tracks )
|
||||
{
|
||||
query_ptr query = Query::get( m_artist->name(), track, QString(), uuid() );
|
||||
m_topHitsModel->append( query );
|
||||
|
||||
if ( ++i == 15 )
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
m_topHitsModel->append( queries );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TopTracksContext::infoSystemFinished( QString target )
|
||||
{
|
||||
Q_UNUSED( target );
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "Album.h"
|
||||
#include "Query.h"
|
||||
#include "context/ContextPage.h"
|
||||
#include "infosystem/InfoSystem.h"
|
||||
|
||||
class PlaylistModel;
|
||||
class PlaylistView;
|
||||
@ -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 onTracksFound( const QList<Tomahawk::query_ptr>& queries, Tomahawk::ModelMode mode );
|
||||
|
||||
private:
|
||||
PlaylistView* m_topHitsView;
|
||||
@ -65,7 +63,6 @@ private:
|
||||
|
||||
QGraphicsProxyWidget* m_proxy;
|
||||
|
||||
QString m_infoId;
|
||||
Tomahawk::artist_ptr m_artist;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user