mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 16:14:40 +02: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:
@@ -21,6 +21,7 @@
|
|||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
|
||||||
#include "databaseimpl.h"
|
#include "databaseimpl.h"
|
||||||
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -45,8 +46,14 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
if ( !m_filter.isEmpty() )
|
if ( !m_filter.isEmpty() )
|
||||||
{
|
{
|
||||||
filterToken = QString( "AND file_join.album = album.id AND file_join.track = track.id "
|
QString filtersql;
|
||||||
"AND ( artist.name LIKE :filterA OR album.name LIKE :filterB OR track.name LIKE :filterC )" );
|
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";
|
tables = "artist, track, album, file, file_join";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -66,13 +73,6 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
|
|||||||
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );
|
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );
|
||||||
|
|
||||||
query.prepare( sql );
|
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();
|
query.exec();
|
||||||
|
|
||||||
while( query.next() )
|
while( query.next() )
|
||||||
|
@@ -174,6 +174,13 @@ appLogDir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
sqlEscape( QString sql )
|
||||||
|
{
|
||||||
|
return sql.replace( "'", "''" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
timeToString( int seconds )
|
timeToString( int seconds )
|
||||||
{
|
{
|
||||||
|
@@ -75,6 +75,7 @@ namespace TomahawkUtils
|
|||||||
DLLEXPORT QDir appDataDir();
|
DLLEXPORT QDir appDataDir();
|
||||||
DLLEXPORT QDir appLogDir();
|
DLLEXPORT QDir appLogDir();
|
||||||
|
|
||||||
|
DLLEXPORT QString sqlEscape( QString sql );
|
||||||
DLLEXPORT QString timeToString( int seconds );
|
DLLEXPORT QString timeToString( int seconds );
|
||||||
DLLEXPORT QString ageToString( const QDateTime& time );
|
DLLEXPORT QString ageToString( const QDateTime& time );
|
||||||
DLLEXPORT QString filesizeToString( unsigned int size );
|
DLLEXPORT QString filesizeToString( unsigned int size );
|
||||||
|
Reference in New Issue
Block a user