phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistboxmodel.cpp
branchRCL_3
changeset 32 2828b4d142c0
parent 23 5586b4d2ec3e
child 39 a6539d1e8e43
equal deleted inserted replaced
26:0d28c1c5b6dd 32:2828b4d142c0
    37 
    37 
    38 //Virtual phonebook
    38 //Virtual phonebook
    39 #include <MVPbkContactViewBase.h>
    39 #include <MVPbkContactViewBase.h>
    40 #include <MVPbkViewContact.h>
    40 #include <MVPbkViewContact.h>
    41 #include <MVPbkContactLink.h>
    41 #include <MVPbkContactLink.h>
       
    42 #include <MVPbkContactViewBase.h>
    42 
    43 
    43 // CONSTANTS
    44 // CONSTANTS
    44 namespace {
    45 namespace {
    45 // Character used to replace invalid characters for UI
    46 // Character used to replace invalid characters for UI
    46 const TText KGraphicReplaceCharacter    = ' ';
    47 const TText KGraphicReplaceCharacter    = ' ';
    62 // iBuffer max size is EMaxListBoxText = 256
    63 // iBuffer max size is EMaxListBoxText = 256
    63 // -> max length for name data is 100 and max lenght for status data is 100
    64 // -> max length for name data is 100 and max lenght for status data is 100
    64 // rest 56 are reserved for icon data
    65 // rest 56 are reserved for icon data
    65 const TInt KMaxTxtLength = 100;
    66 const TInt KMaxTxtLength = 100;
    66 
    67 
       
    68 const TInt KDataElementCacheSize = 20;
    67 }
    69 }
       
    70 
       
    71 /**
       
    72  * Cache for data elements, cache is made to avoid performance problems that 
       
    73  * caused in cases when avkon implementation calls multiple times MdcaPoint function with same index
       
    74  * Cached items must be deleted when there is any change in contact list.
       
    75  */
       
    76 NONSHARABLE_CLASS( CDataElementCache ) : 
       
    77         public CBase,
       
    78         public MVPbkContactViewObserver,
       
    79         public MPbk2FilteredViewStackObserver
       
    80     {
       
    81 public:
       
    82     static CDataElementCache* NewL(MPbk2FilteredViewStack& aView);
       
    83     ~CDataElementCache();
       
    84 
       
    85     void AppendL( CPbk2ContactViewDoubleListboxDataElement* aDataElement );
       
    86     CPbk2ContactViewDoubleListboxDataElement* Element( TInt aListIndex );
       
    87     
       
    88 private:    // From MVPbkContactViewObserver
       
    89      void ContactViewReady(
       
    90              MVPbkContactViewBase& aView );
       
    91      void ContactViewUnavailable(
       
    92              MVPbkContactViewBase& aView );
       
    93      void ContactAddedToView(
       
    94              MVPbkContactViewBase& aView,
       
    95              TInt aIndex,
       
    96              const MVPbkContactLink& aContactLink );
       
    97      void ContactRemovedFromView(
       
    98              MVPbkContactViewBase& aView,
       
    99              TInt aIndex,
       
   100              const MVPbkContactLink& aContactLink );
       
   101      void ContactViewError(
       
   102              MVPbkContactViewBase& aView,
       
   103              TInt aError,
       
   104              TBool aErrorNotified );
       
   105 
       
   106 private:    // From MPbk2FilteredViewStackObserver
       
   107       void TopViewChangedL(
       
   108               MVPbkContactViewBase& aOldView );
       
   109       void TopViewUpdatedL();
       
   110       void BaseViewChangedL();
       
   111       void ViewStackError(
       
   112               TInt aError );
       
   113       void ContactAddedToBaseView( 
       
   114               MVPbkContactViewBase& aBaseView,
       
   115               TInt aIndex,
       
   116               const MVPbkContactLink& aContactLink ); 
       
   117      
       
   118 private:
       
   119     inline CDataElementCache( MPbk2FilteredViewStack& aView );
       
   120     inline void ConstructL();
       
   121     inline void Reset();
       
   122 
       
   123 private:    
       
   124     RPointerArray<CPbk2ContactViewDoubleListboxDataElement> iCache;
       
   125     MPbk2FilteredViewStack& iView;
       
   126     };
       
   127 
       
   128 // --------------------------------------------------------------------------
       
   129 // CDataElementCache::NewL
       
   130 // --------------------------------------------------------------------------
       
   131 //
       
   132 CDataElementCache* CDataElementCache::NewL( MPbk2FilteredViewStack& aView )
       
   133     {
       
   134     CDataElementCache* self = new (ELeave) CDataElementCache(aView);
       
   135     CleanupStack::PushL( self );
       
   136     self->ConstructL();
       
   137     CleanupStack::Pop( self );
       
   138     return self;
       
   139     }
       
   140 
       
   141 // --------------------------------------------------------------------------
       
   142 // CDataElementCache::CDataElementCache
       
   143 // --------------------------------------------------------------------------
       
   144 //
       
   145 inline CDataElementCache::CDataElementCache( MPbk2FilteredViewStack& aView )
       
   146 : iCache( KDataElementCacheSize ), 
       
   147   iView( aView )
       
   148     {
       
   149     }
       
   150 
       
   151 // --------------------------------------------------------------------------
       
   152 // CDataElementCache::ConstructL
       
   153 // --------------------------------------------------------------------------
       
   154 //
       
   155 inline void CDataElementCache::ConstructL()
       
   156     {
       
   157     iView.AddObserverL(*this);
       
   158     iView.AddStackObserverL(*this);
       
   159     }
       
   160 
       
   161 // --------------------------------------------------------------------------
       
   162 // CDataElementCache::~CDataElementCache
       
   163 // --------------------------------------------------------------------------
       
   164 //
       
   165 CDataElementCache::~CDataElementCache()
       
   166     {
       
   167     Reset();
       
   168     iView.RemoveObserver(*this);
       
   169     iView.RemoveStackObserver(*this);
       
   170     }
       
   171 
       
   172 // --------------------------------------------------------------------------
       
   173 // CDataElementCache::AppendL
       
   174 // --------------------------------------------------------------------------
       
   175 //
       
   176 void CDataElementCache::AppendL( 
       
   177         CPbk2ContactViewDoubleListboxDataElement* aDataElement )
       
   178     {
       
   179     iCache.InsertL( aDataElement, 0 );
       
   180     const TInt cacheItemCount( iCache.Count() );
       
   181     if( cacheItemCount > KDataElementCacheSize )
       
   182         {
       
   183         delete iCache[cacheItemCount - 1];
       
   184         iCache.Remove(cacheItemCount - 1);
       
   185         }
       
   186     }
       
   187 
       
   188 // --------------------------------------------------------------------------
       
   189 // CDataElementCache::Reset
       
   190 // --------------------------------------------------------------------------
       
   191 //
       
   192 inline void CDataElementCache::Reset()
       
   193     {
       
   194     iCache.ResetAndDestroy();
       
   195     }
       
   196 
       
   197 // --------------------------------------------------------------------------
       
   198 // CDataElementCache::Element
       
   199 // --------------------------------------------------------------------------
       
   200 //
       
   201 CPbk2ContactViewDoubleListboxDataElement* 
       
   202 CDataElementCache::Element( TInt aListIndex )
       
   203     {
       
   204     const TInt cacheItemCount( iCache.Count() );
       
   205     for( TInt i = 0 ; i < cacheItemCount ; ++i )
       
   206         {
       
   207         CPbk2ContactViewDoubleListboxDataElement* p = iCache[i];
       
   208         if( p->ListIndex() == aListIndex )
       
   209             {
       
   210             return p;
       
   211             }
       
   212         }
       
   213     return NULL;
       
   214     }
       
   215 
       
   216 // --------------------------------------------------------------------------
       
   217 // CDataElementCache::ContactViewReady
       
   218 // --------------------------------------------------------------------------
       
   219 //
       
   220 void CDataElementCache::ContactViewReady(
       
   221         MVPbkContactViewBase& /*aView*/ )
       
   222     {
       
   223     Reset();
       
   224     }
       
   225 
       
   226 // --------------------------------------------------------------------------
       
   227 // CDataElementCache::ContactViewUnavailable
       
   228 // --------------------------------------------------------------------------
       
   229 //
       
   230 void CDataElementCache::ContactViewUnavailable(
       
   231         MVPbkContactViewBase& /*aView*/ )
       
   232     {
       
   233     Reset();
       
   234     }
       
   235 
       
   236 // --------------------------------------------------------------------------
       
   237 // CDataElementCache::ContactAddedToView
       
   238 // --------------------------------------------------------------------------
       
   239 //
       
   240 void CDataElementCache::ContactAddedToView(
       
   241         MVPbkContactViewBase& /*aView*/,
       
   242         TInt /*aIndex*/,
       
   243         const MVPbkContactLink& /*aContactLink*/ )
       
   244     {
       
   245     Reset();
       
   246     }
       
   247 
       
   248 // --------------------------------------------------------------------------
       
   249 // CDataElementCache::ContactRemovedFromView
       
   250 // --------------------------------------------------------------------------
       
   251 //
       
   252 void CDataElementCache::ContactRemovedFromView(
       
   253         MVPbkContactViewBase& /*aView*/,
       
   254         TInt /*aIndex*/,
       
   255         const MVPbkContactLink& /*aContactLink*/ )
       
   256     {
       
   257     Reset();
       
   258     }
       
   259 
       
   260 // --------------------------------------------------------------------------
       
   261 // CDataElementCache::ContactViewError
       
   262 // --------------------------------------------------------------------------
       
   263 //
       
   264 void CDataElementCache::ContactViewError(
       
   265         MVPbkContactViewBase& /*aView*/,
       
   266         TInt /*aError*/,
       
   267         TBool /*aErrorNotified*/ )
       
   268     {
       
   269     Reset();
       
   270     }
       
   271 
       
   272 // --------------------------------------------------------------------------
       
   273 // CDataElementCache::TopViewChangedL
       
   274 // --------------------------------------------------------------------------
       
   275 //
       
   276 void CDataElementCache::TopViewChangedL(
       
   277         MVPbkContactViewBase& /*aOldView*/ )
       
   278     {
       
   279     Reset();
       
   280     }
       
   281 
       
   282 // --------------------------------------------------------------------------
       
   283 // CDataElementCache::TopViewUpdatedL
       
   284 // --------------------------------------------------------------------------
       
   285 //
       
   286 void CDataElementCache::TopViewUpdatedL()
       
   287     {
       
   288     Reset();
       
   289     }
       
   290 
       
   291 // --------------------------------------------------------------------------
       
   292 // CDataElementCache::BaseViewChangedL
       
   293 // --------------------------------------------------------------------------
       
   294 //
       
   295 void CDataElementCache::BaseViewChangedL()
       
   296     {
       
   297     Reset();
       
   298     }
       
   299 
       
   300 // --------------------------------------------------------------------------
       
   301 // CDataElementCache::ViewStackError
       
   302 // --------------------------------------------------------------------------
       
   303 //
       
   304 void CDataElementCache::ViewStackError(
       
   305         TInt /*aError*/ )
       
   306     {
       
   307     Reset();
       
   308     }
       
   309 
       
   310 // --------------------------------------------------------------------------
       
   311 // CDataElementCache::ContactAddedToBaseView
       
   312 // --------------------------------------------------------------------------
       
   313 //
       
   314 void CDataElementCache::ContactAddedToBaseView( 
       
   315         MVPbkContactViewBase& /*aBaseView*/,
       
   316         TInt /*aIndex*/,
       
   317         const MVPbkContactLink& /*aContactLink*/ ) 
       
   318     {
       
   319     Reset();
       
   320     }
       
   321 
    68 
   322 
    69 // --------------------------------------------------------------------------
   323 // --------------------------------------------------------------------------
    70 // CPbk2ContactViewDoubleListBoxModel::CPbk2ContactViewDoubleListBoxModel
   324 // CPbk2ContactViewDoubleListBoxModel::CPbk2ContactViewDoubleListBoxModel
    71 // --------------------------------------------------------------------------
   325 // --------------------------------------------------------------------------
    72 //
   326 //
    73 CPbk2ContactViewDoubleListBoxModel::CPbk2ContactViewDoubleListBoxModel(
   327 CPbk2ContactViewDoubleListBoxModel::CPbk2ContactViewDoubleListBoxModel(
    74     CPbk2ContactViewListBoxModel::TParams& aParams,
   328     CPbk2ContactViewListBoxModel::TParams& aParams,
    75     CPbk2ThumbnailManager& aThumbManager ) :
   329     CPbk2ThumbnailManager& aThumbManager,
       
   330     MPbk2FilteredViewStack& aFilteredViewStack ) :
    76     CPbk2ContactViewListBoxModel( aParams ),
   331     CPbk2ContactViewListBoxModel( aParams ),
    77     iThumbManager( aThumbManager )
   332     iThumbManager( aThumbManager ),
       
   333     iFilteredViewStack( aFilteredViewStack )
    78     {
   334     {
    79     TAny* object = aParams.iUiExtension->ContactUiControlExtensionExtension
   335     TAny* object = aParams.iUiExtension->ContactUiControlExtensionExtension
    80             ( TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) );
   336             ( TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) );
    81     iDoubleListExtensionPoint =
   337     iDoubleListExtensionPoint =
    82             static_cast<MPbk2ContactUiControlDoubleListboxExtension*>( object );
   338             static_cast<MPbk2ContactUiControlDoubleListboxExtension*>( object );
    86 // CPbk2ContactViewDoubleListBoxModel::~CPbk2ContactViewDoubleListBoxModel
   342 // CPbk2ContactViewDoubleListBoxModel::~CPbk2ContactViewDoubleListBoxModel
    87 // --------------------------------------------------------------------------
   343 // --------------------------------------------------------------------------
    88 //
   344 //
    89 CPbk2ContactViewDoubleListBoxModel::~CPbk2ContactViewDoubleListBoxModel()
   345 CPbk2ContactViewDoubleListBoxModel::~CPbk2ContactViewDoubleListBoxModel()
    90     {
   346     {
       
   347     delete iDataElementCache;
    91     }
   348     }
    92 
   349 
    93 // --------------------------------------------------------------------------
   350 // --------------------------------------------------------------------------
    94 // CPbk2ContactViewDoubleListBoxModel::NewL
   351 // CPbk2ContactViewDoubleListBoxModel::NewL
    95 // --------------------------------------------------------------------------
   352 // --------------------------------------------------------------------------
    96 //
   353 //
    97 CPbk2ContactViewDoubleListBoxModel* CPbk2ContactViewDoubleListBoxModel::NewL(
   354 CPbk2ContactViewDoubleListBoxModel* CPbk2ContactViewDoubleListBoxModel::NewL(
    98     CPbk2ContactViewListBoxModel::TParams& aParams,
   355     CPbk2ContactViewListBoxModel::TParams& aParams,
    99     CPbk2ThumbnailManager& aThumbManager )
   356     CPbk2ThumbnailManager& aThumbManager,
       
   357     MPbk2FilteredViewStack& aFilteredViewStack )
   100     {
   358     {
   101     CPbk2ContactViewDoubleListBoxModel* self =
   359     CPbk2ContactViewDoubleListBoxModel* self =
   102         new ( ELeave ) CPbk2ContactViewDoubleListBoxModel( aParams, aThumbManager );
   360         new ( ELeave ) CPbk2ContactViewDoubleListBoxModel( 
       
   361                 aParams, aThumbManager, aFilteredViewStack );
   103 
   362 
   104     CleanupStack::PushL(self);
   363     CleanupStack::PushL(self);
   105     self->ConstructL( aParams.iStoreProperties, aParams.iUiExtension );
   364     self->ConstructL( aParams.iStoreProperties, aParams.iUiExtension );
       
   365     self->iDataElementCache = CDataElementCache::NewL( aFilteredViewStack );
   106     CleanupStack::Pop();
   366     CleanupStack::Pop();
   107     return self;
   367     return self;
   108     }
   368     }
   109 
   369 
   110 // --------------------------------------------------------------------------
   370 // --------------------------------------------------------------------------
       
   371 // CPbk2ContactViewDoubleListBoxModel::FormatBufferL
       
   372 // --------------------------------------------------------------------------
       
   373 //
       
   374 void CPbk2ContactViewDoubleListBoxModel::FormatBufferL( const TInt aIndex ) const
       
   375     {
       
   376     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   377         ("CPbk2ContactViewDoubleListBoxModel::FormatBufferL(0x%x,%d), begin"),
       
   378         this);
       
   379     CPbk2ContactViewDoubleListboxDataElement* element = 
       
   380             iDataElementCache->Element( aIndex );
       
   381     if( element )
       
   382         {
       
   383         FormatBufferForElementDataL(*element, aIndex);
       
   384         }
       
   385     else
       
   386         {
       
   387         const MVPbkViewContact& contact = iView->ContactAtL(aIndex);
       
   388         FormatBufferForContactL(contact, aIndex );
       
   389         }
       
   390     
       
   391     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   392         ("CPbk2ContactViewDoubleListBoxModel::FormatBufferL(0x%x,%d), end"),
       
   393         this);
       
   394     }
       
   395 
       
   396 
       
   397 // --------------------------------------------------------------------------
       
   398 // CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL
       
   399 // --------------------------------------------------------------------------
       
   400 //
       
   401 void CPbk2ContactViewDoubleListBoxModel::FetchDataFromExtension(
       
   402         CPbk2ContactViewDoubleListboxDataElement& aDataElement,
       
   403         TInt aIndex ) const
       
   404     {
       
   405     // Get element data from extension
       
   406     // 
       
   407     if( iDoubleListExtensionPoint )
       
   408         {
       
   409         TRAPD( err, 
       
   410             iDoubleListExtensionPoint->FormatDataL( 
       
   411                     *(aDataElement.ContactLink()), aDataElement ) );
       
   412         if( err )
       
   413             {
       
   414             // extension's errors are ignored.  
       
   415             PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING(
       
   416             "CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL format error %d"),
       
   417                 err );
       
   418             }
       
   419         }
       
   420 
       
   421     // Clip secondary text if it's a phone number 
       
   422     if( MPbk2DoubleListboxDataElement::ETypePhoneNumber == 
       
   423         aDataElement.TextType( MPbk2DoubleListboxDataElement::EStatusText ) && 
       
   424         iClipListBoxText )
       
   425         {
       
   426         TPtr secondary( aDataElement.TextPtr( 
       
   427             MPbk2DoubleListboxDataElement::EStatusText ) );
       
   428         iClipListBoxText->ClipFromBeginning( 
       
   429             secondary, aIndex, KSecondaryTextColumn );
       
   430         }    
       
   431     }
       
   432 
       
   433 // --------------------------------------------------------------------------
       
   434 // CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL
       
   435 // --------------------------------------------------------------------------
       
   436 //
       
   437 void CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL(
       
   438     CPbk2ContactViewDoubleListboxDataElement& aDataElement, 
       
   439     TInt aIndex ) const
       
   440     {
       
   441     FetchDataFromExtension(aDataElement, aIndex);
       
   442 
       
   443     // start fill the new buffer for the avkon list
       
   444     iBuffer.Zero();
       
   445 
       
   446     AppendThumbnailL( aDataElement, aIndex );
       
   447     
       
   448     // Format line buffer based on element's content
       
   449     FormatBufferFromElement( aDataElement );
       
   450     }
       
   451 
       
   452 // --------------------------------------------------------------------------
   111 // CPbk2ContactViewDoubleListBoxModel::FormatBufferForContactL
   453 // CPbk2ContactViewDoubleListBoxModel::FormatBufferForContactL
   112 // --------------------------------------------------------------------------
   454 // --------------------------------------------------------------------------
   113 //
   455 //
   114 void CPbk2ContactViewDoubleListBoxModel::FormatBufferForContactL(
   456 void CPbk2ContactViewDoubleListBoxModel::FormatBufferForContactL(
   115     const MVPbkViewContact& aViewContact, TInt aIndex ) const
   457     const MVPbkViewContact& aViewContact, 
   116     {
   458     TInt aIndex ) const
   117     // Reset buffer
   459     {
   118     iBuffer.Zero();
   460     MVPbkContactLink* link = aViewContact.CreateLinkLC();
   119     
       
   120     CPbk2ContactViewDoubleListboxDataElement* element = 
   461     CPbk2ContactViewDoubleListboxDataElement* element = 
   121         CPbk2ContactViewDoubleListboxDataElement::NewLC();
   462         CPbk2ContactViewDoubleListboxDataElement::NewL( link, aIndex );
   122 
   463     CleanupStack::Pop();    // link
   123     // Fill data element cells
   464     CleanupStack::PushL( element );
   124     
   465 
   125     // (1) Add thumbnail icon
   466     // get data for element
   126     //
   467     // get user name
   127     TInt index = iThumbManager.GetPbkIconIndexL( aIndex, aViewContact );
       
   128     if( index != KErrNotFound )
       
   129         {
       
   130         iBuffer.AppendNum( index );
       
   131         }
       
   132     iBuffer.Append( KListColumnSeparator );
       
   133 
       
   134     // (2) Add contact name
       
   135     //
       
   136     HBufC* name = NULL;
   468     HBufC* name = NULL;
   137     if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ))
   469     if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ))
   138         {
   470         {
   139         MPbk2ContactNameFormatter2* nameformatterExtension =
   471         MPbk2ContactNameFormatter2* nameformatterExtension =
   140             reinterpret_cast<MPbk2ContactNameFormatter2*>(iNameFormatter.
   472             reinterpret_cast<MPbk2ContactNameFormatter2*>(iNameFormatter.
   162     // takes ownership of 'name'
   494     // takes ownership of 'name'
   163     element->SetText( MPbk2DoubleListboxDataElement::EName, name, 
   495     element->SetText( MPbk2DoubleListboxDataElement::EName, name, 
   164         MPbk2DoubleListboxDataElement::ETypeGenericText );
   496         MPbk2DoubleListboxDataElement::ETypeGenericText );
   165     CleanupStack::Pop( name );
   497     CleanupStack::Pop( name );
   166 
   498 
   167     // (3) Secondary text 
   499 
   168     // 
   500     // get icons
   169     // => Empty by default
       
   170   
       
   171     // (4) Trailing icon
       
   172     //
       
   173     RArray<TPbk2IconId> ids;
   501     RArray<TPbk2IconId> ids;
   174     CleanupClosePushL( ids );
   502     CleanupClosePushL( ids );
   175     iContactIcons->GetIconIdsForContactL( aViewContact, ids );
   503     iContactIcons->GetIconIdsForContactL( aViewContact, ids );
   176 
   504 
   177     // ids should contain at least one empty icon in any case
   505     // ids should contain at least one empty icon in any case
   182     
   510     
   183     element->SetIconId( MPbk2DoubleListboxDataElement::EMainIcon, ids[0] );
   511     element->SetIconId( MPbk2DoubleListboxDataElement::EMainIcon, ids[0] );
   184     CleanupStack::PopAndDestroy( &ids );
   512     CleanupStack::PopAndDestroy( &ids );
   185 
   513 
   186     // Get element data from extension
   514     // Get element data from extension
   187     if( iDoubleListExtensionPoint )
   515     FetchDataFromExtension( *element, aIndex );
   188         {
   516 
   189         TRAPD( err, 
   517     // start format data for the avkon list
   190             iDoubleListExtensionPoint->FormatDataL( aViewContact, *element ) );
   518     iBuffer.Zero();
   191         if( err )
   519     
   192             {
   520     AppendThumbnailL( *element, aIndex );
   193             // extension's errors are ignored.  
       
   194             PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING(
       
   195             "CPbk2ContactViewDoubleListBoxModel::FormatBufferForContactL format error %d"),
       
   196                 err );
       
   197             }
       
   198         }
       
   199 
       
   200     // Clip secondary text if it's a phone number 
       
   201     if( MPbk2DoubleListboxDataElement::ETypePhoneNumber == 
       
   202         element->TextType( MPbk2DoubleListboxDataElement::EStatusText ) && iClipListBoxText )
       
   203         {
       
   204         TPtr secondary( element->TextPtr( 
       
   205             MPbk2DoubleListboxDataElement::EStatusText ) );
       
   206         iClipListBoxText->ClipFromBeginning( 
       
   207             secondary, aIndex, KSecondaryTextColumn );
       
   208         }
       
   209     
   521     
   210     // Format line buffer based on element's content
   522     // Format line buffer based on element's content
   211     FormatBufferFromElement( *element );
   523     FormatBufferFromElement( *element );
   212     
   524     
   213     CleanupStack::PopAndDestroy( element ); 
   525     iDataElementCache->AppendL( element );
       
   526     CleanupStack::Pop( element ); 
   214     }
   527     }
   215 
   528 
   216 // --------------------------------------------------------------------------
   529 // --------------------------------------------------------------------------
   217 // CPbk2ContactViewDoubleListBoxModel::FormatBufferFromElement
   530 // CPbk2ContactViewDoubleListBoxModel::FormatBufferFromElement
   218 // --------------------------------------------------------------------------
   531 // --------------------------------------------------------------------------
   222     {
   535     {
   223 
   536 
   224     // List model format:
   537     // List model format:
   225     //   [thumbnail icon] \t [contact name] \t [secondary text] \t
   538     //   [thumbnail icon] \t [contact name] \t [secondary text] \t
   226     //   [trailing icon]
   539     //   [trailing icon]
   227 
       
   228     // (1) Thumbnail icon
       
   229     // No element support needed for thumbnail at the moment 
       
   230 
   540 
   231     // (2) Contact name
   541     // (2) Contact name
   232     AppendName( aElement.TextPtr( 
   542     AppendName( aElement.TextPtr( 
   233             MPbk2DoubleListboxDataElement::EName ).Left( KMaxTxtLength ) );
   543             MPbk2DoubleListboxDataElement::EName ).Left( KMaxTxtLength ) );
   234     iBuffer.Append( KListColumnSeparator );
   544     iBuffer.Append( KListColumnSeparator );
   238     AppendText( status );
   548     AppendText( status );
   239     
   549     
   240     // (4) Trailing icon
   550     // (4) Trailing icon
   241     AppendIconIndexIfFound( 
   551     AppendIconIndexIfFound( 
   242         aElement.IconId( MPbk2DoubleListboxDataElement::EMainIcon ) );
   552         aElement.IconId( MPbk2DoubleListboxDataElement::EMainIcon ) );
       
   553     }
       
   554 
       
   555 // --------------------------------------------------------------------------
       
   556 // CPbk2ContactViewDoubleListBoxModel::AppendThumbnailL
       
   557 // --------------------------------------------------------------------------
       
   558 //
       
   559 void CPbk2ContactViewDoubleListBoxModel::AppendThumbnailL( 
       
   560         CPbk2ContactViewDoubleListboxDataElement& aDataElement, 
       
   561         TInt aIndex ) const
       
   562     {
       
   563     // (1) Add thumbnail icon
       
   564     //
       
   565     TInt index = iThumbManager.GetPbkIconIndexL( 
       
   566             aIndex, *(aDataElement.ContactLink()) );
       
   567     if( index != KErrNotFound )
       
   568         {
       
   569         iBuffer.AppendNum( index );
       
   570         }
       
   571     iBuffer.Append( KListColumnSeparator );
   243     }
   572     }
   244 
   573 
   245 // --------------------------------------------------------------------------
   574 // --------------------------------------------------------------------------
   246 // CPbk2ContactViewDoubleListBoxModel::AppendText
   575 // CPbk2ContactViewDoubleListBoxModel::AppendText
   247 // --------------------------------------------------------------------------
   576 // --------------------------------------------------------------------------