predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsAlgorithm2Helper.cpp
branchRCL_3
changeset 21 b3431bff8c19
parent 0 e686773b3f54
child 58 d4f567ce2e7c
equal deleted inserted replaced
15:e8e3147d53eb 21:b3431bff8c19
   114     // Create filtering helper for the required sort type
   114     // Create filtering helper for the required sort type
   115     TSortType sortType = aSettings.GetSortType();
   115     TSortType sortType = aSettings.GetSortType();
   116     CPcsAlgorithm2FilterHelper* filterHelper =
   116     CPcsAlgorithm2FilterHelper* filterHelper =
   117             CPcsAlgorithm2FilterHelper::NewL(sortType);
   117             CPcsAlgorithm2FilterHelper::NewL(sortType);
   118 
   118 
   119     // Convert the search condition to numeric key string
       
   120     TBuf<KPsQueryMaxLen> numericKeyStr;
       
   121     TPtrC queryPtr = aPsQuery.QueryAsStringLC();
       
   122     keyMap->GetNumericKeyString(queryPtr, numericKeyStr);
       
   123     PRINT2 ( _L("Numeric Key String for %S = %S"), &queryPtr, &numericKeyStr );
       
   124 
       
   125     // Reset the result set array for new search
   119     // Reset the result set array for new search
   126     iSearchResultsArr.ResetAndDestroy();
   120     iSearchResultsArr.ResetAndDestroy();
   127 
   121 
   128     // Get the data stores
   122     // Get the data stores
   129     RPointerArray<TDesC> aDataStores;
   123     RPointerArray<TDesC> aDataStores;
   130     aSettings.SearchUrisL(aDataStores);
   124     aSettings.SearchUrisL(aDataStores);
   131 
   125 
   132     // Get the required display fields from the client
   126     // Get the required display fields from the client
   133     RArray<TInt> requiredDataFields;
   127     RArray<TInt> requiredDataFields;
   134     aSettings.DisplayFieldsL(requiredDataFields);
   128     aSettings.DisplayFieldsL(requiredDataFields);
   135 
   129     
   136     // Search based on first key str
   130     // Search from cache based on first character
   137     TInt numValue = keyMap->PoolIdForCharacter(numericKeyStr[0]);
   131      const CPsQueryItem& firstCharItem = aPsQuery.GetItemAtL(0);
       
   132      TInt numValue  = keyMap->PoolIdForCharacter( firstCharItem.Character() );
   138 
   133 
   139     // Perform search for each required data store
   134     // Perform search for each required data store
   140     RPointerArray<CPcsPoolElement> elements;
   135     RPointerArray<CPcsPoolElement> elements;
   141 
   136 
   142     for (int dsIndex = 0; dsIndex < aDataStores.Count(); dsIndex++)
   137     for (int dsIndex = 0; dsIndex < aDataStores.Count(); dsIndex++)
   223     // Create filtering helper for the required sort type
   218     // Create filtering helper for the required sort type
   224     TSortType sortType = aSettings.GetSortType();
   219     TSortType sortType = aSettings.GetSortType();
   225     CPcsAlgorithm2FilterHelper* filterHelper =
   220     CPcsAlgorithm2FilterHelper* filterHelper =
   226             CPcsAlgorithm2FilterHelper::NewL(sortType);
   221             CPcsAlgorithm2FilterHelper::NewL(sortType);
   227 
   222 
   228     // Convert the search condition to numeric key string
   223     // Convert the query to string
   229     TBuf<KPsQueryMaxLen> numericKeyStr;
       
   230     TPtrC queryPtr = aPsQuery.QueryAsStringLC();
   224     TPtrC queryPtr = aPsQuery.QueryAsStringLC();
   231     keyMap->GetNumericKeyString(queryPtr, numericKeyStr);
   225 
   232     PRINT2 ( _L("Numeric Key String for %S = %S"), &queryPtr, &numericKeyStr );
   226     // Search from cache based on first character
   233     TInt numValue = keyMap->PoolIdForCharacter(numericKeyStr[0]);
   227     const CPsQueryItem& firstCharItem = aPsQuery.GetItemAtL(0);
       
   228     TInt numValue  = keyMap->PoolIdForCharacter( firstCharItem.Character() );
   234 
   229 
   235     // Reset the result set array for new search
   230     // Reset the result set array for new search
   236     iSearchResultsArr.ResetAndDestroy();
   231     iSearchResultsArr.ResetAndDestroy();
   237 
   232 
   238     // Get the data stores
   233     // Get the data stores
   259             }
   254             }
   260         CPcsCache* cache = iAlgorithm->GetCache(arrayIndex);
   255         CPcsCache* cache = iAlgorithm->GetCache(arrayIndex);
   261         cache->GetContactsForKeyL(numValue, elements);
   256         cache->GetContactsForKeyL(numValue, elements);
   262 
   257 
   263         // Perform filtering
   258         // Perform filtering
   264         FilterResultsL(filterHelper, elements, numericKeyStr,
   259         FilterResultsL(filterHelper, elements, queryPtr,
   265                        isSearchInGroup, aContactsInGroup);
   260                        isSearchInGroup, aContactsInGroup);
   266 
   261 
   267         // If alphabetical sorting, get the results for this datastore               
   262         // If alphabetical sorting, get the results for this datastore               
   268         if (sortType == EAlphabetical)
   263         if (sortType == EAlphabetical)
   269             {
   264             {
   326     // te filtering helper for the required sort type
   321     // te filtering helper for the required sort type
   327     TSortType sortType = aSettings.GetSortType();
   322     TSortType sortType = aSettings.GetSortType();
   328     CPcsAlgorithm2FilterHelper* filterHelper =
   323     CPcsAlgorithm2FilterHelper* filterHelper =
   329             CPcsAlgorithm2FilterHelper::NewL(sortType);
   324             CPcsAlgorithm2FilterHelper::NewL(sortType);
   330 
   325 
   331     // Convert the search condition to numeric key string
   326     // Convert the query to string
   332     TBuf<KPsQueryMaxLen> numericKeyStr;
       
   333     TPtrC queryPtr = aPsQuery.QueryAsStringLC();
   327     TPtrC queryPtr = aPsQuery.QueryAsStringLC();
   334 
   328 
   335     TChar queryChar;
   329     // Search from cache based on first character
   336 
   330     const CPsQueryItem& firstCharItem = aPsQuery.GetItemAtL(0);
   337     // Handle Chinese word search case: extract the first char of one of its spelling
   331     TInt numValue  = keyMap->PoolIdForCharacter( firstCharItem.Character() );
   338     // which will be used as search string
   332     
   339     if (iAlgorithm->FindUtilECE()->IsChineseWord(queryPtr))
       
   340         {
       
   341         RPointerArray<HBufC> spellList;
       
   342         if (iAlgorithm->FindUtilECE()->T9ChineseTranslationL(queryPtr[0], spellList))
       
   343             {
       
   344             queryChar = *(spellList[0]->Ptr());
       
   345             }
       
   346         else
       
   347             {
       
   348             queryChar = queryPtr[0];
       
   349             }
       
   350         spellList.ResetAndDestroy();
       
   351         }
       
   352     else
       
   353         {
       
   354         queryChar = queryPtr[0];
       
   355         }
       
   356 
       
   357     TInt numValue = keyMap->PoolIdForCharacter(queryChar);
       
   358     // Reset the result set array for new search
   333     // Reset the result set array for new search
   359     iSearchResultsArr.ResetAndDestroy();
   334     iSearchResultsArr.ResetAndDestroy();
   360 
   335 
   361     // Get the data stores  
   336     // Get the data stores  
   362     RPointerArray<TDesC> aDataStores;
   337     RPointerArray<TDesC> aDataStores;