1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-15 05:22:35 +02:00

* Added option to filter result of sourcesWithSocialAction by friendlyName.

This commit is contained in:
Christian Muehlhaeuser 2013-09-10 01:26:01 +02:00
parent ca11b08f2d
commit ba670716a7
4 changed files with 22 additions and 7 deletions

View File

@ -571,10 +571,10 @@ Track::socialActionDescription( const QString& action, DescriptionMode mode ) co
QList< Tomahawk::source_ptr >
Track::sourcesWithSocialAction( const QString& action, const QVariant& value )
Track::sourcesWithSocialAction( const QString& action, const QVariant& value, bool filterDupeNames )
{
Q_D( Track );
return d->trackData->sourcesWithSocialAction( action, value );
return d->trackData->sourcesWithSocialAction( action, value, filterDupeNames );
}

View File

@ -109,7 +109,7 @@ public:
void loadSocialActions( bool force = false );
QList< Tomahawk::SocialAction > allSocialActions() const;
QList< Tomahawk::source_ptr > sourcesWithSocialAction( const QString& action, const QVariant& value = QVariant() );
QList< Tomahawk::source_ptr > sourcesWithSocialAction( const QString& action, const QVariant& value = QVariant(), bool filterDupeNames = false );
QString socialActionDescription( const QString& action, DescriptionMode mode ) const;
QList<Tomahawk::query_ptr> similarTracks() const;

View File

@ -278,7 +278,7 @@ TrackData::allSocialActions() const
QList< Tomahawk::source_ptr >
TrackData::sourcesWithSocialAction( const QString& action, const QVariant& value )
TrackData::sourcesWithSocialAction( const QString& action, const QVariant& value, bool filterDupeNames )
{
QMutexLocker locker( &s_memberMutex );
@ -292,9 +292,24 @@ TrackData::sourcesWithSocialAction( const QString& action, const QVariant& value
sources.removeAll( sa.source );
continue;
}
if ( sources.contains( sa.source ) )
continue;
bool dupe = false;
if ( sources.contains( sa.source ) )
dupe = true;
if ( filterDupeNames )
{
foreach ( const Tomahawk::source_ptr& source, sources )
{
if ( source->friendlyName() == sa.source->friendlyName() )
{
dupe = true;
break;
}
}
}
if ( dupe )
continue;
sources << sa.source;
}
}

View File

@ -80,7 +80,7 @@ public:
void loadSocialActions( bool force = false );
QList< Tomahawk::SocialAction > allSocialActions() const;
QList< Tomahawk::source_ptr > sourcesWithSocialAction( const QString& action, const QVariant& value = QVariant() );
QList< Tomahawk::source_ptr > sourcesWithSocialAction( const QString& action, const QVariant& value = QVariant(), bool filterDupeNames = false );
void setAllSocialActions( const QList< Tomahawk::SocialAction >& socialActions );
void loadStats();