diff --git a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp index 8c6da8048..924e42a89 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp @@ -317,11 +317,14 @@ ChartsPlugin::chartTypes() if ( name.startsWith( "iTunes Store:" ) ) // truncate name = name.mid( 13 ); - const Chart c( id, name, "album" ); - QList countryTypeData = countries[ country ][ type ].value >(); + InfoStringHash c; + c[ "id" ] = id; + c[ "label" ] = name; + c[ "type" ] = "album"; + QList countryTypeData = countries[ country ][ type ].value< QList< InfoStringHash > >(); countryTypeData.append( c ); - countries[ country ].insert( type, QVariant::fromValue >( 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 >( albumCharts ) ); - charts.insert( tr( "Tracks" ), QVariant::fromValue< QList >( 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( 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 top_tracks; - QList 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 diff --git a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h index 3a75f1f0b..3d35b39cf 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h +++ b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h @@ -67,7 +67,7 @@ private: void dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData ); QVariantList m_chartResources; - QList m_charts; + QList m_charts; ChartType m_chartType; QVariantMap m_allChartsMap; diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp index 8b5d477bd..ae99903ec 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp @@ -434,18 +434,33 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash criteria, case InfoChartCapabilities: { - QList 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 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 >( track_charts ) ); - charts.insert( "Artists", QVariant::fromValue >( 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( charts ) ); diff --git a/src/libtomahawk/infosystem/infosystem.h b/src/libtomahawk/infosystem/infosystem.h index ee6662037..ebef34a42 100644 --- a/src/libtomahawk/infosystem/infosystem.h +++ b/src/libtomahawk/infosystem/infosystem.h @@ -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 ); -Q_DECLARE_METATYPE( QList ); #endif // TOMAHAWK_INFOSYSTEM_H diff --git a/src/libtomahawk/widgets/whatshotwidget.cpp b/src/libtomahawk/widgets/whatshotwidget.cpp index 38e444ee3..3f2fb795c 100644 --- a/src/libtomahawk/widgets/whatshotwidget.cpp +++ b/src/libtomahawk/widgets/whatshotwidget.cpp @@ -334,13 +334,13 @@ WhatsHotWidget::parseNode( QStandardItem* parentItem, const QString &label, cons QStandardItem *sourceItem = new QStandardItem(label); - if ( data.canConvert >() ) + if ( data.canConvert< QList< Tomahawk::InfoSystem::InfoStringHash > >() ) { - QList charts = data.value >(); - 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 ); } } diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 798684eab..c2a3c098b 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -414,8 +414,6 @@ TomahawkApp::registerMetaTypes() qRegisterMetaType< QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > >( "QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache >" ); qRegisterMetaType< QList >("QList"); - qRegisterMetaType< Tomahawk::InfoSystem::Chart>("Tomahawk::InfoSystem::Chart"); - qRegisterMetaType< QList >("QList"); qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" ); }