mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
* Support loading and cache artists' biographies in Artist object directly.
This commit is contained in:
@@ -85,6 +85,7 @@ Artist::Artist( unsigned int id, const QString& name )
|
|||||||
, m_coverLoaded( false )
|
, m_coverLoaded( false )
|
||||||
, m_coverLoading( false )
|
, m_coverLoading( false )
|
||||||
, m_simArtistsLoaded( false )
|
, m_simArtistsLoaded( false )
|
||||||
|
, m_biographyLoaded( false )
|
||||||
, m_infoJobs( 0 )
|
, m_infoJobs( 0 )
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
, m_cover( 0 )
|
, 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
|
void
|
||||||
Artist::loadStats()
|
Artist::loadStats()
|
||||||
{
|
{
|
||||||
@@ -313,6 +343,22 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari
|
|||||||
break;
|
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:
|
default:
|
||||||
Q_ASSERT( false );
|
Q_ASSERT( false );
|
||||||
}
|
}
|
||||||
|
@@ -59,6 +59,8 @@ public:
|
|||||||
QList< Tomahawk::PlaybackLog > playbackHistory( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
|
QList< Tomahawk::PlaybackLog > playbackHistory( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
|
||||||
void setPlaybackHistory( const QList< Tomahawk::PlaybackLog >& playbackData );
|
void setPlaybackHistory( const QList< Tomahawk::PlaybackLog >& playbackData );
|
||||||
unsigned int playbackCount( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() );
|
unsigned int playbackCount( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() );
|
||||||
|
|
||||||
|
QString biography() const;
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
||||||
@@ -77,6 +79,7 @@ signals:
|
|||||||
void updated();
|
void updated();
|
||||||
void coverChanged();
|
void coverChanged();
|
||||||
void similarArtistsLoaded();
|
void similarArtistsLoaded();
|
||||||
|
void biographyLoaded();
|
||||||
void statsLoaded();
|
void statsLoaded();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -98,6 +101,7 @@ private:
|
|||||||
mutable bool m_coverLoading;
|
mutable bool m_coverLoading;
|
||||||
QHash<Tomahawk::ModelMode, bool> m_albumsLoaded;
|
QHash<Tomahawk::ModelMode, bool> m_albumsLoaded;
|
||||||
bool m_simArtistsLoaded;
|
bool m_simArtistsLoaded;
|
||||||
|
bool m_biographyLoaded;
|
||||||
|
|
||||||
mutable QString m_uuid;
|
mutable QString m_uuid;
|
||||||
mutable int m_infoJobs;
|
mutable int m_infoJobs;
|
||||||
@@ -105,6 +109,7 @@ private:
|
|||||||
QList<Tomahawk::album_ptr> m_databaseAlbums;
|
QList<Tomahawk::album_ptr> m_databaseAlbums;
|
||||||
QList<Tomahawk::album_ptr> m_officialAlbums;
|
QList<Tomahawk::album_ptr> m_officialAlbums;
|
||||||
QList<Tomahawk::artist_ptr> m_similarArtists;
|
QList<Tomahawk::artist_ptr> m_similarArtists;
|
||||||
|
QString m_biography;
|
||||||
|
|
||||||
bool m_playbackHistoryLoaded;
|
bool m_playbackHistoryLoaded;
|
||||||
QList< PlaybackLog > m_playbackHistory;
|
QList< PlaybackLog > m_playbackHistory;
|
||||||
|
Reference in New Issue
Block a user