diff --git a/src/libtomahawk/DropJob.cpp b/src/libtomahawk/DropJob.cpp index 49d0e6732..aad50d36a 100644 --- a/src/libtomahawk/DropJob.cpp +++ b/src/libtomahawk/DropJob.cpp @@ -25,6 +25,7 @@ #include "jobview/JobStatusView.h" #include "jobview/JobStatusModel.h" #include "jobview/ErrorStatusMessage.h" +#include "playlist/PlaylistTemplate.h" #include "resolvers/ExternalResolver.h" #include "utils/SpotifyParser.h" #include "utils/ItunesParser.h" @@ -43,6 +44,7 @@ #include "Pipeline.h" #include "Result.h" #include "Source.h" +#include "ViewManager.h" #ifdef QCA2_FOUND #include "utils/GroovesharkParser.h" @@ -823,6 +825,66 @@ DropJob::informationForUrl( const QString&, const QSharedPointer& infor return; } + + // Try to interpret as Album + Tomahawk::album_ptr album = information.objectCast(); + if ( !album.isNull() ) + { + if ( m_dropAction == Append ) + { + onTracksAdded( album->tracks() ); + } + else + { + // The Url describes an album + ViewManager::instance()->show( album ); + // We're done. + deleteLater(); + } + + return; + } + + Tomahawk::playlisttemplate_ptr pltemplate = information.objectCast(); + if ( !pltemplate.isNull() ) + { + if ( m_dropAction == Create ) + { + ViewManager::instance()->show( pltemplate->get() ); + // We're done. + deleteLater(); + } + else + { + onTracksAdded( pltemplate->tracks() ); + } + return; + } + + // Try to interpret as Playlist + Tomahawk::playlist_ptr playlist = information.objectCast(); + if ( !playlist.isNull() ) + { + if ( m_dropAction == Create ) + { + QList tracks; + foreach( Tomahawk::plentry_ptr entry, playlist->entries() ) + { + tracks.append( entry->query() ); + } + onTracksAdded( tracks ); + } + else + { + // The url describes a playlist + ViewManager::instance()->show( playlist ); + // We're done. + deleteLater(); + }\ + + return; + } + // Try to interpret as Track/Query Tomahawk::query_ptr query = information.objectCast(); if ( !query.isNull() ) diff --git a/src/libtomahawk/playlist/PlaylistTemplate.cpp b/src/libtomahawk/playlist/PlaylistTemplate.cpp index f698b8c6b..b14c8f8a5 100644 --- a/src/libtomahawk/playlist/PlaylistTemplate.cpp +++ b/src/libtomahawk/playlist/PlaylistTemplate.cpp @@ -53,3 +53,10 @@ Tomahawk::PlaylistTemplate::get() return d->playlist; } + +QList Tomahawk::PlaylistTemplate::tracks() const +{ + Q_D( const PlaylistTemplate ); + + return d->queries; +} diff --git a/src/libtomahawk/playlist/PlaylistTemplate.h b/src/libtomahawk/playlist/PlaylistTemplate.h index 20663f881..f9af4c8c0 100644 --- a/src/libtomahawk/playlist/PlaylistTemplate.h +++ b/src/libtomahawk/playlist/PlaylistTemplate.h @@ -45,6 +45,8 @@ public: */ Tomahawk::playlist_ptr get(); + QList tracks() const; + protected: PlaylistTemplatePrivate* d_ptr;