mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Create artist filters when dragging a query from the artist in audiocontrols
This commit is contained in:
@@ -566,6 +566,26 @@ QueryLabel::startDrag()
|
|||||||
queryStream << qlonglong( &m_query );
|
queryStream << qlonglong( &m_query );
|
||||||
|
|
||||||
mimeData->setData( "application/tomahawk.query.list", queryData );
|
mimeData->setData( "application/tomahawk.query.list", queryData );
|
||||||
|
|
||||||
|
if ( m_hoverType != None )
|
||||||
|
{
|
||||||
|
QString extra;
|
||||||
|
switch( m_hoverType )
|
||||||
|
{
|
||||||
|
case Artist:
|
||||||
|
extra = "artist";
|
||||||
|
break;
|
||||||
|
case Album:
|
||||||
|
extra = "album";
|
||||||
|
break;
|
||||||
|
case Track:
|
||||||
|
extra = "track";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mimeData->setData( "application/tomahawk.dragsource.type", extra.toUtf8() );
|
||||||
|
}
|
||||||
QDrag *drag = new QDrag( this );
|
QDrag *drag = new QDrag( this );
|
||||||
drag->setMimeData( mimeData );
|
drag->setMimeData( mimeData );
|
||||||
drag->setPixmap( TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeTrack ) );
|
drag->setPixmap( TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeTrack ) );
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "dropjob.h"
|
#include "dropjob.h"
|
||||||
|
|
||||||
|
#include <echonest/Playlist.h>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
@@ -251,6 +253,9 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
|
|||||||
|
|
||||||
// Create a new playlist seeded with these items
|
// Create a new playlist seeded with these items
|
||||||
DropJob *dj = new DropJob();
|
DropJob *dj = new DropJob();
|
||||||
|
if ( data->hasFormat( "application/tomahawk.dragsource.type" ) )
|
||||||
|
dj->setProperty( "dragsource", QString::fromUtf8( data->data( "application/tomahawk.dragsource.type" ) ) );
|
||||||
|
|
||||||
connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ), this, SLOT( parsedDroppedTracks( QList< Tomahawk::query_ptr > ) ) );
|
connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ), this, SLOT( parsedDroppedTracks( QList< Tomahawk::query_ptr > ) ) );
|
||||||
if ( dropType() == DropTypeAllFromArtist )
|
if ( dropType() == DropTypeAllFromArtist )
|
||||||
dj->setGetWholeArtists( true );
|
dj->setGetWholeArtists( true );
|
||||||
@@ -284,18 +289,30 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
|
|||||||
// Give a shot to try to rename it. The playlist has to be created first. ugly.
|
// Give a shot to try to rename it. The playlist has to be created first. ugly.
|
||||||
QTimer::singleShot( 300, APP->mainWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
|
QTimer::singleShot( 300, APP->mainWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
|
||||||
} else if( m_categoryType == SourcesModel::StationsCategory ) {
|
} else if( m_categoryType == SourcesModel::StationsCategory ) {
|
||||||
// seed the playlist with these song filters
|
// seed the playlist with these song or artist filters
|
||||||
QString name = tracks.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( tracks.first()->track() );
|
QString name = tracks.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( tracks.first()->track() );
|
||||||
dynplaylist_ptr newpl = DynamicPlaylist::create( SourceList::instance()->getLocal(), uuid(), name, "", SourceList::instance()->getLocal()->friendlyName(), OnDemand, false );
|
dynplaylist_ptr newpl = DynamicPlaylist::create( SourceList::instance()->getLocal(), uuid(), name, "", SourceList::instance()->getLocal()->friendlyName(), OnDemand, false );
|
||||||
newpl->setMode( OnDemand );
|
newpl->setMode( OnDemand );
|
||||||
|
|
||||||
// now we want to add each query as a song filter...
|
// now we want to add each query as a song or similar artist filter...
|
||||||
QList< dyncontrol_ptr > contrls;
|
QList< dyncontrol_ptr > contrls;
|
||||||
|
if ( sender() && sender()->property( "dragsource" ).toString() == "artist" )
|
||||||
|
{
|
||||||
|
foreach( const Tomahawk::query_ptr& q, tracks ) {
|
||||||
|
dyncontrol_ptr c = newpl->generator()->createControl( "Artist" );
|
||||||
|
c->setMatch( QString::number( (int)Echonest::DynamicPlaylist::ArtistRadioType ) );
|
||||||
|
c->setInput( QString( "%1" ).arg( q->artist() ) );
|
||||||
|
contrls << c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
foreach( const Tomahawk::query_ptr& q, tracks ) {
|
foreach( const Tomahawk::query_ptr& q, tracks ) {
|
||||||
dyncontrol_ptr c = newpl->generator()->createControl( "Song" );
|
dyncontrol_ptr c = newpl->generator()->createControl( "Song" );
|
||||||
c->setInput( QString( "%1 %2" ).arg( q->track() ).arg( q->artist() ) );
|
c->setInput( QString( "%1 %2" ).arg( q->track() ).arg( q->artist() ) );
|
||||||
contrls << c;
|
contrls << c;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
newpl->createNewRevision( uuid(), newpl->currentrevision(), newpl->type(), contrls );
|
newpl->createNewRevision( uuid(), newpl->currentrevision(), newpl->type(), contrls );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user