From aec1b1ac801fef46cac1584fe045d1e3e260af51 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 21 Jul 2013 15:11:13 +0200 Subject: [PATCH] Support dropping of artists --- src/libtomahawk/DropJob.cpp | 15 +++++++++++++++ src/libtomahawk/resolvers/JSResolverHelper.cpp | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/DropJob.cpp b/src/libtomahawk/DropJob.cpp index e7c6122db..3749c0a61 100644 --- a/src/libtomahawk/DropJob.cpp +++ b/src/libtomahawk/DropJob.cpp @@ -827,11 +827,14 @@ DropJob::informationForUrl( const QString&, const QSharedPointer& infor return; } + tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Got a drop from a ScriptResolver."; + // Try to interpret as Album Tomahawk::album_ptr album = information.objectCast(); if ( !album.isNull() ) { + tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped an Album"; if ( m_dropAction == Append ) { onTracksAdded( album->tracks() ); @@ -847,9 +850,19 @@ DropJob::informationForUrl( const QString&, const QSharedPointer& infor return; } + Tomahawk::artist_ptr artist = information.objectCast(); + if ( !artist.isNull() ) + { + tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped an artist"; + ViewManager::instance()->show( artist ); + // We're done. + deleteLater(); + } + Tomahawk::playlisttemplate_ptr pltemplate = information.objectCast(); if ( !pltemplate.isNull() ) { + tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a playlist (template)"; if ( m_dropAction == Create ) { ViewManager::instance()->show( pltemplate->get() ); @@ -867,6 +880,7 @@ DropJob::informationForUrl( const QString&, const QSharedPointer& infor Tomahawk::playlist_ptr playlist = information.objectCast(); if ( !playlist.isNull() ) { + tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a playlist"; if ( m_dropAction == Create ) { QList tracks; @@ -891,6 +905,7 @@ DropJob::informationForUrl( const QString&, const QSharedPointer& infor Tomahawk::query_ptr query = information.objectCast(); if ( !query.isNull() ) { + tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a track"; QList tracks; // The Url describes a track tracks.append( query ); diff --git a/src/libtomahawk/resolvers/JSResolverHelper.cpp b/src/libtomahawk/resolvers/JSResolverHelper.cpp index fbab2c9e1..5aef37e2a 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.cpp +++ b/src/libtomahawk/resolvers/JSResolverHelper.cpp @@ -249,7 +249,20 @@ void JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result ) { QString type = result.value( "type" ).toString(); - if ( type == "track" ) + if ( type == "artist" ) + { + QString name = result.value( "name" ).toString(); + Q_ASSERT( !name.isEmpty() ); + emit m_resolver->informationFound( url, Artist::get( name, true ).objectCast() ); + } + else if ( type == "album" ) + { + QString name = result.value( "name" ).toString(); + QString artist = result.value( "artist" ).toString(); + emit m_resolver->informationFound( url, Album::get( Artist::get( artist, true ), name ).objectCast() ); + + } + else if ( type == "track" ) { Tomahawk::query_ptr query = parseTrack( result ); if ( query.isNull() )