1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

TWK-968: Part Two: Allow drop helper for mixed query/result lists.

This commit is contained in:
Leo Franchi 2012-07-14 00:31:27 -04:00
parent bd0e347281
commit 96c6ebfe99

View File

@ -170,6 +170,34 @@ PlaylistItem::willAcceptDrag( const QMimeData* data ) const
PlaylistItem::DropTypes
PlaylistItem::supportedDropTypes( const QMimeData* data ) const
{
if ( data->hasFormat( "application/tomahawk.mixed" ) )
{
// If this is mixed but only queries/results, we can still handle them
bool mixedQueries = true;
QByteArray itemData = data->data( "application/tomahawk.mixed" );
QDataStream stream( &itemData, QIODevice::ReadOnly );
QString mimeType;
qlonglong val;
while ( !stream.atEnd() )
{
stream >> mimeType;
if ( mimeType != "application/tomahawk.query.list" &&
mimeType != "application/tomahawk.result.list" )
{
mixedQueries = false;
break;
}
stream >> val;
}
if ( mixedQueries )
return DropTypeThisTrack | DropTypeThisAlbum | DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
else
return DropTypesNone;
}
if ( data->hasFormat( "application/tomahawk.query.list" ) )
return DropTypeThisTrack | DropTypeThisAlbum | DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
else if ( data->hasFormat( "application/tomahawk.result.list" ) )
@ -178,10 +206,6 @@ PlaylistItem::supportedDropTypes( const QMimeData* data ) const
return DropTypeThisAlbum | DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
else if ( data->hasFormat( "application/tomahawk.metadata.artist" ) )
return DropTypeAllFromArtist | DropTypeLocalItems | DropTypeTop50;
else if ( data->hasFormat( "application/tomahawk.mixed" ) )
{
return DropTypesNone;
}
else if ( data->hasFormat( "text/plain" ) )
{
return DropTypesNone;