1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

Style fixes.

This commit is contained in:
Christian Muehlhaeuser
2015-04-07 01:35:59 +02:00
parent b22be87979
commit ca05f17911
8 changed files with 38 additions and 60 deletions

View File

@@ -98,11 +98,9 @@ HypemPlugin::HypemPlugin()
} }
HypemPlugin::~HypemPlugin() HypemPlugin::~HypemPlugin()
{ {
qDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
} }
@@ -128,11 +126,8 @@ HypemPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
qDebug() << Q_FUNC_INFO << requestData.customData; qDebug() << Q_FUNC_INFO << requestData.customData;
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >(); InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
switch ( requestData.type ) switch ( requestData.type )
{ {
case InfoChart: case InfoChart:
if ( !hash.contains( "chart_source" ) || hash["chart_source"].toLower() != "hype machine" ) if ( !hash.contains( "chart_source" ) || hash["chart_source"].toLower() != "hype machine" )
{ {
@@ -146,15 +141,16 @@ HypemPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
case InfoChartCapabilities: case InfoChartCapabilities:
fetchChartCapabilities( requestData ); fetchChartCapabilities( requestData );
break; break;
default: default:
dataError( requestData ); dataError( requestData );
} }
} }
void void
HypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{ {
dataError( requestData ); dataError( requestData );
@@ -179,6 +175,7 @@ HypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
emit getCachedInfo( criteria, Q_INT64_C(86400000), requestData ); emit getCachedInfo( criteria, Q_INT64_C(86400000), requestData );
} }
void void
HypemPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
@@ -192,6 +189,7 @@ HypemPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData reque
emit getCachedInfo( criteria, Q_INT64_C(0), requestData ); emit getCachedInfo( criteria, Q_INT64_C(0), requestData );
} }
void void
HypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
@@ -209,8 +207,6 @@ HypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSys
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
return; return;
} }
case InfoChartCapabilities: case InfoChartCapabilities:
@@ -244,32 +240,29 @@ HypemPlugin::chartTypes()
tDebug() << Q_FUNC_INFO << "Got hypem types"; tDebug() << Q_FUNC_INFO << "Got hypem types";
QVariantMap charts; QVariantMap charts;
foreach ( const QVariant& types, m_types )
foreach(QVariant types, m_types )
{ {
QList< InfoStringHash > chart_types; QList< InfoStringHash > chart_types;
QList< InfoStringHash > pop_charts; QList< InfoStringHash > pop_charts;
InfoStringHash c; InfoStringHash c;
if(types.toString() != "Artists") if ( types.toString() != "Artists" )
{ {
if ( types.toString() == "Tracks" )
if(types.toString() == "Tracks")
{ {
foreach ( const QVariant& trackType, m_trackTypes )
foreach(QVariant trackType, m_trackTypes)
{ {
QString typeId; QString typeId;
if(trackType.toString() == "Last 3 Days") if ( trackType.toString() == "Last 3 Days" )
typeId = "popular/3day"; typeId = "popular/3day";
if(trackType.toString() == "Last Week") if ( trackType.toString() == "Last Week" )
typeId = "popular/lastweek"; typeId = "popular/lastweek";
if(trackType.toString() == "No Remixes") if ( trackType.toString() == "No Remixes" )
typeId = "popular/noremix"; typeId = "popular/noremix";
if(trackType.toString() == "On Twitter") if ( trackType.toString() == "On Twitter" )
typeId = "popular/twitter"; typeId = "popular/twitter";
c[ "id" ] = typeId; c[ "id" ] = typeId;
@@ -279,22 +272,19 @@ HypemPlugin::chartTypes()
} }
chart_types.append( pop_charts ); chart_types.append( pop_charts );
} }
else if(types.toString() == "Recent by Tag") else if ( types.toString() == "Recent by Tag" )
{ {
foreach(QVariant tagTypes, m_byTagTypes) foreach ( const QVariant& tagTypes, m_byTagTypes )
{ {
c[ "id" ] = "tags/" + tagTypes.toString().toLower(); c[ "id" ] = "tags/" + tagTypes.toString().toLower();
c[ "label" ] = tagTypes.toString(); c[ "label" ] = tagTypes.toString();
c[ "type" ] = tagTypes.toString(); c[ "type" ] = tagTypes.toString();
chart_types.append( c ); chart_types.append( c );
} }
} }
}
}else else
{ {
InfoStringHash c; InfoStringHash c;
c[ "id" ] = "popular/artists"; c[ "id" ] = "popular/artists";
@@ -306,17 +296,14 @@ HypemPlugin::chartTypes()
charts.insert( types.toString(), QVariant::fromValue<QList< InfoStringHash > >( chart_types ) ); charts.insert( types.toString(), QVariant::fromValue<QList< InfoStringHash > >( chart_types ) );
} }
m_allChartsMap.insert( "Hype Machine", QVariant::fromValue<QVariantMap>( charts ) ); m_allChartsMap.insert( "Hype Machine", QVariant::fromValue<QVariantMap>( charts ) );
qDebug() << "HypemPlugin:Chartstype: " << m_allChartsMap; qDebug() << "HypemPlugin:Chartstype: " << m_allChartsMap;
} }
void void
HypemPlugin::chartReturned() HypemPlugin::chartReturned()
{ {
/// Chart request returned something! Woho /// Chart request returned something! Woho
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() ); QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
reply->deleteLater(); reply->deleteLater();
@@ -363,7 +350,6 @@ HypemPlugin::chartReturned()
top_tracks << pair; top_tracks << pair;
} }
if ( chartType() == Artist ) if ( chartType() == Artist )
top_artists << artist; top_artists << artist;
} }
@@ -376,8 +362,6 @@ HypemPlugin::chartReturned()
returnedData["type"] = "tracks"; returnedData["type"] = "tracks";
} }
if ( chartType() == Artist ) if ( chartType() == Artist )
{ {
tDebug() << "HypemPlugin:" << "\tgot " << top_artists.size() << " artists"; tDebug() << "HypemPlugin:" << "\tgot " << top_artists.size() << " artists";
@@ -386,9 +370,8 @@ HypemPlugin::chartReturned()
} }
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info( requestData, returnedData ); emit info( requestData, returnedData );
// update cache // update cache
Tomahawk::InfoSystem::InfoStringHash criteria; Tomahawk::InfoSystem::InfoStringHash criteria;
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >(); Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
@@ -400,7 +383,6 @@ HypemPlugin::chartReturned()
} }
else else
qDebug() << "Network error in fetching chart:" << reply->url().toString(); qDebug() << "Network error in fetching chart:" << reply->url().toString();
} }
} }

View File

@@ -144,8 +144,6 @@ MusicBrainzPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requ
break; break;
} }
} }
} }
@@ -252,7 +250,6 @@ MusicBrainzPlugin::gotReleasesSlot()
break; break;
} }
} }
} }
@@ -274,7 +271,6 @@ MusicBrainzPlugin::gotRecordingsSlot()
return; return;
} }
QDomNodeList tracksNL = mediumList.at(0).toElement().elementsByTagName( "track" ); QDomNodeList tracksNL = mediumList.at(0).toElement().elementsByTagName( "track" );
QStringList tracksSL; QStringList tracksSL;
for ( int i = 0; i < tracksNL.count(); i++ ) for ( int i = 0; i < tracksNL.count(); i++ )

View File

@@ -80,7 +80,7 @@ bool
MusixMatchPlugin::isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData ) MusixMatchPlugin::isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{ {
emit info( requestData, QVariant() ); emit info( requestData, QVariant() );

View File

@@ -82,6 +82,7 @@ NewReleasesPlugin::~NewReleasesPlugin()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO; tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
} }
/** /**
* @brief NewReleasesPlugin::init * @brief NewReleasesPlugin::init
* Loops through cache expiration timestamps * Loops through cache expiration timestamps
@@ -120,6 +121,7 @@ NewReleasesPlugin::init()
} }
} }
void void
NewReleasesPlugin::dataError( InfoRequestData requestData ) NewReleasesPlugin::dataError( InfoRequestData requestData )
{ {
@@ -131,7 +133,6 @@ NewReleasesPlugin::dataError( InfoRequestData requestData )
void void
NewReleasesPlugin::getInfo( InfoRequestData requestData ) NewReleasesPlugin::getInfo( InfoRequestData requestData )
{ {
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >(); InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
bool foundSource = false; bool foundSource = false;
@@ -372,7 +373,6 @@ NewReleasesPlugin::nrSourcesList()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "MaxAge for " << source << " is 0. Fetching all"; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "MaxAge for " << source << " is 0. Fetching all";
reply->setProperty( "only_source_list", false ); reply->setProperty( "only_source_list", false );
} }
} }
/** /**
@@ -391,6 +391,7 @@ NewReleasesPlugin::nrSourcesList()
} }
} }
void void
NewReleasesPlugin::fetchAllNRSources() NewReleasesPlugin::fetchAllNRSources()
{ {
@@ -530,7 +531,6 @@ NewReleasesPlugin::nrList()
if ( isDefault ) if ( isDefault )
nr[ "default" ] = "true"; nr[ "default" ] = "true";
QList< Tomahawk::InfoSystem::InfoStringHash > extraTypeData = extraType[ nrExtraType ][ extra ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >(); QList< Tomahawk::InfoSystem::InfoStringHash > extraTypeData = extraType[ nrExtraType ][ extra ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
extraTypeData.append( nr ); extraTypeData.append( nr );
extraType[ nrExtraType ][ extra ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( extraTypeData ); extraType[ nrExtraType ][ extra ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( extraTypeData );
@@ -590,7 +590,6 @@ NewReleasesPlugin::nrList()
tLog() << "Unknown newrelease type " << type; tLog() << "Unknown newrelease type " << type;
continue; continue;
} }
} }
foreach ( const QString& c, extraType.keys() ) foreach ( const QString& c, extraType.keys() )
@@ -637,6 +636,7 @@ NewReleasesPlugin::nrList()
} }
} }
qlonglong qlonglong
NewReleasesPlugin::getMaxAge( const QByteArray &rawHeader ) const NewReleasesPlugin::getMaxAge( const QByteArray &rawHeader ) const
{ {
@@ -649,6 +649,7 @@ NewReleasesPlugin::getMaxAge( const QByteArray &rawHeader ) const
return 0; return 0;
} }
qlonglong qlonglong
NewReleasesPlugin::getMaxAge( const qlonglong expires ) const NewReleasesPlugin::getMaxAge( const qlonglong expires ) const
{ {

View File

@@ -92,6 +92,7 @@ RoviPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomah
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( albumLookupError( QNetworkReply::NetworkError ) ) ); connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( albumLookupError( QNetworkReply::NetworkError ) ) );
break; break;
} }
default: default:
{ {
Q_ASSERT( false ); Q_ASSERT( false );
@@ -113,7 +114,6 @@ RoviPlugin::albumLookupError( QNetworkReply::NetworkError error )
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info( requestData, QVariant() ); emit info( requestData, QVariant() );
} }
@@ -156,7 +156,6 @@ RoviPlugin::albumLookupFinished()
emit info( requestData, QVariant() ); emit info( requestData, QVariant() );
} }
QStringList trackNameList; QStringList trackNameList;
foreach ( const QVariant& track, tracks ) foreach ( const QVariant& track, tracks )
{ {
@@ -192,7 +191,7 @@ RoviPlugin::makeRequest( QUrl url )
QByteArray QByteArray
RoviPlugin::generateSig() const RoviPlugin::generateSig() const
{ {
QByteArray raw = m_apiKey + m_secret + QString::number( QDateTime::currentMSecsSinceEpoch() / 1000 ).toLatin1(); const QByteArray raw = m_apiKey + m_secret + QString::number( QDateTime::currentMSecsSinceEpoch() / 1000 ).toLatin1();
return TomahawkUtils::md5( raw ).toLatin1(); return TomahawkUtils::md5( raw ).toLatin1();
} }

View File

@@ -118,20 +118,15 @@ void
ScriptInfoPlugin::onGetInfoRequestDone( const QVariantMap& result ) ScriptInfoPlugin::onGetInfoRequestDone( const QVariantMap& result )
{ {
Q_ASSERT( QThread::currentThread() == thread() ); Q_ASSERT( QThread::currentThread() == thread() );
Q_D( ScriptInfoPlugin ); Q_D( ScriptInfoPlugin );
ScriptJob* job = qobject_cast< ScriptJob* >( sender() ); ScriptJob* job = qobject_cast< ScriptJob* >( sender() );
if ( job->error() ) if ( job->error() )
{ {
emit info( d->requestDataCache[ job->id().toInt() ], QVariantMap() ); emit info( d->requestDataCache[ job->id().toInt() ], QVariantMap() );
} }
else else
{ {
emit getCachedInfo( convertQVariantMapToInfoStringHash( result[ "criteria" ].toMap() ), result[ "newMaxAge" ].toLongLong(), d->requestDataCache[ job->id().toInt() ] ); emit getCachedInfo( convertQVariantMapToInfoStringHash( result[ "criteria" ].toMap() ), result[ "newMaxAge" ].toLongLong(), d->requestDataCache[ job->id().toInt() ] );
} }
@@ -158,7 +153,6 @@ ScriptInfoPlugin::onNotInCacheRequestDone( const QVariantMap& result )
Tomahawk::InfoSystem::InfoStringHash criteria = d->criteriaCache[ job->id().toInt() ]; Tomahawk::InfoSystem::InfoStringHash criteria = d->criteriaCache[ job->id().toInt() ];
d->criteriaCache.remove( job->id().toInt() ); d->criteriaCache.remove( job->id().toInt() );
QVariantMap resultData = result[ "data" ].toMap(); QVariantMap resultData = result[ "data" ].toMap();
switch ( requestData.type ) switch ( requestData.type )
{ {
@@ -180,9 +174,10 @@ ScriptInfoPlugin::onNotInCacheRequestDone( const QVariantMap& result )
emit updateCache( criteria, result[ "maxAge" ].toLongLong(), requestData.type, resultData ); emit updateCache( criteria, result[ "maxAge" ].toLongLong(), requestData.type, resultData );
break; break;
} }
}; }
} }
void void
ScriptInfoPlugin::onCoverArtReturned() ScriptInfoPlugin::onCoverArtReturned()
{ {
@@ -208,6 +203,7 @@ ScriptInfoPlugin::onCoverArtReturned()
emit updateCache( criteria, reply->property( "maxAge" ).toLongLong(), requestData.type, returnedData ); emit updateCache( criteria, reply->property( "maxAge" ).toLongLong(), requestData.type, returnedData );
} }
QSet< Tomahawk::InfoSystem::InfoType > QSet< Tomahawk::InfoSystem::InfoType >
ScriptInfoPlugin::parseSupportedTypes( const QVariant& variant ) ScriptInfoPlugin::parseSupportedTypes( const QVariant& variant )
{ {

View File

@@ -28,7 +28,6 @@ ScriptPlugin::ScriptPlugin( const scriptobject_ptr& object )
ScriptPlugin::~ScriptPlugin() ScriptPlugin::~ScriptPlugin()
{ {
} }

View File

@@ -22,17 +22,22 @@
using namespace Tomahawk; using namespace Tomahawk;
void ScriptInfoPluginFactory::addPlugin( const QSharedPointer< ScriptInfoPlugin >& infoPlugin ) const void
ScriptInfoPluginFactory::addPlugin( const QSharedPointer< ScriptInfoPlugin >& infoPlugin ) const
{ {
Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin.data() ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin.data() );
} }
void ScriptInfoPluginFactory::removePlugin( const QSharedPointer< ScriptInfoPlugin >& infoPlugin ) const
void
ScriptInfoPluginFactory::removePlugin( const QSharedPointer< ScriptInfoPlugin >& infoPlugin ) const
{ {
Tomahawk::InfoSystem::InfoSystem::instance()->removeInfoPlugin( infoPlugin.data() ); Tomahawk::InfoSystem::InfoSystem::instance()->removeInfoPlugin( infoPlugin.data() );
} }
QSharedPointer< ScriptInfoPlugin > ScriptInfoPluginFactory::createPlugin( const scriptobject_ptr& object, ScriptAccount* scriptAccount )
QSharedPointer< ScriptInfoPlugin >
ScriptInfoPluginFactory::createPlugin( const scriptobject_ptr& object, ScriptAccount* scriptAccount )
{ {
// create infoplugin instance // create infoplugin instance
ScriptInfoPlugin* scriptInfoPlugin = new ScriptInfoPlugin( object, scriptAccount->name() ); ScriptInfoPlugin* scriptInfoPlugin = new ScriptInfoPlugin( object, scriptAccount->name() );