mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 07:52:30 +02:00
* Try: Make artist & album names uniqye by sortname, means lowercase-name. This ensures we always use the same spelling whenever we display the artist's name - for better and for worse.
This commit is contained in:
parent
ae24fe9d5c
commit
35fbb62274
@ -52,7 +52,7 @@ Album::~Album()
|
||||
inline QString
|
||||
albumCacheKey( const Tomahawk::artist_ptr& artist, const QString& albumName )
|
||||
{
|
||||
return QString( "%1\t\t%2" ).arg( artist->name() ).arg( albumName );
|
||||
return QString( "%1\t\t%2" ).arg( artist->name().toLower() ).arg( albumName.toLower() );
|
||||
}
|
||||
|
||||
|
||||
@ -70,11 +70,9 @@ Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCr
|
||||
return s_albumsByName.value( key );
|
||||
}
|
||||
|
||||
album_ptr album = album_ptr( new Album( name, artist ) );
|
||||
album_ptr album = album_ptr( new Album( name, artist ) );
|
||||
album->setWeakRef( album.toWeakRef() );
|
||||
album->loadId( autoCreate );
|
||||
|
||||
// tDebug() << Q_FUNC_INFO << "ADDING:" << artist->name() << name;
|
||||
s_albumsByName.insert( key, album );
|
||||
|
||||
return album;
|
||||
@ -101,8 +99,6 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
|
||||
|
||||
album_ptr a = album_ptr( new Album( id, name, artist ), &QObject::deleteLater );
|
||||
a->setWeakRef( a.toWeakRef() );
|
||||
|
||||
// tDebug() << Q_FUNC_INFO << "ADDING:" << artist->name() << name << id;
|
||||
s_albumsByName.insert( key, a );
|
||||
|
||||
if ( id > 0 )
|
||||
|
@ -59,21 +59,23 @@ Artist::get( const QString& name, bool autoCreate )
|
||||
if ( name.isEmpty() )
|
||||
return artist_ptr();
|
||||
|
||||
const QString sortname = name.toLower();
|
||||
|
||||
QMutexLocker lock( &s_nameCacheMutex );
|
||||
if ( s_artistsByName.contains( name ) )
|
||||
return s_artistsByName.value( name );
|
||||
if ( s_artistsByName.contains( sortname ) )
|
||||
return s_artistsByName.value( sortname );
|
||||
|
||||
if ( !Database::instance() || !Database::instance()->impl() )
|
||||
return artist_ptr();
|
||||
|
||||
#if ID_THREAD_DEBUG
|
||||
qDebug() << "Creating artist:" << name;
|
||||
tDebug() << "Creating artist:" << name << "( sortname:" << sortname << ")";
|
||||
#endif
|
||||
|
||||
artist_ptr artist = artist_ptr( new Artist( name ), &QObject::deleteLater );
|
||||
artist->setWeakRef( artist.toWeakRef() );
|
||||
artist->loadId( autoCreate );
|
||||
|
||||
s_artistsByName.insert( name, artist );
|
||||
s_artistsByName.insert( sortname, artist );
|
||||
|
||||
return artist;
|
||||
}
|
||||
@ -83,9 +85,11 @@ artist_ptr
|
||||
Artist::get( unsigned int id, const QString& name )
|
||||
{
|
||||
QMutexLocker lock( &s_idCacheMutex );
|
||||
if ( s_artistsByName.contains( name ) )
|
||||
|
||||
const QString sortname = name.toLower();
|
||||
if ( s_artistsByName.contains( sortname ) )
|
||||
{
|
||||
return s_artistsByName.value( name );
|
||||
return s_artistsByName.value( sortname );
|
||||
}
|
||||
if ( s_artistsById.contains( id ) )
|
||||
{
|
||||
@ -95,7 +99,7 @@ Artist::get( unsigned int id, const QString& name )
|
||||
artist_ptr a = artist_ptr( new Artist( id, name ), &QObject::deleteLater );
|
||||
a->setWeakRef( a.toWeakRef() );
|
||||
|
||||
s_artistsByName.insert( name, a );
|
||||
s_artistsByName.insert( sortname, a );
|
||||
if ( id > 0 )
|
||||
{
|
||||
s_artistsById.insert( id, a );
|
||||
|
Loading…
x
Reference in New Issue
Block a user