mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
Merge branch 'master' of github.com:tomahawk-player/tomahawk
This commit is contained in:
@@ -30,10 +30,11 @@
|
|||||||
#include <qstringlistmodel.h>
|
#include <qstringlistmodel.h>
|
||||||
|
|
||||||
QHash< QString, QStringList > Tomahawk::EchonestControl::s_suggestCache = QHash< QString, QStringList >();
|
QHash< QString, QStringList > Tomahawk::EchonestControl::s_suggestCache = QHash< QString, QStringList >();
|
||||||
|
bool Tomahawk::EchonestControl::s_fetchingMoodsAndStyles = false;
|
||||||
|
int Tomahawk::EchonestControl::s_stylePollCount = 0;
|
||||||
|
|
||||||
Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent )
|
Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent )
|
||||||
: DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent )
|
: DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent )
|
||||||
, m_stylePollCount( 0 )
|
|
||||||
{
|
{
|
||||||
setType( "echonest" );
|
setType( "echonest" );
|
||||||
m_editingTimer.setInterval( 500 ); //timeout to edits
|
m_editingTimer.setInterval( 500 ); //timeout to edits
|
||||||
@@ -705,6 +706,7 @@ Tomahawk::EchonestControl::calculateSummary()
|
|||||||
void
|
void
|
||||||
Tomahawk::EchonestControl::checkForMoodsOrStylesFetched()
|
Tomahawk::EchonestControl::checkForMoodsOrStylesFetched()
|
||||||
{
|
{
|
||||||
|
s_fetchingMoodsAndStyles = false;
|
||||||
if( selectedType() == "Mood" || selectedType() == "Style" ) {
|
if( selectedType() == "Mood" || selectedType() == "Style" ) {
|
||||||
QComboBox* cb = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* cb = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if( cb && cb->count() == 0 ) { // got nothing, so lets populate
|
if( cb && cb->count() == 0 ) { // got nothing, so lets populate
|
||||||
@@ -722,16 +724,16 @@ Tomahawk::EchonestControl::insertMoodsAndStyles()
|
|||||||
if( !combo )
|
if( !combo )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qDebug() << "Inserting moods and or styles, here's the list" << src;
|
|
||||||
foreach( const QString& item, src ) {
|
foreach( const QString& item, src ) {
|
||||||
combo->addItem( item, item );
|
combo->addItem( item, item );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( src.isEmpty() && !combo->count() ) {
|
if( src.isEmpty() && !combo->count() ) {
|
||||||
if( m_stylePollCount <= 20 ) { // try for 20s to get the styles...
|
if( s_stylePollCount <= 20 && !s_fetchingMoodsAndStyles ) { // try for 20s to get the styles...
|
||||||
|
s_fetchingMoodsAndStyles = true;
|
||||||
QTimer::singleShot( 1000, this, SLOT( checkForMoodsOrStylesFetched() ) );
|
QTimer::singleShot( 1000, this, SLOT( checkForMoodsOrStylesFetched() ) );
|
||||||
}
|
}
|
||||||
m_stylePollCount++;
|
s_stylePollCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,7 +91,8 @@ private:
|
|||||||
|
|
||||||
Echonest::DynamicPlaylist::PlaylistParamData m_data;
|
Echonest::DynamicPlaylist::PlaylistParamData m_data;
|
||||||
QVariant m_cacheData;
|
QVariant m_cacheData;
|
||||||
int m_stylePollCount;
|
static bool s_fetchingMoodsAndStyles;
|
||||||
|
static int s_stylePollCount;
|
||||||
|
|
||||||
QSet< QNetworkReply* > m_suggestWorkers;
|
QSet< QNetworkReply* > m_suggestWorkers;
|
||||||
static QHash< QString, QStringList > s_suggestCache;
|
static QHash< QString, QStringList > s_suggestCache;
|
||||||
|
@@ -26,6 +26,8 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
QVector< QString > EchonestGenerator::s_moods = QVector< QString >();
|
QVector< QString > EchonestGenerator::s_moods = QVector< QString >();
|
||||||
QVector< QString > EchonestGenerator::s_styles = QVector< QString >();
|
QVector< QString > EchonestGenerator::s_styles = QVector< QString >();
|
||||||
|
QNetworkReply* EchonestGenerator::s_moodsJob = 0;
|
||||||
|
QNetworkReply* EchonestGenerator::s_stylesJob = 0;
|
||||||
|
|
||||||
EchonestFactory::EchonestFactory()
|
EchonestFactory::EchonestFactory()
|
||||||
{}
|
{}
|
||||||
@@ -59,12 +61,14 @@ EchonestGenerator::EchonestGenerator ( QObject* parent )
|
|||||||
m_mode = OnDemand;
|
m_mode = OnDemand;
|
||||||
m_logo.load( RESPATH "/images/echonest_logo.png" );
|
m_logo.load( RESPATH "/images/echonest_logo.png" );
|
||||||
|
|
||||||
|
if( !s_stylesJob && s_styles.isEmpty() ) {
|
||||||
// fetch style and moods
|
// fetch style and moods
|
||||||
QNetworkReply* style = Echonest::Artist::listTerms( "style" );
|
s_stylesJob = Echonest::Artist::listTerms( "style" );
|
||||||
connect( style, SIGNAL( finished() ), this, SLOT( stylesReceived() ) );
|
connect( s_stylesJob, SIGNAL( finished() ), this, SLOT( stylesReceived() ) );
|
||||||
|
} else if( !s_moodsJob && s_moods.isEmpty() ) {
|
||||||
QNetworkReply* moods = Echonest::Artist::listTerms( "mood" );
|
s_moodsJob = Echonest::Artist::listTerms( "mood" );
|
||||||
connect( moods, SIGNAL( finished() ), this, SLOT( moodsReceived() ) );
|
connect( s_moodsJob, SIGNAL( finished() ), this, SLOT( moodsReceived() ) );
|
||||||
|
}
|
||||||
|
|
||||||
// qDebug() << "ECHONEST:" << m_logo.size();
|
// qDebug() << "ECHONEST:" << m_logo.size();
|
||||||
}
|
}
|
||||||
@@ -530,6 +534,7 @@ EchonestGenerator::moodsReceived()
|
|||||||
} catch( Echonest::ParseError& e ) {
|
} catch( Echonest::ParseError& e ) {
|
||||||
qWarning() << "Echonest failed to parse moods list";
|
qWarning() << "Echonest failed to parse moods list";
|
||||||
}
|
}
|
||||||
|
s_moodsJob = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector< QString >
|
QVector< QString >
|
||||||
@@ -549,4 +554,5 @@ EchonestGenerator::stylesReceived()
|
|||||||
} catch( Echonest::ParseError& e ) {
|
} catch( Echonest::ParseError& e ) {
|
||||||
qWarning() << "Echonest failed to parse styles list";
|
qWarning() << "Echonest failed to parse styles list";
|
||||||
}
|
}
|
||||||
|
s_stylesJob = 0;
|
||||||
}
|
}
|
||||||
|
@@ -95,6 +95,8 @@ private:
|
|||||||
|
|
||||||
static QVector< QString > s_styles;
|
static QVector< QString > s_styles;
|
||||||
static QVector< QString > s_moods;
|
static QVector< QString > s_moods;
|
||||||
|
static QNetworkReply* s_stylesJob;
|
||||||
|
static QNetworkReply* s_moodsJob;
|
||||||
|
|
||||||
// used for the intermediary song id lookup
|
// used for the intermediary song id lookup
|
||||||
QSet< QNetworkReply* > m_waiting;
|
QSet< QNetworkReply* > m_waiting;
|
||||||
|
Reference in New Issue
Block a user