mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Remove unnecessary Chart type from InfoSytem. It was just mapping
strings, so just use a string map we already have
This commit is contained in:
parent
b2dc6f1f3c
commit
f796f1f133
@ -317,11 +317,14 @@ ChartsPlugin::chartTypes()
|
||||
if ( name.startsWith( "iTunes Store:" ) ) // truncate
|
||||
name = name.mid( 13 );
|
||||
|
||||
const Chart c( id, name, "album" );
|
||||
QList<Chart> countryTypeData = countries[ country ][ type ].value<QList<Chart> >();
|
||||
InfoStringHash c;
|
||||
c[ "id" ] = id;
|
||||
c[ "label" ] = name;
|
||||
c[ "type" ] = "album";
|
||||
QList<InfoStringHash> countryTypeData = countries[ country ][ type ].value< QList< InfoStringHash > >();
|
||||
countryTypeData.append( c );
|
||||
|
||||
countries[ country ].insert( type, QVariant::fromValue<QList<Chart> >( countryTypeData ) );
|
||||
countries[ country ].insert( type, QVariant::fromValue< QList< InfoStringHash > >( countryTypeData ) );
|
||||
}
|
||||
|
||||
foreach( const QString& c, countries.keys() )
|
||||
@ -335,21 +338,28 @@ ChartsPlugin::chartTypes()
|
||||
// We'll just build:
|
||||
// [Source] - Album - Chart Type
|
||||
// [Source] - Track - Chart Type
|
||||
QList< Chart > albumCharts;
|
||||
QList< Chart > trackCharts;
|
||||
QList< InfoStringHash > albumCharts;
|
||||
QList< InfoStringHash > trackCharts;
|
||||
foreach( const QVariant& chartObj, chartObjs.values() )
|
||||
{
|
||||
const QVariantMap chart = chartObj.toMap();
|
||||
const QString type = chart.value( "type" ).toString();
|
||||
const QString id = chart.value( "id" ).toString();
|
||||
const QString name = chart.value( "name" ).toString();
|
||||
InfoStringHash c;
|
||||
c[ "id" ] = chart.value( "id" ).toString();
|
||||
c[ "label" ] = chart.value( "name" ).toString();
|
||||
if ( type == "Album" )
|
||||
albumCharts.append( Chart( id, name, "album" ) );
|
||||
{
|
||||
c[ "type" ] = "album";
|
||||
albumCharts.append( c );
|
||||
}
|
||||
else if ( type == "Track" )
|
||||
trackCharts.append( Chart( id, name, "tracks" ) );
|
||||
{
|
||||
c[ "type" ] = "tracks";
|
||||
trackCharts.append( c );
|
||||
}
|
||||
}
|
||||
charts.insert( tr( "Albums" ), QVariant::fromValue< QList<Chart> >( albumCharts ) );
|
||||
charts.insert( tr( "Tracks" ), QVariant::fromValue< QList<Chart> >( trackCharts ) );
|
||||
charts.insert( tr( "Albums" ), QVariant::fromValue< QList< InfoStringHash > >( albumCharts ) );
|
||||
charts.insert( tr( "Tracks" ), QVariant::fromValue< QList< InfoStringHash > >( trackCharts ) );
|
||||
|
||||
/// @note For displaying purposes, upper the first letter
|
||||
/// @note Remeber to lower it when fetching this!
|
||||
@ -359,7 +369,7 @@ ChartsPlugin::chartTypes()
|
||||
|
||||
/// Add the possible charts and its types to breadcrumb
|
||||
// qDebug() << "ADDING CHART TYPE TO CHARTS:" << chartName;
|
||||
m_allChartsMap.insert( chartName , QVariant::fromValue<QVariantMap>( charts ) );
|
||||
m_allChartsMap.insert( chartName , QVariant::fromValue< QVariantMap >( charts ) );
|
||||
|
||||
}
|
||||
else
|
||||
@ -402,8 +412,8 @@ ChartsPlugin::chartReturned()
|
||||
|
||||
/// SO we have a result, parse it!
|
||||
QVariantList chartResponse = res.value( "list" ).toList();
|
||||
QList<InfoStringHash> top_tracks;
|
||||
QList<InfoStringHash> top_albums;
|
||||
QList< InfoStringHash > top_tracks;
|
||||
QList< InfoStringHash > top_albums;
|
||||
|
||||
/// Deside what type, we need to handle it differently
|
||||
/// @todo: We allready know the type, append it to breadcrumb hash
|
||||
|
@ -67,7 +67,7 @@ private:
|
||||
void dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
QVariantList m_chartResources;
|
||||
QList<Chart> m_charts;
|
||||
QList<InfoStringHash> m_charts;
|
||||
ChartType m_chartType;
|
||||
|
||||
QVariantMap m_allChartsMap;
|
||||
|
@ -434,18 +434,33 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
|
||||
case InfoChartCapabilities:
|
||||
{
|
||||
QList<Chart> track_charts;
|
||||
track_charts.append( Chart( "chart.getTopTracks", "Top Tracks", "tracks" ) );
|
||||
track_charts.append( Chart( "chart.getLovedTracks", "Loved Tracks", "tracks" ) );
|
||||
track_charts.append( Chart( "chart.getHypedTracks", "Hyped Tracks", "tracks" ) );
|
||||
QList< InfoStringHash > track_charts;
|
||||
InfoStringHash c;
|
||||
c[ "type" ] = "tracks";
|
||||
c[ "id" ] = "chart.getTopTracks";
|
||||
c[ "label" ] = "Top Tracks";
|
||||
track_charts.append( c );
|
||||
c[ "id" ] = "chart.getLovedTracks";
|
||||
c[ "label" ] = "Loved Tracks";
|
||||
track_charts.append( c );
|
||||
c[ "id" ] = "chart.getHypedTracks";
|
||||
c[ "label" ] = "Hyped Tracks";
|
||||
track_charts.append( c );
|
||||
|
||||
QList<Chart> artist_charts;
|
||||
artist_charts.append( Chart( "chart.getTopArtists", "Top Artists", "artists" ) );
|
||||
artist_charts.append( Chart( "chart.getHypedArtists", "Hyped Artists", "artists" ) );
|
||||
QList< InfoStringHash > artist_charts;
|
||||
c[ "type" ] = "artists";
|
||||
c[ "id" ] = "chart.getTopArtists";
|
||||
c[ "label" ] = "Top Artists";
|
||||
artist_charts.append( c );
|
||||
c[ "id" ] = "chart.getHypedArtists";
|
||||
c[ "label" ] = "Hyped Artists";
|
||||
artist_charts.append( c );
|
||||
|
||||
|
||||
|
||||
QVariantMap charts;
|
||||
charts.insert( "Tracks", QVariant::fromValue<QList<Chart> >( track_charts ) );
|
||||
charts.insert( "Artists", QVariant::fromValue<QList<Chart> >( artist_charts ) );
|
||||
charts.insert( "Tracks", QVariant::fromValue< QList< InfoStringHash > >( track_charts ) );
|
||||
charts.insert( "Artists", QVariant::fromValue< QList< InfoStringHash > >( artist_charts ) );
|
||||
|
||||
QVariantMap result;
|
||||
result.insert( "Last.fm", QVariant::fromValue<QVariantMap>( charts ) );
|
||||
|
@ -130,18 +130,6 @@ struct InfoRequestData {
|
||||
QVariantMap customData;
|
||||
};
|
||||
|
||||
struct Chart {
|
||||
Chart(){}
|
||||
Chart(const QString _id, const QString _label, const QString _type) {
|
||||
id = _id;
|
||||
label = _label;
|
||||
type = _type;
|
||||
}
|
||||
QString id;
|
||||
QString label;
|
||||
QString type;
|
||||
};
|
||||
|
||||
typedef QMap< InfoType, QVariant > InfoTypeMap;
|
||||
typedef QMap< InfoType, uint > InfoTimeoutMap;
|
||||
typedef QHash< QString, QString > InfoStringHash;
|
||||
@ -276,8 +264,6 @@ inline uint qHash( Tomahawk::InfoSystem::InfoStringHash hash )
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoRequestData );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoStringHash );
|
||||
Q_DECLARE_METATYPE( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::Chart );
|
||||
Q_DECLARE_METATYPE( QList<Tomahawk::InfoSystem::InfoStringHash> );
|
||||
Q_DECLARE_METATYPE( QList<Tomahawk::InfoSystem::Chart> );
|
||||
|
||||
#endif // TOMAHAWK_INFOSYSTEM_H
|
||||
|
@ -334,13 +334,13 @@ WhatsHotWidget::parseNode( QStandardItem* parentItem, const QString &label, cons
|
||||
|
||||
QStandardItem *sourceItem = new QStandardItem(label);
|
||||
|
||||
if ( data.canConvert<QList<Tomahawk::InfoSystem::Chart> >() )
|
||||
if ( data.canConvert< QList< Tomahawk::InfoSystem::InfoStringHash > >() )
|
||||
{
|
||||
QList<Tomahawk::InfoSystem::Chart> charts = data.value<QList<Tomahawk::InfoSystem::Chart> >();
|
||||
foreach ( Tomahawk::InfoSystem::Chart chart, charts)
|
||||
QList< Tomahawk::InfoSystem::InfoStringHash > charts = data.value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
|
||||
foreach ( Tomahawk::InfoSystem::InfoStringHash chart, charts )
|
||||
{
|
||||
QStandardItem *childItem= new QStandardItem( chart.label );
|
||||
childItem->setData( chart.id );
|
||||
QStandardItem *childItem= new QStandardItem( chart[ "label" ] );
|
||||
childItem->setData( chart[ "id" ] );
|
||||
sourceItem->appendRow( childItem );
|
||||
}
|
||||
}
|
||||
|
@ -414,8 +414,6 @@ TomahawkApp::registerMetaTypes()
|
||||
qRegisterMetaType< QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > >( "QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache >" );
|
||||
|
||||
qRegisterMetaType< QList<Tomahawk::InfoSystem::InfoStringHash> >("QList<Tomahawk::InfoSystem::InfoStringHash>");
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::Chart>("Tomahawk::InfoSystem::Chart");
|
||||
qRegisterMetaType< QList<Tomahawk::InfoSystem::Chart> >("QList<Tomahawk::InfoSystem::Chart>");
|
||||
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user