mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 17:29:42 +01:00
* Support loading and cache artists' biographies in Artist object directly.
This commit is contained in:
parent
f5aeeeb9c8
commit
5f473a0c5c
@ -85,6 +85,7 @@ Artist::Artist( unsigned int id, const QString& name )
|
||||
, m_coverLoaded( false )
|
||||
, m_coverLoading( false )
|
||||
, m_simArtistsLoaded( false )
|
||||
, m_biographyLoaded( false )
|
||||
, m_infoJobs( 0 )
|
||||
#ifndef ENABLE_HEADLESS
|
||||
, m_cover( 0 )
|
||||
@ -191,6 +192,35 @@ Artist::similarArtists() const
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
Artist::biography() const
|
||||
{
|
||||
if ( !m_biographyLoaded )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||
requestData.caller = infoid();
|
||||
requestData.customData = QVariantMap();
|
||||
|
||||
requestData.input = name();
|
||||
requestData.type = Tomahawk::InfoSystem::InfoArtistBiography;
|
||||
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( finished( QString ) ),
|
||||
SLOT( infoSystemFinished( QString ) ), Qt::UniqueConnection );
|
||||
|
||||
m_infoJobs++;
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||
}
|
||||
|
||||
return m_biography;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Artist::loadStats()
|
||||
{
|
||||
@ -313,6 +343,22 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari
|
||||
break;
|
||||
}
|
||||
|
||||
case InfoSystem::InfoArtistBiography:
|
||||
{
|
||||
QVariantMap bmap = output.toMap();
|
||||
|
||||
foreach ( const QString& source, bmap.keys() )
|
||||
{
|
||||
if ( source == "last.fm" )
|
||||
m_biography = bmap[ source ].toHash()[ "text" ].toString();
|
||||
}
|
||||
|
||||
m_biographyLoaded = true;
|
||||
emit biographyLoaded();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
QList< Tomahawk::PlaybackLog > playbackHistory( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
|
||||
void setPlaybackHistory( const QList< Tomahawk::PlaybackLog >& playbackData );
|
||||
unsigned int playbackCount( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() );
|
||||
|
||||
QString biography() const;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
||||
@ -77,6 +79,7 @@ signals:
|
||||
void updated();
|
||||
void coverChanged();
|
||||
void similarArtistsLoaded();
|
||||
void biographyLoaded();
|
||||
void statsLoaded();
|
||||
|
||||
private slots:
|
||||
@ -98,6 +101,7 @@ private:
|
||||
mutable bool m_coverLoading;
|
||||
QHash<Tomahawk::ModelMode, bool> m_albumsLoaded;
|
||||
bool m_simArtistsLoaded;
|
||||
bool m_biographyLoaded;
|
||||
|
||||
mutable QString m_uuid;
|
||||
mutable int m_infoJobs;
|
||||
@ -105,6 +109,7 @@ private:
|
||||
QList<Tomahawk::album_ptr> m_databaseAlbums;
|
||||
QList<Tomahawk::album_ptr> m_officialAlbums;
|
||||
QList<Tomahawk::artist_ptr> m_similarArtists;
|
||||
QString m_biography;
|
||||
|
||||
bool m_playbackHistoryLoaded;
|
||||
QList< PlaybackLog > m_playbackHistory;
|
||||
|
Loading…
x
Reference in New Issue
Block a user