author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 21 | 9da50d567e3c |
parent 20 | f4a778e096c2 |
permissions | -rw-r--r-- |
20 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Phonebook2 contact editor dialog. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include "CPbk2AdaptiveSearchGridFiller.h" |
|
21 |
#include "MVPbkViewContact.h" |
|
22 |
#include "MVPbkContactViewBase.h" |
|
23 |
#include "MPbk2ContactNameFormatter.h" |
|
24 |
#include "MPbk2FilteredViewStack.h" |
|
25 |
||
26 |
#include <MVPbkBaseContactFieldCollection.h> |
|
27 |
#include <MVPbkContactFieldTextData.h> |
|
28 |
#include <MVPbkBaseContactField.h> |
|
29 |
||
30 |
||
31 |
#include <MPbk2ContactViewSupplier.h> |
|
32 |
#include <MPbk2ApplicationServices.h> |
|
33 |
#include <MPbk2AppUi.h> |
|
34 |
#include <CPbk2StoreConfiguration.h> |
|
35 |
#include <MPbk2ContactNameFormatter2.h> |
|
36 |
#include <FindUtil.h> |
|
37 |
#include <badesca.h> |
|
38 |
#include <featmgr.h> |
|
39 |
||
40 |
#include <CPsRequestHandler.h> |
|
41 |
||
42 |
const TInt KMaxAdaptiveGridCacheCount = 10; |
|
43 |
const TInt KAdaptiveSearchKeyMapGranularity = 100; |
|
44 |
const TInt KAdaptiveSearchRefineStep = 25; |
|
45 |
const TInt KContactFormattingFlags = MPbk2ContactNameFormatter::EPreserveLeadingSpaces | |
|
46 |
MPbk2ContactNameFormatter::EReplaceNonGraphicChars | |
|
47 |
MPbk2ContactNameFormatter::EDisableCompanyNameSeparator; |
|
48 |
||
49 |
namespace { |
|
50 |
enum TNameOrder |
|
51 |
{ |
|
52 |
ETopContactOrderNumber = 0, //TC control data, not shown |
|
53 |
ENameFirstPart, //Contact name data |
|
54 |
ENameSecondPart, //Contact name data |
|
55 |
ENameCompanyPart //to support Company name |
|
56 |
}; |
|
57 |
} // namespace |
|
58 |
||
59 |
NONSHARABLE_CLASS(CPbk2AdaptiveGrid) : public CBase |
|
60 |
{ |
|
61 |
HBufC* iFindText; |
|
62 |
HBufC* iKeyMap; |
|
63 |
||
64 |
public: |
|
65 |
||
66 |
CPbk2AdaptiveGrid() |
|
67 |
{ |
|
68 |
} |
|
69 |
||
70 |
~CPbk2AdaptiveGrid() |
|
71 |
{ |
|
72 |
delete iFindText; |
|
73 |
delete iKeyMap; |
|
74 |
} |
|
75 |
||
76 |
void SetKeyMapL( const TDesC& aFindText, const TDesC& aKeyMap ) |
|
77 |
{ |
|
78 |
delete iFindText; |
|
79 |
delete iKeyMap; |
|
80 |
||
81 |
iFindText = iKeyMap = NULL; |
|
82 |
||
83 |
iFindText = aFindText.AllocL(); |
|
84 |
iKeyMap = aKeyMap.AllocL(); |
|
85 |
} |
|
86 |
||
87 |
const TDesC& GetFindText() const |
|
88 |
{ |
|
89 |
return *iFindText; |
|
90 |
} |
|
91 |
||
92 |
const TDesC& GetKeyMap() const |
|
93 |
{ |
|
94 |
return *iKeyMap; |
|
95 |
} |
|
96 |
}; |
|
97 |
||
98 |
// -------------------------------------------------------------------------- |
|
99 |
// CPbk2ContactEditorDlg::CPbk2ContactEditorDlg |
|
100 |
// -------------------------------------------------------------------------- |
|
101 |
// |
|
102 |
CPbk2AdaptiveSearchGridFiller::CPbk2AdaptiveSearchGridFiller( CAknSearchField& aField, MPbk2ContactNameFormatter& aNameFormatter ) |
|
103 |
: CActive( CActive::EPriorityIdle ), iSearchField( aField ), iNameFormatter( aNameFormatter ), |
|
104 |
iInvalidateAdaptiveSearchGrid( EFalse ),iSetFocusToSearchGrid( ETrue ) |
|
105 |
{ |
|
106 |
CActiveScheduler::Add( this ); |
|
107 |
} |
|
108 |
||
109 |
// -------------------------------------------------------------------------- |
|
110 |
// CPbk2ContactEditorDlg::~CPbk2ContactEditorDlg |
|
111 |
// -------------------------------------------------------------------------- |
|
112 |
// |
|
113 |
CPbk2AdaptiveSearchGridFiller::~CPbk2AdaptiveSearchGridFiller() |
|
114 |
{ |
|
115 |
Cancel(); |
|
116 |
if ( iPsHandler ) |
|
117 |
{ |
|
118 |
iPsHandler->RemoveObserver( this ); |
|
119 |
delete iPsHandler; |
|
120 |
} |
|
121 |
delete iKeyMap; |
|
122 |
delete iCurrentGrid; |
|
123 |
iAdaptiveGridCache.ResetAndDestroy(); |
|
124 |
delete iSearchString; |
|
125 |
delete iFindUtil; |
|
126 |
iDigraphContactsTitleArray.ResetAndDestroy(); |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
127 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
128 |
if (iFeatureManagerInitialized) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
129 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
130 |
// It can be safely called UnInitializeLib as it has been really intialized. |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
131 |
FeatureManager::UnInitializeLib(); // Decreases ref.count |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
132 |
} |
20 | 133 |
} |
134 |
||
135 |
||
136 |
// -------------------------------------------------------------------------- |
|
137 |
// CPbk2ContactEditorDlg::NewL |
|
138 |
// -------------------------------------------------------------------------- |
|
139 |
// |
|
140 |
CPbk2AdaptiveSearchGridFiller* CPbk2AdaptiveSearchGridFiller::NewL( CAknSearchField& aField, MPbk2ContactNameFormatter& aNameFormatter ) |
|
141 |
{ |
|
142 |
CPbk2AdaptiveSearchGridFiller* self = |
|
143 |
new(ELeave) CPbk2AdaptiveSearchGridFiller( aField, aNameFormatter ); |
|
144 |
CleanupStack::PushL(self); |
|
145 |
self->ConstructL(); |
|
146 |
CleanupStack::Pop(self); |
|
147 |
return self; |
|
148 |
} |
|
149 |
||
150 |
||
151 |
// -------------------------------------------------------------------------- |
|
152 |
// CPbk2ContactEditorDlg::ConstructL |
|
153 |
// -------------------------------------------------------------------------- |
|
154 |
// |
|
155 |
void CPbk2AdaptiveSearchGridFiller::ConstructL() |
|
156 |
{ |
|
157 |
iKeyMap = HBufC::NewL( KAdaptiveSearchKeyMapGranularity ); |
|
158 |
iFindUtil = CFindUtil::NewL(); |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
159 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
160 |
// Initialize feature manager |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
161 |
FeatureManager::InitializeLibL(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
162 |
iFeatureManagerInitialized = ETrue; |
20 | 163 |
// UI Language |
164 |
TLanguage uiLanguage = User::Language(); |
|
165 |
if ( uiLanguage != ELangJapanese && uiLanguage != ELangPrcChinese && |
|
166 |
uiLanguage != ELangHongKongChinese && uiLanguage != ELangTaiwanChinese && |
|
167 |
uiLanguage != ELangKorean ) |
|
168 |
{ |
|
169 |
iPsHandler = CPSRequestHandler::NewL(); |
|
170 |
iPsHandler->AddObserverL( this ); |
|
171 |
} |
|
172 |
} |
|
173 |
||
174 |
void CPbk2AdaptiveSearchGridFiller::StartFillingL( const MVPbkContactViewBase& aView, |
|
175 |
const TDesC& aSearchString, TBool aClearCache ) |
|
176 |
{ |
|
177 |
||
178 |
if( aClearCache ) |
|
179 |
{ |
|
180 |
ClearCache(); |
|
181 |
} |
|
182 |
||
183 |
if ( IsActive() && iView == &aView && iViewItemCount == aView.ContactCountL() |
|
184 |
&& iSearchString && !iSearchString->Compare( aSearchString ) ) |
|
185 |
{ |
|
186 |
return; |
|
187 |
} |
|
188 |
else |
|
189 |
{ |
|
190 |
StopFilling(); |
|
191 |
} |
|
192 |
||
193 |
CPbk2AdaptiveGrid* keyMap = KeyMapFromCache( aSearchString ); |
|
194 |
||
195 |
if( keyMap ) |
|
196 |
{ |
|
197 |
iSearchField.SetAdaptiveGridChars( keyMap->GetKeyMap() ); |
|
198 |
return; |
|
199 |
} |
|
200 |
||
201 |
iViewItemCount = aView.ContactCountL(); |
|
202 |
delete iSearchString; |
|
203 |
iSearchString = NULL; |
|
204 |
||
205 |
iSearchString = aSearchString.AllocL(); |
|
206 |
||
207 |
// If there is no search word, the user is not searching any contacts |
|
208 |
// so we should reset the array to prepare for the next searching. |
|
209 |
if ( iSearchString->Length() == 0 ) |
|
210 |
{ |
|
211 |
iDigraphContactsTitleArray.ResetAndDestroy(); |
|
212 |
} |
|
213 |
iView = &aView; |
|
214 |
||
215 |
iKeyMap->Des().Zero(); |
|
216 |
||
217 |
iCounter = 0; |
|
218 |
||
219 |
if ( iSearchString->Length() <= KPsAdaptiveGridSupportedMaxLen && GridFromPsEngineL( aView ) ) |
|
220 |
{ |
|
221 |
return; |
|
222 |
} |
|
223 |
||
224 |
SetActive(); |
|
225 |
TRequestStatus* status = &iStatus; |
|
226 |
User::RequestComplete( status, KErrNone ); |
|
227 |
} |
|
228 |
||
229 |
void CPbk2AdaptiveSearchGridFiller::StopFilling() |
|
230 |
{ |
|
231 |
Cancel(); |
|
232 |
iView = NULL; |
|
233 |
} |
|
234 |
||
235 |
void CPbk2AdaptiveSearchGridFiller::RunL() |
|
236 |
{ |
|
237 |
if( !iView ) |
|
238 |
{ |
|
239 |
return; |
|
240 |
} |
|
241 |
||
242 |
TInt stopCount = iCounter + KAdaptiveSearchRefineStep; |
|
243 |
const TInt itemCount = iView->ContactCountL(); |
|
244 |
||
245 |
if( stopCount > itemCount ) |
|
246 |
{ |
|
247 |
stopCount = itemCount; |
|
248 |
} |
|
249 |
||
250 |
TInt maxSpacesNumber = 0; |
|
251 |
||
252 |
CDesC16Array* searchWordsArray = SplitSearchFieldTextIntoArrayLC( *iSearchString ); |
|
253 |
TInt searchStringSpacesNumber = searchWordsArray->MdcaCount() - 1; |
|
254 |
||
255 |
for( ; iCounter < stopCount; iCounter++ ) |
|
256 |
{ |
|
257 |
const MVPbkViewContact& contact = iView->ContactAtL( iCounter ); |
|
258 |
const TInt titleLength = iNameFormatter.MaxTitleLength( contact.Fields(), KContactFormattingFlags ); |
|
259 |
HBufC* title = NULL; |
|
260 |
||
261 |
if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ) ) |
|
262 |
{ |
|
263 |
MPbk2ContactNameFormatter2* nameformatterExtension = |
|
264 |
reinterpret_cast<MPbk2ContactNameFormatter2*>( iNameFormatter. |
|
265 |
ContactNameFormatterExtension( MPbk2ContactNameFormatterExtension2Uid ) ); |
|
266 |
if ( nameformatterExtension && titleLength ) |
|
267 |
{ |
|
268 |
title = nameformatterExtension->GetContactTitleWithCompanyNameL( contact.Fields(), |
|
269 |
KContactFormattingFlags ); |
|
270 |
||
271 |
} |
|
272 |
} |
|
273 |
else if ( titleLength ) |
|
274 |
{ |
|
275 |
title = iNameFormatter.GetContactTitleL( contact.Fields(), KContactFormattingFlags ); |
|
276 |
||
277 |
// In FDN, the number will be displayed in the list if the contact is no name. |
|
278 |
// If it is, set the search string as NULL. |
|
279 |
if ( IsActualTitleEmpty( contact ) ) |
|
280 |
{ |
|
281 |
delete title; |
|
282 |
title = NULL; |
|
283 |
} |
|
284 |
} |
|
285 |
||
286 |
if ( !title ) |
|
287 |
{ |
|
288 |
title = HBufC::NewL( titleLength ); |
|
289 |
} |
|
290 |
||
291 |
CleanupStack::PushL( title ); |
|
292 |
BuildGridL( *title, searchWordsArray, iKeyMap ); |
|
293 |
||
294 |
// check number of spaces in the contact title |
|
295 |
TInt numberOfSpaces = NumberOfSpacesInString( *title ); |
|
296 |
if ( numberOfSpaces > maxSpacesNumber ) |
|
297 |
{ |
|
298 |
maxSpacesNumber = numberOfSpaces; |
|
299 |
} |
|
300 |
// Check if the contact's title include drgraphs, |
|
301 |
// if it is, add it to array to save. |
|
302 |
if ( IsDigraphContactsTitleL( *title ) ) |
|
303 |
{ |
|
304 |
iDigraphContactsTitleArray.AppendL( title ); |
|
305 |
CleanupStack::Pop(); //title |
|
306 |
} |
|
307 |
else |
|
308 |
{ |
|
309 |
CleanupStack::PopAndDestroy( title ); |
|
310 |
} |
|
311 |
} |
|
312 |
// If there are titles in array, we should add them to build grids again, |
|
313 |
// because the contacts include drgraphs will be filtered |
|
314 |
// when the application builds grids again. |
|
315 |
if ( iDigraphContactsTitleArray.Count()!= 0 ) |
|
316 |
{ |
|
317 |
for( TInt i(0); i < iDigraphContactsTitleArray.Count() ; i++ ) |
|
318 |
{ |
|
319 |
TPtr ptrContactsTitle = iDigraphContactsTitleArray[i]->Des(); |
|
320 |
BuildGridL( ptrContactsTitle, searchWordsArray, iKeyMap ); |
|
321 |
} |
|
322 |
} |
|
323 |
||
324 |
CleanupStack::PopAndDestroy( searchWordsArray ); //searchWordsArray |
|
325 |
||
326 |
if( stopCount == itemCount ) |
|
327 |
{ |
|
328 |
SetAdaptiveGridCharsL( maxSpacesNumber, searchStringSpacesNumber ); |
|
329 |
AddKeyMapToCacheL( *iSearchString, *iKeyMap ); |
|
330 |
} |
|
331 |
else |
|
332 |
{ |
|
333 |
//else continue |
|
334 |
SetActive(); |
|
335 |
TRequestStatus* status = &iStatus; |
|
336 |
User::RequestComplete( status, KErrNone ); |
|
337 |
} |
|
338 |
} |
|
339 |
||
340 |
void CPbk2AdaptiveSearchGridFiller::DoCancel() |
|
341 |
{ |
|
342 |
iView = NULL; |
|
343 |
} |
|
344 |
||
345 |
TInt CPbk2AdaptiveSearchGridFiller::RunError( TInt /*aError*/ ) |
|
346 |
{ |
|
347 |
//ignore errors, nothing critical has happened, lets forget it |
|
348 |
return KErrNone; |
|
349 |
} |
|
350 |
||
351 |
CPbk2AdaptiveGrid* CPbk2AdaptiveSearchGridFiller::KeyMapFromCache( const TDesC& aFindText ) |
|
352 |
{ |
|
353 |
const TInt count = iAdaptiveGridCache.Count(); |
|
354 |
||
355 |
for( TInt i( 0 ); i < count; i++ ) |
|
356 |
{ |
|
357 |
if( iAdaptiveGridCache[i] != NULL |
|
358 |
&& !aFindText.Compare( iAdaptiveGridCache[i]->GetFindText() ) ) |
|
359 |
{ |
|
360 |
return iAdaptiveGridCache[i]; |
|
361 |
} |
|
362 |
} |
|
363 |
||
364 |
return NULL; |
|
365 |
} |
|
366 |
||
367 |
void CPbk2AdaptiveSearchGridFiller::AddKeyMapToCacheL( const TDesC& aFindText, const TDesC& aKeyMap ) |
|
368 |
{ |
|
369 |
CPbk2AdaptiveGrid* keyMap = new( ELeave )CPbk2AdaptiveGrid; |
|
370 |
CleanupStack::PushL( keyMap ); |
|
371 |
keyMap->SetKeyMapL( aFindText, aKeyMap ); |
|
372 |
||
373 |
// Keep always in the cache at position 0 the grid cache element for empty find box, |
|
374 |
// which is the one that requires more time to be built |
|
375 |
if ( aFindText.Length() == 0 ) |
|
376 |
{ |
|
377 |
if ( iAdaptiveGridCache.Count() > 0 ) |
|
378 |
{ |
|
379 |
delete iAdaptiveGridCache[0]; |
|
380 |
iAdaptiveGridCache.Remove( 0 ); |
|
381 |
} |
|
382 |
||
383 |
iAdaptiveGridCache.InsertL( keyMap, 0 ); |
|
384 |
} |
|
385 |
else |
|
386 |
{ |
|
387 |
if ( iAdaptiveGridCache.Count() == 0 ) |
|
388 |
{ |
|
389 |
iAdaptiveGridCache.InsertL( NULL, 0 ); |
|
390 |
} |
|
391 |
||
392 |
iAdaptiveGridCache.InsertL( keyMap, 1 ); |
|
393 |
||
394 |
// Delete oldest cache element |
|
395 |
if( iAdaptiveGridCache.Count() > KMaxAdaptiveGridCacheCount ) |
|
396 |
{ |
|
397 |
delete iAdaptiveGridCache[KMaxAdaptiveGridCacheCount]; |
|
398 |
iAdaptiveGridCache.Remove( KMaxAdaptiveGridCacheCount ); |
|
399 |
} |
|
400 |
} |
|
401 |
||
402 |
CleanupStack::Pop(); //keyMap |
|
403 |
} |
|
404 |
||
405 |
void CPbk2AdaptiveSearchGridFiller::ClearCache() |
|
406 |
{ |
|
407 |
iAdaptiveGridCache.ResetAndDestroy(); |
|
408 |
if ( iCurrentGrid ) |
|
409 |
{ |
|
410 |
delete iCurrentGrid; |
|
411 |
iCurrentGrid = NULL; |
|
412 |
} |
|
413 |
} |
|
414 |
||
415 |
void CPbk2AdaptiveSearchGridFiller::InvalidateAdaptiveSearchGrid() |
|
416 |
{ |
|
417 |
iInvalidateAdaptiveSearchGrid = ETrue; |
|
418 |
} |
|
419 |
||
420 |
void CPbk2AdaptiveSearchGridFiller::SetFocusToAdaptiveSearchGrid() |
|
421 |
{ |
|
422 |
iSetFocusToSearchGrid = ETrue; |
|
423 |
} |
|
424 |
||
425 |
void CPbk2AdaptiveSearchGridFiller::SetAdaptiveGridCharsL( |
|
426 |
const TInt aMaxSpacesNumber, const TInt aSearchStringSpacesNumber ) |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
427 |
{ |
20 | 428 |
// Add space character only if: |
429 |
// - user typed already some characters in the find pane, |
|
430 |
// - and more spaces can be found in contacts than in the current search string, |
|
431 |
// - and space is not the last character in the search string. |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
432 |
TBool addSpace = ( iSearchString->Length() > 0 |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
433 |
&& aMaxSpacesNumber > aSearchStringSpacesNumber |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
434 |
&& (*iSearchString)[iSearchString->Length() - 1] != TChar( ' ' ) ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
435 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
436 |
SortGridL( addSpace ); |
20 | 437 |
|
438 |
if( iCurrentGrid ) |
|
439 |
{ |
|
440 |
if( !iCurrentGrid->Des().Compare( *iKeyMap ) ) |
|
441 |
{ |
|
442 |
//same grid again |
|
443 |
if( !iInvalidateAdaptiveSearchGrid ) |
|
444 |
{ |
|
445 |
//if grid hasn't been invalidated, we do not need to set it again |
|
446 |
return; |
|
447 |
} |
|
448 |
} |
|
449 |
} |
|
450 |
||
451 |
delete iCurrentGrid; |
|
452 |
iCurrentGrid = NULL; |
|
453 |
iCurrentGrid = iKeyMap->Des().AllocL(); |
|
454 |
||
455 |
iSearchField.SetAdaptiveGridChars( *iKeyMap ); |
|
456 |
||
457 |
iInvalidateAdaptiveSearchGrid = EFalse; |
|
458 |
||
459 |
if ( iSetFocusToSearchGrid ) |
|
460 |
{ |
|
461 |
// set the focus to findbox |
|
462 |
iSearchField.DrawDeferred(); |
|
463 |
iSetFocusToSearchGrid = EFalse; |
|
464 |
} |
|
465 |
||
466 |
} |
|
467 |
||
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
468 |
void CPbk2AdaptiveSearchGridFiller::SortGridL( TBool aAddSpace ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
469 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
470 |
TPtr ptr = iKeyMap->Des(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
471 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
472 |
// Do upper case for all characters |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
473 |
ptr.UpperCase(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
474 |
CDesCArray* array = new (ELeave) CDesCArrayFlat( KAdaptiveSearchKeyMapGranularity ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
475 |
CleanupStack::PushL( array ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
476 |
TInt length = ptr.Length(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
477 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
478 |
for( TInt ii = 0; ii < length; ii++ ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
479 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
480 |
array->AppendL( ptr.Mid( ii, 1 ) ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
481 |
} |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
482 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
483 |
// Alphabetical sort |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
484 |
array->Sort( ECmpCollated ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
485 |
ptr.Zero(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
486 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
487 |
if ( aAddSpace ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
488 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
489 |
ptr.Append( TChar( ' ' ) ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
490 |
} |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
491 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
492 |
for( TInt ii = 0; ii < length; ii++ ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
493 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
494 |
ptr.Append( array->MdcaPoint( ii ) ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
495 |
} |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
496 |
CleanupStack::PopAndDestroy();//array |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
497 |
} |
20 | 498 |
|
499 |
CDesC16Array* CPbk2AdaptiveSearchGridFiller::SplitContactFieldTextIntoArrayLC( |
|
500 |
const TDesC& aText ) |
|
501 |
{ |
|
502 |
// Attempt to minimize the allocations considering 3 words for the search fields: |
|
503 |
// FirstName, LastName, CompanyName. |
|
504 |
const TInt KGranularity = 2; // Attempt to minimize the allocations |
|
505 |
||
506 |
CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat( KGranularity ); |
|
507 |
CleanupStack::PushL( array ); |
|
508 |
const TInt textLength = aText.Length(); |
|
509 |
for ( TInt beg = 0; beg < textLength; beg++ ) |
|
510 |
{ |
|
511 |
// Skip separators before next word |
|
512 |
if ( iNameFormatter.IsFindSeparatorChar( aText[beg] ) ) |
|
513 |
{ |
|
514 |
continue; |
|
515 |
} |
|
516 |
||
517 |
// Scan till the end of the word |
|
518 |
TInt end; |
|
519 |
for ( end = beg + 1; |
|
520 |
end < textLength && !iNameFormatter.IsFindSeparatorChar( aText[end] ); |
|
521 |
++end ) |
|
522 |
{ |
|
523 |
} |
|
524 |
||
525 |
// Append found word to the array |
|
526 |
array->AppendL( aText.Mid( beg, end - beg) ); |
|
527 |
||
528 |
// Scan for next word |
|
529 |
beg = end; |
|
530 |
} |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
531 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
532 |
// consonent based adaptive search: |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
533 |
if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
534 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
535 |
/* |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
536 |
When user has a contact with first name "??" and last name "?", |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
537 |
It should be displayed with "? ??" in Korea variant. |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
538 |
That means it should be found with search keyword, "?" or "??". |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
539 |
Thus, need to put the "? ??" in the item list which is delivered to FindUtil. |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
540 |
no need to care about just one word like "???" |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
541 |
*/ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
542 |
if ( array->MdcaCount() != 1 ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
543 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
544 |
array->AppendL( aText ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
545 |
} |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
546 |
} |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
547 |
|
20 | 548 |
return array; |
549 |
} |
|
550 |
||
551 |
CDesC16Array* CPbk2AdaptiveSearchGridFiller::SplitSearchFieldTextIntoArrayLC( |
|
552 |
const TDesC& aText ) |
|
553 |
{ |
|
554 |
CDesC16Array* searchWordsArray = SplitContactFieldTextIntoArrayLC( aText ); |
|
555 |
||
556 |
// In searchWordsArray, the last word is the only one which generates new keymap characters |
|
557 |
// for the grid; the other words are used only for matching the contact words. |
|
558 |
// |
|
559 |
// KNullDesC fake word as last word in search string will match all contact words so that all |
|
560 |
// initials of contact words will be put into the grid. |
|
561 |
// We do this in case the search string is empty or the last character is a space separator. |
|
562 |
||
563 |
if( searchWordsArray->MdcaCount() == 0 || |
|
564 |
( aText.Length() > 0 && aText[aText.Length() - 1] == TChar(' ') ) ) |
|
565 |
{ |
|
566 |
searchWordsArray->AppendL( KNullDesC ); |
|
567 |
} |
|
568 |
||
569 |
return searchWordsArray; |
|
570 |
} |
|
571 |
||
572 |
void CPbk2AdaptiveSearchGridFiller::BuildGridL( const TDesC& aContactString, const CDesC16Array* aSearchWords, HBufC*& aKeyMap ) |
|
573 |
{ |
|
574 |
CDesC16Array* contactWords = SplitContactFieldTextIntoArrayLC( aContactString ); |
|
575 |
||
576 |
const TInt contactWordCount = contactWords->MdcaCount(); |
|
577 |
const TInt searchWordCount = aSearchWords->MdcaCount(); |
|
578 |
||
579 |
TPtrC searchWord; |
|
580 |
TPtrC contactWord; |
|
581 |
||
582 |
// Try to make as fast algorithm as possible if there is only one search word, |
|
583 |
// which is the most common case |
|
584 |
if ( searchWordCount == 1 ) |
|
585 |
{ |
|
586 |
searchWord.Set( aSearchWords->MdcaPoint( 0 ) ); // Search word |
|
587 |
||
588 |
for( TInt j = 0; j < contactWordCount; j++ ) |
|
589 |
{ |
|
590 |
contactWord.Set( contactWords->MdcaPoint( j ) ); |
|
591 |
||
592 |
iFindUtil->Interface()->MatchAdaptiveRefineL( contactWord, searchWord, aKeyMap ); |
|
593 |
} |
|
594 |
} |
|
595 |
||
596 |
// The clients of this method will provide at least one search word, so 0 is unexpected |
|
597 |
else if ( searchWordCount > 1 ) |
|
598 |
{ |
|
599 |
RArray<TBool> contactWordsMatchedArray; |
|
600 |
contactWordsMatchedArray.ReserveL( contactWordCount ); |
|
601 |
for ( TInt i = 0; i < contactWordCount; ++i ) |
|
602 |
{ |
|
603 |
contactWordsMatchedArray.AppendL( EFalse ); |
|
604 |
} |
|
605 |
||
606 |
TBool matched = ETrue; |
|
607 |
||
608 |
// Scan search words except for the last one |
|
609 |
for ( TInt i = 0; matched && i < searchWordCount - 1; i++ ) |
|
610 |
{ |
|
611 |
searchWord.Set( aSearchWords->MdcaPoint( i ) ); |
|
612 |
||
613 |
matched = EFalse; // Search word not matched yet |
|
614 |
||
615 |
// Check if the search word is matched in the contact |
|
616 |
for( TInt j = 0; !matched && j < contactWordCount; j++ ) |
|
617 |
{ |
|
618 |
contactWord.Set( contactWords->MdcaPoint( j ) ); |
|
619 |
||
620 |
// Partially or fully matched |
|
621 |
if ( iFindUtil->Interface()->MatchRefineL( contactWord, searchWord ) ) |
|
622 |
{ |
|
623 |
// Allow one search word to match only one contact word. |
|
624 |
// This could be done better if both search and grid creation would |
|
625 |
// work in the same way for contacts matching... |
|
626 |
// Example: Contact: "Dim Din Dit" |
|
627 |
// Search: "DIN DI" |
|
628 |
// - DIN is matched fully |
|
629 |
// - DI is matched partially and assigned to "Dim" |
|
630 |
// - The grid will show "_T" instead of "_MT" |
|
631 |
contactWordsMatchedArray[j] = ETrue; |
|
632 |
matched = ETrue; |
|
633 |
} |
|
634 |
} |
|
635 |
} |
|
636 |
||
637 |
// If all search words before the last one matched (fully or partially), |
|
638 |
// add characters to the grid using last search word. |
|
639 |
if ( matched ) |
|
640 |
{ |
|
641 |
searchWord.Set( aSearchWords->MdcaPoint( searchWordCount - 1 ) ); // Last search word |
|
642 |
||
643 |
for( TInt j = 0; j < contactWordCount; j++ ) |
|
644 |
{ |
|
645 |
// skip Contact words matched by previous search words |
|
646 |
if (contactWordsMatchedArray[j]) |
|
647 |
{ |
|
648 |
continue; |
|
649 |
} |
|
650 |
||
651 |
contactWord.Set( contactWords->MdcaPoint( j ) ); |
|
652 |
||
653 |
iFindUtil->Interface()->MatchAdaptiveRefineL( contactWord, searchWord, aKeyMap ); |
|
654 |
} |
|
655 |
} |
|
656 |
||
657 |
contactWordsMatchedArray.Close(); |
|
658 |
} |
|
659 |
||
660 |
CleanupStack::PopAndDestroy( contactWords ); |
|
661 |
} |
|
662 |
||
663 |
TInt CPbk2AdaptiveSearchGridFiller::NumberOfSpacesInString( |
|
664 |
const TDesC& aSearchString ) |
|
665 |
{ |
|
666 |
TInt numberOfSpaces = 0; |
|
667 |
TInt searchResult = 0; |
|
668 |
TPtrC ptr = aSearchString; |
|
669 |
while ( searchResult != KErrNotFound ) |
|
670 |
{ |
|
671 |
searchResult = ptr.Locate( TChar( ' ' ) ); |
|
672 |
if ( searchResult != KErrNotFound ) |
|
673 |
{ |
|
674 |
numberOfSpaces++; |
|
675 |
ptr.Set( ptr.Right( ptr.Length() - searchResult - 1 ) ); |
|
676 |
} |
|
677 |
} |
|
678 |
return numberOfSpaces; |
|
679 |
} |
|
680 |
||
681 |
TBool CPbk2AdaptiveSearchGridFiller::IsDigraphContactsTitleL(const TDesC& aContactTitle) |
|
682 |
{ |
|
683 |
TBool isDigraphic( EFalse ); |
|
684 |
// Go through the contactTitles one-by-one and check if they |
|
685 |
// include digraphs |
|
686 |
const TInt KDigraphLength(2); |
|
687 |
if ( aContactTitle.Length()>= KDigraphLength ) |
|
688 |
{ |
|
689 |
TPtrC substring = aContactTitle.Left(1); |
|
690 |
if( !iFindUtil->Interface()->MatchRefineL( aContactTitle, substring ) ) |
|
691 |
{ |
|
692 |
// The substring did not match the characters of the contactTitles |
|
693 |
// For example with Croatian locale the contactTitles "nj" does |
|
694 |
// not include the substring "n" because "nj" is a digraph |
|
695 |
isDigraphic = ETrue; |
|
696 |
} |
|
697 |
} |
|
698 |
return isDigraphic; |
|
699 |
} |
|
700 |
||
701 |
void CPbk2AdaptiveSearchGridFiller::HandlePsResultsUpdate( |
|
702 |
RPointerArray<CPsClientData>& /*searchResults*/, |
|
703 |
RPointerArray<CPsPattern>& /*searchSeqs*/ ) |
|
704 |
{ |
|
705 |
||
706 |
} |
|
707 |
||
708 |
void CPbk2AdaptiveSearchGridFiller::HandlePsError( TInt /*aErrorCode*/ ) |
|
709 |
{ |
|
710 |
||
711 |
} |
|
712 |
||
713 |
void CPbk2AdaptiveSearchGridFiller::CachingStatus( TCachingStatus& aStatus, TInt& /*aError*/ ) |
|
714 |
{ |
|
715 |
TRAP_IGNORE( |
|
716 |
MVPbkContactViewBase* allContactsView = Phonebook2::Pbk2AppUi()->ApplicationServices().ViewSupplier().AllContactsViewL(); |
|
717 |
||
718 |
const MPbk2FilteredViewStack* filteredView = dynamic_cast<const MPbk2FilteredViewStack*> ( iView ); |
|
719 |
||
720 |
if ( aStatus >= ECachingComplete && filteredView && filteredView->Level() == 0 && &filteredView->BaseView() == allContactsView ) |
|
721 |
{ |
|
722 |
HBufC* string = iSearchString->AllocL(); |
|
723 |
CleanupStack::PushL( string ); |
|
724 |
StartFillingL( *iView, *string, ETrue ); |
|
725 |
CleanupStack::PopAndDestroy( string ); |
|
726 |
} |
|
727 |
); |
|
728 |
} |
|
729 |
||
730 |
TBool CPbk2AdaptiveSearchGridFiller::GridFromPsEngineL( const MVPbkContactViewBase& aView ) |
|
731 |
{ |
|
732 |
if ( iPsHandler == NULL ) |
|
733 |
{ |
|
734 |
return EFalse; |
|
735 |
} |
|
736 |
MPbk2ApplicationServices& appServices = Phonebook2::Pbk2AppUi()->ApplicationServices(); |
|
737 |
MVPbkContactViewBase* allContactsView = appServices.ViewSupplier().AllContactsViewL(); |
|
738 |
const MPbk2FilteredViewStack* filteredView = dynamic_cast<const MPbk2FilteredViewStack*> ( &aView ); |
|
739 |
||
740 |
if ( filteredView && filteredView->Level() == 0 && &filteredView->BaseView() == allContactsView ) |
|
741 |
{ |
|
742 |
CPbk2StoreConfiguration& config = appServices.StoreConfiguration(); |
|
743 |
CVPbkContactStoreUriArray* stores = NULL; |
|
744 |
stores = config.CurrentConfigurationL(); |
|
745 |
if ( !stores || stores->Count() == 0 ) |
|
746 |
{ |
|
747 |
delete stores; |
|
748 |
return EFalse; |
|
749 |
} |
|
750 |
||
751 |
TInt count = stores->Count(); |
|
752 |
CleanupStack::PushL(stores); |
|
753 |
||
754 |
CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat( count ); |
|
755 |
CleanupStack::PushL( array ); |
|
756 |
||
757 |
for ( TInt i = 0; i < count; ++i) |
|
758 |
{ |
|
759 |
TVPbkContactStoreUriPtr uriPtr = stores->operator[](i); |
|
760 |
array->AppendL( uriPtr.UriDes() ); |
|
761 |
} |
|
762 |
||
763 |
TBool companyName = EFalse; |
|
764 |
TBuf<KPsAdaptiveGridStringMaxLen> gridChars; |
|
765 |
if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ) ) |
|
766 |
{ |
|
767 |
companyName = ETrue; |
|
768 |
} |
|
769 |
iPsHandler->GetAdaptiveGridCharactersL( *array, *iSearchString, companyName, gridChars ); |
|
770 |
||
771 |
CleanupStack::PopAndDestroy( array ); |
|
772 |
CleanupStack::PopAndDestroy( stores ); |
|
773 |
||
774 |
if ( !gridChars.Length() && iViewItemCount > 0 ) |
|
775 |
{ |
|
776 |
// grid should be created on standard way |
|
777 |
return EFalse; |
|
778 |
} |
|
779 |
if ( iKeyMap->Des().MaxLength() < gridChars.Length() ) |
|
780 |
{ |
|
781 |
iKeyMap = iKeyMap->ReAllocL( gridChars.Length() ); |
|
782 |
} |
|
783 |
iKeyMap->Des().Copy( gridChars ); |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
784 |
// Sort the grid, space is not needed |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
785 |
SortGridL( EFalse ); |
20 | 786 |
|
787 |
delete iCurrentGrid; |
|
788 |
iCurrentGrid = NULL; |
|
789 |
iCurrentGrid = iKeyMap->Des().AllocL(); |
|
790 |
||
791 |
iSearchField.SetAdaptiveGridChars( *iKeyMap ); |
|
792 |
||
793 |
iInvalidateAdaptiveSearchGrid = EFalse; |
|
794 |
||
795 |
if ( iSetFocusToSearchGrid ) |
|
796 |
{ |
|
797 |
// set the focus to findbox |
|
798 |
iSearchField.DrawDeferred(); |
|
799 |
iSetFocusToSearchGrid = EFalse; |
|
800 |
} |
|
801 |
AddKeyMapToCacheL( *iSearchString, *iKeyMap ); |
|
802 |
return ETrue; |
|
803 |
} |
|
804 |
else |
|
805 |
{ |
|
806 |
return EFalse; |
|
807 |
} |
|
808 |
} |
|
809 |
||
810 |
TBool CPbk2AdaptiveSearchGridFiller::IsActualTitleEmpty( const MVPbkViewContact& aContact ) |
|
811 |
{ |
|
812 |
TBool result = ETrue; |
|
813 |
const TInt fieldCount = aContact.Fields().FieldCount(); |
|
814 |
if ( fieldCount > ENameCompanyPart ) |
|
815 |
{ |
|
816 |
const MVPbkBaseContactField& field = aContact.Fields().FieldAt( ENameCompanyPart ); |
|
817 |
if ( iNameFormatter.IsTitleField( field ) ) |
|
818 |
{ |
|
819 |
return EFalse; |
|
820 |
} |
|
821 |
} |
|
822 |
||
823 |
if ( fieldCount > ENameFirstPart ) |
|
824 |
{ |
|
825 |
const MVPbkBaseContactField& field = aContact.Fields().FieldAt( ENameFirstPart ); |
|
826 |
if ( iNameFormatter.IsTitleField( field ) ) |
|
827 |
{ |
|
828 |
const MVPbkContactFieldData& fieldData = field.FieldData(); |
|
829 |
if ( fieldData.DataType() == EVPbkFieldStorageTypeText ) |
|
830 |
{ |
|
831 |
const TDesC& fieldText = MVPbkContactFieldTextData::Cast( fieldData ).Text(); |
|
832 |
TInt length = fieldText.Length(); |
|
833 |
||
834 |
if ( length > 0 ) |
|
835 |
{ |
|
836 |
TInt firstNonSpaceChar = 0; |
|
837 |
while ( firstNonSpaceChar < length |
|
838 |
&& TChar( fieldText[firstNonSpaceChar] ).IsSpace() ) |
|
839 |
{ |
|
840 |
++firstNonSpaceChar; |
|
841 |
} |
|
842 |
if ( firstNonSpaceChar != length ) |
|
843 |
{ |
|
844 |
result = EFalse; |
|
845 |
} |
|
846 |
} |
|
847 |
} |
|
848 |
} |
|
849 |
} |
|
850 |
return result; |
|
851 |
} |
|
852 |
// End of File |