mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Added ScriptCommand_AllAlbums.
This commit is contained in:
@@ -178,10 +178,16 @@ Artist::albums( ModelMode mode, const Tomahawk::collection_ptr& collection ) con
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//collection is *surely* not null
|
//collection is *surely* not null, and might be a ScriptCollection
|
||||||
connect( collection.data(), SIGNAL( albumsResult( QList< Tomahawk::album_ptr > ) ),
|
Tomahawk::AlbumsRequest* cmd = collection->requestAlbums( artist );
|
||||||
SLOT( onAlbumsFound( QList<Tomahawk::album_ptr> ) ), Qt::UniqueConnection );
|
|
||||||
collection->albums( artist );
|
// There is also a signal albums( QList, QVariant ).
|
||||||
|
// The QVariant might carry a bool that says whether the dbcmd was executed for a null collection
|
||||||
|
// but here we know for a fact that the collection is not null, so we'll happily ignore it
|
||||||
|
connect( dynamic_cast< QObject* >( cmd ), SIGNAL( albums( QList<Tomahawk::album_ptr> ) ),
|
||||||
|
this, SLOT( onAlbumsFound( QList<Tomahawk::album_ptr> ) ) );
|
||||||
|
|
||||||
|
cmd->enqueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -304,6 +304,7 @@ list(APPEND libSources
|
|||||||
resolvers/Resolver.cpp
|
resolvers/Resolver.cpp
|
||||||
resolvers/ScriptCollection.cpp
|
resolvers/ScriptCollection.cpp
|
||||||
resolvers/ScriptCommand_AllArtists.cpp
|
resolvers/ScriptCommand_AllArtists.cpp
|
||||||
|
resolvers/ScriptCommand_AllAlbums.cpp
|
||||||
resolvers/ScriptCommandQueue.cpp
|
resolvers/ScriptCommandQueue.cpp
|
||||||
|
|
||||||
sip/SipPlugin.cpp
|
sip/SipPlugin.cpp
|
||||||
|
43
src/libtomahawk/collection/AlbumsRequest.h
Normal file
43
src/libtomahawk/collection/AlbumsRequest.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ALBUMSREQUEST_H
|
||||||
|
#define ALBUMSREQUEST_H
|
||||||
|
|
||||||
|
#include "Typedefs.h"
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class DLLEXPORT AlbumsRequest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~AlbumsRequest() {}
|
||||||
|
|
||||||
|
virtual void enqueue() = 0;
|
||||||
|
|
||||||
|
protected: //signals
|
||||||
|
virtual void albums( const QList< Tomahawk::album_ptr >& ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //ns
|
||||||
|
|
||||||
|
#endif // ALBUMSREQUEST_H
|
@@ -35,6 +35,7 @@
|
|||||||
#include "Playlist.h"
|
#include "Playlist.h"
|
||||||
#include "playlist/dynamic/DynamicPlaylist.h"
|
#include "playlist/dynamic/DynamicPlaylist.h"
|
||||||
#include "collection/ArtistsRequest.h"
|
#include "collection/ArtistsRequest.h"
|
||||||
|
#include "collection/AlbumsRequest.h"
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ public:
|
|||||||
|
|
||||||
// Async requests. Emit artists/albums/tracksResult in subclasses when finished.
|
// Async requests. Emit artists/albums/tracksResult in subclasses when finished.
|
||||||
virtual Tomahawk::ArtistsRequest* requestArtists() = 0;
|
virtual Tomahawk::ArtistsRequest* requestArtists() = 0;
|
||||||
virtual void albums( const Tomahawk::artist_ptr& artist ) = 0;
|
virtual Tomahawk::AlbumsRequest* requestAlbums( const Tomahawk::artist_ptr& artist ) = 0;
|
||||||
virtual void tracks( const Tomahawk::album_ptr& album ) = 0;
|
virtual void tracks( const Tomahawk::album_ptr& album ) = 0;
|
||||||
|
|
||||||
const source_ptr& source() const;
|
const source_ptr& source() const;
|
||||||
|
@@ -147,30 +147,17 @@ DatabaseCollection::requestArtists()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
Tomahawk::AlbumsRequest*
|
||||||
DatabaseCollection::albums( const Tomahawk::artist_ptr& artist )
|
DatabaseCollection::requestAlbums( const Tomahawk::artist_ptr& artist )
|
||||||
{
|
{
|
||||||
//FIXME: assuming there's only one dbcollection per source, and that this is the one
|
//FIXME: assuming there's only one dbcollection per source, and that this is the one
|
||||||
Tomahawk::collection_ptr thisCollection = source()->dbCollection();
|
Tomahawk::collection_ptr thisCollection = source()->dbCollection();
|
||||||
if ( thisCollection->name() != this->name() )
|
if ( thisCollection->name() != this->name() )
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( thisCollection, artist );
|
Tomahawk::AlbumsRequest* cmd = new DatabaseCommand_AllAlbums( thisCollection, artist );
|
||||||
|
|
||||||
// The QVariant might carry a bool that says whether the dbcmd was executed for a null collection
|
return cmd;
|
||||||
// but here we know for a fact that the collection is not null, so we'll happily ignore it
|
|
||||||
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
|
||||||
SLOT( onAlbumsFetched( QList<Tomahawk::album_ptr>, QVariant ) ) );
|
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DatabaseCollection::onAlbumsFetched( const QList< album_ptr >& albums, const QVariant& data )
|
|
||||||
{
|
|
||||||
Q_UNUSED( data );
|
|
||||||
emit albumsResult( albums );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ public:
|
|||||||
virtual QList< Tomahawk::dynplaylist_ptr > stations();
|
virtual QList< Tomahawk::dynplaylist_ptr > stations();
|
||||||
|
|
||||||
virtual Tomahawk::ArtistsRequest* requestArtists();
|
virtual Tomahawk::ArtistsRequest* requestArtists();
|
||||||
virtual void albums( const Tomahawk::artist_ptr& artist );
|
virtual Tomahawk::AlbumsRequest* requestAlbums( const Tomahawk::artist_ptr& artist );
|
||||||
virtual void tracks( const Tomahawk::album_ptr& album );
|
virtual void tracks( const Tomahawk::album_ptr& album );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -59,7 +59,6 @@ public slots:
|
|||||||
virtual void removeTracks( const QDir& dir );
|
virtual void removeTracks( const QDir& dir );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAlbumsFetched( const QList< Tomahawk::album_ptr >& albums, const QVariant& data );
|
|
||||||
void onTracksFetched( const QList< Tomahawk::query_ptr >& tracks );
|
void onTracksFetched( const QList< Tomahawk::query_ptr >& tracks );
|
||||||
|
|
||||||
void stationCreated( const Tomahawk::source_ptr& source, const QVariantList& data );
|
void stationCreated( const Tomahawk::source_ptr& source, const QVariantList& data );
|
||||||
|
@@ -34,7 +34,8 @@ DatabaseCommand_AllAlbums::DatabaseCommand_AllAlbums( const Tomahawk::collection
|
|||||||
, m_amount( 0 )
|
, m_amount( 0 )
|
||||||
, m_sortOrder( DatabaseCommand_AllAlbums::None )
|
, m_sortOrder( DatabaseCommand_AllAlbums::None )
|
||||||
, m_sortDescending( false )
|
, m_sortDescending( false )
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DatabaseCommand_AllAlbums::~DatabaseCommand_AllAlbums()
|
DatabaseCommand_AllAlbums::~DatabaseCommand_AllAlbums()
|
||||||
@@ -114,6 +115,7 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit albums( al, data() );
|
emit albums( al, data() );
|
||||||
|
emit albums( al );
|
||||||
emit done();
|
emit done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,6 +164,7 @@ DatabaseCommand_AllAlbums::execForCollection( DatabaseImpl* dbi )
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit albums( al, data() );
|
emit albums( al, data() );
|
||||||
|
emit albums( al );
|
||||||
emit done();
|
emit done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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
|
||||||
@@ -25,12 +26,15 @@
|
|||||||
#include "Album.h"
|
#include "Album.h"
|
||||||
#include "Artist.h"
|
#include "Artist.h"
|
||||||
#include "collection/Collection.h"
|
#include "collection/Collection.h"
|
||||||
|
#include "collection/AlbumsRequest.h"
|
||||||
#include "Typedefs.h"
|
#include "Typedefs.h"
|
||||||
#include "DatabaseCommand.h"
|
#include "DatabaseCommand.h"
|
||||||
|
#include "Database.h"
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
class DLLEXPORT DatabaseCommand_AllAlbums : public DatabaseCommand
|
class DLLEXPORT DatabaseCommand_AllAlbums : public DatabaseCommand
|
||||||
|
, public Tomahawk::AlbumsRequest
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -39,7 +43,9 @@ public:
|
|||||||
ModificationTime = 1
|
ModificationTime = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit DatabaseCommand_AllAlbums( const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr(), const Tomahawk::artist_ptr& artist = Tomahawk::artist_ptr(), QObject* parent = 0 );
|
explicit DatabaseCommand_AllAlbums( const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr(),
|
||||||
|
const Tomahawk::artist_ptr& artist = Tomahawk::artist_ptr(),
|
||||||
|
QObject* parent = 0 );
|
||||||
virtual ~DatabaseCommand_AllAlbums();
|
virtual ~DatabaseCommand_AllAlbums();
|
||||||
|
|
||||||
virtual void exec( DatabaseImpl* );
|
virtual void exec( DatabaseImpl* );
|
||||||
@@ -47,6 +53,8 @@ public:
|
|||||||
virtual bool doesMutates() const { return false; }
|
virtual bool doesMutates() const { return false; }
|
||||||
virtual QString commandname() const { return "allalbums"; }
|
virtual QString commandname() const { return "allalbums"; }
|
||||||
|
|
||||||
|
virtual void enqueue() { Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( this ) ); }
|
||||||
|
|
||||||
Tomahawk::collection_ptr collection() const { return m_collection; }
|
Tomahawk::collection_ptr collection() const { return m_collection; }
|
||||||
|
|
||||||
void execForCollection( DatabaseImpl* );
|
void execForCollection( DatabaseImpl* );
|
||||||
@@ -60,6 +68,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void albums( const QList<Tomahawk::album_ptr>&, const QVariant& data );
|
void albums( const QList<Tomahawk::album_ptr>&, const QVariant& data );
|
||||||
|
void albums( const QList<Tomahawk::album_ptr>& );
|
||||||
void done();
|
void done();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "Resolver.h"
|
#include "Resolver.h"
|
||||||
#include "ScriptCommandQueue.h"
|
#include "ScriptCommandQueue.h"
|
||||||
#include "ScriptCommand_AllArtists.h"
|
#include "ScriptCommand_AllArtists.h"
|
||||||
|
#include "ScriptCommand_AllAlbums.h"
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ Q_OBJECT
|
|||||||
|
|
||||||
friend class ::ScriptCommandQueue;
|
friend class ::ScriptCommandQueue;
|
||||||
friend class ::ScriptCommand_AllArtists;
|
friend class ::ScriptCommand_AllArtists;
|
||||||
|
friend class ::ScriptCommand_AllAlbums;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ErrorState {
|
enum ErrorState {
|
||||||
|
@@ -187,8 +187,8 @@ QtScriptResolverHelper::addAlbumResults( const QVariantMap& results )
|
|||||||
tDebug() << Q_FUNC_INFO << "about to push" << albums.count() << "albums";
|
tDebug() << Q_FUNC_INFO << "about to push" << albums.count() << "albums";
|
||||||
foreach( const Tomahawk::album_ptr& album, albums)
|
foreach( const Tomahawk::album_ptr& album, albums)
|
||||||
tDebug() << album->name();
|
tDebug() << album->name();
|
||||||
QMetaObject::invokeMethod( collection.data(), "onAlbumsFetched", Qt::QueuedConnection,
|
|
||||||
Q_ARG( QList< Tomahawk::album_ptr >, albums ) );
|
emit m_resolver->albumsFound( albums );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -535,8 +535,7 @@ QtScriptResolver::albums( const Tomahawk::collection_ptr& collection, const Toma
|
|||||||
if ( !m_collections.contains( collection->name() ) || //if the collection doesn't belong to this resolver
|
if ( !m_collections.contains( collection->name() ) || //if the collection doesn't belong to this resolver
|
||||||
!capabilities().testFlag( Browsable ) ) //or this resolver doesn't even support collections
|
!capabilities().testFlag( Browsable ) ) //or this resolver doesn't even support collections
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod( collection.data(), "onAlbumsFetched", Qt::QueuedConnection,
|
emit albumsFound( QList< Tomahawk::album_ptr >() );
|
||||||
Q_ARG( QList< Tomahawk::album_ptr >, QList< Tomahawk::album_ptr >() ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "resolvers/ScriptCommand_AllArtists.h"
|
#include "resolvers/ScriptCommand_AllArtists.h"
|
||||||
|
#include "resolvers/ScriptCommand_AllAlbums.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@@ -122,10 +123,16 @@ ScriptCollection::requestArtists()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
Tomahawk::AlbumsRequest*
|
||||||
ScriptCollection::albums( const Tomahawk::artist_ptr& artist )
|
ScriptCollection::requestAlbums( const Tomahawk::artist_ptr& artist )
|
||||||
{
|
{
|
||||||
//m_resolver->albums( m_resolver->collections().value( name() ), artist );
|
Tomahawk::collection_ptr thisCollection = m_resolver->collections().value( name() );
|
||||||
|
if ( thisCollection->name() != this->name() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Tomahawk::AlbumsRequest* cmd = new ScriptCommand_AllAlbums( thisCollection, artist );
|
||||||
|
|
||||||
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,13 +143,6 @@ ScriptCollection::tracks( const Tomahawk::album_ptr& album )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ScriptCollection::onAlbumsFetched( const QList<album_ptr>& albums )
|
|
||||||
{
|
|
||||||
emit albumsResult( albums );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScriptCollection::onTracksFetched( const QList<query_ptr>& tracks )
|
ScriptCollection::onTracksFetched( const QList<query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "ExternalResolver.h"
|
#include "ExternalResolver.h"
|
||||||
#include "collection/Collection.h"
|
#include "collection/Collection.h"
|
||||||
#include "collection/ArtistsRequest.h"
|
#include "collection/ArtistsRequest.h"
|
||||||
|
#include "collection/AlbumsRequest.h"
|
||||||
|
|
||||||
#include "Typedefs.h"
|
#include "Typedefs.h"
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
@@ -50,11 +51,10 @@ public:
|
|||||||
virtual ExternalResolver* resolver() { return m_resolver; }
|
virtual ExternalResolver* resolver() { return m_resolver; }
|
||||||
|
|
||||||
virtual Tomahawk::ArtistsRequest* requestArtists();
|
virtual Tomahawk::ArtistsRequest* requestArtists();
|
||||||
virtual void albums( const Tomahawk::artist_ptr& artist );
|
virtual Tomahawk::AlbumsRequest* requestAlbums( const Tomahawk::artist_ptr& artist );
|
||||||
virtual void tracks( const Tomahawk::album_ptr& album );
|
virtual void tracks( const Tomahawk::album_ptr& album );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAlbumsFetched( const QList< Tomahawk::album_ptr >& albums );
|
|
||||||
void onTracksFetched( const QList< Tomahawk::query_ptr >& tracks );
|
void onTracksFetched( const QList< Tomahawk::query_ptr >& tracks );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -53,7 +53,7 @@ ScriptCommandQueue::nextCommand()
|
|||||||
NewClosure( m_timer, SIGNAL( timeout() ),
|
NewClosure( m_timer, SIGNAL( timeout() ),
|
||||||
this, SLOT( onTimeout( QSharedPointer< ScriptCommand > ) ), req );
|
this, SLOT( onTimeout( QSharedPointer< ScriptCommand > ) ), req );
|
||||||
|
|
||||||
m_timer->start( 2000 );
|
m_timer->start( 5000 );
|
||||||
|
|
||||||
req->exec();
|
req->exec();
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,6 @@ ScriptCommandQueue::onCommandDone( const QSharedPointer< ScriptCommand >& req )
|
|||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
|
|
||||||
m_queue.removeAll( req );
|
m_queue.removeAll( req );
|
||||||
req->deleteLater();
|
|
||||||
|
|
||||||
if ( m_queue.count() > 0 )
|
if ( m_queue.count() > 0 )
|
||||||
nextCommand();
|
nextCommand();
|
||||||
@@ -80,9 +79,8 @@ ScriptCommandQueue::onTimeout( const QSharedPointer< ScriptCommand >& req )
|
|||||||
|
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
|
|
||||||
m_queue.removeAll( req );
|
|
||||||
req->reportFailure();
|
req->reportFailure();
|
||||||
req->deleteLater();
|
m_queue.removeAll( req );
|
||||||
|
|
||||||
if ( m_queue.count() > 0 )
|
if ( m_queue.count() > 0 )
|
||||||
nextCommand();
|
nextCommand();
|
||||||
|
86
src/libtomahawk/resolvers/ScriptCommand_AllAlbums.cpp
Normal file
86
src/libtomahawk/resolvers/ScriptCommand_AllAlbums.cpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ScriptCommand_AllAlbums.h"
|
||||||
|
|
||||||
|
#include "ExternalResolver.h"
|
||||||
|
#include "ScriptCollection.h"
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
ScriptCommand_AllAlbums::ScriptCommand_AllAlbums( const Tomahawk::collection_ptr& collection,
|
||||||
|
const Tomahawk::artist_ptr& artist,
|
||||||
|
QObject* parent )
|
||||||
|
: ScriptCommand( parent )
|
||||||
|
, m_collection( collection )
|
||||||
|
, m_artist( artist )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScriptCommand_AllAlbums::enqueue()
|
||||||
|
{
|
||||||
|
Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
|
||||||
|
if ( collection == 0 )
|
||||||
|
{
|
||||||
|
emit albums( QList< Tomahawk::album_ptr >() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
collection->resolver()->enqueue( QSharedPointer< ScriptCommand >( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScriptCommand_AllAlbums::exec()
|
||||||
|
{
|
||||||
|
Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
|
||||||
|
if ( collection == 0 )
|
||||||
|
{
|
||||||
|
reportFailure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_artist.isNull() )
|
||||||
|
{
|
||||||
|
reportFailure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect( collection->resolver(), SIGNAL( albumsFound( QList< Tomahawk::album_ptr > ) ),
|
||||||
|
this, SLOT( onResolverDone( QList< Tomahawk::album_ptr > ) ) );
|
||||||
|
|
||||||
|
collection->resolver()->albums( m_collection, m_artist );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScriptCommand_AllAlbums::reportFailure()
|
||||||
|
{
|
||||||
|
emit albums( QList< Tomahawk::album_ptr >() );
|
||||||
|
emit done();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScriptCommand_AllAlbums::onResolverDone( const QList< Tomahawk::album_ptr >& a )
|
||||||
|
{
|
||||||
|
emit albums( a );
|
||||||
|
emit done();
|
||||||
|
}
|
54
src/libtomahawk/resolvers/ScriptCommand_AllAlbums.h
Normal file
54
src/libtomahawk/resolvers/ScriptCommand_AllAlbums.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SCRIPTCOMMAND_ALLALBUMS_H
|
||||||
|
#define SCRIPTCOMMAND_ALLALBUMS_H
|
||||||
|
|
||||||
|
#include "collection/AlbumsRequest.h"
|
||||||
|
#include "collection/Collection.h"
|
||||||
|
#include "resolvers/ScriptCommand.h"
|
||||||
|
|
||||||
|
class ScriptCommand_AllAlbums : public ScriptCommand
|
||||||
|
, public Tomahawk::AlbumsRequest
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ScriptCommand_AllAlbums( const Tomahawk::collection_ptr& collection,
|
||||||
|
const Tomahawk::artist_ptr& artist,
|
||||||
|
QObject* parent = 0 );
|
||||||
|
virtual ~ScriptCommand_AllAlbums() {}
|
||||||
|
|
||||||
|
virtual void enqueue();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void albums( const QList< Tomahawk::album_ptr >& );
|
||||||
|
void done();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void exec();
|
||||||
|
virtual void reportFailure();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onResolverDone( const QList< Tomahawk::album_ptr >& );
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tomahawk::collection_ptr m_collection;
|
||||||
|
Tomahawk::artist_ptr m_artist;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCRIPTCOMMAND_ALLALBUMS_H
|
@@ -35,7 +35,7 @@ ScriptCommand_AllArtists::enqueue()
|
|||||||
Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
|
Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
|
||||||
if ( collection == 0 )
|
if ( collection == 0 )
|
||||||
{
|
{
|
||||||
emit artists( QList< Tomahawk::artist_ptr >() );
|
reportFailure();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,8 +23,6 @@
|
|||||||
#include "collection/Collection.h"
|
#include "collection/Collection.h"
|
||||||
#include "resolvers/ScriptCommand.h"
|
#include "resolvers/ScriptCommand.h"
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class ScriptCommand_AllArtists : public ScriptCommand
|
class ScriptCommand_AllArtists : public ScriptCommand
|
||||||
, public Tomahawk::ArtistsRequest
|
, public Tomahawk::ArtistsRequest
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user