From a520f7bff3f8f4fdce792c19d389f3f541d33fe3 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 11 Oct 2011 09:08:55 -0400 Subject: [PATCH] Remove InfoGenericMap --- .../infoplugins/generic/echonestplugin.cpp | 45 ++++++++++--------- src/libtomahawk/infosystem/infosystem.h | 2 - .../widgets/infowidgets/ArtistInfoWidget.cpp | 4 +- src/tomahawkapp.cpp | 1 - 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp index bdcf190eb..a975dbe08 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp @@ -182,21 +182,22 @@ EchoNestPlugin::getArtistBiographySlot() QNetworkReply* reply = qobject_cast( sender() ); Echonest::Artist artist = artistFromReply( reply ); BiographyList biographies = artist.biographies(); - InfoGenericMap biographyMap; - Q_FOREACH(const Biography& biography, biographies) + QVariantMap biographyMap; + Q_FOREACH( const Biography& biography, biographies ) { - biographyMap[biography.site()]["site"] = biography.site(); - biographyMap[biography.site()]["url"] = biography.url().toString(); - biographyMap[biography.site()]["text"] = biography.text(); - biographyMap[biography.site()]["attribution"] = biography.license().attribution; - biographyMap[biography.site()]["licensetype"] = biography.license().type; - biographyMap[biography.site()]["attribution"] = biography.license().url.toString(); - + QVariantHash siteData; + siteData[ "site" ] = biography.site(); + siteData[ "url" ] = biography.url().toString(); + siteData[ "text" ] = biography.text(); + siteData[ "attribution" ] = biography.license().attribution; + siteData[ "licensetype" ] = biography.license().type; + siteData[ "attribution" ] = biography.license().url.toString(); + biographyMap[ biography.site() ] = siteData; } Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); emit info( reply->property( "requestId" ).toUInt(), requestData, - QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( biographyMap ) ); + biographyMap ); reply->deleteLater(); } @@ -232,17 +233,17 @@ EchoNestPlugin::getArtistTermsSlot() QNetworkReply* reply = qobject_cast( sender() ); Echonest::Artist artist = artistFromReply( reply ); TermList terms = artist.terms(); - InfoGenericMap termsMap; + QVariantMap termsMap; Q_FOREACH( const Echonest::Term& term, terms ) { - QMap< QString, QString > termMap; - termMap[ "weight" ] = QString::number(term.weight()); - termMap[ "frequency" ] = QString::number(term.frequency()); - termsMap[ term.name() ] = termMap; + QVariantHash termHash; + termHash[ "weight" ] = QString::number( term.weight() ); + termHash[ "frequency" ] = QString::number( term.frequency() ); + termsMap[ term.name() ] = termHash; } Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); emit info( reply->property( "requestId" ).toUInt(), requestData, - QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ) ); + termsMap ); reply->deleteLater(); } @@ -251,17 +252,17 @@ EchoNestPlugin::getMiscTopSlot() { QNetworkReply* reply = qobject_cast( sender() ); TermList terms = Echonest::Artist::parseTopTerms( reply ); - InfoGenericMap termsMap; + QVariantMap termsMap; Q_FOREACH( const Echonest::Term& term, terms ) { - QMap< QString, QString > termMap; - termMap[ "weight" ] = QString::number( term.weight() ); - termMap[ "frequency" ] = QString::number( term.frequency() ); - termsMap[ term.name().toLower() ] = termMap; + QVariantHash termHash; + termHash[ "weight" ] = QString::number( term.weight() ); + termHash[ "frequency" ] = QString::number( term.frequency() ); + termsMap[ term.name() ] = termHash; } Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); emit info( reply->property( "requestId" ).toUInt(), requestData, - QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ) ); + termsMap ); reply->deleteLater(); } diff --git a/src/libtomahawk/infosystem/infosystem.h b/src/libtomahawk/infosystem/infosystem.h index 23ea52246..a0df8fdfb 100644 --- a/src/libtomahawk/infosystem/infosystem.h +++ b/src/libtomahawk/infosystem/infosystem.h @@ -154,7 +154,6 @@ struct Chart { typedef QMap< InfoType, QVariant > InfoTypeMap; typedef QMap< InfoType, uint > InfoTimeoutMap; -typedef QMap< QString, QMap< QString, QString > > InfoGenericMap; typedef QHash< QString, QString > InfoCriteriaHash; class DLLEXPORT InfoPlugin : public QObject @@ -285,7 +284,6 @@ inline uint qHash( Tomahawk::InfoSystem::InfoCriteriaHash hash ) } Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoRequestData ); -Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCriteriaHash ); Q_DECLARE_METATYPE( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::ArtistTrackPair ); diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp index 05837acf3..73ecc14c0 100644 --- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp +++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp @@ -154,12 +154,12 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD { case InfoSystem::InfoArtistBiography: { - InfoSystem::InfoGenericMap bmap = output.value< Tomahawk::InfoSystem::InfoGenericMap >(); + QVariantMap bmap = output.toMap(); foreach ( const QString& source, bmap.keys() ) { if ( m_longDescription.isEmpty() || source == "last.fm" ) - m_longDescription = bmap[source]["text"]; + m_longDescription = bmap[ source ].toHash()[ "text" ].toString(); } emit longDescriptionChanged( m_longDescription ); break; diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 4b78abd85..060600466 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -399,7 +399,6 @@ TomahawkApp::registerMetaTypes() qRegisterMetaType< AudioErrorCode >("AudioErrorCode"); - qRegisterMetaType< QMap< QString, QMap< QString, QString > > >( "Tomahawk::InfoSystem::InfoGenericMap" ); qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoCriteriaHash" ); qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" ); qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );