mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01:00
Have browsable resolvers return a collection.
This commit is contained in:
parent
43ae736d61
commit
c705676ec1
@ -71,6 +71,7 @@ public:
|
||||
virtual ErrorState error() const;
|
||||
virtual bool running() const = 0;
|
||||
virtual Capabilities capabilities() const = 0;
|
||||
virtual QList< Tomahawk::collection_ptr > collections() { return m_collections; }
|
||||
|
||||
public slots:
|
||||
virtual void start() = 0;
|
||||
|
@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -23,6 +24,7 @@
|
||||
#include "Album.h"
|
||||
#include "config.h"
|
||||
#include "Pipeline.h"
|
||||
#include "ScriptCollection.h"
|
||||
#include "SourceList.h"
|
||||
|
||||
#include "accounts/AccountConfigWidget.h"
|
||||
@ -368,6 +370,8 @@ QtScriptResolver::init()
|
||||
QVariantMap config = resolverUserConfig();
|
||||
fillDataInWidgets( config );
|
||||
|
||||
loadCollections();
|
||||
|
||||
qDebug() << "JS" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon received" << success;
|
||||
|
||||
m_ready = true;
|
||||
@ -504,6 +508,13 @@ void
|
||||
QtScriptResolver::stop()
|
||||
{
|
||||
m_stopped = true;
|
||||
|
||||
foreach ( const Tomahawk::collection_ptr& collection, m_collections )
|
||||
{
|
||||
emit collectionRemoved( collection );
|
||||
}
|
||||
m_collections.clear();
|
||||
|
||||
Tomahawk::Pipeline::instance()->removeResolver( this );
|
||||
emit stopped();
|
||||
}
|
||||
@ -634,6 +645,22 @@ QtScriptResolver::fillDataInWidgets( const QVariantMap& data )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
QtScriptResolver::loadCollections()
|
||||
{
|
||||
if ( m_capabilities.testFlag( Browsable ) )
|
||||
{
|
||||
m_collections.clear();
|
||||
// at this point we assume that all the tracks browsable through a resolver belong to the local source
|
||||
Tomahawk::collection_ptr collection( new Tomahawk::ScriptCollection( SourceList::instance()->getLocal(), this ) );
|
||||
m_collections.append( collection );
|
||||
emit collectionAdded( collection );
|
||||
|
||||
//TODO: implement multiple collections from a resolver
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariantMap
|
||||
QtScriptResolver::resolverSettings()
|
||||
{
|
||||
@ -654,3 +681,10 @@ QtScriptResolver::resolverInit()
|
||||
return m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "resolver.init();" ).toMap();
|
||||
}
|
||||
|
||||
|
||||
QVariantMap
|
||||
QtScriptResolver::resolverCollections()
|
||||
{
|
||||
return QVariantMap(); //TODO: add a way to distinguish collections
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -144,6 +145,7 @@ public:
|
||||
virtual void reload();
|
||||
|
||||
virtual void setIcon( const QPixmap& icon ) { m_icon = icon; }
|
||||
|
||||
public slots:
|
||||
virtual void resolve( const Tomahawk::query_ptr& query );
|
||||
virtual void stop();
|
||||
@ -160,11 +162,13 @@ private:
|
||||
QVariant widgetData( QWidget* widget, const QString& property );
|
||||
QVariantMap loadDataFromWidgets();
|
||||
void fillDataInWidgets( const QVariantMap& data );
|
||||
void loadCollections();
|
||||
|
||||
// encapsulate javascript calls
|
||||
QVariantMap resolverSettings();
|
||||
QVariantMap resolverUserConfig();
|
||||
QVariantMap resolverInit();
|
||||
QVariantMap resolverCollections();
|
||||
|
||||
QList< Tomahawk::result_ptr > parseResultVariantList( const QVariantList& reslist );
|
||||
|
||||
|
@ -25,7 +25,7 @@ using namespace Tomahawk;
|
||||
|
||||
|
||||
ScriptCollection::ScriptCollection( const source_ptr& source,
|
||||
QtScriptResolver* resolver,
|
||||
ExternalResolver* resolver,
|
||||
QObject* parent )
|
||||
: Collection( source, resolver->name(), parent )
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef SCRIPTCOLLECTION_H
|
||||
#define SCRIPTCOLLECTION_H
|
||||
|
||||
#include "resolvers/QtScriptResolver.h"
|
||||
#include "ExternalResolver.h"
|
||||
#include "Collection.h"
|
||||
|
||||
#include "Typedefs.h"
|
||||
@ -36,12 +36,12 @@ class DLLEXPORT ScriptCollection : public Collection
|
||||
|
||||
public:
|
||||
explicit ScriptCollection( const source_ptr& source,
|
||||
QtScriptResolver* resolver,
|
||||
ExternalResolver* resolver,
|
||||
QObject* parent = 0 );
|
||||
virtual ~ScriptCollection();
|
||||
|
||||
private:
|
||||
QtScriptResolver* m_resolver;
|
||||
ExternalResolver* m_resolver;
|
||||
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -22,6 +23,7 @@
|
||||
#include "Artist.h"
|
||||
#include "Album.h"
|
||||
#include "Pipeline.h"
|
||||
#include "ScriptCollection.h"
|
||||
#include "SourceList.h"
|
||||
|
||||
#include "accounts/AccountConfigWidget.h"
|
||||
@ -415,6 +417,8 @@ ScriptResolver::doSetup( const QVariantMap& m )
|
||||
m_configSent = false;
|
||||
m_num_restarts = 0;
|
||||
|
||||
loadCollections();
|
||||
|
||||
if ( !m_stopped )
|
||||
Tomahawk::Pipeline::instance()->addResolver( this );
|
||||
|
||||
@ -442,6 +446,22 @@ ScriptResolver::setupConfWidget( const QVariantMap& m )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScriptResolver::loadCollections()
|
||||
{
|
||||
if ( m_capabilities.testFlag( Browsable ) )
|
||||
{
|
||||
m_collections.clear();
|
||||
// at this point we assume that all the tracks browsable through a resolver belong to the local source
|
||||
Tomahawk::collection_ptr collection( new Tomahawk::ScriptCollection( SourceList::instance()->getLocal(), this ) );
|
||||
m_collections.append( collection );
|
||||
emit collectionAdded( collection );
|
||||
|
||||
//TODO: implement multiple collections from a resolver
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScriptResolver::startProcess()
|
||||
{
|
||||
@ -537,5 +557,12 @@ void
|
||||
ScriptResolver::stop()
|
||||
{
|
||||
m_stopped = true;
|
||||
|
||||
foreach ( const Tomahawk::collection_ptr& collection, m_collections )
|
||||
{
|
||||
emit collectionRemoved( collection );
|
||||
}
|
||||
m_collections.clear();
|
||||
|
||||
Tomahawk::Pipeline::instance()->removeResolver( this );
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -81,6 +82,7 @@ private:
|
||||
void sendMsg( const QByteArray& msg );
|
||||
void doSetup( const QVariantMap& m );
|
||||
void setupConfWidget( const QVariantMap& m );
|
||||
void loadCollections();
|
||||
|
||||
void startProcess();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user