mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Check mimedata source on osx as Qt::DropAction is not reliable. Also, minor cleanups
This commit is contained in:
@@ -367,8 +367,17 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
m_dropStorage.action = action;
|
m_dropStorage.action = action;
|
||||||
|
|
||||||
DropJob* dj = new DropJob();
|
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 )
|
if ( action & Qt::CopyAction )
|
||||||
dj->setDropAction( DropJob::Append );
|
dj->setDropAction( DropJob::Append );
|
||||||
|
#endif
|
||||||
|
|
||||||
connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ), this, SLOT( parsedDroppedTracks( QList< Tomahawk::query_ptr > ) ) );
|
connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ), this, SLOT( parsedDroppedTracks( QList< Tomahawk::query_ptr > ) ) );
|
||||||
dj->tracksFromMimeData( data );
|
dj->tracksFromMimeData( data );
|
||||||
|
@@ -108,7 +108,7 @@ SpotifyParser::lookupSpotifyBrowse( const QString& link )
|
|||||||
if ( link.contains( "spotify:track" ) )
|
if ( link.contains( "spotify:track" ) )
|
||||||
type = DropJob::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 );
|
JobStatusView::instance()->model()->addJob( m_browseJob );
|
||||||
|
|
||||||
m_queries.insert( reply );
|
m_queries.insert( reply );
|
||||||
@@ -165,19 +165,12 @@ SpotifyParser::spotifyBrowseFinished()
|
|||||||
checkTrackFinished();
|
checkTrackFinished();
|
||||||
return;
|
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();
|
QVariantMap resultResponse = res.value( res.value( "type" ).toString() ).toMap();
|
||||||
|
|
||||||
|
|
||||||
if ( !resultResponse.isEmpty() )
|
if ( !resultResponse.isEmpty() )
|
||||||
{
|
{
|
||||||
|
|
||||||
m_title = resultResponse.value( "name" ).toString();
|
m_title = resultResponse.value( "name" ).toString();
|
||||||
m_single = false;
|
m_single = false;
|
||||||
|
|
||||||
@@ -185,17 +178,17 @@ SpotifyParser::spotifyBrowseFinished()
|
|||||||
m_creator = resultResponse.value( "creator" ).toString();
|
m_creator = resultResponse.value( "creator" ).toString();
|
||||||
|
|
||||||
// TODO for now only take the first artist
|
// TODO for now only take the first artist
|
||||||
foreach ( QVariant result, resultResponse.value( "result" ).toList() )
|
foreach ( QVariant result, resultResponse.value( "result" ).toList() )
|
||||||
{
|
{
|
||||||
QVariantMap trackResult = result.toMap();
|
QVariantMap trackResult = result.toMap();
|
||||||
|
|
||||||
QString title, artist, album;
|
QString title, artist, album;
|
||||||
|
|
||||||
title = trackResult.value( "title", QString() ).toString();
|
title = trackResult.value( "title", QString() ).toString();
|
||||||
artist = trackResult.value( "artist", QString() ).toString();
|
artist = trackResult.value( "artist", QString() ).toString();
|
||||||
album = trackResult.value( "album", 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;
|
tLog() << "Didn't get an artist and track name from spotify, not enough to build a query on. Aborting" << title << artist << album;
|
||||||
return;
|
return;
|
||||||
@@ -203,7 +196,7 @@ SpotifyParser::spotifyBrowseFinished()
|
|||||||
|
|
||||||
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, title, album, uuid(), m_trackMode );
|
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, title, album, uuid(), m_trackMode );
|
||||||
m_tracks << q;
|
m_tracks << q;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user