From dc4035dd97c62823003d1622c95060be255fd705 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 29 Dec 2012 18:46:46 +0100 Subject: [PATCH] * Now we can have temporary dynamic playlists. --- .../playlist/dynamic/DynamicPlaylist.cpp | 19 +++++++++++-------- .../playlist/dynamic/DynamicPlaylist.h | 5 +++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp index e3c9cde4d..8808dc345 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp @@ -142,7 +142,7 @@ DynamicPlaylist::load( const QString& guid ) dynplaylist_ptr -DynamicPlaylist::create( const Tomahawk::source_ptr& author, +DynamicPlaylist::create(const Tomahawk::source_ptr& author, const QString& guid, const QString& title, const QString& info, @@ -150,17 +150,20 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author, GeneratorMode mode, bool shared, const QString& type, - bool autoLoad - ) + bool autoLoad, + bool temporary ) { dynplaylist_ptr dynplaylist = Tomahawk::dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ), &QObject::deleteLater ); dynplaylist->setWeakSelf( dynplaylist.toWeakRef() ); - DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist, autoLoad ); - connect( cmd, SIGNAL( finished() ), dynplaylist.data(), SIGNAL( created() ) ); - Database::instance()->enqueue( QSharedPointer(cmd) ); - if ( autoLoad ) - dynplaylist->reportCreated( dynplaylist ); + if ( !temporary ) + { + DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist, autoLoad ); + connect( cmd, SIGNAL( finished() ), dynplaylist.data(), SIGNAL( created() ) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); + if ( autoLoad ) + dynplaylist->reportCreated( dynplaylist ); + } return dynplaylist; } diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h index 1886f6c12..176b26eeb 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h @@ -85,7 +85,8 @@ public: GeneratorMode mode, bool shared, const QString& type = QString(), - bool autoLoad = true + bool autoLoad = true, + bool temporary = false ); static void remove( const dynplaylist_ptr& playlist ); @@ -95,7 +96,7 @@ public: int mode() const; QString type() const; geninterface_ptr generator() const; - bool autoLoad() const { return m_autoLoad; } + bool autoLoad() const { return m_autoLoad; } // Creates a new revision from the playlist in memory. Use this is you change the controls or // mode of a playlist and want to save it to db/others.