121 } |
121 } |
122 |
122 |
123 // --------------------------------------------------------------------------- |
123 // --------------------------------------------------------------------------- |
124 // CVPbkFilteredContactView::NewL |
124 // CVPbkFilteredContactView::NewL |
125 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
126 // |
126 // |
127 EXPORT_C CVPbkFilteredContactView* CVPbkFilteredContactView::NewL( |
127 EXPORT_C CVPbkFilteredContactView* CVPbkFilteredContactView::NewL( |
128 MVPbkContactViewBase& aBaseView, |
128 MVPbkContactViewBase& aBaseView, |
129 MVPbkContactViewObserver& aObserver, |
129 MVPbkContactViewObserver& aObserver, |
130 MVPbkContactSelector& aContactSelector, |
130 MVPbkContactSelector& aContactSelector, |
131 const MVPbkFieldTypeList& aMasterFieldTypeList ) |
131 const MVPbkFieldTypeList& aMasterFieldTypeList ) |
132 { |
132 { |
133 CVPbkFilteredContactView* self = new(ELeave) CVPbkFilteredContactView |
133 CVPbkFilteredContactView* self = new(ELeave) CVPbkFilteredContactView |
134 (aBaseView, aContactSelector, &aMasterFieldTypeList ); |
134 (aBaseView, aContactSelector, &aMasterFieldTypeList ); |
135 CleanupStack::PushL(self); |
135 CleanupStack::PushL(self); |
136 self->ConstructL( aObserver ); |
136 self->ConstructL( aObserver ); |
151 } |
151 } |
152 |
152 |
153 // --------------------------------------------------------------------------- |
153 // --------------------------------------------------------------------------- |
154 // CVPbkFilteredContactView::Type |
154 // CVPbkFilteredContactView::Type |
155 // --------------------------------------------------------------------------- |
155 // --------------------------------------------------------------------------- |
156 // |
156 // |
157 TVPbkContactViewType CVPbkFilteredContactView::Type() const |
157 TVPbkContactViewType CVPbkFilteredContactView::Type() const |
158 { |
158 { |
159 return iBaseView.Type(); |
159 return iBaseView.Type(); |
160 } |
160 } |
161 |
161 |
162 // --------------------------------------------------------------------------- |
162 // --------------------------------------------------------------------------- |
163 // CVPbkFilteredContactView::ChangeSortOrderL |
163 // CVPbkFilteredContactView::ChangeSortOrderL |
164 // --------------------------------------------------------------------------- |
164 // --------------------------------------------------------------------------- |
165 // |
165 // |
166 void CVPbkFilteredContactView::ChangeSortOrderL( |
166 void CVPbkFilteredContactView::ChangeSortOrderL( |
167 const MVPbkFieldTypeList& aSortOrder ) |
167 const MVPbkFieldTypeList& aSortOrder ) |
168 { |
168 { |
169 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
169 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
170 ("CVPbkFilteredContactView::ChangeSortOrderL(0x%x)"), &aSortOrder); |
170 ("CVPbkFilteredContactView::ChangeSortOrderL(0x%x)"), &aSortOrder); |
173 } |
173 } |
174 |
174 |
175 // --------------------------------------------------------------------------- |
175 // --------------------------------------------------------------------------- |
176 // CVPbkFilteredContactView::SortOrder |
176 // CVPbkFilteredContactView::SortOrder |
177 // --------------------------------------------------------------------------- |
177 // --------------------------------------------------------------------------- |
178 // |
178 // |
179 const MVPbkFieldTypeList& CVPbkFilteredContactView::SortOrder() const |
179 const MVPbkFieldTypeList& CVPbkFilteredContactView::SortOrder() const |
180 { |
180 { |
181 return iBaseView.SortOrder(); |
181 return iBaseView.SortOrder(); |
182 } |
182 } |
183 |
183 |
184 // --------------------------------------------------------------------------- |
184 // --------------------------------------------------------------------------- |
185 // CVPbkFilteredContactView::RefreshL |
185 // CVPbkFilteredContactView::RefreshL |
186 // --------------------------------------------------------------------------- |
186 // --------------------------------------------------------------------------- |
187 // |
187 // |
188 void CVPbkFilteredContactView::RefreshL() |
188 void CVPbkFilteredContactView::RefreshL() |
189 { |
189 { |
190 iBaseView.RefreshL(); |
190 iBaseView.RefreshL(); |
191 } |
191 } |
192 |
192 |
193 // --------------------------------------------------------------------------- |
193 // --------------------------------------------------------------------------- |
194 // CVPbkFilteredContactView::ContactCountL |
194 // CVPbkFilteredContactView::ContactCountL |
195 // --------------------------------------------------------------------------- |
195 // --------------------------------------------------------------------------- |
196 // |
196 // |
197 TInt CVPbkFilteredContactView::ContactCountL() const |
197 TInt CVPbkFilteredContactView::ContactCountL() const |
198 { |
198 { |
199 return iContactMapping.Count(); |
199 return iContactMapping.Count(); |
200 } |
200 } |
201 |
201 |
202 // --------------------------------------------------------------------------- |
202 // --------------------------------------------------------------------------- |
203 // CVPbkFilteredContactView::ContactAtL |
203 // CVPbkFilteredContactView::ContactAtL |
204 // --------------------------------------------------------------------------- |
204 // --------------------------------------------------------------------------- |
205 // |
205 // |
206 const MVPbkViewContact& CVPbkFilteredContactView::ContactAtL( |
206 const MVPbkViewContact& CVPbkFilteredContactView::ContactAtL( |
207 TInt aIndex ) const |
207 TInt aIndex ) const |
208 { |
208 { |
209 __ASSERT_ALWAYS( aIndex >= 0, |
209 __ASSERT_ALWAYS( aIndex >= 0, |
210 VPbkError::Panic( VPbkError::EInvalidContactIndex ) ); |
210 VPbkError::Panic( VPbkError::EInvalidContactIndex ) ); |
233 } |
233 } |
234 |
234 |
235 // --------------------------------------------------------------------------- |
235 // --------------------------------------------------------------------------- |
236 // CVPbkFilteredContactView::IndexOfLinkL |
236 // CVPbkFilteredContactView::IndexOfLinkL |
237 // --------------------------------------------------------------------------- |
237 // --------------------------------------------------------------------------- |
238 // |
238 // |
239 TInt CVPbkFilteredContactView::IndexOfLinkL( |
239 TInt CVPbkFilteredContactView::IndexOfLinkL( |
240 const MVPbkContactLink& aContactLink ) const |
240 const MVPbkContactLink& aContactLink ) const |
241 { |
241 { |
242 TInt baseIndex = iBaseView.IndexOfLinkL(aContactLink); |
242 TInt baseIndex = iBaseView.IndexOfLinkL(aContactLink); |
243 return iContactMapping.Find(baseIndex); |
243 return iContactMapping.Find(baseIndex); |
244 } |
244 } |
245 |
245 |
246 // --------------------------------------------------------------------------- |
246 // --------------------------------------------------------------------------- |
247 // CVPbkFilteredContactView::AddObserverL |
247 // CVPbkFilteredContactView::AddObserverL |
248 // --------------------------------------------------------------------------- |
248 // --------------------------------------------------------------------------- |
249 // |
249 // |
250 void CVPbkFilteredContactView::AddObserverL( |
250 void CVPbkFilteredContactView::AddObserverL( |
251 MVPbkContactViewObserver& aObserver ) |
251 MVPbkContactViewObserver& aObserver ) |
252 { |
252 { |
253 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
253 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
254 ("CVPbkFilteredContactView::AddObserverL(0x%x)"), &aObserver); |
254 ("CVPbkFilteredContactView::AddObserverL(0x%x)"), &aObserver); |
255 |
255 |
272 } |
272 } |
273 |
273 |
274 // --------------------------------------------------------------------------- |
274 // --------------------------------------------------------------------------- |
275 // CVPbkFilteredContactView::DoAddObserverL |
275 // CVPbkFilteredContactView::DoAddObserverL |
276 // --------------------------------------------------------------------------- |
276 // --------------------------------------------------------------------------- |
277 // |
277 // |
278 void CVPbkFilteredContactView::DoAddObserverL( |
278 void CVPbkFilteredContactView::DoAddObserverL( |
279 MVPbkContactViewObserver& aObserver ) |
279 MVPbkContactViewObserver& aObserver ) |
280 { |
280 { |
281 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
281 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
282 ("CVPbkFilteredContactView::DoAddObserverL(0x%x)"), &aObserver); |
282 ("CVPbkFilteredContactView::DoAddObserverL(0x%x)"), &aObserver); |
283 |
283 |
284 // Check if aObserver is still observer of this view |
284 // Check if aObserver is still observer of this view |
285 if ( iObservers.FindInAddressOrder( &aObserver ) != KErrNotFound ) |
285 if ( iObservers.FindInAddressOrder( &aObserver ) != KErrNotFound ) |
286 { |
286 { |
287 if (iIsReady) |
287 if (iIsReady) |
288 { |
288 { |
289 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
289 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
290 ("CVPbkFilteredContactView::DoAddObserverL(0x%x) contact view ready"), |
290 ("CVPbkFilteredContactView::DoAddObserverL(0x%x) contact view ready"), |
291 &aObserver); |
291 &aObserver); |
292 |
292 |
293 // If this view is ready and there was no error, |
293 // If this view is ready and there was no error, |
294 // tell it to the observer |
294 // tell it to the observer |
295 aObserver.ContactViewReady(*this); |
295 aObserver.ContactViewReady(*this); |
333 } |
333 } |
334 |
334 |
335 // --------------------------------------------------------------------------- |
335 // --------------------------------------------------------------------------- |
336 // CVPbkFilteredContactView::MatchContactStore |
336 // CVPbkFilteredContactView::MatchContactStore |
337 // --------------------------------------------------------------------------- |
337 // --------------------------------------------------------------------------- |
338 // |
338 // |
339 TBool CVPbkFilteredContactView::MatchContactStore( |
339 TBool CVPbkFilteredContactView::MatchContactStore( |
340 const TDesC& aContactStoreUri ) const |
340 const TDesC& aContactStoreUri ) const |
341 { |
341 { |
342 return iBaseView.MatchContactStore(aContactStoreUri); |
342 return iBaseView.MatchContactStore(aContactStoreUri); |
343 } |
343 } |
344 |
344 |
345 // --------------------------------------------------------------------------- |
345 // --------------------------------------------------------------------------- |
346 // CVPbkFilteredContactView::MatchContactStoreDomain |
346 // CVPbkFilteredContactView::MatchContactStoreDomain |
347 // --------------------------------------------------------------------------- |
347 // --------------------------------------------------------------------------- |
348 // |
348 // |
349 TBool CVPbkFilteredContactView::MatchContactStoreDomain( |
349 TBool CVPbkFilteredContactView::MatchContactStoreDomain( |
350 const TDesC& aContactStoreDomain ) const |
350 const TDesC& aContactStoreDomain ) const |
351 { |
351 { |
352 return iBaseView.MatchContactStoreDomain(aContactStoreDomain); |
352 return iBaseView.MatchContactStoreDomain(aContactStoreDomain); |
353 } |
353 } |
354 |
354 |
355 // --------------------------------------------------------------------------- |
355 // --------------------------------------------------------------------------- |
356 // CVPbkFilteredContactView::CreateBookmarkLC |
356 // CVPbkFilteredContactView::CreateBookmarkLC |
357 // --------------------------------------------------------------------------- |
357 // --------------------------------------------------------------------------- |
358 // |
358 // |
359 MVPbkContactBookmark* CVPbkFilteredContactView::CreateBookmarkLC( |
359 MVPbkContactBookmark* CVPbkFilteredContactView::CreateBookmarkLC( |
360 TInt aIndex ) const |
360 TInt aIndex ) const |
361 { |
361 { |
362 __ASSERT_ALWAYS( aIndex >= 0, |
362 __ASSERT_ALWAYS( aIndex >= 0, |
363 VPbkError::Panic( VPbkError::EInvalidContactIndex ) ); |
363 VPbkError::Panic( VPbkError::EInvalidContactIndex ) ); |
364 |
364 |
365 return iBaseView.ContactAtL(iContactMapping[aIndex]).CreateBookmarkLC(); |
365 return iBaseView.ContactAtL(iContactMapping[aIndex]).CreateBookmarkLC(); |
366 } |
366 } |
367 |
367 |
368 // --------------------------------------------------------------------------- |
368 // --------------------------------------------------------------------------- |
369 // CVPbkFilteredContactView::IndexOfBookmarkL |
369 // CVPbkFilteredContactView::IndexOfBookmarkL |
370 // --------------------------------------------------------------------------- |
370 // --------------------------------------------------------------------------- |
371 // |
371 // |
372 TInt CVPbkFilteredContactView::IndexOfBookmarkL( |
372 TInt CVPbkFilteredContactView::IndexOfBookmarkL( |
373 const MVPbkContactBookmark& aContactBookmark ) const |
373 const MVPbkContactBookmark& aContactBookmark ) const |
374 { |
374 { |
375 TInt baseIndex = iBaseView.IndexOfBookmarkL(aContactBookmark); |
375 TInt baseIndex = iBaseView.IndexOfBookmarkL(aContactBookmark); |
376 return iContactMapping.Find(baseIndex); |
376 return iContactMapping.Find(baseIndex); |
377 } |
377 } |
378 |
378 |
379 // --------------------------------------------------------------------------- |
379 // --------------------------------------------------------------------------- |
380 // CVPbkFilteredContactView::ViewFiltering |
380 // CVPbkFilteredContactView::ViewFiltering |
381 // --------------------------------------------------------------------------- |
381 // --------------------------------------------------------------------------- |
382 // |
382 // |
383 MVPbkContactViewFiltering* CVPbkFilteredContactView::ViewFiltering() |
383 MVPbkContactViewFiltering* CVPbkFilteredContactView::ViewFiltering() |
384 { |
384 { |
385 if ( iMasterFieldTypeList ) |
385 if ( iMasterFieldTypeList ) |
386 { |
386 { |
387 return this; |
387 return this; |
388 } |
388 } |
389 return NULL; |
389 return NULL; |
390 } |
390 } |
391 |
391 |
392 // --------------------------------------------------------------------------- |
392 // --------------------------------------------------------------------------- |
393 // CVPbkFilteredContactView::CreateFilteredViewLC |
393 // CVPbkFilteredContactView::CreateFilteredViewLC |
394 // --------------------------------------------------------------------------- |
394 // --------------------------------------------------------------------------- |
395 // |
395 // |
396 MVPbkContactViewBase* CVPbkFilteredContactView::CreateFilteredViewLC( |
396 MVPbkContactViewBase* CVPbkFilteredContactView::CreateFilteredViewLC( |
397 MVPbkContactViewObserver& aObserver, |
397 MVPbkContactViewObserver& aObserver, |
398 const MDesCArray& aFindWords, |
398 const MDesCArray& aFindWords, |
399 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ) |
399 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ) |
400 { |
400 { |
401 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
401 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
402 ("CVPbkFilteredContactView::CreateFilteredViewLC(0x%x)"), this); |
402 ("CVPbkFilteredContactView::CreateFilteredViewLC(0x%x)"), this); |
403 |
403 |
404 if ( iMasterFieldTypeList ) |
404 if ( iMasterFieldTypeList ) |
405 { |
405 { |
406 return CVPbkFindView::NewLC( *this, |
406 return CVPbkFindView::NewLC( *this, |
407 aObserver, |
407 aObserver, |
408 aFindWords, |
408 aFindWords, |
409 aAlwaysIncludedContacts, |
409 aAlwaysIncludedContacts, |
410 *iMasterFieldTypeList ); |
410 *iMasterFieldTypeList ); |
411 } |
411 } |
412 return NULL; |
412 return NULL; |
413 } |
413 } |
414 |
414 |
415 // --------------------------------------------------------------------------- |
415 // --------------------------------------------------------------------------- |
416 // CVPbkFilteredContactView::UpdateFilterL |
416 // CVPbkFilteredContactView::UpdateFilterL |
417 // --------------------------------------------------------------------------- |
417 // --------------------------------------------------------------------------- |
418 // |
418 // |
419 void CVPbkFilteredContactView::UpdateFilterL( |
419 void CVPbkFilteredContactView::UpdateFilterL( |
420 const MDesCArray& /*aFindWords*/, |
420 const MDesCArray& /*aFindWords*/, |
421 const MVPbkContactBookmarkCollection* /*aAlwaysIncludedContacts*/ ) |
421 const MVPbkContactBookmarkCollection* /*aAlwaysIncludedContacts*/ ) |
422 { |
422 { |
423 User::Leave( KErrNotSupported ); |
423 User::Leave( KErrNotSupported ); |
424 } |
424 } |
425 |
425 |
426 // --------------------------------------------------------------------------- |
426 // --------------------------------------------------------------------------- |
427 // CVPbkFilteredContactView::BuildViewMappingL |
427 // CVPbkFilteredContactView::BuildViewMappingL |
428 // --------------------------------------------------------------------------- |
428 // --------------------------------------------------------------------------- |
429 // |
429 // |
430 void CVPbkFilteredContactView::BuildViewMappingL() |
430 void CVPbkFilteredContactView::BuildViewMappingL() |
431 { |
431 { |
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 |
440 if (iContactSelector.IsContactIncluded(iBaseView.ContactAtL(i))) |
440 if (iContactSelector.IsContactIncluded(iBaseView.ContactAtL(i))) |
441 { |
441 { |
442 iContactMapping.AppendL(i); |
442 iContactMapping.AppendL(i); |
443 } |
443 } |
444 } |
444 } |
445 |
445 |
446 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
446 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
447 ("CVPbkFilteredContactView::BuildViewMappingL(0x%x) end"), this); |
447 ("CVPbkFilteredContactView::BuildViewMappingL(0x%x) end"), this); |
448 } |
448 } |
449 |
449 |
450 // --------------------------------------------------------------------------- |
450 // --------------------------------------------------------------------------- |
451 // CVPbkFilteredContactView::HandleBuildViewMapping |
451 // CVPbkFilteredContactView::HandleBuildViewMapping |
452 // --------------------------------------------------------------------------- |
452 // --------------------------------------------------------------------------- |
453 // |
453 // |
454 void CVPbkFilteredContactView::HandleBuildViewMapping() |
454 void CVPbkFilteredContactView::HandleBuildViewMapping() |
455 { |
455 { |
456 TRAPD( res, BuildViewMappingL() ); |
456 TRAPD( res, BuildViewMappingL() ); |
457 if ( res == KErrNone ) |
457 if ( res == KErrNone ) |
458 { |
458 { |
459 // Mapping was succesfully built. Send ready event |
459 // Mapping was succesfully built. Send ready event |
460 SendEventToObservers( *this, iObservers, |
460 SendEventToObservers( *this, iObservers, |
461 &MVPbkContactViewObserver::ContactViewReady ); |
461 &MVPbkContactViewObserver::ContactViewReady ); |
462 } |
462 } |
463 else |
463 else |
464 { |
464 { |
465 // Building the mapping failed. Leave mappings as they are and |
465 // Building the mapping failed. Leave mappings as they are and |
466 // send error |
466 // send error |
467 SendEventToObservers( *this, iObservers, |
467 SendEventToObservers( *this, iObservers, |
468 &MVPbkContactViewObserver::ContactViewError, res, EFalse ); |
468 &MVPbkContactViewObserver::ContactViewError, res, EFalse ); |
469 } |
469 } |
470 } |
470 } |
471 |
471 |
472 // --------------------------------------------------------------------------- |
472 // --------------------------------------------------------------------------- |
473 // From class MVPbkContactViewBase. |
473 // From class MVPbkContactViewBase. |
474 // CVPbkFilteredContactView::ContactViewReady |
474 // CVPbkFilteredContactView::ContactViewReady |
475 // --------------------------------------------------------------------------- |
475 // --------------------------------------------------------------------------- |
476 // |
476 // |
477 void CVPbkFilteredContactView::ContactViewReady( MVPbkContactViewBase& aView ) |
477 void CVPbkFilteredContactView::ContactViewReady( MVPbkContactViewBase& aView ) |
478 { |
478 { |
479 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
479 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
480 ("CVPbkFilteredContactView::ContactViewReady(0x%x)"), &aView); |
480 ("CVPbkFilteredContactView::ContactViewReady(0x%x)"), &aView); |
481 |
481 |
482 iIsReady = ETrue; |
482 iIsReady = ETrue; |
483 HandleBuildViewMapping(); |
483 HandleBuildViewMapping(); |
484 |
484 |
485 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
485 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
486 ("CVPbkFilteredContactView::ContactViewReady(0x%x) end"), &aView); |
486 ("CVPbkFilteredContactView::ContactViewReady(0x%x) end"), &aView); |
487 } |
487 } |
488 |
488 |
489 // --------------------------------------------------------------------------- |
489 // --------------------------------------------------------------------------- |
490 // From class MVPbkContactViewBase. |
490 // From class MVPbkContactViewBase. |
491 // CVPbkFilteredContactView::ContactViewUnavailable |
491 // CVPbkFilteredContactView::ContactViewUnavailable |
492 // --------------------------------------------------------------------------- |
492 // --------------------------------------------------------------------------- |
493 // |
493 // |
494 void CVPbkFilteredContactView::ContactViewUnavailable( |
494 void CVPbkFilteredContactView::ContactViewUnavailable( |
495 MVPbkContactViewBase& aView ) |
495 MVPbkContactViewBase& aView ) |
496 { |
496 { |
497 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
497 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
498 ("CVPbkFilteredContactView::ContactViewUnavailable(0x%x)"), &aView); |
498 ("CVPbkFilteredContactView::ContactViewUnavailable(0x%x)"), &aView); |
499 |
499 |
526 |
526 |
527 // --------------------------------------------------------------------------- |
527 // --------------------------------------------------------------------------- |
528 // From class MVPbkContactViewBase. |
528 // From class MVPbkContactViewBase. |
529 // CVPbkFilteredContactView::ContactAddedToView |
529 // CVPbkFilteredContactView::ContactAddedToView |
530 // --------------------------------------------------------------------------- |
530 // --------------------------------------------------------------------------- |
531 // |
531 // |
532 void CVPbkFilteredContactView::ContactAddedToView |
532 void CVPbkFilteredContactView::ContactAddedToView |
533 (MVPbkContactViewBase& /*aView*/, TInt aIndex, |
533 (MVPbkContactViewBase& /*aView*/, TInt aIndex, |
534 const MVPbkContactLink& aContactLink) |
534 const MVPbkContactLink& aContactLink) |
535 { |
535 { |
536 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
536 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
537 ("CVPbkFilteredContactView::ContactAddedToView(0x%x %d)"), this, aIndex); |
537 ("CVPbkFilteredContactView::ContactAddedToView(0x%x %d)"), this, aIndex); |
538 |
538 |
539 TInt filteredIndex(0); |
539 TInt filteredIndex(0); |
540 TRAPD( res, filteredIndex = UpdateViewMappingAfterAddingL( aIndex ) ); |
540 TRAPD( res, filteredIndex = UpdateViewMappingAfterAddingL( aIndex ) ); |
541 if ( res == KErrNone ) |
541 if ( res == KErrNone ) |
542 { |
542 { |
543 if ( filteredIndex != KErrNotFound ) |
543 if ( filteredIndex != KErrNotFound ) |
544 { |
544 { |
545 // Mapping was succesfully updated and the new contact |
545 // Mapping was succesfully updated and the new contact |
546 // belongs to the filtered view. |
546 // belongs to the filtered view. |
547 SendEventToObservers( *this, iObservers, |
547 SendEventToObservers( *this, iObservers, |
548 &MVPbkContactViewObserver::ContactAddedToView, filteredIndex, |
548 &MVPbkContactViewObserver::ContactAddedToView, filteredIndex, |
549 aContactLink ); |
549 aContactLink ); |
550 } |
550 } |
551 } |
551 } |
552 else |
552 else |
553 { |
553 { |
561 |
561 |
562 // --------------------------------------------------------------------------- |
562 // --------------------------------------------------------------------------- |
563 // From class MVPbkContactViewBase. |
563 // From class MVPbkContactViewBase. |
564 // CVPbkFilteredContactView::ContactRemovedFromView |
564 // CVPbkFilteredContactView::ContactRemovedFromView |
565 // --------------------------------------------------------------------------- |
565 // --------------------------------------------------------------------------- |
566 // |
566 // |
567 void CVPbkFilteredContactView::ContactRemovedFromView( |
567 void CVPbkFilteredContactView::ContactRemovedFromView( |
568 MVPbkContactViewBase& /*aView*/, TInt aIndex, |
568 MVPbkContactViewBase& /*aView*/, TInt aIndex, |
569 const MVPbkContactLink& aContactLink) |
569 const MVPbkContactLink& aContactLink) |
570 { |
570 { |
571 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
571 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
572 ("CVPbkFilteredContactView::ContactRemovedFromView(0x%x %d)"), this, aIndex); |
572 ("CVPbkFilteredContactView::ContactRemovedFromView(0x%x %d)"), this, aIndex); |
573 |
573 |
574 const TInt filteredIndex = UpdateViewMappingAfterDeleting( aIndex ); |
574 const TInt filteredIndex = UpdateViewMappingAfterDeleting( aIndex ); |
575 if ( filteredIndex != KErrNotFound ) |
575 if ( filteredIndex != KErrNotFound ) |
576 { |
576 { |
577 // Mapping was succesfully updated and the contact removed from the mapping |
577 // Mapping was succesfully updated and the contact removed from the mapping |
578 SendEventToObservers( *this, iObservers, |
578 SendEventToObservers( *this, iObservers, |
579 &MVPbkContactViewObserver::ContactRemovedFromView, filteredIndex, |
579 &MVPbkContactViewObserver::ContactRemovedFromView, filteredIndex, |
580 aContactLink ); |
580 aContactLink ); |
581 } |
581 } |
582 |
582 else |
583 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
583 { |
584 ("CVPbkFilteredContactView::ContactRemovedFromView(0x%x)"), this); |
584 const TInt count = iObservers.Count(); |
|
585 |
|
586 for( TInt i = 0; i < count; i++ ) |
|
587 { |
|
588 MVPbkContactViewObserver* observer = iObservers[i]; |
|
589 |
|
590 TAny* extension = observer->ContactViewObserverExtension( |
|
591 KVPbkContactViewObserverExtension2Uid ); |
|
592 |
|
593 if( extension ) |
|
594 { |
|
595 MVPbkContactViewObserverExtension* contactViewExtension = |
|
596 static_cast<MVPbkContactViewObserverExtension*>( extension ); |
|
597 |
|
598 if( contactViewExtension ) |
|
599 { |
|
600 contactViewExtension->FilteredContactRemovedFromView( *this ); |
|
601 } |
|
602 } |
|
603 } |
|
604 } |
|
605 |
|
606 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
|
607 ("CVPbkFilteredContactView::ContactRemovedFromView(0x%x)"), this); |
585 } |
608 } |
586 |
609 |
587 // --------------------------------------------------------------------------- |
610 // --------------------------------------------------------------------------- |
588 // CVPbkFilteredContactView::UpdateViewMappingAfterAdding |
611 // CVPbkFilteredContactView::UpdateViewMappingAfterAdding |
589 // |
612 // |
590 // Update the mapping when a new contact is added to the base view |
613 // Update the mapping when a new contact is added to the base view |
591 // Returns its mapped index if it is added to the mapping |
614 // Returns its mapped index if it is added to the mapping |
592 // or KErrNotFound if it's filtered out |
615 // or KErrNotFound if it's filtered out |
593 // --------------------------------------------------------------------------- |
616 // --------------------------------------------------------------------------- |
594 // |
617 // |
595 TInt CVPbkFilteredContactView::UpdateViewMappingAfterAddingL( TInt aBaseIndex ) |
618 TInt CVPbkFilteredContactView::UpdateViewMappingAfterAddingL( TInt aBaseIndex ) |
596 { |
619 { |
597 // first update the mapping for all elements which > aBaseIndex |
620 // first update the mapping for all elements which > aBaseIndex |
598 TInt filteredIndex; |
621 TInt filteredIndex; |
599 // find first elemnt which >= aBaseIndex |
622 // find first elemnt which >= aBaseIndex |
612 } |
635 } |
613 else |
636 else |
614 { |
637 { |
615 filteredIndex = KErrNotFound; |
638 filteredIndex = KErrNotFound; |
616 } |
639 } |
617 |
640 |
618 return filteredIndex; |
641 return filteredIndex; |
619 } |
642 } |
620 |
643 |
621 // --------------------------------------------------------------------------- |
644 // --------------------------------------------------------------------------- |
622 // CVPbkFilteredContactView::UpdateViewMappingAfterDeleting |
645 // CVPbkFilteredContactView::UpdateViewMappingAfterDeleting |
623 // |
646 // |
624 // Update the mapping when a new contact is deleted from the base view |
647 // Update the mapping when a new contact is deleted from the base view |
625 // Returns its mapped index if it was removed from the mapping |
648 // Returns its mapped index if it was removed from the mapping |
626 // or KErrNotFound otherwise |
649 // or KErrNotFound otherwise |
627 // --------------------------------------------------------------------------- |
650 // --------------------------------------------------------------------------- |
628 // |
651 // |
629 TInt CVPbkFilteredContactView::UpdateViewMappingAfterDeleting( TInt aBaseIndex ) |
652 TInt CVPbkFilteredContactView::UpdateViewMappingAfterDeleting( TInt aBaseIndex ) |
630 { |
653 { |
631 // if the contact is in mappings, filteredIndex contains its index |
654 // if the contact is in mappings, filteredIndex contains its index |
632 // otherwise, the index of the next element greater than aIndex |
655 // otherwise, the index of the next element greater than aIndex |
633 TInt filteredIndex; |
656 TInt filteredIndex; |
634 const TInt err = iContactMapping.FindInOrder( aBaseIndex, filteredIndex ); |
657 const TInt err = iContactMapping.FindInOrder( aBaseIndex, filteredIndex ); |
635 |
658 |
636 // mapping should be updated in any case even if deleted contact |
659 // mapping should be updated in any case even if deleted contact |
637 // is not in the mapping |
660 // is not in the mapping |
638 // because all items in the mappings which > aIndex should be updated |
661 // because all items in the mappings which > aIndex should be updated |
639 for ( TInt i = filteredIndex; i < iContactMapping.Count(); ++i ) |
662 for ( TInt i = filteredIndex; i < iContactMapping.Count(); ++i ) |
640 { |
663 { |
641 // Subtract one because one contact was deleted |
664 // Subtract one because one contact was deleted |
642 // from the list before the current index |
665 // from the list before the current index |
643 --iContactMapping[i]; |
666 --iContactMapping[i]; |
644 } |
667 } |
645 |
668 |
646 if ( err == KErrNone ) |
669 if ( err == KErrNone ) |
647 { |
670 { |
648 iContactMapping.Remove( filteredIndex ); |
671 iContactMapping.Remove( filteredIndex ); |
649 } |
672 } |
650 else |
673 else |
651 { |
674 { |
652 filteredIndex = KErrNotFound; |
675 filteredIndex = KErrNotFound; |
653 } |
676 } |
654 |
677 |
655 return filteredIndex; |
678 return filteredIndex; |
656 } |
679 } |
657 |
680 |
658 // End of File |
681 // End of File |