mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +02:00
Factor out some code
This commit is contained in:
@@ -433,21 +433,13 @@ GlobalActionManager::handlePlaylistCommand( const QUrl& url )
|
|||||||
}
|
}
|
||||||
if ( url.hasQueryItem( "xspf" ) )
|
if ( url.hasQueryItem( "xspf" ) )
|
||||||
{
|
{
|
||||||
QUrl xspf = QUrl::fromUserInput( url.queryItemValue( "xspf" ) );
|
createPlaylistFromUrl( "xspf", url.queryItemValue( "xspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
|
||||||
QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
|
return true;
|
||||||
XSPFLoader* l= new XSPFLoader( true, this );
|
|
||||||
l->setOverrideTitle( title );
|
|
||||||
l->load( xspf );
|
|
||||||
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
|
||||||
}
|
}
|
||||||
else if ( url.hasQueryItem( "jspf" ) )
|
else if ( url.hasQueryItem( "jspf" ) )
|
||||||
{
|
{
|
||||||
QUrl jspf = QUrl::fromUserInput( url.queryItemValue( "jspf" ) );
|
createPlaylistFromUrl( "jspf", url.queryItemValue( "jspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
|
||||||
QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
|
return true;
|
||||||
JSPFLoader* l= new JSPFLoader( true, this );
|
|
||||||
l->setOverrideTitle( title );
|
|
||||||
l->load( jspf );
|
|
||||||
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( parts [ 0 ] == "new" )
|
else if ( parts [ 0 ] == "new" )
|
||||||
@@ -486,24 +478,12 @@ GlobalActionManager::handleImportCommand( const QUrl& url )
|
|||||||
{
|
{
|
||||||
if ( url.hasQueryItem( "xspf" ) )
|
if ( url.hasQueryItem( "xspf" ) )
|
||||||
{
|
{
|
||||||
QUrl xspf = QUrl::fromUserInput( url.queryItemValue( "xspf" ) );
|
createPlaylistFromUrl( "xspf", url.queryItemValue( "xspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
|
||||||
QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
|
|
||||||
XSPFLoader* l= new XSPFLoader( true, this );
|
|
||||||
l->setOverrideTitle( title );
|
|
||||||
l->load( xspf );
|
|
||||||
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( url.hasQueryItem( "jspf" ) )
|
else if ( url.hasQueryItem( "jspf" ) )
|
||||||
{
|
{
|
||||||
QUrl jspf = QUrl::fromUserInput( url.queryItemValue( "jspf" ) );
|
createPlaylistFromUrl( "jspf", url.queryItemValue( "jspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
|
||||||
QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
|
|
||||||
JSPFLoader* l= new JSPFLoader( true, this );
|
|
||||||
l->setOverrideTitle( title );
|
|
||||||
l->load( jspf );
|
|
||||||
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -512,6 +492,28 @@ GlobalActionManager::handleImportCommand( const QUrl& url )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GlobalActionManager::createPlaylistFromUrl( const QString& type, const QString &url, const QString& title )
|
||||||
|
{
|
||||||
|
if ( type == "xspf" )
|
||||||
|
{
|
||||||
|
QUrl xspf = QUrl::fromUserInput( url );
|
||||||
|
XSPFLoader* l= new XSPFLoader( true, this );
|
||||||
|
l->setOverrideTitle( title );
|
||||||
|
l->load( xspf );
|
||||||
|
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
||||||
|
}
|
||||||
|
else if ( type == "jspf" )
|
||||||
|
{
|
||||||
|
QUrl jspf = QUrl::fromUserInput( url );
|
||||||
|
JSPFLoader* l= new JSPFLoader( true, this );
|
||||||
|
l->setOverrideTitle( title );
|
||||||
|
l->load( jspf );
|
||||||
|
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::playlistCreatedToShow( const playlist_ptr& pl )
|
GlobalActionManager::playlistCreatedToShow( const playlist_ptr& pl )
|
||||||
{
|
{
|
||||||
|
@@ -125,6 +125,8 @@ private:
|
|||||||
bool handleBookmarkCommand( const QUrl& url );
|
bool handleBookmarkCommand( const QUrl& url );
|
||||||
bool handleOpenCommand( const QUrl& url );
|
bool handleOpenCommand( const QUrl& url );
|
||||||
|
|
||||||
|
void createPlaylistFromUrl( const QString& type, const QString& url, const QString& title );
|
||||||
|
|
||||||
QString hostname() const;
|
QString hostname() const;
|
||||||
|
|
||||||
Tomahawk::playlist_ptr m_toShow;
|
Tomahawk::playlist_ptr m_toShow;
|
||||||
|
Reference in New Issue
Block a user