diff -r 2b40d63a9c3d -r 90517678cc4f qtmobility/plugins/contacts/symbian/src/filtering/cntfilterdetail.cpp --- a/qtmobility/plugins/contacts/symbian/src/filtering/cntfilterdetail.cpp Fri Apr 16 15:51:22 2010 +0300 +++ b/qtmobility/plugins/contacts/symbian/src/filtering/cntfilterdetail.cpp Mon May 03 13:18:40 2010 +0300 @@ -74,25 +74,26 @@ const QContactFilter &filter, const QList &sortOrders, bool &filterSupportedflag, - QContactManager::Error &error) + QContactManager::Error* error) { Q_UNUSED(sortOrders); Q_UNUSED(filterSupportedflag); //Check if any invalid filter is passed if(!filterSupported(filter) ) { - error = QContactManager::NotSupportedError; + *error = QContactManager::NotSupportedError; return QList(); } QList idList; QContactDetailFilter detailFilter(filter); QString sqlQuery; //Check for phonenumber. Special handling needed - if(detailFilter.detailDefinitionName() == QContactPhoneNumber::DefinitionName ) + if( (detailFilter.detailDefinitionName() == QContactPhoneNumber::DefinitionName ) && + (detailFilter.detailFieldName() != QContactPhoneNumber::FieldSubTypes)) { //Handle phonenumber ... - idList = HandlePhonenumberDetailFilter(filter); + } else if (detailFilter.matchFlags() == QContactFilter::MatchKeypadCollation) { @@ -104,10 +105,12 @@ else { createSelectQuery(filter,sqlQuery,error); - if(error == QContactManager::NoError) + QString sortQuery = m_dbInfo.getSortQuery(sortOrders, sqlQuery, error); + + if(*error == QContactManager::NoError) { //fetch the contacts - idList = m_srvConnection.searchContacts(sqlQuery, error); + idList = m_srvConnection.searchContacts(sortQuery, error); } } @@ -131,12 +134,12 @@ void CntFilterDetail::createSelectQuery(const QContactFilter& filter, QString& sqlQuery, - QContactManager::Error& error) + QContactManager::Error* error) { if(!filterSupported(filter) ) { - error = QContactManager::NotSupportedError; + *error = QContactManager::NotSupportedError; return; } QContactDetailFilter detailFilter(filter); @@ -159,10 +162,10 @@ { if(detailFilter.detailFieldName() == QContactGuid::FieldGuid) { - QStringList fullGuidValue = detailFilter.value().toString().split("-"); + QStringList fullGuidValue = detailFilter.value().toString().split('-'); if (fullGuidValue.count() == 3) { QString localGuidValue = fullGuidValue.at(1); - sqlQuery = "SELECT contact_id FROM contact WHERE guid_string = '" + localGuidValue + "'"; + sqlQuery = "SELECT contact_id FROM contact WHERE guid_string = '" + localGuidValue + '\''; } } } @@ -183,7 +186,7 @@ */ void CntFilterDetail::updateForMatchFlag( const QContactDetailFilter& filter, QString& fieldToUpdate , - QContactManager::Error& error) const + QContactManager::Error* error) const { // Modify the filed depending on the query switch(filter.matchFlags()) @@ -193,8 +196,8 @@ // Pattern for MatchExactly: // " ='xyz'" fieldToUpdate = " ='" - + filter.value().toString() + "'"; - error = QContactManager::NoError; + + filter.value().toString() + '\''; + *error = QContactManager::NoError; break; } case QContactFilter::MatchContains: @@ -202,7 +205,7 @@ // Pattern for MatchContains: // " LIKE '%xyz%'" fieldToUpdate = " LIKE '%" + filter.value().toString() + "%'" ; - error = QContactManager::NoError; + *error = QContactManager::NoError; break; } case QContactFilter::MatchStartsWith: @@ -210,30 +213,30 @@ // Pattern for MatchStartsWith: // " LIKE 'xyz%'" fieldToUpdate = " LIKE '" + filter.value().toString() + "%'" ; - error = QContactManager::NoError; + *error = QContactManager::NoError; break; } case QContactFilter::MatchEndsWith: { // Pattern for MatchEndsWith: // " LIKE '%xyz'" - fieldToUpdate = " LIKE '%" + filter.value().toString() + "'" ; - error = QContactManager::NoError; + fieldToUpdate = " LIKE '%" + filter.value().toString() + '\'' ; + *error = QContactManager::NoError; break; } case QContactFilter::MatchFixedString: { - error = QContactManager::NotSupportedError; + *error = QContactManager::NotSupportedError; break; } case QContactFilter::MatchCaseSensitive: { - error = QContactManager::NotSupportedError; + *error = QContactManager::NotSupportedError; break; } default: { - error = QContactManager::NotSupportedError; + *error = QContactManager::NotSupportedError; break; } } @@ -243,7 +246,7 @@ void CntFilterDetail::getTableNameWhereClause( const QContactDetailFilter& detailfilter, QString& tableName, QString& sqlWhereClause , - QContactManager::Error& error) const + QContactManager::Error* error) const { //Get the table name and the column name bool isSubType; @@ -253,35 +256,36 @@ CntTransformContact transformContact; quint32 fieldId = transformContact.GetIdForDetailL(detailfilter, isSubType); m_dbInfo.getDbTableAndColumnName(fieldId,tableName,columnName); - + //return if tableName is empty - if(tableName == "" ){ - error = QContactManager::NotSupportedError; + if(tableName.isEmpty()) + { + *error = QContactManager::NotSupportedError; return; - } + } //check columnName - if(columnName == "") { - error = QContactManager::NotSupportedError; + if(columnName.isEmpty()) + { + *error = QContactManager::NotSupportedError; return; - } - else if(isSubType) { + } + else if(isSubType) + { sqlWhereClause += columnName; sqlWhereClause += " NOT NULL "; - } - else { - - sqlWhereClause += " " + columnName + " "; + } + else + { + sqlWhereClause += ' ' + columnName + ' '; QString fieldToUpdate; //Update the value depending on the match flag updateForMatchFlag(detailfilter,fieldToUpdate,error); sqlWhereClause += fieldToUpdate; - } - - + } } -QList CntFilterDetail::HandlePredictiveSearchFilter(const QContactFilter& filter,QContactManager::Error& error) +QList CntFilterDetail::HandlePredictiveSearchFilter(const QContactFilter& filter,QContactManager::Error* error) { QString sqlQuery;