122 delete iCurrentGrid; |
122 delete iCurrentGrid; |
123 iAdaptiveGridCache.ResetAndDestroy(); |
123 iAdaptiveGridCache.ResetAndDestroy(); |
124 delete iSearchString; |
124 delete iSearchString; |
125 delete iFindUtil; |
125 delete iFindUtil; |
126 iDigraphContactsTitleArray.ResetAndDestroy(); |
126 iDigraphContactsTitleArray.ResetAndDestroy(); |
127 |
|
128 if (iFeatureManagerInitialized) |
|
129 { |
|
130 // It can be safely called UnInitializeLib as it has been really intialized. |
|
131 FeatureManager::UnInitializeLib(); // Decreases ref.count |
|
132 } |
|
133 } |
127 } |
134 |
128 |
135 |
129 |
136 // -------------------------------------------------------------------------- |
130 // -------------------------------------------------------------------------- |
137 // CPbk2ContactEditorDlg::NewL |
131 // CPbk2ContactEditorDlg::NewL |
154 // |
148 // |
155 void CPbk2AdaptiveSearchGridFiller::ConstructL() |
149 void CPbk2AdaptiveSearchGridFiller::ConstructL() |
156 { |
150 { |
157 iKeyMap = HBufC::NewL( KAdaptiveSearchKeyMapGranularity ); |
151 iKeyMap = HBufC::NewL( KAdaptiveSearchKeyMapGranularity ); |
158 iFindUtil = CFindUtil::NewL(); |
152 iFindUtil = CFindUtil::NewL(); |
159 |
|
160 // Initialize feature manager |
|
161 FeatureManager::InitializeLibL(); |
|
162 iFeatureManagerInitialized = ETrue; |
|
163 // UI Language |
153 // UI Language |
164 TLanguage uiLanguage = User::Language(); |
154 TLanguage uiLanguage = User::Language(); |
165 if ( uiLanguage != ELangJapanese && uiLanguage != ELangPrcChinese && |
155 if ( uiLanguage != ELangJapanese && uiLanguage != ELangPrcChinese && |
166 uiLanguage != ELangHongKongChinese && uiLanguage != ELangTaiwanChinese && |
156 uiLanguage != ELangHongKongChinese && uiLanguage != ELangTaiwanChinese && |
167 uiLanguage != ELangKorean ) |
157 uiLanguage != ELangKorean ) |
422 iSetFocusToSearchGrid = ETrue; |
412 iSetFocusToSearchGrid = ETrue; |
423 } |
413 } |
424 |
414 |
425 void CPbk2AdaptiveSearchGridFiller::SetAdaptiveGridCharsL( |
415 void CPbk2AdaptiveSearchGridFiller::SetAdaptiveGridCharsL( |
426 const TInt aMaxSpacesNumber, const TInt aSearchStringSpacesNumber ) |
416 const TInt aMaxSpacesNumber, const TInt aSearchStringSpacesNumber ) |
427 { |
417 { |
|
418 TPtr ptr = iKeyMap->Des(); |
|
419 |
|
420 // Do upper case for all characters |
|
421 ptr.UpperCase(); |
|
422 CDesCArray* array = new (ELeave) CDesCArrayFlat( KAdaptiveSearchKeyMapGranularity ); |
|
423 CleanupStack::PushL( array ); |
|
424 TInt length = ptr.Length(); |
|
425 |
|
426 for( TInt ii = 0; ii < length; ii++ ) |
|
427 { |
|
428 array->AppendL( ptr.Mid( ii, 1 ) ); |
|
429 } |
|
430 |
|
431 // Alphabetical sort |
|
432 array->Sort( ECmpCollated ); |
|
433 ptr.Zero(); |
|
434 |
428 // Add space character only if: |
435 // Add space character only if: |
429 // - user typed already some characters in the find pane, |
436 // - user typed already some characters in the find pane, |
430 // - and more spaces can be found in contacts than in the current search string, |
437 // - 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. |
438 // - and space is not the last character in the search string. |
432 TBool addSpace = ( iSearchString->Length() > 0 |
439 if ( iSearchString->Length() > 0 |
433 && aMaxSpacesNumber > aSearchStringSpacesNumber |
440 && aMaxSpacesNumber > aSearchStringSpacesNumber |
434 && (*iSearchString)[iSearchString->Length() - 1] != TChar( ' ' ) ); |
441 && (*iSearchString)[iSearchString->Length() - 1] != TChar( ' ' ) ) |
435 |
442 { |
436 SortGridL( addSpace ); |
443 ptr.Append( TChar( ' ' ) ); |
|
444 } |
|
445 |
|
446 for( TInt ii = 0; ii < length; ii++ ) |
|
447 { |
|
448 ptr.Append(array->MdcaPoint( ii )); |
|
449 } |
|
450 CleanupStack::PopAndDestroy();//array |
437 |
451 |
438 if( iCurrentGrid ) |
452 if( iCurrentGrid ) |
439 { |
453 { |
440 if( !iCurrentGrid->Des().Compare( *iKeyMap ) ) |
454 if( !iCurrentGrid->Des().Compare( *iKeyMap ) ) |
441 { |
455 { |
463 iSetFocusToSearchGrid = EFalse; |
477 iSetFocusToSearchGrid = EFalse; |
464 } |
478 } |
465 |
479 |
466 } |
480 } |
467 |
481 |
468 void CPbk2AdaptiveSearchGridFiller::SortGridL( TBool aAddSpace ) |
|
469 { |
|
470 TPtr ptr = iKeyMap->Des(); |
|
471 |
|
472 // Do upper case for all characters |
|
473 ptr.UpperCase(); |
|
474 CDesCArray* array = new (ELeave) CDesCArrayFlat( KAdaptiveSearchKeyMapGranularity ); |
|
475 CleanupStack::PushL( array ); |
|
476 TInt length = ptr.Length(); |
|
477 |
|
478 for( TInt ii = 0; ii < length; ii++ ) |
|
479 { |
|
480 array->AppendL( ptr.Mid( ii, 1 ) ); |
|
481 } |
|
482 |
|
483 // Alphabetical sort |
|
484 array->Sort( ECmpCollated ); |
|
485 ptr.Zero(); |
|
486 |
|
487 if ( aAddSpace ) |
|
488 { |
|
489 ptr.Append( TChar( ' ' ) ); |
|
490 } |
|
491 |
|
492 for( TInt ii = 0; ii < length; ii++ ) |
|
493 { |
|
494 ptr.Append( array->MdcaPoint( ii ) ); |
|
495 } |
|
496 CleanupStack::PopAndDestroy();//array |
|
497 } |
|
498 |
482 |
499 CDesC16Array* CPbk2AdaptiveSearchGridFiller::SplitContactFieldTextIntoArrayLC( |
483 CDesC16Array* CPbk2AdaptiveSearchGridFiller::SplitContactFieldTextIntoArrayLC( |
500 const TDesC& aText ) |
484 const TDesC& aText ) |
501 { |
485 { |
502 // Attempt to minimize the allocations considering 3 words for the search fields: |
486 // Attempt to minimize the allocations considering 3 words for the search fields: |
526 array->AppendL( aText.Mid( beg, end - beg) ); |
510 array->AppendL( aText.Mid( beg, end - beg) ); |
527 |
511 |
528 // Scan for next word |
512 // Scan for next word |
529 beg = end; |
513 beg = end; |
530 } |
514 } |
531 |
515 |
532 // consonent based adaptive search: |
|
533 if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) ) |
|
534 { |
|
535 /* |
|
536 When user has a contact with first name "??" and last name "?", |
|
537 It should be displayed with "? ??" in Korea variant. |
|
538 That means it should be found with search keyword, "?" or "??". |
|
539 Thus, need to put the "? ??" in the item list which is delivered to FindUtil. |
|
540 no need to care about just one word like "???" |
|
541 */ |
|
542 if ( array->MdcaCount() != 1 ) |
|
543 { |
|
544 array->AppendL( aText ); |
|
545 } |
|
546 } |
|
547 |
|
548 return array; |
516 return array; |
549 } |
517 } |
550 |
518 |
551 CDesC16Array* CPbk2AdaptiveSearchGridFiller::SplitSearchFieldTextIntoArrayLC( |
519 CDesC16Array* CPbk2AdaptiveSearchGridFiller::SplitSearchFieldTextIntoArrayLC( |
552 const TDesC& aText ) |
520 const TDesC& aText ) |
779 if ( iKeyMap->Des().MaxLength() < gridChars.Length() ) |
747 if ( iKeyMap->Des().MaxLength() < gridChars.Length() ) |
780 { |
748 { |
781 iKeyMap = iKeyMap->ReAllocL( gridChars.Length() ); |
749 iKeyMap = iKeyMap->ReAllocL( gridChars.Length() ); |
782 } |
750 } |
783 iKeyMap->Des().Copy( gridChars ); |
751 iKeyMap->Des().Copy( gridChars ); |
784 // Sort the grid, space is not needed |
|
785 SortGridL( EFalse ); |
|
786 |
752 |
787 delete iCurrentGrid; |
753 delete iCurrentGrid; |
788 iCurrentGrid = NULL; |
754 iCurrentGrid = NULL; |
789 iCurrentGrid = iKeyMap->Des().AllocL(); |
755 iCurrentGrid = iKeyMap->Des().AllocL(); |
790 |
756 |