@ -26,12 +26,12 @@
# include <knuminput.h>
# include <kurl.h>
# include <kapp.h>
# include < qstring.h>
# include < qcstring.h>
# include < qstringlist.h>
# include < qdatastream.h>
# include < t qstring.h>
# include < t qcstring.h>
# include < t qstringlist.h>
# include < t qdatastream.h>
# include <dcopclient.h>
# include < qregexp.h>
# include < t qregexp.h>
# include "actionplaysong.h"
# include "song.h"
@ -43,11 +43,11 @@
K_EXPORT_COMPONENT_FACTORY ( katapult_amarokcatalog ,
KGenericFactory < AmarokCatalog > ( " katapult_amarokcatalog " ) )
AmarokCatalog : : AmarokCatalog ( QObject* , const char * , const QStringList& ) : _result ( QString: : null )
AmarokCatalog : : AmarokCatalog ( T QObject* , const char * , const T QStringList& ) : _result ( TQString( ) )
{
_minQueryLen = 3 ;
ActionRegistry : : self ( ) - > registerAction ( new ActionPlaySong ( ) ) ;
_gotCollection Status = false ;
_gotCollection tq Status = false ;
_dynamicCollection = false ;
checkCollectionType ( ) ;
@ -58,16 +58,16 @@ AmarokCatalog::~AmarokCatalog()
void AmarokCatalog : : queryChanged ( )
{
int new Status = 0 ;
QString queryString = query ( ) ;
int new tq Status = 0 ;
T QString queryString = query ( ) ;
if ( ( QString( queryString ) . remove ( ' : ' ) . remove ( ' \" ' ) . remove ( ' ' ) . isEmpty ( ) ) | | ( queryString . length ( ) < _minQueryLen ) ) {
if ( ( T QString( queryString ) . remove ( ' : ' ) . remove ( ' \" ' ) . remove ( ' ' ) . isEmpty ( ) ) | | ( queryString . length ( ) < _minQueryLen ) ) {
reset ( ) ;
setBestMatch ( Match ( ) ) ;
set Status( 0 ) ;
set tq Status( 0 ) ;
} else {
if ( _gotCollection Status)
if ( _gotCollection tq Status)
{
if ( ! _dynamicCollection )
@ -75,9 +75,9 @@ void AmarokCatalog::queryChanged()
// Stuff for Amarok < 1.4.2
QStringList queryList ;
//prepares SQL-query QRegExp
QString sqlQuery (
T QStringList queryList ;
//prepares SQL-query T QRegExp
T QString sqlQuery (
" SELECT artist.name, tags.title, tags.url, images.path, album.name "
" FROM tags "
" INNER JOIN album ON (tags.album = album.id) "
@ -87,29 +87,29 @@ void AmarokCatalog::queryChanged()
" WHERE 1=1 "
) ; // AND
queryList = QStringList: : split ( QString( " " ) , QString( queryString ) . replace( QChar( ' : ' ) , " " ) . replace( QChar( ' \' ' ) , " " ) . replace( QChar( ' \' ' ) , " % " ) ) ;
for ( QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
sqlQuery . append ( QString( " AND (t.title LIKE ' \ %%1 \ %' " ) . arg( * it ) ) ;
sqlQuery . append ( QString( " OR a.name LIKE ' \ %%1 \ %') " ) . arg( * it ) ) ;
queryList = T QStringList: : split ( T QString( " " ) , T QString( queryString ) . tq replace( T QChar( ' : ' ) , " " ) . tq replace( T QChar( ' \' ' ) , " " ) . tq replace( T QChar( ' \' ' ) , " % " ) ) ;
for ( T QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
sqlQuery . append ( T QString( " AND (t.title LIKE ' \ %%1 \ %' " ) . tq arg( * it ) ) ;
sqlQuery . append ( T QString( " OR a.name LIKE ' \ %%1 \ %') " ) . tq arg( * it ) ) ;
}
sqlQuery . append ( " ORDER BY a.name, t.title, s.percentage DESC " ) ;
//sending SQL-query to ararok via dcop
QByteArray sqlQueryData , replyData ;
QCString replyType ;
QDataStream arg ( sqlQueryData , IO_WriteOnly ) ;
T QByteArray sqlQueryData , replyData ;
T QCString replyType ;
T QDataStream arg ( sqlQueryData , IO_WriteOnly ) ;
arg < < sqlQuery ;
if ( ! kapp - > dcopClient ( ) - > call ( " amarok " , " collection " , " query( QString)" ,
if ( ! kapp - > dcopClient ( ) - > call ( " amarok " , " collection " , " query( T QString)" ,
sqlQueryData , replyType , replyData ) ) {
new Status = 0 ;
new tq Status = 0 ;
} else {
QDataStream reply ( replyData , IO_ReadOnly ) ;
if ( replyType = = " QStringList " ) {
QStringList sqlResult ;
T QDataStream reply ( replyData , IO_ReadOnly ) ;
if ( replyType = = TQSTRINGLIST_OBJECT_NAME_STRING ) {
T QStringList sqlResult ;
reply > > sqlResult ;
if ( sqlResult . isEmpty ( ) ) {
new Status = 0 ;
new tq Status = 0 ;
} else {
reset ( ) ;
//Reads information from SQL-Query
@ -118,35 +118,35 @@ void AmarokCatalog::queryChanged()
_result . setURL ( KURL ( sqlResult [ 2 ] ) ) ;
_result . setAlbum ( sqlResult [ 4 ] ) ;
//_result.setIcon( QString());
//_result.setIcon( T QString());
if ( ! sqlResult [ 3 ] . isEmpty ( ) ) {
_result . setIcon ( sqlResult [ 3 ] ) ;
}
//counts the matched charecters
int i = queryString . find( ' : ' ) ;
int i = queryString . tq find( ' : ' ) ;
if ( i ! = - 1 ) {
if ( queryString [ i + 1 ] ! = ' ' )
queryString . insert ( i + 1 , ' ' ) ;
if ( queryString [ i - 1 ] ! = ' ' )
queryString . insert ( i , ' ' ) ;
}
queryList = QStringList: : split ( " " , queryString ) ;
queryList = T QStringList: : split ( " " , queryString ) ;
unsigned int matched = 0 ;
for ( QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
if ( matched < ( _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ) )
matched = _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ;
for ( T QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
if ( matched < ( _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ) )
matched = _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ;
}
setBestMatch ( Match ( & _result , 100 * queryString . length ( ) / _result . text ( ) . length ( ) , matched ) ) ;
//Checks if there are multiple results
if ( ! sqlResult [ 5 ] . isEmpty ( ) )
new Status = S_HasResults | S_Multiple ;
new tq Status = S_HasResults | S_Multiple ;
else
new Status = S_HasResults ;
new tq Status = S_HasResults ;
}
} else {
new Status = 0 ;
new tq Status = 0 ;
}
}
@ -154,37 +154,37 @@ void AmarokCatalog::queryChanged()
// Do same as above here again but with dyn collection stuff
QStringList queryList ;
//prepares SQL-query QRegExp
QString 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 = QStringList: : split ( QString( " " ) , QString( queryString ) . replace( QChar( ' : ' ) , " " ) . replace( QChar( ' \' ' ) , " " ) . replace( QChar( ' \' ' ) , " % " ) ) ;
T QStringList queryList ;
//prepares SQL-query T QRegExp
T QString 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 = T QStringList: : split ( T QString( " " ) , T QString( queryString ) . tq replace( T QChar( ' : ' ) , " " ) . tq replace( T QChar( ' \' ' ) , " " ) . tq replace( T QChar( ' \' ' ) , " % " ) ) ;
// Let's build each of these clauses
QStringList clauses ;
for ( QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
T QStringList clauses ;
for ( T QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
clauses + = QString( " (t.title LIKE ' \ %%1 \ %' " ) . arg( * it ) +
QString( " OR a.name LIKE ' \ %%1 \ %') " ) . arg( * it ) ;
clauses + = T QString( " (t.title LIKE ' \ %%1 \ %' " ) . tq arg( * it ) +
T QString( " OR a.name LIKE ' \ %%1 \ %') " ) . tq arg( * it ) ;
}
sqlQuery . append ( clauses . join ( QString( " AND " ) ) ) ;
sqlQuery . append ( clauses . join ( T QString( " AND " ) ) ) ;
sqlQuery . append ( " ORDER BY a.name, t.title, s.percentage DESC " ) ;
//sending SQL-query to ararok via dcop
QByteArray sqlQueryData , replyData ;
QCString replyType ;
QDataStream arg ( sqlQueryData , IO_WriteOnly ) ;
T QByteArray sqlQueryData , replyData ;
T QCString replyType ;
T QDataStream arg ( sqlQueryData , IO_WriteOnly ) ;
arg < < sqlQuery ;
if ( ! kapp - > dcopClient ( ) - > call ( " amarok " , " collection " , " query( QString)" ,
if ( ! kapp - > dcopClient ( ) - > call ( " amarok " , " collection " , " query( T QString)" ,
sqlQueryData , replyType , replyData ) ) {
new Status = 0 ;
new tq Status = 0 ;
} else {
QDataStream reply ( replyData , IO_ReadOnly ) ;
if ( replyType = = " QStringList " ) {
QStringList sqlResult ;
T QDataStream reply ( replyData , IO_ReadOnly ) ;
if ( replyType = = TQSTRINGLIST_OBJECT_NAME_STRING ) {
T QStringList sqlResult ;
reply > > sqlResult ;
if ( sqlResult . isEmpty ( ) ) {
new Status = 0 ;
new tq Status = 0 ;
} else {
reset ( ) ;
//Reads information from SQL-Query
@ -208,48 +208,48 @@ void AmarokCatalog::queryChanged()
_result . setAlbum ( sqlResult [ 6 ] ) ;
//_result.setIcon( QString());
//_result.setIcon( T QString());
if ( ! sqlResult [ 3 ] . isEmpty ( ) ) {
_result . setIcon ( sqlResult [ 5 ] ) ;
}
//counts the matched charecters
int i = queryString . find( ' : ' ) ;
int i = queryString . tq find( ' : ' ) ;
if ( i ! = - 1 ) {
if ( queryString [ i + 1 ] ! = ' ' )
queryString . insert ( i + 1 , ' ' ) ;
if ( queryString [ i - 1 ] ! = ' ' )
queryString . insert ( i , ' ' ) ;
}
queryList = QStringList: : split ( " " , queryString ) ;
queryList = T QStringList: : split ( " " , queryString ) ;
unsigned int matched = 0 ;
for ( QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
if ( matched < ( _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ) )
matched = _result . text ( ) . find( * it , matched , false ) + ( * it ) . length ( ) ;
for ( T QStringList: : Iterator it = queryList . begin ( ) ; it ! = queryList . end ( ) ; + + it ) {
if ( matched < ( _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ) )
matched = _result . text ( ) . tq find( * it , matched , false ) + ( * it ) . length ( ) ;
}
setBestMatch ( Match ( & _result , 100 * queryString . length ( ) / _result . text ( ) . length ( ) , matched ) ) ;
//Checks if there are multiple results
if ( ! sqlResult [ 7 ] . isEmpty ( ) )
new Status = S_HasResults | S_Multiple ;
new tq Status = S_HasResults | S_Multiple ;
else
new Status = S_HasResults ;
new tq Status = S_HasResults ;
}
} else {
new Status = 0 ;
new tq Status = 0 ;
}
}
} //end of >1.4.2 section
set Status( new Status) ;
set tq Status( new tq Status) ;
} else { //We haven't got the collection status
checkCollectionType ( ) ;
reset ( ) ;
setBestMatch ( Match ( ) ) ;
set Status( 0 ) ;
set tq Status( 0 ) ;
}
@ -259,31 +259,31 @@ void AmarokCatalog::queryChanged()
void AmarokCatalog : : reset ( )
{
_result . setName ( QString: : null ) ;
_result . setArtist ( QString: : null ) ;
_result . setAlbum ( QString: : null ) ;
_result . setIcon ( QString: : null ) ;
_result . setName ( TQString( ) ) ;
_result . setArtist ( TQString( ) ) ;
_result . setAlbum ( TQString( ) ) ;
_result . setIcon ( TQString( ) ) ;
}
void AmarokCatalog : : checkCollectionType ( )
{
QString sqlQuery ( " SELECT COUNT(*) FROM admin WHERE noption = ' Database Devices Version ' " ) ;
T QString sqlQuery ( " SELECT COUNT(*) FROM admin WHERE noption = ' Database Devices Version ' " ) ;
QByteArray sqlQueryData , replyData ;
QCString replyType ;
QDataStream arg ( sqlQueryData , IO_WriteOnly ) ;
T QByteArray sqlQueryData , replyData ;
T QCString replyType ;
T QDataStream arg ( sqlQueryData , IO_WriteOnly ) ;
arg < < sqlQuery ;
if ( ! kapp - > dcopClient ( ) - > call ( " amarok " , " collection " , " query( QString)" , sqlQueryData , replyType , replyData ) )
if ( ! kapp - > dcopClient ( ) - > call ( " amarok " , " collection " , " query( T QString)" , sqlQueryData , replyType , replyData ) )
{
_gotCollection Status = false ;
_gotCollection tq Status = false ;
}
else
{
QDataStream reply ( replyData , IO_ReadOnly ) ;
if ( replyType = = " QStringList " )
T QDataStream reply ( replyData , IO_ReadOnly ) ;
if ( replyType = = TQSTRINGLIST_OBJECT_NAME_STRING )
{
QStringList sqlResult ;
T QStringList sqlResult ;
reply > > sqlResult ;
if ( sqlResult [ 0 ] = = " 1 " )
@ -296,11 +296,11 @@ void AmarokCatalog::checkCollectionType()
_dynamicCollection = false ;
}
_gotCollection Status = true ;
_gotCollection tq Status = true ;
}
else
{
_gotCollection Status = false ;
_gotCollection tq Status = false ;
}
}
}
@ -317,12 +317,12 @@ unsigned int AmarokCatalog::minQueryLen() const
return _minQueryLen ;
}
QWidget * AmarokCatalog : : configure ( )
T QWidget * AmarokCatalog : : configure ( )
{
AmarokCatalogSettings * settings = new AmarokCatalogSettings ( ) ;
settings - > minQueryLen - > setValue ( _minQueryLen ) ;
connect ( settings - > minQueryLen , SIGNAL( valueChanged ( int ) ) , this , SLOT( minQueryLenChanged ( int ) ) ) ;
connect ( settings - > minQueryLen , TQT_ SIGNAL( valueChanged ( int ) ) , this , TQT_ SLOT( minQueryLenChanged ( int ) ) ) ;
return settings ;
}