432 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
432 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
433 ("CVPbkFilteredContactView::BuildViewMappingL(0x%x)"), this); |
433 ("CVPbkFilteredContactView::BuildViewMappingL(0x%x)"), this); |
434 |
434 |
435 iContactMapping.Reset(); |
435 iContactMapping.Reset(); |
436 |
436 |
|
437 MVPbkOptimizedSelector* optimizedSelector = |
|
438 static_cast<MVPbkOptimizedSelector*>( |
|
439 iContactSelector.ContactSelectorExtension( |
|
440 KVPbkOptimizedSelectorExtensionUid ) ); |
|
441 |
437 const TInt count = iBaseView.ContactCountL(); |
442 const TInt count = iBaseView.ContactCountL(); |
438 for (TInt i = 0; i < count; ++i) |
443 for (TInt i = 0; i < count; ++i) |
439 { |
444 { |
440 if (iContactSelector.IsContactIncluded(iBaseView.ContactAtL(i))) |
445 if (iContactSelector.IsContactIncluded(iBaseView.ContactAtL(i))) |
441 { |
446 { |
442 iContactMapping.AppendL(i); |
447 iContactMapping.AppendL(i); |
443 } |
448 } |
|
449 |
|
450 if( optimizedSelector && !optimizedSelector->Continue() ) |
|
451 { |
|
452 // we doesn't need use selector anymore -> include rest of contacts |
|
453 for (TInt j = i+1; j < count; ++j ) |
|
454 { |
|
455 iContactMapping.AppendL(j); |
|
456 } |
|
457 break; |
|
458 } |
|
459 |
444 } |
460 } |
445 |
461 |
446 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
462 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
447 ("CVPbkFilteredContactView::BuildViewMappingL(0x%x) end"), this); |
463 ("CVPbkFilteredContactView::BuildViewMappingL(0x%x) end"), this); |
448 } |
464 } |
615 // or KErrNotFound if it's filtered out |
631 // or KErrNotFound if it's filtered out |
616 // --------------------------------------------------------------------------- |
632 // --------------------------------------------------------------------------- |
617 // |
633 // |
618 TInt CVPbkFilteredContactView::UpdateViewMappingAfterAddingL( TInt aBaseIndex ) |
634 TInt CVPbkFilteredContactView::UpdateViewMappingAfterAddingL( TInt aBaseIndex ) |
619 { |
635 { |
|
636 // protect against ghost contacts. Can happen if last of the contacts is |
|
637 // deleted or changed into own card immediately after creation. |
|
638 if ( iBaseView.ContactCountL() <= aBaseIndex ) |
|
639 { |
|
640 return KErrNotFound; |
|
641 } |
|
642 |
620 // first update the mapping for all elements which > aBaseIndex |
643 // first update the mapping for all elements which > aBaseIndex |
621 TInt filteredIndex; |
644 TInt filteredIndex; |
622 // find first elemnt which >= aBaseIndex |
645 // find first elemnt which >= aBaseIndex |
623 // NOTE: if iContactMapping contains aBaseIndex element, |
646 // NOTE: if iContactMapping contains aBaseIndex element, |
624 // it refers to a view contact which is already at aBaseIndex+1 |
647 // it refers to a view contact which is already at aBaseIndex+1 |