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