1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-15 02:24:50 +02:00

Support dropping of artists

This commit is contained in:
Uwe L. Korn
2013-07-21 15:11:13 +02:00
parent af68c147b9
commit aec1b1ac80
2 changed files with 29 additions and 1 deletions

View File

@@ -827,11 +827,14 @@ DropJob::informationForUrl( const QString&, const QSharedPointer<QObject>& infor
return; return;
} }
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Got a drop from a ScriptResolver.";
// Try to interpret as Album // Try to interpret as Album
Tomahawk::album_ptr album = information.objectCast<Tomahawk::Album>(); Tomahawk::album_ptr album = information.objectCast<Tomahawk::Album>();
if ( !album.isNull() ) if ( !album.isNull() )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped an Album";
if ( m_dropAction == Append ) if ( m_dropAction == Append )
{ {
onTracksAdded( album->tracks() ); onTracksAdded( album->tracks() );
@@ -847,9 +850,19 @@ DropJob::informationForUrl( const QString&, const QSharedPointer<QObject>& infor
return; return;
} }
Tomahawk::artist_ptr artist = information.objectCast<Tomahawk::Artist>();
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<Tomahawk::PlaylistTemplate>(); Tomahawk::playlisttemplate_ptr pltemplate = information.objectCast<Tomahawk::PlaylistTemplate>();
if ( !pltemplate.isNull() ) if ( !pltemplate.isNull() )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a playlist (template)";
if ( m_dropAction == Create ) if ( m_dropAction == Create )
{ {
ViewManager::instance()->show( pltemplate->get() ); ViewManager::instance()->show( pltemplate->get() );
@@ -867,6 +880,7 @@ DropJob::informationForUrl( const QString&, const QSharedPointer<QObject>& infor
Tomahawk::playlist_ptr playlist = information.objectCast<Tomahawk::Playlist>(); Tomahawk::playlist_ptr playlist = information.objectCast<Tomahawk::Playlist>();
if ( !playlist.isNull() ) if ( !playlist.isNull() )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a playlist";
if ( m_dropAction == Create ) if ( m_dropAction == Create )
{ {
QList<Tomahawk::query_ptr> tracks; QList<Tomahawk::query_ptr> tracks;
@@ -891,6 +905,7 @@ DropJob::informationForUrl( const QString&, const QSharedPointer<QObject>& infor
Tomahawk::query_ptr query = information.objectCast<Tomahawk::Query>(); Tomahawk::query_ptr query = information.objectCast<Tomahawk::Query>();
if ( !query.isNull() ) if ( !query.isNull() )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a track";
QList<Tomahawk::query_ptr> tracks; QList<Tomahawk::query_ptr> tracks;
// The Url describes a track // The Url describes a track
tracks.append( query ); tracks.append( query );

View File

@@ -249,7 +249,20 @@ void
JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result ) JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result )
{ {
QString type = result.value( "type" ).toString(); 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<QObject>() );
}
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<QObject>() );
}
else if ( type == "track" )
{ {
Tomahawk::query_ptr query = parseTrack( result ); Tomahawk::query_ptr query = parseTrack( result );
if ( query.isNull() ) if ( query.isNull() )