mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Return the chart list if we receive it after the infosystem request
This commit is contained in:
parent
d07f191a1e
commit
f4f9a148af
@ -222,18 +222,20 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
emit info(
|
||||
requestId,
|
||||
requestData,
|
||||
m_result
|
||||
m_allChartsMap
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -269,11 +271,12 @@ ChartsPlugin::chartTypes()
|
||||
}
|
||||
|
||||
/// Got types, append!
|
||||
foreach(QVariant chart, res.value( "charts" ).toMap() ){
|
||||
m_chartTypes.append(chart);
|
||||
|
||||
foreach ( QVariant chart, res.value( "charts" ).toMap() )
|
||||
{
|
||||
m_chartTypes.append( chart );
|
||||
}
|
||||
|
||||
tDebug() << "Chart types we got:" << m_chartType;
|
||||
/// Itunes have alot of country specified charts,
|
||||
/// Get those for later use
|
||||
QList<QString> geos;
|
||||
@ -337,22 +340,24 @@ ChartsPlugin::chartTypes()
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Billboard, and maybe others
|
||||
foreach( QVariant type, m_chartTypes )
|
||||
foreach ( QVariant type, m_chartTypes )
|
||||
{
|
||||
|
||||
/// Append each type to its parent source
|
||||
/// @todo Add chartType enum
|
||||
if( type.toMap().value( "source" ).toString() == chartResource.toString() )
|
||||
if ( type.toMap().value( "source" ).toString() == chartResource.toString() )
|
||||
{
|
||||
if( type.toMap().value( "type" ).toString() == "Album" )
|
||||
if ( type.toMap().value( "type" ).toString() == "Album" )
|
||||
{
|
||||
album_charts.append( Chart( type.toMap().value("id").toString(), type.toMap().value("name").toString(), "album" ) );
|
||||
charts.insert( "Albums", QVariant::fromValue<QList<Chart> >( album_charts ) );
|
||||
}
|
||||
|
||||
if( type.toMap().value( "type" ).toString() == "Track" )
|
||||
if ( type.toMap().value( "type" ).toString() == "Track" )
|
||||
{
|
||||
track_charts.append( Chart( type.toMap().value("id").toString(), type.toMap().value("name").toString(), "tracks" ) );
|
||||
charts.insert( "Tracks", QVariant::fromValue<QList<Chart> >( track_charts ) );
|
||||
@ -367,9 +372,23 @@ ChartsPlugin::chartTypes()
|
||||
chartName[0] = chartName[0].toUpper();
|
||||
|
||||
/// 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,9 +71,10 @@ private:
|
||||
QList<Chart> m_charts;
|
||||
ChartType m_chartType;
|
||||
|
||||
QVariantMap m_result;
|
||||
QVariantMap m_chartResult;
|
||||
bool chartHasReturned;
|
||||
QVariantMap m_allChartsMap;
|
||||
|
||||
QList< QPair< uint, InfoRequestData > > m_cachedRequests;
|
||||
|
||||
QWeakPointer< QNetworkAccessManager > m_nam;
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,7 @@ InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||
, m_cacheVersion( 2 )
|
||||
{
|
||||
TomahawkSettings *s = TomahawkSettings::instance();
|
||||
if( s->infoSystemCacheVersion() != m_cacheVersion )
|
||||
if ( s->infoSystemCacheVersion() != m_cacheVersion )
|
||||
{
|
||||
tLog() << "Cache version outdated, old:" << s->infoSystemCacheVersion()
|
||||
<< "new:" << m_cacheVersion
|
||||
|
Loading…
x
Reference in New Issue
Block a user