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

View File

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

View File

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

View File

@ -82,6 +82,7 @@ NewReleasesPlugin::~NewReleasesPlugin()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
}
/**
* @brief NewReleasesPlugin::init
* Loops through cache expiration timestamps
@ -120,6 +121,7 @@ NewReleasesPlugin::init()
}
}
void
NewReleasesPlugin::dataError( InfoRequestData requestData )
{
@ -131,7 +133,6 @@ NewReleasesPlugin::dataError( InfoRequestData requestData )
void
NewReleasesPlugin::getInfo( InfoRequestData requestData )
{
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
bool foundSource = false;
@ -372,7 +373,6 @@ NewReleasesPlugin::nrSourcesList()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "MaxAge for " << source << " is 0. Fetching all";
reply->setProperty( "only_source_list", false );
}
}
/**
@ -391,6 +391,7 @@ NewReleasesPlugin::nrSourcesList()
}
}
void
NewReleasesPlugin::fetchAllNRSources()
{
@ -530,7 +531,6 @@ NewReleasesPlugin::nrList()
if ( isDefault )
nr[ "default" ] = "true";
QList< Tomahawk::InfoSystem::InfoStringHash > extraTypeData = extraType[ nrExtraType ][ extra ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
extraTypeData.append( nr );
extraType[ nrExtraType ][ extra ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( extraTypeData );
@ -590,7 +590,6 @@ NewReleasesPlugin::nrList()
tLog() << "Unknown newrelease type " << type;
continue;
}
}
foreach ( const QString& c, extraType.keys() )
@ -637,6 +636,7 @@ NewReleasesPlugin::nrList()
}
}
qlonglong
NewReleasesPlugin::getMaxAge( const QByteArray &rawHeader ) const
{
@ -649,6 +649,7 @@ NewReleasesPlugin::getMaxAge( const QByteArray &rawHeader ) const
return 0;
}
qlonglong
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 ) ) );
break;
}
default:
{
Q_ASSERT( false );
@ -113,7 +114,6 @@ RoviPlugin::albumLookupError( QNetworkReply::NetworkError error )
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info( requestData, QVariant() );
}
@ -156,7 +156,6 @@ RoviPlugin::albumLookupFinished()
emit info( requestData, QVariant() );
}
QStringList trackNameList;
foreach ( const QVariant& track, tracks )
{
@ -192,7 +191,7 @@ RoviPlugin::makeRequest( QUrl url )
QByteArray
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();
}

View File

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

View File

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

View File

@ -22,17 +22,22 @@
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() );
}
void ScriptInfoPluginFactory::removePlugin( const QSharedPointer< ScriptInfoPlugin >& infoPlugin ) const
void
ScriptInfoPluginFactory::removePlugin( const QSharedPointer< ScriptInfoPlugin >& infoPlugin ) const
{
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
ScriptInfoPlugin* scriptInfoPlugin = new ScriptInfoPlugin( object, scriptAccount->name() );