mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Do not use TomahawkSettings in (Dynamic)Playlist
This commit is contained in:
parent
50de3c029d
commit
527c68b15a
@ -36,13 +36,13 @@
|
||||
#include "PlaylistPlaylistInterface.h"
|
||||
#include "Source.h"
|
||||
#include "SourceList.h"
|
||||
#include "TomahawkSettings.h"
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QDomElement>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
static QSharedPointer<PlaylistRemovalHandler> s_removalHandler;
|
||||
|
||||
Playlist::Playlist( const source_ptr& author )
|
||||
: d_ptr( new PlaylistPrivate( this, author ) )
|
||||
@ -112,6 +112,16 @@ Playlist::~Playlist()
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
QSharedPointer<PlaylistRemovalHandler> Playlist::removalHandler()
|
||||
{
|
||||
if ( s_removalHandler.isNull() )
|
||||
{
|
||||
s_removalHandler = QSharedPointer<PlaylistRemovalHandler>( new PlaylistRemovalHandler() );
|
||||
}
|
||||
|
||||
return s_removalHandler;
|
||||
}
|
||||
|
||||
|
||||
playlist_ptr
|
||||
Playlist::create( const source_ptr& author,
|
||||
@ -179,18 +189,6 @@ Playlist::get( const QString& guid )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Playlist::remove( const playlist_ptr& playlist )
|
||||
{
|
||||
emit playlist->aboutToBeDeleted( playlist );
|
||||
|
||||
TomahawkSettings::instance()->removePlaylistSettings( playlist->guid() );
|
||||
|
||||
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() );
|
||||
Database::instance()->enqueue( Tomahawk::dbcmd_ptr(cmd) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Playlist::rename( const QString& title )
|
||||
{
|
||||
@ -502,6 +500,14 @@ Playlist::setNewRevision( const QString& rev,
|
||||
return pr;
|
||||
}
|
||||
|
||||
void
|
||||
Playlist::removeFromDatabase()
|
||||
{
|
||||
Q_D( Playlist );
|
||||
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( d->source, d->guid );
|
||||
Database::instance()->enqueue( Tomahawk::dbcmd_ptr(cmd) );
|
||||
}
|
||||
|
||||
Playlist::Playlist( PlaylistPrivate *d )
|
||||
: d_ptr( d )
|
||||
{
|
||||
@ -896,3 +902,16 @@ Playlist::updaters() const
|
||||
Q_D( const Playlist );
|
||||
return d->updaters;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistRemovalHandler::remove( const playlist_ptr& playlist )
|
||||
{
|
||||
emit playlist->aboutToBeDeleted( playlist );
|
||||
playlist->removeFromDatabase();
|
||||
}
|
||||
|
||||
|
||||
PlaylistRemovalHandler::PlaylistRemovalHandler()
|
||||
{
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ class DatabaseCommand_LoadAllSortedPlaylists;
|
||||
class DatabaseCommand_SetPlaylistRevision;
|
||||
class DatabaseCommand_CreatePlaylist;
|
||||
|
||||
class Playlist;
|
||||
class PlaylistPrivate;
|
||||
class PlaylistUpdaterInterface;
|
||||
|
||||
@ -62,6 +63,22 @@ struct PlaylistRevision
|
||||
bool applied; // false if conflict
|
||||
};
|
||||
|
||||
class DLLEXPORT PlaylistRemovalHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class Playlist;
|
||||
|
||||
public slots:
|
||||
void remove( const playlist_ptr& playlist );
|
||||
|
||||
signals:
|
||||
void aboutToBeDeletePlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
|
||||
private:
|
||||
PlaylistRemovalHandler();
|
||||
};
|
||||
|
||||
|
||||
class DLLEXPORT Playlist : public QObject
|
||||
{
|
||||
@ -79,11 +96,13 @@ friend class DatabaseCommand_LoadAllSortedPlaylists;
|
||||
friend class DatabaseCommand_SetPlaylistRevision;
|
||||
friend class DatabaseCommand_CreatePlaylist;
|
||||
friend class DynamicPlaylist;
|
||||
friend class PlaylistRemovalHandler;
|
||||
friend class ::PlaylistModel;
|
||||
|
||||
public:
|
||||
virtual ~Playlist();
|
||||
|
||||
static QSharedPointer<PlaylistRemovalHandler> removalHandler();
|
||||
static Tomahawk::playlist_ptr get( const QString& guid );
|
||||
|
||||
// one CTOR is private, only called by DatabaseCommand_LoadAllPlaylists
|
||||
@ -95,7 +114,6 @@ public:
|
||||
bool shared,
|
||||
const QList<Tomahawk::query_ptr>& queries = QList<Tomahawk::query_ptr>() );
|
||||
|
||||
static void remove( const playlist_ptr& playlist );
|
||||
void rename( const QString& title );
|
||||
|
||||
virtual void loadRevision( const QString& rev = "" );
|
||||
@ -245,6 +263,9 @@ protected:
|
||||
const QList<QString>& oldorderedguids,
|
||||
bool is_newest_rev,
|
||||
const QMap< QString, Tomahawk::plentry_ptr >& addedmap );
|
||||
|
||||
virtual void removeFromDatabase();
|
||||
|
||||
Playlist( PlaylistPrivate* d );
|
||||
|
||||
Tomahawk::PlaylistPrivate* d_ptr;
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "PlaylistEntry.h"
|
||||
#include "PlaylistInterface.h"
|
||||
#include "SourceList.h"
|
||||
#include "TomahawkSettings.h"
|
||||
|
||||
|
||||
using namespace Tomahawk;
|
||||
@ -319,18 +318,6 @@ DynamicPlaylist::loadRevision( const QString& rev )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
{
|
||||
playlist->aboutToBeDeleted( playlist );
|
||||
|
||||
TomahawkSettings::instance()->removePlaylistSettings( playlist->guid() );
|
||||
|
||||
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeleteDynamicPlaylist( playlist->author(), playlist->guid() );
|
||||
Database::instance()->enqueue( Tomahawk::dbcmd_ptr(cmd) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self )
|
||||
{
|
||||
@ -515,6 +502,14 @@ DynamicPlaylist::setRevision( const QString& rev,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DynamicPlaylist::removeFromDatabase()
|
||||
{
|
||||
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeleteDynamicPlaylist( author(), guid() ) ;
|
||||
Database::instance()->enqueue( Tomahawk::dbcmd_ptr(cmd) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DynamicPlaylist::setRevision( const QString& rev,
|
||||
bool is_newest_rev,
|
||||
|
@ -155,6 +155,10 @@ public slots:
|
||||
const QString& type,
|
||||
const QList< Tomahawk::dyncontrol_ptr>& controls,
|
||||
bool applied );
|
||||
|
||||
protected:
|
||||
virtual void removeFromDatabase();
|
||||
|
||||
private:
|
||||
// called from loadAllPlaylists DB cmd via databasecollection (in GUI thread)
|
||||
explicit DynamicPlaylist( const source_ptr& src,
|
||||
|
@ -273,6 +273,9 @@ TomahawkApp::init()
|
||||
connect( m_shortcutHandler.data(), SIGNAL( mute() ), m_audioEngine.data(), SLOT( mute() ) );
|
||||
}
|
||||
|
||||
connect( Playlist::removalHandler().data(), SIGNAL( aboutToBeDeletePlaylist( Tomahawk::playlist_ptr ) ),
|
||||
SLOT( playlistRemoved( Tomahawk::playlist_ptr ) ));
|
||||
|
||||
tDebug() << "Init InfoSystem.";
|
||||
m_infoSystem = QPointer<Tomahawk::InfoSystem::InfoSystem>( Tomahawk::InfoSystem::InfoSystem::instance() );
|
||||
connect( m_infoSystem, SIGNAL( ready() ), SLOT( onInfoSystemReady() ) );
|
||||
@ -835,6 +838,13 @@ TomahawkApp::instanceStarted( KDSingleApplicationGuard::Instance instance )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkApp::playlistRemoved(const playlist_ptr &playlist)
|
||||
{
|
||||
TomahawkSettings::instance()->removePlaylistSettings( playlist->guid() );
|
||||
}
|
||||
|
||||
|
||||
TomahawkWindow*
|
||||
TomahawkApp::mainWindow() const
|
||||
{
|
||||
|
@ -106,6 +106,7 @@ public slots:
|
||||
void instanceStarted( KDSingleApplicationGuard::Instance );
|
||||
|
||||
private slots:
|
||||
void playlistRemoved( const Tomahawk::playlist_ptr& playlist );
|
||||
void initServent();
|
||||
void initSIP();
|
||||
void initHTTP();
|
||||
|
@ -455,9 +455,8 @@ SourceTreeView::onDeletePlaylistResult( bool result )
|
||||
{
|
||||
updater->setQuestionResults( questionResults );
|
||||
}
|
||||
|
||||
qDebug() << "Doing delete of playlist:" << playlist->title();
|
||||
Playlist::remove( playlist );
|
||||
Playlist::removalHandler()->remove( playlist );
|
||||
}
|
||||
else if ( type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
|
||||
{
|
||||
@ -467,9 +466,8 @@ SourceTreeView::onDeletePlaylistResult( bool result )
|
||||
{
|
||||
updater->setQuestionResults( questionResults );
|
||||
}
|
||||
|
||||
qDebug() << "Doing delete of playlist:" << playlist->title();
|
||||
DynamicPlaylist::remove( playlist );
|
||||
Playlist::removalHandler()->remove( playlist );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user