mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
Try to append xspf
This commit is contained in:
@@ -92,13 +92,18 @@ DropJob::acceptsMimeData( const QMimeData* data, DropJob::DropTypes acceptedType
|
|||||||
|
|
||||||
// check plain text url types
|
// check plain text url types
|
||||||
if ( !data->hasFormat( "text/plain" ) )
|
if ( !data->hasFormat( "text/plain" ) )
|
||||||
|
if ( !data->hasFormat( "text/uri-list" ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
const QString url = data->data( "text/plain" );
|
const QString url = data->data( "text/plain" );
|
||||||
|
|
||||||
if ( acceptedType.testFlag( Playlist ) )
|
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;
|
return true;
|
||||||
|
|
||||||
// Not the most elegant
|
// Not the most elegant
|
||||||
@@ -418,7 +423,7 @@ void
|
|||||||
DropJob::handleXspfs( const QString& fileUrls )
|
DropJob::handleXspfs( const QString& fileUrls )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "Got xspf playlist!!" << fileUrls;
|
tDebug() << Q_FUNC_INFO << "Got xspf playlist!!" << fileUrls;
|
||||||
|
bool error = false;
|
||||||
QStringList urls = fileUrls.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
|
QStringList urls = fileUrls.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
|
||||||
|
|
||||||
if ( dropAction() == Default )
|
if ( dropAction() == Default )
|
||||||
@@ -426,23 +431,37 @@ DropJob::handleXspfs( const QString& fileUrls )
|
|||||||
|
|
||||||
foreach ( const QString& url, urls )
|
foreach ( const QString& url, urls )
|
||||||
{
|
{
|
||||||
|
XSPFLoader* l;
|
||||||
|
|
||||||
QFile xspfFile( QUrl::fromUserInput( url ).toLocalFile() );
|
QFile xspfFile( QUrl::fromUserInput( url ).toLocalFile() );
|
||||||
|
|
||||||
if ( xspfFile.exists() )
|
if ( xspfFile.exists() )
|
||||||
{
|
{
|
||||||
XSPFLoader* l = new XSPFLoader( true, this );
|
l = new XSPFLoader( dropAction() == Create, this );
|
||||||
tDebug( LOGINFO ) << "Loading local xspf " << xspfFile.fileName();
|
tDebug( LOGINFO ) << "Loading local xspf " << xspfFile.fileName();
|
||||||
l->load( xspfFile );
|
l->load( xspfFile );
|
||||||
}
|
}
|
||||||
else if( QUrl( url ).isValid() )
|
else if( QUrl( url ).isValid() )
|
||||||
{
|
{
|
||||||
|
|
||||||
XSPFLoader* l = new XSPFLoader( true, this );
|
l = new XSPFLoader( dropAction() == Create, this );
|
||||||
tDebug( LOGINFO ) << "Loading remote xspf " << url;
|
tDebug( LOGINFO ) << "Loading remote xspf " << url;
|
||||||
l->load( QUrl( url ) );
|
l->load( QUrl( url ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
error = true;
|
||||||
tLog() << "Failed to load or parse dropped XSPF";
|
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<Tomahawk::query_ptr> ) ), this, SLOT( onTracksAdded( QList< Tomahawk::query_ptr > ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -235,9 +235,16 @@ XSPFLoader::gotBody()
|
|||||||
m_entries );
|
m_entries );
|
||||||
|
|
||||||
// 10 minute default---for now, no way to change it
|
// 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() );
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -51,6 +51,8 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void error( XSPFLoader::XSPFErrorCode error );
|
void error( XSPFLoader::XSPFErrorCode error );
|
||||||
void ok( const Tomahawk::playlist_ptr& );
|
void ok( const Tomahawk::playlist_ptr& );
|
||||||
|
void track( const Tomahawk::query_ptr& track );
|
||||||
|
void tracks( const QList< Tomahawk::query_ptr > tracks );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void load( const QUrl& url );
|
void load( const QUrl& url );
|
||||||
|
Reference in New Issue
Block a user