mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Wait until we have loaded Albums track
This commit is contained in:
@@ -248,6 +248,11 @@ JSResolverHelper::parseTrack( const QVariantMap& track )
|
|||||||
void
|
void
|
||||||
JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result )
|
JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result )
|
||||||
{
|
{
|
||||||
|
// It may seem a bit weird, but currently no slot should do anything
|
||||||
|
// more as we starting on a new URL and not task are waiting for it yet.
|
||||||
|
m_pendingUrl = QString();
|
||||||
|
m_pendingAlbum = album_ptr();
|
||||||
|
|
||||||
QString type = result.value( "type" ).toString();
|
QString type = result.value( "type" ).toString();
|
||||||
if ( type == "artist" )
|
if ( type == "artist" )
|
||||||
{
|
{
|
||||||
@@ -259,8 +264,15 @@ JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result )
|
|||||||
{
|
{
|
||||||
QString name = result.value( "name" ).toString();
|
QString name = result.value( "name" ).toString();
|
||||||
QString artist = result.value( "artist" ).toString();
|
QString artist = result.value( "artist" ).toString();
|
||||||
emit m_resolver->informationFound( url, Album::get( Artist::get( artist, true ), name ).objectCast<QObject>() );
|
album_ptr album = Album::get( Artist::get( artist, true ), name );
|
||||||
|
m_pendingUrl = url;
|
||||||
|
m_pendingAlbum = album;
|
||||||
|
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
||||||
|
SLOT( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ) );
|
||||||
|
if ( album->tracks().count() > 0 )
|
||||||
|
{
|
||||||
|
emit m_resolver->informationFound( url, album.objectCast<QObject>() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( type == "track" )
|
else if ( type == "track" )
|
||||||
{
|
{
|
||||||
@@ -335,6 +347,19 @@ JSResolverHelper::reportCapabilities( const QVariant& v )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
JSResolverHelper::tracksAdded( const QList<query_ptr>&, const ModelMode, const collection_ptr&)
|
||||||
|
{
|
||||||
|
// Check if we still are actively waiting
|
||||||
|
if ( m_pendingAlbum.isNull() || m_pendingUrl.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit m_resolver->informationFound( m_pendingUrl, m_pendingAlbum.objectCast<QObject>() );
|
||||||
|
m_pendingAlbum = album_ptr();
|
||||||
|
m_pendingUrl = QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JSResolverHelper::setResolverConfig( const QVariantMap& config )
|
JSResolverHelper::setResolverConfig( const QVariantMap& config )
|
||||||
{
|
{
|
||||||
|
@@ -74,6 +74,9 @@ public slots:
|
|||||||
|
|
||||||
void reportCapabilities( const QVariant& capabilities );
|
void reportCapabilities( const QVariant& capabilities );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::ModelMode, const Tomahawk::collection_ptr& collection );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tomahawk::query_ptr parseTrack( const QVariantMap& track );
|
Tomahawk::query_ptr parseTrack( const QVariantMap& track );
|
||||||
void returnStreamUrl( const QString& streamUrl, boost::function< void( QSharedPointer< QIODevice >& ) > callback );
|
void returnStreamUrl( const QString& streamUrl, boost::function< void( QSharedPointer< QIODevice >& ) > callback );
|
||||||
@@ -83,5 +86,7 @@ private:
|
|||||||
bool m_urlCallbackIsAsync;
|
bool m_urlCallbackIsAsync;
|
||||||
QVariantMap m_resolverConfig;
|
QVariantMap m_resolverConfig;
|
||||||
JSResolver* m_resolver;
|
JSResolver* m_resolver;
|
||||||
|
QString m_pendingUrl;
|
||||||
|
Tomahawk::album_ptr m_pendingAlbum;
|
||||||
};
|
};
|
||||||
#endif // JSRESOLVERHELPER_H
|
#endif // JSRESOLVERHELPER_H
|
||||||
|
Reference in New Issue
Block a user