1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

allow dropping of results as well as queries on the categoryadd items

Fixes TWK-232
This commit is contained in:
Leo Franchi
2011-06-17 12:40:30 -04:00
parent 2088e78020
commit f72c60969b

View File

@@ -114,7 +114,8 @@ bool
CategoryAddItem::willAcceptDrag( const QMimeData* data ) const
{
if( ( m_categoryType == SourcesModel::PlaylistsCategory || m_categoryType == SourcesModel::StationsCategory ) &&
data->hasFormat( "application/tomahawk.query.list" ) ) {
data->hasFormat( "application/tomahawk.query.list" ) ||
data->hasFormat( "application/tomahawk.result.list" ) ) {
return true;
}
return false;
@@ -124,10 +125,13 @@ bool
CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
{
// Create a new playlist seeded with these items
if( data->hasFormat( "application/tomahawk.query.list" ) || data->hasFormat( "application/tomahawk.result.list" ) ) {
QList< Tomahawk::query_ptr > queries;
if( data->hasFormat( "application/tomahawk.query.list" ) ) {
QByteArray itemData = data->data( "application/tomahawk.query.list" );
QDataStream stream( &itemData, QIODevice::ReadOnly );
QList< Tomahawk::query_ptr > queries;
while ( !stream.atEnd() )
{
@@ -141,6 +145,25 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
queries << *query;
}
}
} else if( data->hasFormat( "application/tomahawk.result.list" ) ) {
QByteArray itemData = data->data( "application/tomahawk.result.list" );
QDataStream stream( &itemData, QIODevice::ReadOnly );
while ( !stream.atEnd() )
{
qlonglong qptr;
stream >> qptr;
Tomahawk::result_ptr* result = reinterpret_cast<Tomahawk::result_ptr*>(qptr);
if ( result && !result->isNull() )
{
qDebug() << "Dropped result item:" << result->data()->artist() << "-" << result->data()->track();
query_ptr q = result->data()->toQuery();
q->addResults( QList< result_ptr >() << *result );
queries << q;
}
}
}
if( m_categoryType == SourcesModel::PlaylistsCategory ) {