mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Use new API in TopTracksContext.
This commit is contained in:
@@ -29,7 +29,6 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
TopTracksContext::TopTracksContext()
|
TopTracksContext::TopTracksContext()
|
||||||
: ContextPage()
|
: ContextPage()
|
||||||
, m_infoId( uuid() )
|
|
||||||
{
|
{
|
||||||
m_topHitsView = new PlaylistView();
|
m_topHitsView = new PlaylistView();
|
||||||
m_topHitsView->setGuid( "TopTracksContext" );
|
m_topHitsView->setGuid( "TopTracksContext" );
|
||||||
@@ -45,12 +44,6 @@ TopTracksContext::TopTracksContext()
|
|||||||
|
|
||||||
m_proxy = new QGraphicsProxyWidget();
|
m_proxy = new QGraphicsProxyWidget();
|
||||||
m_proxy->setWidget( m_topHitsView );
|
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() )
|
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
|
||||||
return;
|
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;
|
m_artist = artist;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash artistInfo;
|
connect( m_artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
||||||
artistInfo["artist"] = artist->name();
|
SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode ) ) );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
m_topHitsModel->clear();
|
||||||
requestData.caller = m_infoId;
|
onTracksFound( m_artist->tracks(), Mixed );
|
||||||
requestData.customData = QVariantMap();
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
|
||||||
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,51 +97,11 @@ TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TopTracksContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
TopTracksContext::onTracksFound( const QList<Tomahawk::query_ptr>& queries, ModelMode mode )
|
||||||
{
|
{
|
||||||
if ( requestData.caller != m_infoId )
|
Q_UNUSED( mode );
|
||||||
return;
|
|
||||||
|
|
||||||
InfoSystem::InfoStringHash trackInfo;
|
m_topHitsModel->append( queries );
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TopTracksContext::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 PlaylistModel;
|
class PlaylistModel;
|
||||||
class PlaylistView;
|
class PlaylistView;
|
||||||
@@ -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 onTracksFound( const QList<Tomahawk::query_ptr>& queries, Tomahawk::ModelMode mode );
|
||||||
void infoSystemFinished( QString target );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlaylistView* m_topHitsView;
|
PlaylistView* m_topHitsView;
|
||||||
@@ -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