mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Don't allow dropping of playlist items onto the current playlist in the sourcetree.
This commit is contained in:
@@ -296,11 +296,19 @@ PlaylistModel::onRevisionLoaded( Tomahawk::PlaylistRevision revision )
|
|||||||
loadPlaylist( m_playlist );
|
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
|
bool
|
||||||
PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
qDebug() << "LALALA";
|
|
||||||
Q_UNUSED( column );
|
Q_UNUSED( column );
|
||||||
if ( action == Qt::IgnoreAction || isReadOnly() )
|
if ( action == Qt::IgnoreAction || isReadOnly() )
|
||||||
return true;
|
return true;
|
||||||
@@ -310,6 +318,10 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
&& !data->hasFormat( "application/tomahawk.result.list" ) )
|
&& !data->hasFormat( "application/tomahawk.result.list" ) )
|
||||||
return false;
|
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;
|
int beginRow;
|
||||||
if ( row != -1 )
|
if ( row != -1 )
|
||||||
beginRow = row;
|
beginRow = row;
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class QMimeData;
|
||||||
class QMetaData;
|
class QMetaData;
|
||||||
|
|
||||||
class DLLEXPORT PlaylistModel : public TrackModel
|
class DLLEXPORT PlaylistModel : public TrackModel
|
||||||
@@ -47,6 +48,7 @@ public:
|
|||||||
QVariant data( const QModelIndex& index, int role ) const;
|
QVariant data( const QModelIndex& index, int role ) const;
|
||||||
QVariant headerData( int section, Qt::Orientation orientation, 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 );
|
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
||||||
|
|
||||||
Tomahawk::playlist_ptr playlist() const { return m_playlist; }
|
Tomahawk::playlist_ptr playlist() const { return m_playlist; }
|
||||||
|
@@ -112,6 +112,12 @@ bool
|
|||||||
PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
||||||
{
|
{
|
||||||
QList< Tomahawk::query_ptr > queries;
|
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" ) )
|
if ( data->hasFormat( "application/tomahawk.result.list" ) )
|
||||||
{
|
{
|
||||||
QByteArray itemData = data->data( "application/tomahawk.result.list" );
|
QByteArray itemData = data->data( "application/tomahawk.result.list" );
|
||||||
|
Reference in New Issue
Block a user