diff --git a/src/libtomahawk/dropjob.cpp b/src/libtomahawk/dropjob.cpp index cea16be1f..c88ae7cc1 100644 --- a/src/libtomahawk/dropjob.cpp +++ b/src/libtomahawk/dropjob.cpp @@ -92,13 +92,18 @@ DropJob::acceptsMimeData( const QMimeData* data, DropJob::DropTypes acceptedType // check plain text url types if ( !data->hasFormat( "text/plain" ) ) - return false; + if ( !data->hasFormat( "text/uri-list" ) ) + return false; + const QString url = data->data( "text/plain" ); if ( acceptedType.testFlag( Playlist ) ) { - if( url.contains( "xspf" ) || data->data( "text/uri-list" ).contains( "xspf" ) ) + if( url.contains( "xspf" ) ) + return true; + + if( data->data( "text/uri-list" ).contains( "xspf" ) ) return true; // Not the most elegant @@ -418,7 +423,7 @@ void DropJob::handleXspfs( const QString& fileUrls ) { tDebug() << Q_FUNC_INFO << "Got xspf playlist!!" << fileUrls; - + bool error = false; QStringList urls = fileUrls.split( QRegExp( "\\s+" ), QString::SkipEmptyParts ); if ( dropAction() == Default ) @@ -426,23 +431,37 @@ DropJob::handleXspfs( const QString& fileUrls ) foreach ( const QString& url, urls ) { + XSPFLoader* l; QFile xspfFile( QUrl::fromUserInput( url ).toLocalFile() ); + if ( xspfFile.exists() ) { - XSPFLoader* l = new XSPFLoader( true, this ); + l = new XSPFLoader( dropAction() == Create, this ); tDebug( LOGINFO ) << "Loading local xspf " << xspfFile.fileName(); l->load( xspfFile ); } else if( QUrl( url ).isValid() ) { - XSPFLoader* l = new XSPFLoader( true, this ); + l = new XSPFLoader( dropAction() == Create, this ); tDebug( LOGINFO ) << "Loading remote xspf " << url; l->load( QUrl( url ) ); } else + { + error = true; tLog() << "Failed to load or parse dropped XSPF"; + + } + + if ( dropAction() == Append && !error ) + { + qDebug() << Q_FUNC_INFO << "Trying to append xspf"; + connect( l, SIGNAL( tracks( QList ) ), this, SLOT( onTracksAdded( QList< Tomahawk::query_ptr > ) ) ); + } + + } } diff --git a/src/libtomahawk/utils/xspfloader.cpp b/src/libtomahawk/utils/xspfloader.cpp index 08930ac01..77dba6a26 100644 --- a/src/libtomahawk/utils/xspfloader.cpp +++ b/src/libtomahawk/utils/xspfloader.cpp @@ -235,9 +235,16 @@ XSPFLoader::gotBody() m_entries ); // 10 minute default---for now, no way to change it + connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistCreated() ) ); new Tomahawk::XspfUpdater( m_playlist, 6000000, m_autoUpdate, m_url.toString() ); - deleteLater(); + emit ok( m_playlist ); + } + else{ + + if( !m_entries.isEmpty() ) + emit tracks( m_entries ); } - emit ok( m_playlist ); + deleteLater(); + } diff --git a/src/libtomahawk/utils/xspfloader.h b/src/libtomahawk/utils/xspfloader.h index 33826bc03..fa9a27194 100644 --- a/src/libtomahawk/utils/xspfloader.h +++ b/src/libtomahawk/utils/xspfloader.h @@ -51,6 +51,8 @@ public: signals: void error( XSPFLoader::XSPFErrorCode error ); void ok( const Tomahawk::playlist_ptr& ); + void track( const Tomahawk::query_ptr& track ); + void tracks( const QList< Tomahawk::query_ptr > tracks ); public slots: void load( const QUrl& url );