menufw/menufwui/mmwidgets/inc/mmitemsdatacache.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *  Version     : 2 << Don't touch! Updated by Synergy at check-out.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef MMITEMSDATACACHE_H
       
    20 #define MMITEMSDATACACHE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32cmn.h>
       
    24 
       
    25 class CMmCacheForItem;
       
    26 
       
    27 /**
       
    28  * Provides a cache of data needed to draw every item in grid or list view.
       
    29  * This class is only used by CMmListBoxItemDrawer.
       
    30  */
       
    31 NONSHARABLE_CLASS( CMmItemsDataCache ): public CBase
       
    32     {
       
    33 public:
       
    34     /**
       
    35      * Creates new CMmItemsDataCache object. 
       
    36      */
       
    37     static CMmItemsDataCache* NewLC();
       
    38     
       
    39     /**
       
    40      * Creates new CMmItemsDataCache object.
       
    41      */
       
    42     static CMmItemsDataCache* NewL();
       
    43     
       
    44     /**
       
    45      * Returns item cache object for an item at specified index.
       
    46      * 
       
    47      * @param aItemIndex Item index
       
    48      * @return Item cache object.
       
    49      */
       
    50     CMmCacheForItem* GetItemCacheL( TInt aItemIndex );
       
    51     
       
    52     /**
       
    53      * Gets an integer identifier of a template of given name.
       
    54      * The identifier is guaranteed to be unique among other
       
    55      * identifiers obtained from this instance of CMmItemsDataCache
       
    56      * object.
       
    57      * Such identifier can be used to perform fast template
       
    58      * comparisons in the CMmListBoxItemDrawer code.
       
    59      * @c TMmSubcellsSetupCode code assumes that the template
       
    60      * identifier will not exceed 255. Assumption will be met unless
       
    61      * there are more that 256 different templates used in one suite
       
    62      * which is extremely unlikely.
       
    63      * 
       
    64      * @param aTemplateName Name of a template.
       
    65      * @return Template identifier based on template name.
       
    66      */
       
    67     TInt GetTemplateIdentifierL( const TDesC8& aTemplateName );
       
    68     
       
    69     /**
       
    70      * Translates a template identifier obtained from @c GetTemplateIdentifierL
       
    71      * into a regular string containing template name.
       
    72      * 
       
    73      * @param aTemplateIdentifier Template identifier from GetTemplateIdentifierL.
       
    74      * @return Template name.
       
    75      */
       
    76     const TDesC8& GetTemplateNameByIdentifier( TInt aTemplateIdentifier ) const;
       
    77     
       
    78     /**
       
    79      * Marks the whole data in cache as outdated so that
       
    80      * it cannot possibly be used until it is updated by
       
    81      * setting up subcells in normal (non-cached) mode.
       
    82      */
       
    83     void Invalidate();
       
    84     
       
    85     /**
       
    86      * Reduces the number of cache entries to given number.
       
    87      * If there are less entries than aItemCount then nothing
       
    88      * is done.
       
    89      * 
       
    90      * @param aItemCount number of items to store cached data for
       
    91      */
       
    92     void Trim( TInt aItemCount );
       
    93     
       
    94     /**
       
    95      * Standard C++ virtual destructor. 
       
    96      */
       
    97     ~CMmItemsDataCache();
       
    98 protected:
       
    99     
       
   100     /**
       
   101      * Standard C++ constructor.
       
   102      */
       
   103     CMmItemsDataCache();
       
   104     
       
   105     /**
       
   106      * 2nd phase constructor.
       
   107      */
       
   108     void ConstructL();
       
   109 
       
   110 protected: // data
       
   111 
       
   112     /**
       
   113      * Array of cache objects for individual items.
       
   114      * Own.
       
   115      */
       
   116     RPointerArray<CMmCacheForItem> iItemCacheArr;
       
   117     
       
   118     /**
       
   119      * Array of template names used by @c GetTemplateIdentifierL and
       
   120      * @c GetTemplateNameByIdentifier methods. Template identifiers
       
   121      * that @c GetTemplateIdentifierL returns are in fact indices in
       
   122      * this array.
       
   123      * Own. Contents of the array owned too.
       
   124      */
       
   125     RPointerArray<HBufC8> iTemplateNames;
       
   126 
       
   127     };
       
   128 
       
   129 #endif // MMITEMSDATACACHE_H