qtmobility/plugins/contacts/symbian/src/filtering/cntsymbianfilterdbms.cpp
changeset 8 71781823f776
parent 4 90517678cc4f
child 11 06b8e2af4411
equal deleted inserted replaced
5:453da2cfceef 8:71781823f776
   325             TInt matchLength(KDefaultMatchLength);
   325             TInt matchLength(KDefaultMatchLength);
   326             // no need to propagate error, we can use the default match length
   326             // no need to propagate error, we can use the default match length
   327             TRAP_IGNORE(getMatchLengthL(matchLength));
   327             TRAP_IGNORE(getMatchLengthL(matchLength));
   328 
   328 
   329             TInt err = matchContacts(idArray, commPtr, matchLength);
   329             TInt err = matchContacts(idArray, commPtr, matchLength);
   330             if(err != KErrNone) {
   330             if (err == KErrNone) {
       
   331                 // Phone number matching sometimes includes nonexisting contacts to
       
   332                 // the result for some reason. Remove them.
       
   333                 for (TInt i(0); i < idArray->Count(); ) {
       
   334                     if(!contactExists((*idArray)[i])) {
       
   335                         idArray->Remove(i);
       
   336                     } else {
       
   337                         i++;
       
   338                     }
       
   339                 }
       
   340             } else {
   331                 CntSymbianTransformError::transformError(err, error);
   341                 CntSymbianTransformError::transformError(err, error);
   332             }
   342             }
   333         // Names, e-mail, display label (other flags)
   343         // Names, e-mail, display label (other flags)
   334         } else {
   344         } else {
   335             QString name((detailFilter.value()).toString());
   345             QString name((detailFilter.value()).toString());
   409         // character is a space)
   419         // character is a space)
   410         else if(index > 0 && TChar(text[index-1]) == TChar(0x20))
   420         else if(index > 0 && TChar(text[index-1]) == TChar(0x20))
   411             value = false;
   421             value = false;
   412     }
   422     }
   413     return value;
   423     return value;
       
   424 }
       
   425 
       
   426 bool CntSymbianFilter::contactExists(const TContactItemId &contactId)
       
   427 {
       
   428     TRAPD(err, m_contactDatabase.ReadMinimalContactL(contactId));
       
   429     return err == KErrNone;
   414 }
   430 }
   415 
   431 
   416 /*!
   432 /*!
   417  * Transform detail filter into a contact item field definition that can be
   433  * Transform detail filter into a contact item field definition that can be
   418  * used with CContactDatabase finds.
   434  * used with CContactDatabase finds.