diff --git a/src/libtomahawk/playlist.cpp b/src/libtomahawk/playlist.cpp index 2d59dcb25..61fa3097a 100644 --- a/src/libtomahawk/playlist.cpp +++ b/src/libtomahawk/playlist.cpp @@ -34,6 +34,7 @@ #include "sourcelist.h" #include "utils/logger.h" +#include "PlaylistUpdaterInterface.h" using namespace Tomahawk; @@ -254,6 +255,9 @@ Playlist::reportDeleted( const Tomahawk::playlist_ptr& self ) m_deleted = true; m_source->collection()->deletePlaylist( self ); + if ( m_updater ) + m_updater->remove(); + emit deleted( self ); } diff --git a/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp b/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp index 288889963..7daca9d30 100644 --- a/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp +++ b/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp @@ -80,6 +80,18 @@ PlaylistUpdaterInterface::doSave() } } +void +PlaylistUpdaterInterface::remove() +{ + TomahawkSettings* s = TomahawkSettings::instance(); + const QString key = QString( "playlistupdaters/%1" ).arg( m_playlist->guid() ); + removeFromSettings( key ); + s->remove( QString( "%1/type" ).arg( key ) ); + s->remove( QString( "%1/autoupdate" ).arg( key ) ); + s->remove( QString( "%1/interval" ).arg( key ) ); +} + + void PlaylistUpdaterInterface::setAutoUpdate( bool autoUpdate ) { diff --git a/src/libtomahawk/playlist/PlaylistUpdaterInterface.h b/src/libtomahawk/playlist/PlaylistUpdaterInterface.h index 2a92b3a34..5fd3532b4 100644 --- a/src/libtomahawk/playlist/PlaylistUpdaterInterface.h +++ b/src/libtomahawk/playlist/PlaylistUpdaterInterface.h @@ -49,6 +49,8 @@ public: void setInterval( int intervalMsecs ) ; int intervalMsecs() const { return m_timer->interval(); } + void remove(); + playlist_ptr playlist() const { return m_playlist; } /// If you want to try to load a updater from the settings. Returns a valid @@ -64,6 +66,7 @@ private slots: protected: virtual void loadFromSettings( const QString& group ) = 0; virtual void saveToSettings( const QString& group ) const = 0; + virtual void removeFromSettings( const QString& group ) const = 0; private: QTimer* m_timer; diff --git a/src/libtomahawk/playlist/XspfUpdater.cpp b/src/libtomahawk/playlist/XspfUpdater.cpp index f63c3d87d..7b417025a 100644 --- a/src/libtomahawk/playlist/XspfUpdater.cpp +++ b/src/libtomahawk/playlist/XspfUpdater.cpp @@ -82,3 +82,9 @@ XspfUpdater::loadFromSettings( const QString& group ) { m_url = TomahawkSettings::instance()->value( QString( "%1/xspfurl" ).arg( group ) ).toString(); } + +void +XspfUpdater::removeFromSettings( const QString& group ) const +{ + TomahawkSettings::instance()->remove( QString( "%1/xspfurl" ).arg( group ) ); +} diff --git a/src/libtomahawk/playlist/XspfUpdater.h b/src/libtomahawk/playlist/XspfUpdater.h index 8ddb6e6dc..148930fb4 100644 --- a/src/libtomahawk/playlist/XspfUpdater.h +++ b/src/libtomahawk/playlist/XspfUpdater.h @@ -42,6 +42,7 @@ public slots: protected: void loadFromSettings( const QString& group ); void saveToSettings( const QString& group ) const; + virtual void removeFromSettings(const QString& group) const; private slots: void playlistLoaded();