mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 19:30:21 +02:00
fix deleting
This commit is contained in:
@@ -31,6 +31,7 @@ void
|
||||
DatabaseCommand_DeleteDynamicPlaylist::exec( DatabaseImpl* lib )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "deleting dynamic playlist:" << m_playlistguid;
|
||||
DatabaseCommand_DeletePlaylist::exec( lib );
|
||||
TomahawkSqlQuery cre = lib->newquery();
|
||||
|
||||
@@ -44,7 +45,7 @@ DatabaseCommand_DeleteDynamicPlaylist::exec( DatabaseImpl* lib )
|
||||
void
|
||||
DatabaseCommand_DeleteDynamicPlaylist::postCommitHook()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "..reporting..";
|
||||
qDebug() << Q_FUNC_INFO << "..reporting..:" << m_playlistguid;
|
||||
|
||||
dynplaylist_ptr playlist = source()->collection()->dynamicPlaylist( m_playlistguid );
|
||||
Q_ASSERT( !playlist.isNull() );
|
||||
|
@@ -37,9 +37,7 @@ public:
|
||||
virtual void exec( DatabaseImpl* lib );
|
||||
virtual void postCommitHook();
|
||||
virtual bool doesMutates() const { return true; }
|
||||
|
||||
private:
|
||||
QString m_playlistguid;
|
||||
|
||||
};
|
||||
|
||||
#endif // DATABASECOMMAND_DELETEDYNAMICPLAYLIST_H
|
||||
|
@@ -29,7 +29,7 @@ public:
|
||||
QString playlistguid() const { return m_playlistguid; }
|
||||
void setPlaylistguid( const QString& s ) { m_playlistguid = s; }
|
||||
|
||||
private:
|
||||
protected:
|
||||
QString m_playlistguid;
|
||||
};
|
||||
|
||||
|
@@ -135,7 +135,7 @@ CREATE TABLE IF NOT EXISTS dynamic_playlist_controls (
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dynamic_playlist_revision (
|
||||
guid TEXT PRIMARY KEY,
|
||||
guid TEXT PRIMARY KEY NOT NULL REFERENCES playlist_revision(guid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
controls TEXT, -- qlist( id, id, id )
|
||||
plmode INTEGER,
|
||||
pltype TEXT
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
This file was automatically generated from schema.sql on Sun Jan 9 10:33:49 EST 2011.
|
||||
This file was automatically generated from schema.sql on Sun Jan 9 13:09:56 EST 2011.
|
||||
*/
|
||||
|
||||
static const char * tomahawk_schema_sql =
|
||||
@@ -89,7 +89,7 @@ static const char * tomahawk_schema_sql =
|
||||
""
|
||||
""
|
||||
"CREATE TABLE IF NOT EXISTS dynamic_playlist_revision ("
|
||||
" guid TEXT PRIMARY KEY,"
|
||||
" guid TEXT PRIMARY KEY NOT NULL REFERENCES playlist_revision(guid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
|
||||
" controls TEXT, "
|
||||
" plmode INTEGER,"
|
||||
" pltype TEXT"
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "database/databasecommand_createdynamicplaylist.h"
|
||||
#include "database/databasecommand_setdynamicplaylistrevision.h"
|
||||
#include "database/databasecommand_loaddynamicplaylist.h"
|
||||
#include "database/databasecommand_deletedynamicplaylist.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -221,9 +222,8 @@ DynamicPlaylist::loadRevision( const QString& rev )
|
||||
bool
|
||||
DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
{
|
||||
// TODO
|
||||
// DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() );
|
||||
// APP->database()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeleteDynamicPlaylist( playlist->author(), playlist->guid() );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -180,10 +180,10 @@ void SourceTreeItem::onDynamicPlaylistsDeleted( const QList< dynplaylist_ptr >&
|
||||
for ( int i = rows - 1; i >= 0; i-- )
|
||||
{
|
||||
QStandardItem* pi = item->child( i );
|
||||
qlonglong piptr = pi->data( PlaylistPointer ).toLongLong();
|
||||
qlonglong piptr = pi->data( DynamicPlaylistPointer ).toLongLong();
|
||||
playlist_ptr* pl = reinterpret_cast<playlist_ptr*>(piptr);
|
||||
SourcesModel::SourceType type = static_cast<SourcesModel::SourceType>( pi->data( Type ).toInt() );
|
||||
|
||||
qDebug() << "Deleting dynamic playlsit:" << pl->isNull();
|
||||
if ( type == SourcesModel::DynamicPlaylistSource && ptr == qlonglong( pl->data() ) )
|
||||
{
|
||||
m_dynplaylists.removeAll( p );
|
||||
|
@@ -89,9 +89,13 @@ SourceTreeView::setupMenus()
|
||||
|
||||
bool readonly = true;
|
||||
SourcesModel::SourceType type = SourcesModel::indexType( m_contextMenuIndex );
|
||||
if ( type == SourcesModel::PlaylistSource )
|
||||
if ( type == SourcesModel::PlaylistSource || type == SourcesModel::DynamicPlaylistSource )
|
||||
{
|
||||
playlist_ptr playlist = SourcesModel::indexToPlaylist( m_contextMenuIndex );
|
||||
playlist_ptr playlist = SourcesModel::indexToDynamicPlaylist( m_contextMenuIndex );
|
||||
if( playlist.isNull() )
|
||||
{
|
||||
playlist_ptr playlist = SourcesModel::indexToPlaylist( m_contextMenuIndex );
|
||||
}
|
||||
if ( !playlist.isNull() )
|
||||
{
|
||||
readonly = !playlist->author()->isLocal();
|
||||
@@ -186,16 +190,18 @@ SourceTreeView::deletePlaylist()
|
||||
return;
|
||||
|
||||
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
||||
if ( type == SourcesModel::PlaylistSource || type == SourcesModel::DynamicPlaylistSource )
|
||||
if ( type == SourcesModel::PlaylistSource )
|
||||
{
|
||||
playlist_ptr playlist = ( type == SourcesModel::DynamicPlaylistSource )
|
||||
? SourcesModel::indexToDynamicPlaylist( idx ).staticCast< Playlist >()
|
||||
: SourcesModel::indexToPlaylist( idx );
|
||||
playlist_ptr playlist = SourcesModel::indexToPlaylist( idx );
|
||||
if ( !playlist.isNull() )
|
||||
{
|
||||
qDebug() << "Playlist about to be deleted:" << playlist->title();
|
||||
Playlist::remove( playlist );
|
||||
}
|
||||
} else if( type == SourcesModel::DynamicPlaylistSource ) {
|
||||
dynplaylist_ptr playlist = SourcesModel::indexToDynamicPlaylist( idx );
|
||||
if( !playlist.isNull() )
|
||||
DynamicPlaylist::remove( playlist );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user