@ -87,7 +87,7 @@ void AmarokCatalog::queryChanged()
" WHERE 1=1 "
" WHERE 1=1 "
) ; // AND
) ; // AND
queryList = TQStringList : : split ( TQString ( " " ) , TQString ( queryString ) . tq replace( TQChar ( ' : ' ) , " " ) . tq replace( TQChar ( ' \' ' ) , " " ) . tq replace( TQChar ( ' \' ' ) , " % " ) ) ;
queryList = TQStringList : : split ( TQString ( " " ) , TQString ( queryString ) . replace( TQChar ( ' : ' ) , " " ) . replace( TQChar ( ' \' ' ) , " " ) . replace( TQChar ( ' \' ' ) , " % " ) ) ;
for ( TQStringList : : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
for ( TQStringList : : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
sqlQuery . append ( TQString ( " AND (t.title LIKE ' \ %%1 \ %' " ) . tqarg ( * it ) ) ;
sqlQuery . append ( TQString ( " AND (t.title LIKE ' \ %%1 \ %' " ) . tqarg ( * it ) ) ;
sqlQuery . append ( TQString ( " OR a.name LIKE ' \ %%1 \ %') " ) . tqarg ( * it ) ) ;
sqlQuery . append ( TQString ( " OR a.name LIKE ' \ %%1 \ %') " ) . tqarg ( * it ) ) ;
@ -124,7 +124,7 @@ void AmarokCatalog::queryChanged()
}
}
//counts the matched charecters
//counts the matched charecters
int i = queryString . tq find( ' : ' ) ;
int i = queryString . find( ' : ' ) ;
if ( i ! = - 1 ) {
if ( i ! = - 1 ) {
if ( queryString [ i + 1 ] ! = ' ' )
if ( queryString [ i + 1 ] ! = ' ' )
queryString . insert ( i + 1 , ' ' ) ;
queryString . insert ( i + 1 , ' ' ) ;
@ -134,8 +134,8 @@ void AmarokCatalog::queryChanged()
queryList = TQStringList : : split ( " " , queryString ) ;
queryList = TQStringList : : split ( " " , queryString ) ;
unsigned int matched = 0 ;
unsigned int matched = 0 ;
for ( TQStringList : : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
for ( TQStringList : : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
if ( matched < ( _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ) )
if ( matched < ( _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ) )
matched = _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ;
matched = _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ;
}
}
setBestMatch ( Match ( & _result , 100 * queryString . length ( ) / _result . text ( ) . length ( ) , matched ) ) ;
setBestMatch ( Match ( & _result , 100 * queryString . length ( ) / _result . text ( ) . length ( ) , matched ) ) ;
@ -157,7 +157,7 @@ void AmarokCatalog::queryChanged()
TQStringList queryList ;
TQStringList queryList ;
//prepares SQL-queryTQRegExp
//prepares SQL-queryTQRegExp
TQString sqlQuery ( " SELECT a.name, t.title, t.deviceid, d.lastmountpoint, t.url, i.path, album.name FROM tags t LEFT JOIN statistics s ON (t.url = s.url AND t.deviceid = s.deviceid) LEFT JOIN artist a ON ( t . artist = a . id ) LEFT JOIN album ON ( t . album = album . id ) LEFT JOIN images i ON ( a . name = i . artist AND album . name = i . album ) LEFT JOIN devices d ON ( t . deviceid = d . id ) WHERE " ) ;
TQString sqlQuery ( " SELECT a.name, t.title, t.deviceid, d.lastmountpoint, t.url, i.path, album.name FROM tags t LEFT JOIN statistics s ON (t.url = s.url AND t.deviceid = s.deviceid) LEFT JOIN artist a ON ( t . artist = a . id ) LEFT JOIN album ON ( t . album = album . id ) LEFT JOIN images i ON ( a . name = i . artist AND album . name = i . album ) LEFT JOIN devices d ON ( t . deviceid = d . id ) WHERE " ) ;
queryList = TQStringList : : split ( TQString ( " " ) , TQString ( queryString ) . tq replace( TQChar ( ' : ' ) , " " ) . tq replace( TQChar ( ' \' ' ) , " " ) . tq replace( TQChar ( ' \' ' ) , " % " ) ) ;
queryList = TQStringList : : split ( TQString ( " " ) , TQString ( queryString ) . replace( TQChar ( ' : ' ) , " " ) . replace( TQChar ( ' \' ' ) , " " ) . replace( TQChar ( ' \' ' ) , " % " ) ) ;
// Let's build each of these clauses
// Let's build each of these clauses
TQStringList clauses ;
TQStringList clauses ;
@ -214,7 +214,7 @@ void AmarokCatalog::queryChanged()
}
}
//counts the matched charecters
//counts the matched charecters
int i = queryString . tq find( ' : ' ) ;
int i = queryString . find( ' : ' ) ;
if ( i ! = - 1 ) {
if ( i ! = - 1 ) {
if ( queryString [ i + 1 ] ! = ' ' )
if ( queryString [ i + 1 ] ! = ' ' )
queryString . insert ( i + 1 , ' ' ) ;
queryString . insert ( i + 1 , ' ' ) ;
@ -224,8 +224,8 @@ void AmarokCatalog::queryChanged()
queryList = TQStringList : : split ( " " , queryString ) ;
queryList = TQStringList : : split ( " " , queryString ) ;
unsigned int matched = 0 ;
unsigned int matched = 0 ;
for ( TQStringList : : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
for ( TQStringList : : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
if ( matched < ( _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ) )
if ( matched < ( _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ) )
matched = _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ;
matched = _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ;
}
}
setBestMatch ( Match ( & _result , 100 * queryString . length ( ) / _result . text ( ) . length ( ) , matched ) ) ;
setBestMatch ( Match ( & _result , 100 * queryString . length ( ) / _result . text ( ) . length ( ) , matched ) ) ;