1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-11 03:21:52 +02:00

fix up checking for moods and styles

This commit is contained in:
Leo Franchi 2011-06-05 16:40:35 -04:00
parent 73e5828d41
commit aa076684dc
2 changed files with 8 additions and 4 deletions
src/libtomahawk/playlist/dynamic/echonest

@ -30,10 +30,11 @@
#include <qstringlistmodel.h>
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 )
: DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent )
, m_stylePollCount( 0 )
{
setType( "echonest" );
m_editingTimer.setInterval( 500 ); //timeout to edits
@ -705,6 +706,7 @@ Tomahawk::EchonestControl::calculateSummary()
void
Tomahawk::EchonestControl::checkForMoodsOrStylesFetched()
{
s_fetchingMoodsAndStyles = false;
if( selectedType() == "Mood" || selectedType() == "Style" ) {
QComboBox* cb = qobject_cast< QComboBox* >( m_input.data() );
if( cb && cb->count() == 0 ) { // got nothing, so lets populate
@ -728,10 +730,11 @@ Tomahawk::EchonestControl::insertMoodsAndStyles()
}
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() ) );
}
m_stylePollCount++;
s_stylePollCount++;
return false;
}

@ -91,7 +91,8 @@ private:
Echonest::DynamicPlaylist::PlaylistParamData m_data;
QVariant m_cacheData;
int m_stylePollCount;
static bool s_fetchingMoodsAndStyles;
static int s_stylePollCount;
QSet< QNetworkReply* > m_suggestWorkers;
static QHash< QString, QStringList > s_suggestCache;