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