1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-01 03:40:16 +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 CategoryAddItem::willAcceptDrag( const QMimeData* data ) const
{ {
if( ( m_categoryType == SourcesModel::PlaylistsCategory || m_categoryType == SourcesModel::StationsCategory ) && 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 true;
} }
return false; return false;
@@ -124,21 +125,43 @@ bool
CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction ) CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
{ {
// Create a new playlist seeded with these items // Create a new playlist seeded with these items
if( data->hasFormat( "application/tomahawk.query.list" ) ) { if( data->hasFormat( "application/tomahawk.query.list" ) || data->hasFormat( "application/tomahawk.result.list" ) ) {
QByteArray itemData = data->data( "application/tomahawk.query.list" );
QDataStream stream( &itemData, QIODevice::ReadOnly );
QList< Tomahawk::query_ptr > queries; QList< Tomahawk::query_ptr > queries;
while ( !stream.atEnd() ) if( data->hasFormat( "application/tomahawk.query.list" ) ) {
{ QByteArray itemData = data->data( "application/tomahawk.query.list" );
qlonglong qptr; QDataStream stream( &itemData, QIODevice::ReadOnly );
stream >> qptr;
Tomahawk::query_ptr* query = reinterpret_cast<Tomahawk::query_ptr*>(qptr); while ( !stream.atEnd() )
if ( query && !query->isNull() )
{ {
qDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track(); qlonglong qptr;
queries << *query; stream >> qptr;
Tomahawk::query_ptr* query = reinterpret_cast<Tomahawk::query_ptr*>(qptr);
if ( query && !query->isNull() )
{
qDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track();
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;
}
} }
} }