plugins/contacts/symbian/contactsmodel/cntplsql/src/cpplpredictivesearchtable.cpp
equal
deleted
inserted
replaced
18 #include "pltables.h" |
18 #include "pltables.h" |
19 #include "dbsqlconstants.h" |
19 #include "dbsqlconstants.h" |
20 #include "cpcskeymap.h" |
20 #include "cpcskeymap.h" |
21 #include "cntitem.h" |
21 #include "cntitem.h" |
22 #include <QStringList> |
22 #include <QStringList> |
|
23 // This macro suppresses log writes |
|
24 //#define NO_PRED_SEARCH_LOGS |
23 #include "predictivesearchlog.h" |
25 #include "predictivesearchlog.h" |
24 |
26 |
25 |
27 |
26 // How many characters from the beginning of the first name and last name are |
28 // How many characters from the beginning of the first name and last name are |
27 // stored. This only affects how precisely the results are put in alphabetic order. |
29 // stored. This only affects how precisely the results are put in alphabetic order. |
93 |
95 |
94 /** |
96 /** |
95 Default implementation returns empty list. |
97 Default implementation returns empty list. |
96 */ |
98 */ |
97 QStringList CPplPredictiveSearchTableBase::GetTableSpecificFields( |
99 QStringList CPplPredictiveSearchTableBase::GetTableSpecificFields( |
98 const CContactItem& /*aItem*/, |
100 const CContactItem& /*aItem*/) const |
99 TBool& aMandatoryFieldsPresent) const |
101 { |
100 { |
|
101 aMandatoryFieldsPresent = ETrue; |
|
102 QStringList emptyList; |
102 QStringList emptyList; |
103 return emptyList; |
103 return emptyList; |
|
104 } |
|
105 |
|
106 |
|
107 const CPcsKeyMap* CPplPredictiveSearchTableBase::KeyMap() const |
|
108 { |
|
109 return iKeyMap; |
104 } |
110 } |
105 |
111 |
106 |
112 |
107 HBufC* CPplPredictiveSearchTableBase::GetNextTableNameL(QList<QChar>& aTables) const |
113 HBufC* CPplPredictiveSearchTableBase::GetNextTableNameL(QList<QChar>& aTables) const |
108 { |
114 { |
181 |
187 |
182 |
188 |
183 // Insert a contact to predictive search tables. |
189 // Insert a contact to predictive search tables. |
184 // Write contact's all tokens to each associate pred.search table. |
190 // Write contact's all tokens to each associate pred.search table. |
185 // E.g. if FN="11 22" LN="2 333", write "11","22","2" and "333" to tables 1, 2 and 3. |
191 // E.g. if FN="11 22" LN="2 333", write "11","22","2" and "333" to tables 1, 2 and 3. |
|
192 // |
|
193 // Store also contacts that have a mail address beginning by an unknown character |
|
194 // as the contact can still be searched by first name or last name. |
186 void CPplPredictiveSearchTableBase::WriteToDbL(const CContactItem& aItem) |
195 void CPplPredictiveSearchTableBase::WriteToDbL(const CContactItem& aItem) |
187 { |
196 { |
188 PRINT(_L("CPplPredictiveSearchTableBase::WriteToDbL")); |
197 PRINT(_L("CPplPredictiveSearchTableBase::WriteToDbL")); |
189 |
198 |
190 HBufC* firstNameAsNbr(NULL); // owned |
199 HBufC* firstNameAsNbr(NULL); // owned |
194 GetFieldsLC(aItem, &firstNameAsNbr, &lastNameAsNbr, &firstName, &lastName); |
203 GetFieldsLC(aItem, &firstNameAsNbr, &lastNameAsNbr, &firstName, &lastName); |
195 |
204 |
196 QStringList tokens; |
205 QStringList tokens; |
197 QList<QChar> tables; |
206 QList<QChar> tables; |
198 QT_TRYCATCH_LEAVING({ |
207 QT_TRYCATCH_LEAVING({ |
199 TBool mandatoryFieldsPresent(EFalse); |
208 QStringList tableSpecificFields = GetTableSpecificFields(aItem); |
200 QStringList tableSpecificFields = |
209 tokens = GetTokens(tableSpecificFields, firstNameAsNbr, lastNameAsNbr); |
201 GetTableSpecificFields(aItem, mandatoryFieldsPresent); |
210 tables = DetermineTables(tokens); |
202 if (mandatoryFieldsPresent) |
|
203 { |
|
204 tokens = GetTokens(tableSpecificFields, firstNameAsNbr, lastNameAsNbr); |
|
205 tables = DetermineTables(tokens); |
|
206 } |
|
207 }); |
211 }); |
208 |
212 |
209 HBufC* tableName(NULL); |
213 HBufC* tableName(NULL); |
210 while ((tableName = GetNextTableNameL(tables)) != NULL) |
214 while ((tableName = GetNextTableNameL(tables)) != NULL) |
211 { |
215 { |
362 CPplPredictiveSearchTableBase::AddTokens(HBufC* aString, QStringList& aTokens) const |
366 CPplPredictiveSearchTableBase::AddTokens(HBufC* aString, QStringList& aTokens) const |
363 { |
367 { |
364 if (aString) |
368 if (aString) |
365 { |
369 { |
366 QString s((QChar*)aString->Ptr(), aString->Length()); |
370 QString s((QChar*)aString->Ptr(), aString->Length()); |
367 #if defined(USE_ORBIT_KEYMAP) |
|
368 QStringList tokens = s.split(iKeyMap->Separator(), QString::SkipEmptyParts); |
371 QStringList tokens = s.split(iKeyMap->Separator(), QString::SkipEmptyParts); |
369 #else |
|
370 QStringList tokens = s.split(' ', QString::SkipEmptyParts); |
|
371 #endif |
|
372 |
372 |
373 // Select tokens in the same order they are in original aString |
373 // Select tokens in the same order they are in original aString |
374 for (TInt i = 0; i < tokens.count(); ++i) |
374 for (TInt i = 0; i < tokens.count(); ++i) |
375 { |
375 { |
376 if (IsValidChar(tokens[i][0])) |
376 if (IsValidChar(tokens[i][0])) |