void CntFilterDetail::createPhoneNumberQuery( const QContactFilter& filter, QString& sqlQuery, QContactManager::Error* error) { QContactDetailFilter detailFilter(filter); if (detailFilter.detailDefinitionName() != QContactPhoneNumber::DefinitionName) { *error = QContactManager::NotSupportedError; return; } if (detailFilter.detailFieldName().isEmpty()) { fetchAllPhoneNumbers(sqlQuery); } else if (detailFilter.detailFieldName() == QContactPhoneNumber::FieldNumber) { // Matches phonenumbers // Phonenumber matching algorithm used if (bestMatchingEnabled()) { bestMatchPhoneNumberQuery(filter,sqlQuery,error); } else { createMatchPhoneNumberQuery(filter,sqlQuery,error); } } else if (detailFilter.detailFieldName() == QContactPhoneNumber::FieldSubTypes) { // Finds all mobile numbers. other subtypes not supported createSelectQuery(filter,sqlQuery,error); } else { *error = QContactManager::NotSupportedError; } }
QList<QContactLocalId> CntFilterDetail::contacts( const QContactFilter &filter, const QList<QContactSortOrder> &sortOrders, bool &filterSupportedflag, QContactManager::Error* error) { //Check if any invalid filter is passed if (!filterSupported(filter) ) { *error = QContactManager::NotSupportedError; filterSupportedflag = false; return QList<QContactLocalId>(); } QList<QContactLocalId> idList; QContactDetailFilter detailFilter(filter); QString sqlQuery; //Check for phonenumber. Special handling needed if ( (detailFilter.detailDefinitionName() == QContactPhoneNumber::DefinitionName ) && (detailFilter.detailFieldName() != QContactPhoneNumber::FieldSubTypes)) { //Handle phonenumber ... if(detailFilter.detailFieldName().isEmpty()){ fetchAllPhoneNumbers(sqlQuery); } else if(bestMatchingEnabled()) { bestMatchPhoneNumberQuery(filter,sqlQuery,error); } else { createMatchPhoneNumberQuery(filter,sqlQuery,error); } if (*error == QContactManager::NoError) { //fetch the contacts idList = m_srvConnection.searchContacts(sqlQuery,error); } } else if (detailFilter.matchFlags() == QContactFilter::MatchKeypadCollation) { //predictive search filter idList = HandlePredictiveSearchFilter(filter,error); } // handle other cases else { createSelectQuery(filter,sqlQuery,error); QString sortQuery = m_dbInfo.getSortQuery(sortOrders, sqlQuery, error); if (*error == QContactManager::NoError) { //fetch the contacts idList = m_srvConnection.searchContacts(sortQuery, error); } } return idList; }