mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
* Implement limiting for index searching.
This commit is contained in:
parent
b80230c962
commit
30cabb304c
src/libtomahawk/database
@ -370,20 +370,27 @@ 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" )
|
||||
if ( table != "artist" && table != "track" && table != "album" )
|
||||
return resultslist;
|
||||
|
||||
QMap< int, float > resultsmap = m_fuzzyIndex->search( table, name );
|
||||
foreach( int i, resultsmap.keys() )
|
||||
foreach ( int i, resultsmap.keys() )
|
||||
{
|
||||
resultslist << QPair<int, float>( i, (float)resultsmap.value( i ) );
|
||||
}
|
||||
qSort( resultslist.begin(), resultslist.end(), DatabaseImpl::scorepairSorter );
|
||||
|
||||
return resultslist;
|
||||
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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user