mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Add playlist D'n'D handling
This commit is contained in:
@@ -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<QObject>& infor
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Try to interpret as Album
|
||||
Tomahawk::album_ptr album = information.objectCast<Tomahawk::Album>();
|
||||
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<Tomahawk::PlaylistTemplate>();
|
||||
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<Tomahawk::Playlist>();
|
||||
if ( !playlist.isNull() )
|
||||
{
|
||||
if ( m_dropAction == Create )
|
||||
{
|
||||
QList<Tomahawk::query_ptr> 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<Tomahawk::Query>();
|
||||
if ( !query.isNull() )
|
||||
|
@@ -53,3 +53,10 @@ Tomahawk::PlaylistTemplate::get()
|
||||
|
||||
return d->playlist;
|
||||
}
|
||||
|
||||
QList<Tomahawk::query_ptr> Tomahawk::PlaylistTemplate::tracks() const
|
||||
{
|
||||
Q_D( const PlaylistTemplate );
|
||||
|
||||
return d->queries;
|
||||
}
|
||||
|
@@ -45,6 +45,8 @@ public:
|
||||
*/
|
||||
Tomahawk::playlist_ptr get();
|
||||
|
||||
QList<Tomahawk::query_ptr> tracks() const;
|
||||
|
||||
protected:
|
||||
PlaylistTemplatePrivate* d_ptr;
|
||||
|
||||
|
Reference in New Issue
Block a user