apengine/apsettingshandlerui/inc/ApSelectorListBoxModel.h
changeset 61 8b0c979bbe8c
parent 59 2709c04a4af5
child 70 ac5daea24fb0
equal deleted inserted replaced
59:2709c04a4af5 61:8b0c979bbe8c
     1 /*
       
     2 * Copyright (c) 2002 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:  Declaration of class CApSelectorListboxModel.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef APSELECTOR_LISTBOX_MODEL_H
       
    20 #define APSELECTOR_LISTBOX_MODEL_H
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <eikdialg.h>
       
    24 #include <ApListItemList.h>
       
    25 
       
    26 
       
    27 // CONSTANTS
       
    28 // Granularity of the model array.
       
    29 const TInt KGranularity = 8;
       
    30 
       
    31 // const TInt KErrInvalidBitmapType = -300;
       
    32 
       
    33 _LIT( KListItemFormatGraphicBearer, "%d\t%*S\t\t" );
       
    34 _LIT( KListItemFormatGraphicNone, "%*S" );
       
    35 _LIT( KListItemFormatGraphicOnOff, "%d\t%*S" );
       
    36 
       
    37 _LIT( KListItemFormatGraphicProtected, "%d\t%*S\t%d\t" );
       
    38 _LIT( KListItemFormatGraphicOnOffWithLock, "%d\t%*S\t\t%d\t" );
       
    39 _LIT( KListItemFormatGraphicWithLock, "%*S\t\t%d\t" );
       
    40 
       
    41 const TInt KMaxFormatSize = sizeof( KListItemFormatGraphicBearer );
       
    42 const TInt KMaxListItemNameLength = 50; // = KCommsDbSvrMaxFieldLength
       
    43 
       
    44 /**
       
    45 * Buffer size for formatting listbox text. Maximum item length
       
    46 * plus listbox internals (tabulators for icons etc.) must fit into it.
       
    47 *
       
    48 * Important note:
       
    49 * The model of the listbox is a CAknFilteredTextListBoxModel.
       
    50 * The *itemarray* of that model is this class. That is, whatever is in
       
    51 * the model (this class), it may not be visible, if it is filtered out.
       
    52 * We always must use the listbox's Model() to get visible ones.
       
    53 */
       
    54 const TInt KMaxApSelectorListboxName = KMaxListItemNameLength+KMaxFormatSize;
       
    55 
       
    56 
       
    57 // CLASS DECLARATION
       
    58 
       
    59 /**
       
    60 * Model for the access point listbox. It is an array of CApSelectorItem
       
    61 * pointers; items are owned.
       
    62 */
       
    63 NONSHARABLE_CLASS( CApSelectorListboxModel ) :
       
    64         public CApListItemList,
       
    65         public MDesCArray
       
    66     {
       
    67     public:     // Construct / destruct
       
    68         enum TGraphicType       /// Events reported to the database observer.
       
    69             {
       
    70             EGraphicNone,       ///< No graphic or icon.
       
    71             EGraphicProtection, ///< Only protected icon.
       
    72             EGraphicBearer,     ///< Bearer specific icon.
       
    73             EGraphicOnOff       ///< Selection specific icon.
       
    74             };
       
    75 
       
    76 
       
    77         /**
       
    78         * Constructor.
       
    79         * @param aGraphicType   The used graphic type
       
    80         */
       
    81         CApSelectorListboxModel( TGraphicType aGraphicType = EGraphicBearer );
       
    82 
       
    83 
       
    84         /**
       
    85         * Destructor.
       
    86         */
       
    87         virtual ~CApSelectorListboxModel();
       
    88 
       
    89     public:     // from MDesCArray
       
    90 
       
    91         /**
       
    92         * Get number of items in the model.
       
    93         * @return Number of items.
       
    94         */
       
    95         TInt MdcaCount() const;
       
    96 
       
    97 
       
    98         /**
       
    99         * Text to be displayed for this item.
       
   100         * @param aIndex Index of item.
       
   101         * @return TPtrC for this item text (text owned by the model).
       
   102         */
       
   103         TPtrC MdcaPoint( TInt aIndex ) const;
       
   104 
       
   105 
       
   106     public:
       
   107         
       
   108         /**
       
   109         * index <--> Uid conversion
       
   110         * @param aUid   The UID of the item 
       
   111         * @param aErr   Error code
       
   112         * @return       The index of the item 
       
   113         */
       
   114         TInt Item4Uid( TUint32 aUid, TInt& aErr ) const;
       
   115 
       
   116         
       
   117         /**
       
   118         * Sets the icon offset
       
   119         * @param aOffset    The offset of our icons in the iconarray
       
   120         */
       
   121         void SetOwnIconOffset( TInt aOffset );
       
   122 
       
   123 
       
   124     private:    // data
       
   125         /**
       
   126         * Formats the text of the listbox.
       
   127         * @param aIndex Index of item.
       
   128         * @param aBuf Buffer to store formatted text.
       
   129         */
       
   130         void FormatListboxText( TInt aIndex, TDes& aBuf ) const;
       
   131 
       
   132 
       
   133         /**
       
   134         * MdcaPoint() cannot leave, so this buffer is allocated
       
   135         * to allow formatting. Fortunately, doesn't have to be very
       
   136         * large.
       
   137         * We have to use MUTABLE CAST, as MdcaPoint is const (odd enough),
       
   138         * so wouldn't allow formatting the text in a member...
       
   139         */
       
   140         __MUTABLE TBuf<KMaxApSelectorListboxName> iBuf;
       
   141 
       
   142 
       
   143         TGraphicType    iGraphicType;
       
   144         TInt            iOffset;
       
   145         TBool           iFeatureInitialised;
       
   146         TBool           iProtectionSupported;
       
   147     };
       
   148 
       
   149 
       
   150 #endif
       
   151 
       
   152 // End of file