|
|
|
@ -47,7 +47,7 @@ AmarokCatalog::AmarokCatalog(TQObject*, const char*, const TQStringList&): _resu
|
|
|
|
|
{
|
|
|
|
|
_minQueryLen = 3;
|
|
|
|
|
ActionRegistry::self()->registerAction(new ActionPlaySong());
|
|
|
|
|
_gotCollectiontqStatus = false;
|
|
|
|
|
_gotCollectionStatus = false;
|
|
|
|
|
_dynamicCollection = false;
|
|
|
|
|
checkCollectionType();
|
|
|
|
|
|
|
|
|
@ -58,16 +58,16 @@ AmarokCatalog::~AmarokCatalog()
|
|
|
|
|
|
|
|
|
|
void AmarokCatalog::queryChanged()
|
|
|
|
|
{
|
|
|
|
|
int newtqStatus = 0;
|
|
|
|
|
int newStatus = 0;
|
|
|
|
|
TQString queryString = query();
|
|
|
|
|
|
|
|
|
|
if((TQString(queryString).remove(':').remove('\"').remove(' ').isEmpty()) || (queryString.length() < _minQueryLen)) {
|
|
|
|
|
reset();
|
|
|
|
|
setBestMatch(Match());
|
|
|
|
|
settqStatus(0);
|
|
|
|
|
setStatus(0);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if ( _gotCollectiontqStatus)
|
|
|
|
|
if ( _gotCollectionStatus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!_dynamicCollection)
|
|
|
|
@ -89,8 +89,8 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
|
|
|
|
|
queryList = TQStringList::split ( TQString(" "), TQString(queryString).replace(TQChar(':')," ").replace(TQChar('\''), " ").replace(TQChar('\''), "%") );
|
|
|
|
|
for(TQStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) {
|
|
|
|
|
sqlQuery.append(TQString(" AND (t.title LIKE '\%%1\%'").tqarg(*it));
|
|
|
|
|
sqlQuery.append(TQString(" OR a.name LIKE '\%%1\%')").tqarg(*it));
|
|
|
|
|
sqlQuery.append(TQString(" AND (t.title LIKE '\%%1\%'").arg(*it));
|
|
|
|
|
sqlQuery.append(TQString(" OR a.name LIKE '\%%1\%')").arg(*it));
|
|
|
|
|
}
|
|
|
|
|
sqlQuery.append(" ORDER BY a.name, t.title, s.percentage DESC");
|
|
|
|
|
|
|
|
|
@ -101,7 +101,7 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
arg << sqlQuery;
|
|
|
|
|
if (!kapp->dcopClient()->call("amarok", "collection", "query(TQString)",
|
|
|
|
|
sqlQueryData, replyType, replyData)) {
|
|
|
|
|
newtqStatus = 0;
|
|
|
|
|
newStatus = 0;
|
|
|
|
|
} else {
|
|
|
|
|
TQDataStream reply(replyData, IO_ReadOnly);
|
|
|
|
|
if (replyType == TQSTRINGLIST_OBJECT_NAME_STRING) {
|
|
|
|
@ -109,7 +109,7 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
reply >> sqlResult;
|
|
|
|
|
|
|
|
|
|
if(sqlResult.isEmpty()) {
|
|
|
|
|
newtqStatus = 0;
|
|
|
|
|
newStatus = 0;
|
|
|
|
|
} else {
|
|
|
|
|
reset();
|
|
|
|
|
//Reads information from SQL-Query
|
|
|
|
@ -141,12 +141,12 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
|
|
|
|
|
//Checks if there are multiple results
|
|
|
|
|
if( !sqlResult[5].isEmpty() )
|
|
|
|
|
newtqStatus = S_HasResults | S_Multiple;
|
|
|
|
|
newStatus = S_HasResults | S_Multiple;
|
|
|
|
|
else
|
|
|
|
|
newtqStatus = S_HasResults;
|
|
|
|
|
newStatus = S_HasResults;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
newtqStatus = 0;
|
|
|
|
|
newStatus = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -163,8 +163,8 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
TQStringList clauses;
|
|
|
|
|
for(TQStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) {
|
|
|
|
|
|
|
|
|
|
clauses += TQString(" (t.title LIKE '\%%1\%'").tqarg(*it) +
|
|
|
|
|
TQString(" OR a.name LIKE '\%%1\%')").tqarg(*it);
|
|
|
|
|
clauses += TQString(" (t.title LIKE '\%%1\%'").arg(*it) +
|
|
|
|
|
TQString(" OR a.name LIKE '\%%1\%')").arg(*it);
|
|
|
|
|
}
|
|
|
|
|
sqlQuery.append(clauses.join(TQString(" AND ")));
|
|
|
|
|
sqlQuery.append(" ORDER BY a.name, t.title, s.percentage DESC");
|
|
|
|
@ -176,7 +176,7 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
arg << sqlQuery;
|
|
|
|
|
if (!kapp->dcopClient()->call("amarok", "collection", "query(TQString)",
|
|
|
|
|
sqlQueryData, replyType, replyData)) {
|
|
|
|
|
newtqStatus = 0;
|
|
|
|
|
newStatus = 0;
|
|
|
|
|
} else {
|
|
|
|
|
TQDataStream reply(replyData, IO_ReadOnly);
|
|
|
|
|
if (replyType == TQSTRINGLIST_OBJECT_NAME_STRING) {
|
|
|
|
@ -184,7 +184,7 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
reply >> sqlResult;
|
|
|
|
|
|
|
|
|
|
if(sqlResult.isEmpty()) {
|
|
|
|
|
newtqStatus = 0;
|
|
|
|
|
newStatus = 0;
|
|
|
|
|
} else {
|
|
|
|
|
reset();
|
|
|
|
|
//Reads information from SQL-Query
|
|
|
|
@ -231,25 +231,25 @@ void AmarokCatalog::queryChanged()
|
|
|
|
|
|
|
|
|
|
//Checks if there are multiple results
|
|
|
|
|
if( !sqlResult[7].isEmpty() )
|
|
|
|
|
newtqStatus = S_HasResults | S_Multiple;
|
|
|
|
|
newStatus = S_HasResults | S_Multiple;
|
|
|
|
|
else
|
|
|
|
|
newtqStatus = S_HasResults;
|
|
|
|
|
newStatus = S_HasResults;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
newtqStatus = 0;
|
|
|
|
|
newStatus = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} //end of >1.4.2 section
|
|
|
|
|
settqStatus(newtqStatus);
|
|
|
|
|
setStatus(newStatus);
|
|
|
|
|
|
|
|
|
|
} else { //We haven't got the collection status
|
|
|
|
|
|
|
|
|
|
checkCollectionType();
|
|
|
|
|
reset();
|
|
|
|
|
setBestMatch(Match());
|
|
|
|
|
settqStatus(0);
|
|
|
|
|
setStatus(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -275,7 +275,7 @@ void AmarokCatalog::checkCollectionType()
|
|
|
|
|
arg << sqlQuery;
|
|
|
|
|
if (!kapp->dcopClient()->call("amarok", "collection", "query(TQString)", sqlQueryData, replyType, replyData))
|
|
|
|
|
{
|
|
|
|
|
_gotCollectiontqStatus = false;
|
|
|
|
|
_gotCollectionStatus = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -296,11 +296,11 @@ void AmarokCatalog::checkCollectionType()
|
|
|
|
|
_dynamicCollection = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
_gotCollectiontqStatus = true;
|
|
|
|
|
_gotCollectionStatus = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_gotCollectiontqStatus = false;
|
|
|
|
|
_gotCollectionStatus = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|