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