1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 21:57:41 +02:00

Return the chart list if we receive it after the infosystem request

This commit is contained in:
Leo Franchi
2011-10-14 16:07:14 -04:00
parent d07f191a1e
commit f4f9a148af
3 changed files with 37 additions and 17 deletions

View File

@@ -222,18 +222,20 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
case InfoChartCapabilities: case InfoChartCapabilities:
{ {
if( m_result.isEmpty() ){ if ( m_allChartsMap.isEmpty() )
{
qDebug() << Q_FUNC_INFO << "InfoChartCapabilities is empty!"; qDebug() << Q_FUNC_INFO << "InfoChartCapabilities is empty, probably still fetching!";
m_cachedRequests.append( QPair< uint, InfoRequestData >( requestId, requestData ) );;
dataError( requestId, requestData ); // dataError( requestId, requestData );
return; return;
} }
emit info( emit info(
requestId, requestId,
requestData, requestData,
m_result m_allChartsMap
); );
return; return;
} }
@@ -269,11 +271,12 @@ ChartsPlugin::chartTypes()
} }
/// Got types, append! /// Got types, append!
foreach(QVariant chart, res.value( "charts" ).toMap() ){ foreach ( QVariant chart, res.value( "charts" ).toMap() )
{
m_chartTypes.append( chart ); m_chartTypes.append( chart );
} }
tDebug() << "Chart types we got:" << m_chartType;
/// Itunes have alot of country specified charts, /// Itunes have alot of country specified charts,
/// Get those for later use /// Get those for later use
QList<QString> geos; QList<QString> geos;
@@ -337,7 +340,9 @@ ChartsPlugin::chartTypes()
} }
} }
}else{ }
else
{
/// Billboard, and maybe others /// Billboard, and maybe others
foreach ( QVariant type, m_chartTypes ) foreach ( QVariant type, m_chartTypes )
{ {
@@ -367,9 +372,23 @@ ChartsPlugin::chartTypes()
chartName[0] = chartName[0].toUpper(); chartName[0] = chartName[0].toUpper();
/// Add the possible charts and its types to breadcrumb /// Add the possible charts and its types to breadcrumb
m_result.insert( chartName , QVariant::fromValue<QVariantMap>( charts ) ); m_allChartsMap.insert( chartName , QVariant::fromValue<QVariantMap>( charts ) );
} }
} }
else
{
tLog() << "Error fetching charts:" << reply->errorString();
}
if ( !m_cachedRequests.isEmpty() )
{
QPair< uint, InfoRequestData > request;
foreach ( request, m_cachedRequests )
{
emit info( request.first, request.second, m_allChartsMap );
}
m_cachedRequests.clear();
}
} }

View File

@@ -71,9 +71,10 @@ private:
QList<Chart> m_charts; QList<Chart> m_charts;
ChartType m_chartType; ChartType m_chartType;
QVariantMap m_result; QVariantMap m_allChartsMap;
QVariantMap m_chartResult;
bool chartHasReturned; QList< QPair< uint, InfoRequestData > > m_cachedRequests;
QWeakPointer< QNetworkAccessManager > m_nam; QWeakPointer< QNetworkAccessManager > m_nam;
}; };