mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 07:52:30 +02:00
Get rid of obsolete Bookmark handling code in LocalCollection and GlobalActionManager
This commit is contained in:
parent
6c55f8c4a0
commit
69ee958b45
@ -1176,63 +1176,6 @@ GlobalActionManager::playRdio( const QUrl& url )
|
||||
#endif
|
||||
|
||||
|
||||
bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
||||
{
|
||||
QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
|
||||
if ( parts.isEmpty() )
|
||||
{
|
||||
tLog() << "No specific bookmark command:" << url.toString();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( parts[ 0 ] == "track" )
|
||||
{
|
||||
QPair< QString, QString > pair;
|
||||
QString title, artist, album, urlStr;
|
||||
foreach ( pair, urlQueryItems( url ) )
|
||||
{
|
||||
if ( pair.first == "title" )
|
||||
title = pair.second;
|
||||
else if ( pair.first == "artist" )
|
||||
artist = pair.second;
|
||||
else if ( pair.first == "album" )
|
||||
album = pair.second;
|
||||
else if ( pair.first == "url" )
|
||||
urlStr = pair.second;
|
||||
}
|
||||
query_ptr q = Query::get( artist, title, album );
|
||||
if ( q.isNull() )
|
||||
return false;
|
||||
|
||||
if ( !urlStr.isEmpty() )
|
||||
{
|
||||
q->setResultHint( urlStr );
|
||||
q->setSaveHTTPResultHint( true );
|
||||
}
|
||||
Pipeline::instance()->resolve( q, true );
|
||||
|
||||
// now we add it to the special "bookmarks" playlist, creating it if it doesn't exist. if nothing is playing, start playing the track
|
||||
QSharedPointer< LocalCollection > col = SourceList::instance()->getLocal()->dbCollection().dynamicCast< LocalCollection >();
|
||||
playlist_ptr bookmarkpl = col->bookmarksPlaylist();
|
||||
if ( bookmarkpl.isNull() )
|
||||
{
|
||||
// create it and do the deed then
|
||||
m_waitingToBookmark = q;
|
||||
col->createBookmarksPlaylist();
|
||||
connect( col.data(), SIGNAL( bookmarkPlaylistCreated( Tomahawk::playlist_ptr ) ), this, SLOT( bookmarkPlaylistCreated( Tomahawk::playlist_ptr ) ), Qt::UniqueConnection );
|
||||
}
|
||||
else
|
||||
{
|
||||
doBookmark( bookmarkpl, q );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GlobalActionManager::shortenLinkRequestFinished()
|
||||
{
|
||||
@ -1332,37 +1275,6 @@ GlobalActionManager::shortenLinkRequestError( QNetworkReply::NetworkError error
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GlobalActionManager::bookmarkPlaylistCreated( const playlist_ptr& pl )
|
||||
{
|
||||
Q_ASSERT( !m_waitingToBookmark.isNull() );
|
||||
doBookmark( pl, m_waitingToBookmark );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GlobalActionManager::doBookmark( const playlist_ptr& pl, const query_ptr& q )
|
||||
{
|
||||
plentry_ptr e( new PlaylistEntry );
|
||||
e->setGuid( uuid() );
|
||||
|
||||
e->setDuration( q->track()->duration() );
|
||||
e->setLastmodified( 0 );
|
||||
QString annotation = "";
|
||||
if ( !q->property( "annotation" ).toString().isEmpty() )
|
||||
annotation = q->property( "annotation" ).toString();
|
||||
e->setAnnotation( annotation );
|
||||
e->setQuery( q );
|
||||
|
||||
pl->createNewRevision( uuid(), pl->currentrevision(), QList< plentry_ptr >( pl->entries() ) << e );
|
||||
connect( pl.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( showPlaylist() ) );
|
||||
|
||||
m_toShow = pl;
|
||||
|
||||
m_waitingToBookmark.clear();
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
|
||||
void
|
||||
|
@ -84,8 +84,6 @@ private slots:
|
||||
void shortenLinkRequestFinished();
|
||||
void shortenLinkRequestError( QNetworkReply::NetworkError );
|
||||
|
||||
void bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& pl );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
void postShortenFinished();
|
||||
void showPlaylist();
|
||||
@ -101,7 +99,6 @@ private slots:
|
||||
|
||||
private:
|
||||
explicit GlobalActionManager( QObject* parent = 0 );
|
||||
void doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahawk::query_ptr& q );
|
||||
|
||||
/// handle opening of urls
|
||||
#ifndef ENABLE_HEADLESS
|
||||
@ -122,7 +119,6 @@ private:
|
||||
|
||||
bool handleCollectionCommand( const QUrl& url );
|
||||
bool handlePlayCommand( const QUrl& url );
|
||||
bool handleBookmarkCommand( const QUrl& url );
|
||||
bool handleOpenCommand( const QUrl& url );
|
||||
|
||||
void createPlaylistFromUrl( const QString& type, const QString& url, const QString& title );
|
||||
@ -132,7 +128,6 @@ private:
|
||||
inline QByteArray percentEncode( const QUrl& url ) const;
|
||||
|
||||
Tomahawk::playlist_ptr m_toShow;
|
||||
Tomahawk::query_ptr m_waitingToBookmark;
|
||||
Tomahawk::query_ptr m_waitingToPlay;
|
||||
QUrl m_clipboardLongUrl;
|
||||
|
||||
|
@ -51,38 +51,3 @@ LocalCollection::emptyText() const
|
||||
{
|
||||
return tr( "After you have scanned your music collection you will find your tracks right here." );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlist_ptr
|
||||
LocalCollection::bookmarksPlaylist()
|
||||
{
|
||||
if( TomahawkSettings::instance()->bookmarkPlaylist().isEmpty() )
|
||||
return Tomahawk::playlist_ptr();
|
||||
|
||||
return playlist( TomahawkSettings::instance()->bookmarkPlaylist() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LocalCollection::createBookmarksPlaylist()
|
||||
{
|
||||
if( bookmarksPlaylist().isNull() ) {
|
||||
QString guid = uuid();
|
||||
Tomahawk::playlist_ptr p = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), guid, tr( "Bookmarks" ), tr( "Saved tracks" ), QString(), false );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
ViewManager::instance()->createPageForPlaylist( p );
|
||||
// connect( p.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( loaded( Tomahawk::PlaylistRevision ) ), Qt::QueuedConnection );
|
||||
connect( p.data(), SIGNAL( created() ), this, SLOT( created() ) );
|
||||
#endif
|
||||
TomahawkSettings::instance()->setBookmarkPlaylist( guid );
|
||||
// p->createNewRevision( uuid(), p->currentrevision(), QList< Tomahawk::plentry_ptr >() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LocalCollection::created()
|
||||
{
|
||||
emit bookmarkPlaylistCreated( bookmarksPlaylist() );
|
||||
}
|
||||
|
@ -32,18 +32,6 @@ public:
|
||||
|
||||
virtual QString prettyName() const;
|
||||
virtual QString emptyText() const;
|
||||
|
||||
// gets the playlist used for storing stuff from the web, if it already exists. if the returned playlist
|
||||
// is invalid ask to create and listen to the signal
|
||||
Tomahawk::playlist_ptr bookmarksPlaylist();
|
||||
void createBookmarksPlaylist();
|
||||
|
||||
signals:
|
||||
void bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& p );
|
||||
|
||||
private slots:
|
||||
void created();
|
||||
|
||||
};
|
||||
|
||||
#endif // LOCALCOLLECTION_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user