mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Implement limiting for index searching.
This commit is contained in:
@@ -370,8 +370,6 @@ DatabaseImpl::albumId( int artistid, const QString& name_orig, bool autoCreate )
|
||||
QList< QPair<int, float> >
|
||||
DatabaseImpl::searchTable( const QString& table, const QString& name, uint limit )
|
||||
{
|
||||
Q_UNUSED( limit );
|
||||
|
||||
QList< QPair<int, float> > resultslist;
|
||||
if ( table != "artist" && table != "track" && table != "album" )
|
||||
return resultslist;
|
||||
@@ -383,7 +381,16 @@ DatabaseImpl::searchTable( const QString& table, const QString& name, uint limit
|
||||
}
|
||||
qSort( resultslist.begin(), resultslist.end(), DatabaseImpl::scorepairSorter );
|
||||
|
||||
if ( !limit )
|
||||
return resultslist;
|
||||
|
||||
QList< QPair<int, float> > resultscapped;
|
||||
for ( unsigned int i = 0; i < limit && i < resultsmap.count(); i++ )
|
||||
{
|
||||
resultscapped << resultslist.at( i );
|
||||
}
|
||||
|
||||
return resultscapped;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -56,7 +56,7 @@ public:
|
||||
int trackId( int artistid, const QString& name_orig, bool autoCreate );
|
||||
int albumId( int artistid, const QString& name_orig, bool autoCreate );
|
||||
|
||||
QList< QPair<int, float> > searchTable( const QString& table, const QString& name, uint limit = 10 );
|
||||
QList< QPair<int, float> > searchTable( const QString& table, const QString& name, uint limit = 0 );
|
||||
QList< int > getTrackFids( int tid );
|
||||
|
||||
static QString sortname( const QString& str, bool replaceArticle = false );
|
||||
|
Reference in New Issue
Block a user