mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 23:39:42 +01:00
* Filter word by word, not the total term, e.g. 'rock you we will' finds 'we will rock you'.
This commit is contained in:
parent
079f758b66
commit
71117d3c42
@ -21,6 +21,7 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "databaseimpl.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
|
||||
@ -45,8 +46,14 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
|
||||
|
||||
if ( !m_filter.isEmpty() )
|
||||
{
|
||||
filterToken = QString( "AND file_join.album = album.id AND file_join.track = track.id "
|
||||
"AND ( artist.name LIKE :filterA OR album.name LIKE :filterB OR track.name LIKE :filterC )" );
|
||||
QString filtersql;
|
||||
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
|
||||
foreach( QString s, sl )
|
||||
{
|
||||
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";
|
||||
}
|
||||
else
|
||||
@ -66,13 +73,6 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
|
||||
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );
|
||||
|
||||
query.prepare( sql );
|
||||
if ( !m_filter.isEmpty() )
|
||||
{
|
||||
query.bindValue( ":filterA", QString( "%%1%" ).arg( m_filter ) );
|
||||
query.bindValue( ":filterB", QString( "%%1%" ).arg( m_filter ) );
|
||||
query.bindValue( ":filterC", QString( "%%1%" ).arg( m_filter ) );
|
||||
}
|
||||
|
||||
query.exec();
|
||||
|
||||
while( query.next() )
|
||||
|
@ -174,6 +174,13 @@ appLogDir()
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
sqlEscape( QString sql )
|
||||
{
|
||||
return sql.replace( "'", "''" );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
timeToString( int seconds )
|
||||
{
|
||||
|
@ -75,6 +75,7 @@ namespace TomahawkUtils
|
||||
DLLEXPORT QDir appDataDir();
|
||||
DLLEXPORT QDir appLogDir();
|
||||
|
||||
DLLEXPORT QString sqlEscape( QString sql );
|
||||
DLLEXPORT QString timeToString( int seconds );
|
||||
DLLEXPORT QString ageToString( const QDateTime& time );
|
||||
DLLEXPORT QString filesizeToString( unsigned int size );
|
||||
|
Loading…
x
Reference in New Issue
Block a user