menufw/menufwui/mmwidgets/src/mmcacheforitem.cpp
changeset 4 4d54b72983ae
parent 0 f72a12da539e
child 9 f966699dea19
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
    19 #include "mmcacheforitem.h"
    19 #include "mmcacheforitem.h"
    20 #include "mmitemsdatacache.h"
    20 #include "mmitemsdatacache.h"
    21 #include "hniconholder.h"
    21 #include "hniconholder.h"
    22 
    22 
    23 const TInt KIconHolderListGranularity = 2;
    23 const TInt KIconHolderListGranularity = 2;
       
    24 const TInt KIconListGranularity = 2;
    24 
    25 
    25 // -----------------------------------------------------------------------------
    26 // -----------------------------------------------------------------------------
    26 //
    27 //
    27 // -----------------------------------------------------------------------------
    28 // -----------------------------------------------------------------------------
    28 //
    29 //
    52 CMmCacheForItem::~CMmCacheForItem()
    53 CMmCacheForItem::~CMmCacheForItem()
    53     {
    54     {
    54     ClearIconArray();
    55     ClearIconArray();
    55     iIconHolderList.Close();
    56     iIconHolderList.Close();
    56     iItemText.Close();
    57     iItemText.Close();
       
    58     delete iIconList;
    57     }
    59     }
    58 
    60 
    59 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    60 //
    62 //
    61 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    81 //
    83 //
    82 CArrayPtr<CGulIcon>* CMmCacheForItem::GetIconListL()
    84 CArrayPtr<CGulIcon>* CMmCacheForItem::GetIconListL()
    83     {
    85     {
    84     __ASSERT_DEBUG( iIsValid, User::Invariant() );
    86     __ASSERT_DEBUG( iIsValid, User::Invariant() );
    85 
    87     return iIconList;
    86     const TInt iconCount = iIconHolderList.Count();
       
    87     CArrayPtr<CGulIcon>* iconList = new (ELeave) CArrayPtrFlat<CGulIcon>(
       
    88              Max( iconCount, 1 ) );
       
    89     CleanupStack::PushL( iconList );
       
    90     
       
    91     for ( TInt i = 0; i < iconCount; ++i )
       
    92         {
       
    93         iconList->AppendL( iIconHolderList[i]->GetGulIcon() );
       
    94         }
       
    95     
       
    96     CleanupStack::Pop( iconList );
       
    97     return iconList;
       
    98     }
    88     }
    99 
    89 
   100 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
   101 //
    91 //
   102 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
   119 //
   109 //
   120 // -----------------------------------------------------------------------------
   110 // -----------------------------------------------------------------------------
   121 //
   111 //
   122 void CMmCacheForItem::ClearIconArray()
   112 void CMmCacheForItem::ClearIconArray()
   123     {
   113     {
       
   114     iIconList->Reset();
   124     const TInt count = iIconHolderList.Count();
   115     const TInt count = iIconHolderList.Count();
   125     for (TInt i = 0; i < count; ++i )
   116     for (TInt i = 0; i < count; ++i )
   126         {
   117         {
   127         iIconHolderList[i]->Close();
   118         iIconHolderList[i]->Close();
   128         }
   119         }
   140             TMmSubcellsSetupCode aSubcellsSetupCode )
   131             TMmSubcellsSetupCode aSubcellsSetupCode )
   141     {
   132     {
   142     if ( iSubcellsSetupCode != aSubcellsSetupCode ||
   133     if ( iSubcellsSetupCode != aSubcellsSetupCode ||
   143             (!!iIsCurrent) != (!!aIsItemCurrent) )
   134             (!!iIsCurrent) != (!!aIsItemCurrent) )
   144         {
   135         {
   145         iIsValid = EFalse;
   136         SetValidL( EFalse );
   146         }
   137         }
   147     }
   138     }
   148 
   139 
   149 // -----------------------------------------------------------------------------
   140 // -----------------------------------------------------------------------------
   150 //
   141 //
   158 // -----------------------------------------------------------------------------
   149 // -----------------------------------------------------------------------------
   159 //
   150 //
   160 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   161 //
   152 //
   162 void CMmCacheForItem::ConstructL()
   153 void CMmCacheForItem::ConstructL()
   163     {    
   154     {
       
   155     iIconList = new ( ELeave ) CArrayPtrFlat<CGulIcon>( KIconListGranularity );
   164     }
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CMmCacheForItem::UpdateIconListL()
       
   163     {
       
   164     iIconList->Reset();
       
   165     const TInt iconCount = iIconHolderList.Count();
       
   166     for ( TInt i = 0; i < iconCount; ++i )
       
   167         {
       
   168         iIconList->AppendL( iIconHolderList[i]->GetGulIcon() );
       
   169         }
       
   170     }