1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +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;
}
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Got a drop from a ScriptResolver.";
// Try to interpret as Album
Tomahawk::album_ptr album = information.objectCast<Tomahawk::Album>();
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<QObject>& infor
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>();
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<QObject>& infor
Tomahawk::playlist_ptr playlist = information.objectCast<Tomahawk::Playlist>();
if ( !playlist.isNull() )
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a playlist";
if ( m_dropAction == Create )
{
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>();
if ( !query.isNull() )
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Dropped a track";
QList<Tomahawk::query_ptr> tracks;
// The Url describes a track
tracks.append( query );

View File

@@ -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<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 );
if ( query.isNull() )