mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
Maybe a fix for breadcrumb problems
This commit is contained in:
@@ -70,9 +70,11 @@ ChartsPlugin::namChangedSlot( QNetworkAccessManager *nam )
|
|||||||
m_nam = QWeakPointer< QNetworkAccessManager >( nam );
|
m_nam = QWeakPointer< QNetworkAccessManager >( nam );
|
||||||
|
|
||||||
/// Then get each chart from resource
|
/// Then get each chart from resource
|
||||||
if( !m_chartResources.isEmpty() && m_nam && m_chartTypes.isEmpty() ){
|
/// We need to fetch them before they are asked for
|
||||||
tDebug() << "ChartsPlugin: InfoChart fetching possible resources";
|
|
||||||
|
|
||||||
|
if( !m_chartResources.isEmpty() && m_nam && m_chartTypes.isEmpty() ){
|
||||||
|
|
||||||
|
tDebug() << "ChartsPlugin: InfoChart fetching possible resources";
|
||||||
foreach(QVariant resource, m_chartResources)
|
foreach(QVariant resource, m_chartResources)
|
||||||
{
|
{
|
||||||
QUrl url = QUrl( QString( CHART_URL "source/%1" ).arg(resource.toString() ) );
|
QUrl url = QUrl( QString( CHART_URL "source/%1" ).arg(resource.toString() ) );
|
||||||
@@ -220,8 +222,57 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
|||||||
|
|
||||||
case InfoChartCapabilities:
|
case InfoChartCapabilities:
|
||||||
{
|
{
|
||||||
|
if( m_result.isEmpty() ){
|
||||||
|
|
||||||
QVariantMap result;
|
qDebug() << Q_FUNC_INFO << "InfoChartCapabilities is empty!";
|
||||||
|
|
||||||
|
dataError( requestId, requestData );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit info(
|
||||||
|
requestId,
|
||||||
|
requestData,
|
||||||
|
m_result
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
tLog() << Q_FUNC_INFO << "Couldn't figure out what to do with this type of request after cache miss";
|
||||||
|
emit info( requestId, requestData, QVariant() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ChartsPlugin::chartTypes()
|
||||||
|
{
|
||||||
|
/// Get possible chart type for specific chart source
|
||||||
|
tDebug() << "ChartsPlugin: InfoChart types returned!";
|
||||||
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
|
|
||||||
|
if ( reply->error() == QNetworkReply::NoError )
|
||||||
|
{
|
||||||
|
QJson::Parser p;
|
||||||
|
bool ok;
|
||||||
|
QVariantMap res = p.parse( reply, &ok ).toMap();
|
||||||
|
|
||||||
|
if ( !ok )
|
||||||
|
{
|
||||||
|
tLog() << "Failed to parse resources" << p.errorString() << "On line" << p.errorLine();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Got types, append!
|
||||||
|
foreach(QVariant chart, res.value( "charts" ).toMap() ){
|
||||||
|
m_chartTypes.append(chart);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Itunes have alot of country specified charts,
|
/// Itunes have alot of country specified charts,
|
||||||
/// Get those for later use
|
/// Get those for later use
|
||||||
@@ -316,50 +367,7 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
|||||||
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
|
||||||
result.insert( chartName , QVariant::fromValue<QVariantMap>( charts ) );
|
m_result.insert( chartName , QVariant::fromValue<QVariantMap>( charts ) );
|
||||||
}
|
|
||||||
emit info(
|
|
||||||
requestId,
|
|
||||||
requestData,
|
|
||||||
result
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
tLog() << Q_FUNC_INFO << "Couldn't figure out what to do with this type of request after cache miss";
|
|
||||||
emit info( requestId, requestData, QVariant() );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ChartsPlugin::chartTypes()
|
|
||||||
{
|
|
||||||
/// Get possible chart type for specific chart source
|
|
||||||
tDebug() << "ChartsPlugin: InfoChart types returned!";
|
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
|
||||||
|
|
||||||
if ( reply->error() == QNetworkReply::NoError )
|
|
||||||
{
|
|
||||||
QJson::Parser p;
|
|
||||||
bool ok;
|
|
||||||
QVariantMap res = p.parse( reply, &ok ).toMap();
|
|
||||||
|
|
||||||
if ( !ok )
|
|
||||||
{
|
|
||||||
tLog() << "Failed to parse resources" << p.errorString() << "On line" << p.errorLine();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Got types, append!
|
|
||||||
foreach(QVariant chart, res.value( "charts" ).toMap() ){
|
|
||||||
m_chartTypes.append(chart);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,6 +71,7 @@ private:
|
|||||||
QList<Chart> m_charts;
|
QList<Chart> m_charts;
|
||||||
ChartType m_chartType;
|
ChartType m_chartType;
|
||||||
|
|
||||||
|
QVariantMap m_result;
|
||||||
QVariantMap m_chartResult;
|
QVariantMap m_chartResult;
|
||||||
bool chartHasReturned;
|
bool chartHasReturned;
|
||||||
QWeakPointer< QNetworkAccessManager > m_nam;
|
QWeakPointer< QNetworkAccessManager > m_nam;
|
||||||
|
Reference in New Issue
Block a user