mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-16 02:54:33 +02:00
* Get rid of generic failed() signal in XSPFLoader.
This commit is contained in:
@@ -41,18 +41,21 @@ XSPFLoader::XSPFLoader( bool autoCreate, QObject *parent )
|
|||||||
XSPFLoader::~XSPFLoader()
|
XSPFLoader::~XSPFLoader()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XSPFLoader::setOverrideTitle( const QString& newTitle )
|
XSPFLoader::setOverrideTitle( const QString& newTitle )
|
||||||
{
|
{
|
||||||
m_overrideTitle = newTitle;
|
m_overrideTitle = newTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< Tomahawk::query_ptr >
|
QList< Tomahawk::query_ptr >
|
||||||
XSPFLoader::entries() const
|
XSPFLoader::entries() const
|
||||||
{
|
{
|
||||||
return m_entries;
|
return m_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XSPFLoader::load( const QUrl& url )
|
XSPFLoader::load( const QUrl& url )
|
||||||
{
|
{
|
||||||
@@ -72,14 +75,13 @@ XSPFLoader::load( const QUrl& url )
|
|||||||
void
|
void
|
||||||
XSPFLoader::load( QFile& file )
|
XSPFLoader::load( QFile& file )
|
||||||
{
|
{
|
||||||
if( file.open( QFile::ReadOnly ) )
|
if ( file.open( QFile::ReadOnly ) )
|
||||||
{
|
{
|
||||||
m_body = file.readAll();
|
m_body = file.readAll();
|
||||||
gotBody();
|
gotBody();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to open xspf file";
|
|
||||||
reportError();
|
reportError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,8 +90,7 @@ XSPFLoader::load( QFile& file )
|
|||||||
void
|
void
|
||||||
XSPFLoader::reportError()
|
XSPFLoader::reportError()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
emit error( FetchError );
|
||||||
emit failed();
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +98,6 @@ XSPFLoader::reportError()
|
|||||||
void
|
void
|
||||||
XSPFLoader::networkLoadFinished()
|
XSPFLoader::networkLoadFinished()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
||||||
m_body = reply->readAll();
|
m_body = reply->readAll();
|
||||||
gotBody();
|
gotBody();
|
||||||
@@ -105,9 +105,8 @@ XSPFLoader::networkLoadFinished()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XSPFLoader::networkError( QNetworkReply::NetworkError e )
|
XSPFLoader::networkError( QNetworkReply::NetworkError /* error */ )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << e;
|
|
||||||
reportError();
|
reportError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,8 +114,6 @@ XSPFLoader::networkError( QNetworkReply::NetworkError e )
|
|||||||
void
|
void
|
||||||
XSPFLoader::gotBody()
|
XSPFLoader::gotBody()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
QDomDocument xmldoc;
|
QDomDocument xmldoc;
|
||||||
bool namespaceProcessing = true;
|
bool namespaceProcessing = true;
|
||||||
xmldoc.setContent( m_body, namespaceProcessing );
|
xmldoc.setContent( m_body, namespaceProcessing );
|
||||||
@@ -127,19 +124,19 @@ XSPFLoader::gotBody()
|
|||||||
QDomElement n = docElement.firstChildElement();
|
QDomElement n = docElement.firstChildElement();
|
||||||
for ( ; !n.isNull(); n = n.nextSiblingElement() )
|
for ( ; !n.isNull(); n = n.nextSiblingElement() )
|
||||||
{
|
{
|
||||||
if (n.namespaceURI() == m_NS && n.localName() == "title")
|
if ( n.namespaceURI() == m_NS && n.localName() == "title" )
|
||||||
{
|
{
|
||||||
origTitle = n.text();
|
origTitle = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "creator")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "creator" )
|
||||||
{
|
{
|
||||||
m_creator = n.text();
|
m_creator = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "info")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "info" )
|
||||||
{
|
{
|
||||||
m_info = n.text();
|
m_info = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "trackList")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "trackList" )
|
||||||
{
|
{
|
||||||
tracklist = n.childNodes();
|
tracklist = n.childNodes();
|
||||||
}
|
}
|
||||||
@@ -148,7 +145,7 @@ XSPFLoader::gotBody()
|
|||||||
m_title = origTitle;
|
m_title = origTitle;
|
||||||
if ( m_title.isEmpty() )
|
if ( m_title.isEmpty() )
|
||||||
m_title = tr( "New Playlist" );
|
m_title = tr( "New Playlist" );
|
||||||
if( !m_overrideTitle.isEmpty() )
|
if ( !m_overrideTitle.isEmpty() )
|
||||||
m_title = m_overrideTitle;
|
m_title = m_overrideTitle;
|
||||||
|
|
||||||
bool shownError = false;
|
bool shownError = false;
|
||||||
@@ -160,35 +157,35 @@ XSPFLoader::gotBody()
|
|||||||
QDomElement n = e.firstChildElement();
|
QDomElement n = e.firstChildElement();
|
||||||
for ( ; !n.isNull(); n = n.nextSiblingElement() )
|
for ( ; !n.isNull(); n = n.nextSiblingElement() )
|
||||||
{
|
{
|
||||||
if (n.namespaceURI() == m_NS && n.localName() == "duration")
|
if ( n.namespaceURI() == m_NS && n.localName() == "duration" )
|
||||||
{
|
{
|
||||||
duration = n.text();
|
duration = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "annotation")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "annotation" )
|
||||||
{
|
{
|
||||||
annotation = n.text();
|
annotation = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "creator")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "creator" )
|
||||||
{
|
{
|
||||||
artist = n.text();
|
artist = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "album")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "album" )
|
||||||
{
|
{
|
||||||
album = n.text();
|
album = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "title")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "title" )
|
||||||
{
|
{
|
||||||
track = n.text();
|
track = n.text();
|
||||||
}
|
}
|
||||||
else if (n.namespaceURI() == m_NS && n.localName() == "url")
|
else if ( n.namespaceURI() == m_NS && n.localName() == "url" )
|
||||||
{
|
{
|
||||||
url = n.text();
|
url = n.text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( artist.isEmpty() || track.isEmpty() )
|
if ( artist.isEmpty() || track.isEmpty() )
|
||||||
{
|
{
|
||||||
if( !shownError )
|
if ( !shownError )
|
||||||
{
|
{
|
||||||
emit error( InvalidTrackError );
|
emit error( InvalidTrackError );
|
||||||
shownError = true;
|
shownError = true;
|
||||||
@@ -198,7 +195,7 @@ XSPFLoader::gotBody()
|
|||||||
|
|
||||||
query_ptr q = Tomahawk::Query::get( artist, track, album, uuid() );
|
query_ptr q = Tomahawk::Query::get( artist, track, album, uuid() );
|
||||||
q->setDuration( duration.toInt() / 1000 );
|
q->setDuration( duration.toInt() / 1000 );
|
||||||
if( !url.isEmpty() )
|
if ( !url.isEmpty() )
|
||||||
q->setResultHint( url );
|
q->setResultHint( url );
|
||||||
|
|
||||||
m_entries << q;
|
m_entries << q;
|
||||||
|
@@ -39,7 +39,7 @@ class DLLEXPORT XSPFLoader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum XSPFErrorCode { ParseError, InvalidTrackError };
|
enum XSPFErrorCode { ParseError, InvalidTrackError, FetchError };
|
||||||
explicit XSPFLoader( bool autoCreate = true, QObject* parent = 0 );
|
explicit XSPFLoader( bool autoCreate = true, QObject* parent = 0 );
|
||||||
|
|
||||||
virtual ~XSPFLoader();
|
virtual ~XSPFLoader();
|
||||||
@@ -48,7 +48,6 @@ public:
|
|||||||
void setOverrideTitle( const QString& newTitle );
|
void setOverrideTitle( const QString& newTitle );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void failed();
|
|
||||||
void error( XSPFLoader::XSPFErrorCode error );
|
void error( XSPFLoader::XSPFErrorCode error );
|
||||||
void ok( const Tomahawk::playlist_ptr& );
|
void ok( const Tomahawk::playlist_ptr& );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user