From acfaf3970e378cab984c3218059f22c8894c1e3b Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 2 Oct 2011 13:00:50 -0400 Subject: [PATCH] Check mimedata source on osx as Qt::DropAction is not reliable. Also, minor cleanups --- src/libtomahawk/playlist/playlistmodel.cpp | 9 ++++++++ src/libtomahawk/utils/spotifyparser.cpp | 27 ++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/libtomahawk/playlist/playlistmodel.cpp b/src/libtomahawk/playlist/playlistmodel.cpp index 7b3cb9ef2..4684f02ed 100644 --- a/src/libtomahawk/playlist/playlistmodel.cpp +++ b/src/libtomahawk/playlist/playlistmodel.cpp @@ -367,8 +367,17 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r m_dropStorage.action = action; DropJob* dj = new DropJob(); + + // On mac, drags from outside the app are still Qt::MoveActions instead of Qt::CopyAction by default + // so check if the drag originated in this playlist to determine whether or not to copy +#ifdef Q_WS_MAC + if ( !data->hasFormat( "application/tomahawk.playlist.id" ) || + data->data( "application/tomahawk.playlist.id" ) != m_playlist->guid() ) + dj->setDropAction( DropJob::Append ); +#else if ( action & Qt::CopyAction ) dj->setDropAction( DropJob::Append ); +#endif connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ), this, SLOT( parsedDroppedTracks( QList< Tomahawk::query_ptr > ) ) ); dj->tracksFromMimeData( data ); diff --git a/src/libtomahawk/utils/spotifyparser.cpp b/src/libtomahawk/utils/spotifyparser.cpp index 86db98cd0..ba0913fee 100644 --- a/src/libtomahawk/utils/spotifyparser.cpp +++ b/src/libtomahawk/utils/spotifyparser.cpp @@ -108,7 +108,7 @@ SpotifyParser::lookupSpotifyBrowse( const QString& link ) if ( link.contains( "spotify:track" ) ) type = DropJob::Track; - m_browseJob = new DropJobNotifier( pixmap(), QString( "Spotify" ).arg( (int)type ), type, reply ); + m_browseJob = new DropJobNotifier( pixmap(), "Spotify", type, reply ); JobStatusView::instance()->model()->addJob( m_browseJob ); m_queries.insert( reply ); @@ -165,19 +165,12 @@ SpotifyParser::spotifyBrowseFinished() checkTrackFinished(); return; } - else if ( res.contains( "trackCount" ) && res.value( "trackCount" ).toInt() < 0 ) - { - tLog() << "No tracks' item in the spotify browse result... not doing anything"; - checkTrackFinished(); - return; - } QVariantMap resultResponse = res.value( res.value( "type" ).toString() ).toMap(); if ( !resultResponse.isEmpty() ) { - m_title = resultResponse.value( "name" ).toString(); m_single = false; @@ -185,17 +178,17 @@ SpotifyParser::spotifyBrowseFinished() m_creator = resultResponse.value( "creator" ).toString(); // TODO for now only take the first artist - foreach ( QVariant result, resultResponse.value( "result" ).toList() ) - { - QVariantMap trackResult = result.toMap(); + foreach ( QVariant result, resultResponse.value( "result" ).toList() ) + { + QVariantMap trackResult = result.toMap(); - QString title, artist, album; + QString title, artist, album; - title = trackResult.value( "title", QString() ).toString(); - artist = trackResult.value( "artist", QString() ).toString(); - album = trackResult.value( "album", QString() ).toString(); + title = trackResult.value( "title", QString() ).toString(); + artist = trackResult.value( "artist", QString() ).toString(); + album = trackResult.value( "album", QString() ).toString(); - if ( title.isEmpty() && artist.isEmpty() ) // don't have enough... + if ( title.isEmpty() && artist.isEmpty() ) // don't have enough... { tLog() << "Didn't get an artist and track name from spotify, not enough to build a query on. Aborting" << title << artist << album; return; @@ -203,7 +196,7 @@ SpotifyParser::spotifyBrowseFinished() Tomahawk::query_ptr q = Tomahawk::Query::get( artist, title, album, uuid(), m_trackMode ); m_tracks << q; - } + } }