mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 17:29:42 +01:00
Don't allow dropping of playlist items onto the current playlist in the sourcetree.
This commit is contained in:
parent
73ffa506c7
commit
f16451196b
@ -296,11 +296,19 @@ PlaylistModel::onRevisionLoaded( Tomahawk::PlaylistRevision revision )
|
||||
loadPlaylist( m_playlist );
|
||||
}
|
||||
|
||||
QMimeData*
|
||||
PlaylistModel::mimeData( const QModelIndexList& indexes ) const
|
||||
{
|
||||
// Add the playlist id to the mime data so that we can detect dropping on ourselves
|
||||
QMimeData* d = TrackModel::mimeData( indexes );
|
||||
d->setData( "application/tomahawk.playlist.id", m_playlist->guid().toLatin1() );
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
bool
|
||||
PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
||||
{
|
||||
qDebug() << "LALALA";
|
||||
Q_UNUSED( column );
|
||||
if ( action == Qt::IgnoreAction || isReadOnly() )
|
||||
return true;
|
||||
@ -310,6 +318,10 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
||||
&& !data->hasFormat( "application/tomahawk.result.list" ) )
|
||||
return false;
|
||||
|
||||
if ( data->hasFormat( "application/tomahawk.playlist.id" ) &&
|
||||
data->data( "application/tomahawk.playlist.id" ) == m_playlist->guid() )
|
||||
return false; // don't allow dropping on ourselves
|
||||
|
||||
int beginRow;
|
||||
if ( row != -1 )
|
||||
beginRow = row;
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class QMimeData;
|
||||
class QMetaData;
|
||||
|
||||
class DLLEXPORT PlaylistModel : public TrackModel
|
||||
@ -47,6 +48,7 @@ public:
|
||||
QVariant data( const QModelIndex& index, int role ) const;
|
||||
QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
||||
|
||||
virtual QMimeData* mimeData ( const QModelIndexList& indexes ) const;
|
||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
||||
|
||||
Tomahawk::playlist_ptr playlist() const { return m_playlist; }
|
||||
|
@ -112,6 +112,12 @@ bool
|
||||
PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
||||
{
|
||||
QList< Tomahawk::query_ptr > queries;
|
||||
|
||||
if ( data->hasFormat( "application/tomahawk.playlist.id" ) &&
|
||||
data->data( "application/tomahawk.playlist.id" ) == m_playlist->guid() )
|
||||
return false; // don't allow dropping on ourselves
|
||||
|
||||
|
||||
if ( data->hasFormat( "application/tomahawk.result.list" ) )
|
||||
{
|
||||
QByteArray itemData = data->data( "application/tomahawk.result.list" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user