1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 09:19:41 +01:00

* Fixed TWK-523: Don't ignore tracks without an album name when filtering.

This commit is contained in:
Christian Muehlhaeuser 2011-09-23 13:29:22 +02:00
parent 9eeed5223c
commit b84a884387
4 changed files with 14 additions and 11 deletions

View File

@ -81,8 +81,7 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
QString sql = QString(
"SELECT DISTINCT album.id, album.name "
"FROM %1 "
"LEFT OUTER JOIN album "
"ON file_join.album = album.id "
"LEFT OUTER JOIN album ON file_join.album = album.id "
"WHERE file.id = file_join.file "
"AND file_join.artist = %2 "
"%3 %4 %5 %6 %7"
@ -137,8 +136,7 @@ DatabaseCommand_AllAlbums::execForCollection( DatabaseImpl* dbi )
QString sql = QString(
"SELECT DISTINCT album.id, album.name, album.artist, artist.name "
"FROM album, file, file_join "
"LEFT OUTER JOIN artist "
"ON album.artist = artist.id "
"LEFT OUTER JOIN artist ON album.artist = artist.id "
"WHERE file.id = file_join.file "
"AND file_join.album = album.id "
"%1 "

View File

@ -43,7 +43,7 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
QList<Tomahawk::artist_ptr> al;
QString orderToken, sourceToken, filterToken, tables;
QString orderToken, sourceToken, filterToken, tables, joins;
switch ( m_sortOrder )
{
@ -66,8 +66,9 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
filtersql += QString( " AND ( artist.name LIKE '%%1%' OR album.name LIKE '%%1%' OR track.name LIKE '%%1%' )" ).arg( TomahawkUtils::sqlEscape( s ) );
}
filterToken = QString( "AND file_join.album = album.id AND file_join.track = track.id %1" ).arg( filtersql );
tables = "artist, track, album, file, file_join";
filterToken = QString( "AND file_join.track = track.id %1" ).arg( filtersql );
joins = "LEFT JOIN album ON album.id = file_join.album";
tables = "artist, track, file, file_join";
}
else
tables = "artist, file, file_join";
@ -75,10 +76,12 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
QString sql = QString(
"SELECT DISTINCT artist.id, artist.name "
"FROM %1 "
"%2 "
"WHERE file.id = file_join.file "
"AND file_join.artist = artist.id "
"%2 %3 %4 %5 %6"
"%3 %4 %5 %6 %7"
).arg( tables )
.arg( joins )
.arg( sourceToken )
.arg( filterToken )
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() )

View File

@ -159,7 +159,9 @@ TreeProxyModel::onFilterArtists( const QList<Tomahawk::artist_ptr>& artists )
void
TreeProxyModel::onFilterAlbums( const QList<Tomahawk::album_ptr>& albums )
{
m_albumsFilter << albums;
foreach ( const Tomahawk::album_ptr& album, albums )
m_albumsFilter << album->id();
filterFinished();
}
@ -220,7 +222,7 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
else if ( !pi->artist().isNull() )
accepted = m_artistsFilter.contains( pi->artist() );
else if ( !pi->album().isNull() )
accepted = m_albumsFilter.contains( pi->album() );
accepted = m_albumsFilter.contains( pi->album()->id() );
if ( !accepted )
{

View File

@ -99,7 +99,7 @@ private:
mutable QMap< QPersistentModelIndex, Tomahawk::result_ptr > m_cache;
QList<Tomahawk::artist_ptr> m_artistsFilter;
QList<Tomahawk::album_ptr> m_albumsFilter;
QList<int> m_albumsFilter;
DatabaseCommand_AllArtists* m_artistsFilterCmd;
QString m_filter;