412 |
412 |
413 // -------------------------------------------------------------------------- |
413 // -------------------------------------------------------------------------- |
414 // CPbk2ThumbnailManager::GetPbkIconIndexL() |
414 // CPbk2ThumbnailManager::GetPbkIconIndexL() |
415 // -------------------------------------------------------------------------- |
415 // -------------------------------------------------------------------------- |
416 // |
416 // |
417 TInt CPbk2ThumbnailManager::GetPbkIconIndexL( TInt aListboxIndex, const MVPbkBaseContact& aContactLink ) |
417 TInt CPbk2ThumbnailManager::GetPbkIconIndexL( |
|
418 TInt aListboxIndex, |
|
419 const MVPbkContactLink& aContactLink ) |
418 { |
420 { |
419 TInt arrIndex = iDefaultIconIndex; |
421 TInt arrIndex = iDefaultIconIndex; |
420 |
422 |
421 // check that requested thumbnail is allready added to thumbnail array |
423 // check that requested thumbnail is allready added to thumbnail array |
422 if( Rng( 0, aListboxIndex, iContactThumbnails.Count() - 1 ) ) |
424 if( Rng( 0, aListboxIndex, iContactThumbnails.Count() - 1 ) ) |
423 { |
425 { |
424 CPbk2TmItem* item = iContactThumbnails[ aListboxIndex ]; |
426 CPbk2TmItem* item = iContactThumbnails[ aListboxIndex ]; |
425 if( !item ) |
427 if( !item ) |
426 { |
428 { |
427 item = CPbk2TmItem::NewL( aContactLink.CreateLinkLC(), aListboxIndex ); |
429 item = CPbk2TmItem::NewL( aContactLink.CloneLC(), aListboxIndex ); |
428 CleanupStack::Pop(); // link |
430 CleanupStack::Pop(); // link |
429 // set default icon index |
431 // set default icon index |
430 item->SetIconArrayIndexAndId( iDefaultIconIndex,iDefaultIconId ); |
432 item->SetIconArrayIndexAndId( iDefaultIconIndex,iDefaultIconId ); |
431 item->SetHasThumbnail( ETrue ); |
433 item->SetHasThumbnail( ETrue ); |
432 iContactThumbnails[ aListboxIndex ] = item; |
434 iContactThumbnails[ aListboxIndex ] = item; |
1030 { |
1032 { |
1031 PreCreateThumbnailArrayL( aView ); |
1033 PreCreateThumbnailArrayL( aView ); |
1032 } |
1034 } |
1033 else |
1035 else |
1034 { |
1036 { |
1035 // there is items in the listbox that are not loaded yet. If there is favorite contacts, |
1037 // Check if view count has changed |
1036 // those are added afterwards to the list. normal items are added first. |
1038 if ( aView.ContactCountL() != thumbnailCount ) |
1037 const TInt itemCount = aView.ContactCountL() - thumbnailCount; |
|
1038 for( TInt i = 0; i < itemCount; ++i ) |
|
1039 { |
1039 { |
1040 iContactThumbnails.InsertL( NULL, 0 ); |
1040 if( iLoadingQueue.Count() > 0 ) |
1041 } |
1041 { |
1042 if( itemCount > 0 ) |
1042 // store item that is currently in processing |
1043 { |
1043 iInProgressItemToBeRemoved = iLoadingQueue[0]; |
1044 ResetIndexes(); |
1044 } |
|
1045 |
|
1046 for ( TInt i = thumbnailCount - 1; i >= 0; --i ) |
|
1047 { |
|
1048 CPbk2TmItem* item = iContactThumbnails[i]; |
|
1049 if ( item ) |
|
1050 { |
|
1051 // check that the icon is not a default icon |
|
1052 if( iIconArray && item->GetIconArrayIndex() != iDefaultIconIndex ) |
|
1053 { |
|
1054 // inform icon array to remove the icon |
|
1055 iIconArray->RemoveIcon( item->GetIconId() ); |
|
1056 } |
|
1057 |
|
1058 if ( iInProgressItemToBeRemoved == item ) |
|
1059 { |
|
1060 // prevent item from being deleted later |
|
1061 iContactThumbnails[i] = NULL; |
|
1062 } |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 // reset and recreate arrays |
|
1067 iLoadingQueue.Reset(); |
|
1068 iPriorityArray.Reset(); |
|
1069 PreCreateThumbnailArrayL( aView ); |
1045 } |
1070 } |
1046 } |
1071 } |
1047 } |
1072 } |
1048 |
1073 |
1049 // -------------------------------------------------------------------------- |
1074 // -------------------------------------------------------------------------- |