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

* Make sure we always have a working uuid in Artist / Album.

This commit is contained in:
Christian Muehlhaeuser
2012-05-28 16:32:29 +02:00
parent c8afb7a7c6
commit 3b04498661
4 changed files with 30 additions and 15 deletions

View File

@@ -115,14 +115,12 @@ Album::cover( const QSize& size, bool forceLoad ) const
if ( !forceLoad ) if ( !forceLoad )
return QPixmap(); return QPixmap();
m_uuid = uuid();
Tomahawk::InfoSystem::InfoStringHash trackInfo; Tomahawk::InfoSystem::InfoStringHash trackInfo;
trackInfo["artist"] = artist()->name(); trackInfo["artist"] = artist()->name();
trackInfo["album"] = name(); trackInfo["album"] = name();
Tomahawk::InfoSystem::InfoRequestData requestData; Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = m_uuid; requestData.caller = infoid();
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt; requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ); requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
requestData.customData = QVariantMap(); requestData.customData = QVariantMap();
@@ -170,7 +168,7 @@ Album::cover( const QSize& size, bool forceLoad ) const
void void
Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, const QVariant& output ) Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, const QVariant& output )
{ {
if ( requestData.caller != m_uuid || if ( requestData.caller != infoid() ||
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt ) requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{ {
return; return;
@@ -193,7 +191,7 @@ Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData,
void void
Album::infoSystemFinished( const QString& target ) Album::infoSystemFinished( const QString& target )
{ {
if ( target != m_uuid ) if ( target != infoid() )
return; return;
disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
@@ -230,3 +228,13 @@ Album::tracks( ModelMode mode, const Tomahawk::collection_ptr& collection )
{ {
return playlistInterface( mode, collection )->tracks(); return playlistInterface( mode, collection )->tracks();
} }
QString
Album::infoid() const
{
if ( m_uuid.isEmpty() )
m_uuid = uuid();
return m_uuid;
}

View File

@@ -77,6 +77,7 @@ private slots:
private: private:
Q_DISABLE_COPY( Album ) Q_DISABLE_COPY( Album )
QString infoid() const;
unsigned int m_id; unsigned int m_id;
QString m_name; QString m_name;

View File

@@ -111,9 +111,6 @@ Artist::albums( ModelMode mode, const Tomahawk::collection_ptr& collection ) con
if ( !collection.isNull() ) if ( !collection.isNull() )
dbLoaded = false; dbLoaded = false;
m_uuid = uuid();
tDebug() << Q_FUNC_INFO << mode;
if ( ( mode == DatabaseMode || mode == Mixed ) && !dbLoaded ) if ( ( mode == DatabaseMode || mode == Mixed ) && !dbLoaded )
{ {
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection, artist ); DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection, artist );
@@ -131,7 +128,7 @@ Artist::albums( ModelMode mode, const Tomahawk::collection_ptr& collection ) con
artistInfo["artist"] = name(); artistInfo["artist"] = name();
Tomahawk::InfoSystem::InfoRequestData requestData; Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = m_uuid; requestData.caller = infoid();
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo ); requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
requestData.type = Tomahawk::InfoSystem::InfoArtistReleases; requestData.type = Tomahawk::InfoSystem::InfoArtistReleases;
@@ -171,7 +168,7 @@ Artist::similarArtists() const
artistInfo["artist"] = name(); artistInfo["artist"] = name();
Tomahawk::InfoSystem::InfoRequestData requestData; Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = m_uuid; requestData.caller = infoid();
requestData.customData = QVariantMap(); requestData.customData = QVariantMap();
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo ); requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
@@ -259,7 +256,7 @@ Artist::onAlbumsFound( const QList< album_ptr >& albums, const QVariant& data )
void void
Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ) Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{ {
if ( requestData.caller != m_uuid ) if ( requestData.caller != infoid() )
return; return;
QVariantMap returnedData = output.value< QVariantMap >(); QVariantMap returnedData = output.value< QVariantMap >();
@@ -274,7 +271,6 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari
QList< album_ptr > albums; QList< album_ptr > albums;
foreach ( const QString& albumName, albumNames ) foreach ( const QString& albumName, albumNames )
{ {
tDebug() << Q_FUNC_INFO << albumName;
Tomahawk::album_ptr album = Tomahawk::Album::get( m_ownRef.toStrongRef(), albumName, false ); Tomahawk::album_ptr album = Tomahawk::Album::get( m_ownRef.toStrongRef(), albumName, false );
m_officialAlbums << album; m_officialAlbums << album;
albums << album; albums << album;
@@ -328,7 +324,7 @@ Artist::infoSystemFinished( QString target )
{ {
Q_UNUSED( target ); Q_UNUSED( target );
if ( target != m_uuid ) if ( target != infoid() )
return; return;
if ( --m_infoJobs == 0 ) if ( --m_infoJobs == 0 )
@@ -352,13 +348,12 @@ Artist::cover( const QSize& size, bool forceLoad ) const
{ {
if ( !forceLoad ) if ( !forceLoad )
return QPixmap(); return QPixmap();
m_uuid = uuid();
Tomahawk::InfoSystem::InfoStringHash trackInfo; Tomahawk::InfoSystem::InfoStringHash trackInfo;
trackInfo["artist"] = name(); trackInfo["artist"] = name();
Tomahawk::InfoSystem::InfoRequestData requestData; Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = m_uuid; requestData.caller = infoid();
requestData.type = Tomahawk::InfoSystem::InfoArtistImages; requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ); requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
requestData.customData = QVariantMap(); requestData.customData = QVariantMap();
@@ -428,3 +423,13 @@ Artist::tracks( ModelMode mode, const Tomahawk::collection_ptr& collection )
{ {
return playlistInterface( mode, collection )->tracks(); return playlistInterface( mode, collection )->tracks();
} }
QString
Artist::infoid() const
{
if ( m_uuid.isEmpty() )
m_uuid = uuid();
return m_uuid;
}

View File

@@ -88,6 +88,7 @@ private slots:
private: private:
Artist(); Artist();
QString infoid() const;
unsigned int m_id; unsigned int m_id;
QString m_name; QString m_name;