mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
fix up checking for moods and styles
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
|
||||||
@@ -728,10 +730,11 @@ Tomahawk::EchonestControl::insertMoodsAndStyles()
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user