mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
fixed order of filtering. initial work on the Top10 drop action (does actually Top50 for now and tracks can not be resolved yet)
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include "utils/shortenedlinkparser.h"
|
#include "utils/shortenedlinkparser.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "globalactionmanager.h"
|
#include "globalactionmanager.h"
|
||||||
|
#include "infosystem/infosystem.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -96,21 +97,22 @@ DropJob::acceptsMimeData( const QMimeData* data, bool tracksOnly )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DropJob::tracksFromMimeData( const QMimeData* data, bool allowDuplicates, bool onlyLocal )
|
DropJob::tracksFromMimeData( const QMimeData* data, bool allowDuplicates, bool onlyLocal, bool top10 )
|
||||||
{
|
{
|
||||||
m_allowDuplicates = allowDuplicates;
|
m_allowDuplicates = allowDuplicates;
|
||||||
m_onlyLocal = onlyLocal;
|
m_onlyLocal = onlyLocal;
|
||||||
|
m_top10 = top10;
|
||||||
|
|
||||||
parseMimeData( data );
|
parseMimeData( data );
|
||||||
|
|
||||||
if ( m_queryCount == 0 )
|
if ( m_queryCount == 0 )
|
||||||
{
|
{
|
||||||
if ( !allowDuplicates )
|
|
||||||
removeDuplicates();
|
|
||||||
|
|
||||||
if ( onlyLocal )
|
if ( onlyLocal )
|
||||||
removeRemoteSources();
|
removeRemoteSources();
|
||||||
|
|
||||||
|
if ( !allowDuplicates )
|
||||||
|
removeDuplicates();
|
||||||
|
|
||||||
emit tracks( m_resultList );
|
emit tracks( m_resultList );
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
@@ -228,15 +230,38 @@ DropJob::tracksFromArtistMetaData( const QMimeData *data )
|
|||||||
QString artist;
|
QString artist;
|
||||||
stream >> artist;
|
stream >> artist;
|
||||||
|
|
||||||
artist_ptr artistPtr = Artist::get( artist );
|
if ( !m_top10 )
|
||||||
if ( artistPtr->tracks().isEmpty() )
|
|
||||||
{
|
{
|
||||||
connect( artistPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
artist_ptr artistPtr = Artist::get( artist );
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
if ( artistPtr->tracks().isEmpty() )
|
||||||
m_queryCount++;
|
{
|
||||||
|
connect( artistPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||||
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
m_queryCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
queries << artistPtr->tracks();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
queries << artistPtr->tracks();
|
{
|
||||||
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoCriteriaHash artistInfo;
|
||||||
|
artistInfo["artist"] = artist;
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||||
|
requestData.caller = "changeme";
|
||||||
|
requestData.customData = QVariantMap();
|
||||||
|
|
||||||
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo );
|
||||||
|
|
||||||
|
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
|
||||||
|
m_queryCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return queries;
|
return queries;
|
||||||
}
|
}
|
||||||
@@ -340,12 +365,12 @@ DropJob::onTracksAdded( const QList<Tomahawk::query_ptr>& tracksList )
|
|||||||
|
|
||||||
if ( --m_queryCount == 0 )
|
if ( --m_queryCount == 0 )
|
||||||
{
|
{
|
||||||
if ( !m_allowDuplicates )
|
|
||||||
removeDuplicates();
|
|
||||||
|
|
||||||
if ( m_onlyLocal )
|
if ( m_onlyLocal )
|
||||||
removeRemoteSources();
|
removeRemoteSources();
|
||||||
|
|
||||||
|
if ( !m_allowDuplicates )
|
||||||
|
removeDuplicates();
|
||||||
|
|
||||||
emit tracks( m_resultList );
|
emit tracks( m_resultList );
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
@@ -375,9 +400,38 @@ DropJob::removeRemoteSources()
|
|||||||
QList< Tomahawk::query_ptr > list;
|
QList< Tomahawk::query_ptr > list;
|
||||||
foreach ( const Tomahawk::query_ptr& item, m_resultList )
|
foreach ( const Tomahawk::query_ptr& item, m_resultList )
|
||||||
{
|
{
|
||||||
if ( !item->results().isEmpty() && item->results().first()->collection()->source() )
|
bool hasLocalSource = false;
|
||||||
if ( item->results().first()->collection()->source()->isLocal() )
|
foreach ( const Tomahawk::result_ptr& result, item->results() )
|
||||||
list.append( item );
|
{
|
||||||
|
if ( result->collection()->source() && result->collection()->source()->isLocal() )
|
||||||
|
hasLocalSource = true;
|
||||||
|
}
|
||||||
|
if ( hasLocalSource )
|
||||||
|
list.append( item );
|
||||||
}
|
}
|
||||||
m_resultList = list;
|
m_resultList = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DropJob::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||||
|
{
|
||||||
|
if ( requestData.caller == "changeme" )
|
||||||
|
{
|
||||||
|
Tomahawk::InfoSystem::InfoCriteriaHash artistInfo;
|
||||||
|
|
||||||
|
artistInfo = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
||||||
|
|
||||||
|
QString artist = artistInfo["artist"];
|
||||||
|
|
||||||
|
qDebug() << "Got requestData response for artist" << artist << output;
|
||||||
|
|
||||||
|
QList< query_ptr > results;
|
||||||
|
foreach ( const QVariant& title, output.toMap().value( "tracks" ).toList() )
|
||||||
|
{
|
||||||
|
qDebug() << "got title" << title;
|
||||||
|
results << Query::get( artist, title.toString(), QString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
onTracksAdded( results );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
|
||||||
|
#include "infosystem/infosystem.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
@@ -43,7 +45,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
static bool acceptsMimeData( const QMimeData* data, bool tracksOnly = true );
|
static bool acceptsMimeData( const QMimeData* data, bool tracksOnly = true );
|
||||||
static QStringList mimeTypes();
|
static QStringList mimeTypes();
|
||||||
void tracksFromMimeData( const QMimeData* data, bool allowDuplicates = false, bool onlyLocal = false );
|
void tracksFromMimeData( const QMimeData* data, bool allowDuplicates = false, bool onlyLocal = false, bool top10 = false );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// QMimeData parsing results
|
/// QMimeData parsing results
|
||||||
@@ -54,6 +56,8 @@ private slots:
|
|||||||
|
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& );
|
||||||
|
|
||||||
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// handle parsing mime data
|
/// handle parsing mime data
|
||||||
void parseMimeData( const QMimeData* data );
|
void parseMimeData( const QMimeData* data );
|
||||||
@@ -71,6 +75,7 @@ private:
|
|||||||
int m_queryCount;
|
int m_queryCount;
|
||||||
bool m_allowDuplicates;
|
bool m_allowDuplicates;
|
||||||
bool m_onlyLocal;
|
bool m_onlyLocal;
|
||||||
|
bool m_top10;
|
||||||
|
|
||||||
QList< Tomahawk::query_ptr > m_resultList;
|
QList< Tomahawk::query_ptr > m_resultList;
|
||||||
};
|
};
|
||||||
|
@@ -161,6 +161,8 @@ PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
|||||||
|
|
||||||
if ( dropType() == DropTypeLocalItems )
|
if ( dropType() == DropTypeLocalItems )
|
||||||
dj->tracksFromMimeData( data, false, true );
|
dj->tracksFromMimeData( data, false, true );
|
||||||
|
else if ( dropType() == DropTypeTop10 )
|
||||||
|
dj->tracksFromMimeData( data, false, false, true );
|
||||||
else
|
else
|
||||||
dj->tracksFromMimeData( data, false, false );
|
dj->tracksFromMimeData( data, false, false );
|
||||||
|
|
||||||
@@ -171,6 +173,7 @@ PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
|||||||
void
|
void
|
||||||
PlaylistItem::parsedDroppedTracks( const QList< query_ptr >& tracks)
|
PlaylistItem::parsedDroppedTracks( const QList< query_ptr >& tracks)
|
||||||
{
|
{
|
||||||
|
qDebug() << "adding" << tracks.count() << "tracks";
|
||||||
if ( tracks.count() && !m_playlist.isNull() && m_playlist->author()->isLocal() )
|
if ( tracks.count() && !m_playlist.isNull() && m_playlist->author()->isLocal() )
|
||||||
{
|
{
|
||||||
qDebug() << "on playlist:" << m_playlist->title() << m_playlist->guid() << m_playlist->currentrevision();
|
qDebug() << "on playlist:" << m_playlist->title() << m_playlist->guid() << m_playlist->currentrevision();
|
||||||
|
Reference in New Issue
Block a user