1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-14 01:54:07 +02:00

Port Genre parsing & datatypes to new API

This commit is contained in:
Stefan Derkits
2014-09-09 14:50:50 +02:00
parent 020c6f5bc1
commit 6bf379dd39
3 changed files with 14 additions and 10 deletions

View File

@@ -1038,7 +1038,10 @@ Tomahawk::EchonestControl::insertMoodsStylesAndGenres()
}
else
{
src = EchonestGenerator::genres();
foreach( const Echonest::Genre& genre, EchonestGenerator::genres() )
{
src.append( genre.name() );
}
}
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );

View File

@@ -33,14 +33,13 @@
#include <QDir>
#include <QReadWriteLock>
#include <EchonestCatalogSynchronizer.h>
#include <echonest/Genre.h>
using namespace Tomahawk;
QStringList EchonestGenerator::s_moods = QStringList();
QStringList EchonestGenerator::s_styles = QStringList();
QStringList EchonestGenerator::s_genres = QStringList();
Echonest::Genres EchonestGenerator::s_genres = Echonest::Genres();
QNetworkReply* EchonestGenerator::s_moodsJob = 0;
QNetworkReply* EchonestGenerator::s_stylesJob = 0;
QNetworkReply* EchonestGenerator::s_genresJob = 0;
@@ -707,9 +706,9 @@ EchonestGenerator::loadGenres()
{
QVariant genres = TomahawkUtils::Cache::instance()->getData( "EchonestGenerator", "genres" );
s_genres_lock.unlock();
if ( genres.isValid() && genres.canConvert< QStringList >() )
if ( genres.isValid() && genres.canConvert< Echonest::Genres >() )
{
s_genres = genres.toStringList();
s_genres = genres.value< Echonest::Genres >();
}
else
{
@@ -785,7 +784,7 @@ EchonestGenerator::stylesReceived()
emit stylesSaved();
}
QStringList
Echonest::Genres
EchonestGenerator::genres()
{
return s_genres;
@@ -800,7 +799,7 @@ EchonestGenerator::genresReceived()
try
{
s_genres = Echonest::Artist::parseGenreList( r ).toList();
s_genres = Echonest::Genre::parseList( r );
}
catch( Echonest::ParseError& e )
{
@@ -808,7 +807,7 @@ EchonestGenerator::genresReceived()
}
s_genresJob = 0;
TomahawkUtils::Cache::instance()->putData( "EchonestGenerator", 1209600000 /* 2 weeks */, "genres", QVariant::fromValue< QStringList >( s_genres ) );
TomahawkUtils::Cache::instance()->putData( "EchonestGenerator", 1209600000 /* 2 weeks */, "genres", QVariant::fromValue< Echonest::Genres >( s_genres ) );
s_genres_lock.unlock();
emit genresSaved();
}

View File

@@ -31,8 +31,10 @@
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include <echonest5/Playlist.h>
#include <echonest5/Genre.h>
#else
#include <echonest/Playlist.h>
#include <echonest/Genre.h>
#endif
namespace Tomahawk
@@ -88,7 +90,7 @@ public:
static QStringList styles();
static QStringList moods();
static QStringList genres();
static Echonest::Genres genres();
static QStringList userCatalogs();
static QByteArray catalogId( const QString& collectionId );
@@ -133,7 +135,7 @@ private:
static QStringList s_styles;
static QStringList s_moods;
static QStringList s_genres;
static Echonest::Genres s_genres;
static QNetworkReply* s_stylesJob;
static QNetworkReply* s_moodsJob;
static QNetworkReply* s_genresJob;