mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 23:57:34 +02:00
fix deleting
This commit is contained in:
@@ -31,6 +31,7 @@ void
|
|||||||
DatabaseCommand_DeleteDynamicPlaylist::exec( DatabaseImpl* lib )
|
DatabaseCommand_DeleteDynamicPlaylist::exec( DatabaseImpl* lib )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
qDebug() << "deleting dynamic playlist:" << m_playlistguid;
|
||||||
DatabaseCommand_DeletePlaylist::exec( lib );
|
DatabaseCommand_DeletePlaylist::exec( lib );
|
||||||
TomahawkSqlQuery cre = lib->newquery();
|
TomahawkSqlQuery cre = lib->newquery();
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ DatabaseCommand_DeleteDynamicPlaylist::exec( DatabaseImpl* lib )
|
|||||||
void
|
void
|
||||||
DatabaseCommand_DeleteDynamicPlaylist::postCommitHook()
|
DatabaseCommand_DeleteDynamicPlaylist::postCommitHook()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "..reporting..";
|
qDebug() << Q_FUNC_INFO << "..reporting..:" << m_playlistguid;
|
||||||
|
|
||||||
dynplaylist_ptr playlist = source()->collection()->dynamicPlaylist( m_playlistguid );
|
dynplaylist_ptr playlist = source()->collection()->dynamicPlaylist( m_playlistguid );
|
||||||
Q_ASSERT( !playlist.isNull() );
|
Q_ASSERT( !playlist.isNull() );
|
||||||
|
@@ -38,8 +38,6 @@ public:
|
|||||||
virtual void postCommitHook();
|
virtual void postCommitHook();
|
||||||
virtual bool doesMutates() const { return true; }
|
virtual bool doesMutates() const { return true; }
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_playlistguid;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATABASECOMMAND_DELETEDYNAMICPLAYLIST_H
|
#endif // DATABASECOMMAND_DELETEDYNAMICPLAYLIST_H
|
||||||
|
@@ -29,7 +29,7 @@ public:
|
|||||||
QString playlistguid() const { return m_playlistguid; }
|
QString playlistguid() const { return m_playlistguid; }
|
||||||
void setPlaylistguid( const QString& s ) { m_playlistguid = s; }
|
void setPlaylistguid( const QString& s ) { m_playlistguid = s; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QString m_playlistguid;
|
QString m_playlistguid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -135,7 +135,7 @@ CREATE TABLE IF NOT EXISTS dynamic_playlist_controls (
|
|||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS dynamic_playlist_revision (
|
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 )
|
controls TEXT, -- qlist( id, id, id )
|
||||||
plmode INTEGER,
|
plmode INTEGER,
|
||||||
pltype TEXT
|
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 =
|
static const char * tomahawk_schema_sql =
|
||||||
@@ -89,7 +89,7 @@ static const char * tomahawk_schema_sql =
|
|||||||
""
|
""
|
||||||
""
|
""
|
||||||
"CREATE TABLE IF NOT EXISTS dynamic_playlist_revision ("
|
"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, "
|
" controls TEXT, "
|
||||||
" plmode INTEGER,"
|
" plmode INTEGER,"
|
||||||
" pltype TEXT"
|
" pltype TEXT"
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "database/databasecommand_createdynamicplaylist.h"
|
#include "database/databasecommand_createdynamicplaylist.h"
|
||||||
#include "database/databasecommand_setdynamicplaylistrevision.h"
|
#include "database/databasecommand_setdynamicplaylistrevision.h"
|
||||||
#include "database/databasecommand_loaddynamicplaylist.h"
|
#include "database/databasecommand_loaddynamicplaylist.h"
|
||||||
|
#include "database/databasecommand_deletedynamicplaylist.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -221,9 +222,8 @@ DynamicPlaylist::loadRevision( const QString& rev )
|
|||||||
bool
|
bool
|
||||||
DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
|
DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
|
||||||
{
|
{
|
||||||
// TODO
|
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeleteDynamicPlaylist( playlist->author(), playlist->guid() );
|
||||||
// DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
// APP->database()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -180,10 +180,10 @@ void SourceTreeItem::onDynamicPlaylistsDeleted( const QList< dynplaylist_ptr >&
|
|||||||
for ( int i = rows - 1; i >= 0; i-- )
|
for ( int i = rows - 1; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
QStandardItem* pi = item->child( 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);
|
playlist_ptr* pl = reinterpret_cast<playlist_ptr*>(piptr);
|
||||||
SourcesModel::SourceType type = static_cast<SourcesModel::SourceType>( pi->data( Type ).toInt() );
|
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() ) )
|
if ( type == SourcesModel::DynamicPlaylistSource && ptr == qlonglong( pl->data() ) )
|
||||||
{
|
{
|
||||||
m_dynplaylists.removeAll( p );
|
m_dynplaylists.removeAll( p );
|
||||||
|
@@ -89,9 +89,13 @@ SourceTreeView::setupMenus()
|
|||||||
|
|
||||||
bool readonly = true;
|
bool readonly = true;
|
||||||
SourcesModel::SourceType type = SourcesModel::indexType( m_contextMenuIndex );
|
SourcesModel::SourceType type = SourcesModel::indexType( m_contextMenuIndex );
|
||||||
if ( type == SourcesModel::PlaylistSource )
|
if ( type == SourcesModel::PlaylistSource || type == SourcesModel::DynamicPlaylistSource )
|
||||||
|
{
|
||||||
|
playlist_ptr playlist = SourcesModel::indexToDynamicPlaylist( m_contextMenuIndex );
|
||||||
|
if( playlist.isNull() )
|
||||||
{
|
{
|
||||||
playlist_ptr playlist = SourcesModel::indexToPlaylist( m_contextMenuIndex );
|
playlist_ptr playlist = SourcesModel::indexToPlaylist( m_contextMenuIndex );
|
||||||
|
}
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
{
|
{
|
||||||
readonly = !playlist->author()->isLocal();
|
readonly = !playlist->author()->isLocal();
|
||||||
@@ -186,16 +190,18 @@ SourceTreeView::deletePlaylist()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
||||||
if ( type == SourcesModel::PlaylistSource || type == SourcesModel::DynamicPlaylistSource )
|
if ( type == SourcesModel::PlaylistSource )
|
||||||
{
|
{
|
||||||
playlist_ptr playlist = ( type == SourcesModel::DynamicPlaylistSource )
|
playlist_ptr playlist = SourcesModel::indexToPlaylist( idx );
|
||||||
? SourcesModel::indexToDynamicPlaylist( idx ).staticCast< Playlist >()
|
|
||||||
: SourcesModel::indexToPlaylist( idx );
|
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Playlist about to be deleted:" << playlist->title();
|
qDebug() << "Playlist about to be deleted:" << playlist->title();
|
||||||
Playlist::remove( playlist );
|
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