commonuis/CommonDialogs/src/CAknMemorySelectionModel.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Model used in listbox of memory selection dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_AKNMEMORYSELECTIONMODEL_H
       
    21 #define C_AKNMEMORYSELECTIONMODEL_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 
       
    27 #include "maknmemoryselectionmodel.h"
       
    28 
       
    29 class CCoeEnv;
       
    30 class TCFDDriveInfo;
       
    31 
       
    32 
       
    33 /**
       
    34  *  A model class for memory selection. Model is derived from MDesCArray which
       
    35  *  provides an interface for list boxes to get items. Model has the
       
    36  *  responsibility to maintain a list of items for the listbox.
       
    37  *
       
    38  *  @lib CommonDialogs.lib
       
    39  *  @since S60 1.2
       
    40 */
       
    41 NONSHARABLE_CLASS(CAknMemorySelectionModel)
       
    42     : public CBase,
       
    43       public MAknMemorySelectionModel
       
    44 	{
       
    45 public:		
       
    46     
       
    47 // Constructors and destructor
       
    48 
       
    49 	/**
       
    50 	* Static constructor.
       
    51 	* @return Returns a pointer to an instance of itself.
       
    52 	*/
       
    53 	static CAknMemorySelectionModel* NewL(
       
    54 		CCoeEnv* aCoeEnv,
       
    55 		MDesCArray* aDriveArray,
       
    56 		TBool aShowUnavailable,
       
    57 		TListBoxLayout aLayout );
       
    58 
       
    59 	~CAknMemorySelectionModel();
       
    60 
       
    61 // New functions
       
    62 
       
    63 	/**
       
    64 	* Gets listbox text of a memory at desired lbx index.
       
    65 	* @param aIndex Index of the memory.
       
    66 	* @param aItem A reference to a descriptor where the item is stored.
       
    67 	*/
       
    68 	void GetItem( TInt aIndex, TDes& aItem );
       
    69 
       
    70 // Functions from base class MAknMemorySelectionModel
       
    71 
       
    72 	/**
       
    73 	* Updates items in listbox.
       
    74 	*/
       
    75 	void UpdateItemsL();
       
    76 
       
    77     /**
       
    78     * Get path of a drive referenced by given listbox item index.
       
    79     * @param aLbxItemIndex Index of the listbox item.
       
    80     * @param aDrivePath A reference to a descriptor where the drive path is
       
    81     *        stored.
       
    82     */
       
    83     void GetDrive( TInt aLbxItemIndex, TDes& aDrivePath );
       
    84     
       
    85 // Functions from base class MDesCArray
       
    86 
       
    87 	/**
       
    88 	** From MDesCArray.
       
    89 	*/
       
    90 	TInt MdcaCount() const;
       
    91 
       
    92 	/**
       
    93 	** From MDesCArray.
       
    94 	*/
       
    95 	TPtrC MdcaPoint( TInt aIndex ) const;
       
    96 
       
    97 private:	
       
    98     
       
    99 // Enumerations    
       
   100 
       
   101     /**
       
   102     * Indexes to the memory icons owned by the listbox.
       
   103     */
       
   104     enum TMemIcons
       
   105         {
       
   106         EIconPhoneMemory = 0,
       
   107 		EIconMMC,
       
   108 		EIconMMCLocked,
       
   109 		EIconMMCUnavailable,
       
   110 		EIconRemoteDrive,
       
   111 		EIconRemoteDriveActive // Icon used in D-column if drive active
       
   112         };
       
   113 
       
   114     /**
       
   115     * Indexes to the localized memory texts (iLocStringArray).
       
   116     */
       
   117     enum TMemLocTexts
       
   118         {
       
   119         ETextPhoneMemory = 0,
       
   120 		ETextMMC,
       
   121 		ETextMMCLocked,
       
   122 		ETextMMCUnavailable,
       
   123 		ETextRemoteDrive,
       
   124 		ETextCount // Count of the localized texts - must remain last!
       
   125         };
       
   126 
       
   127 // New functions
       
   128 
       
   129 	/**
       
   130 	* Reads localised texts from resource.
       
   131 	*/
       
   132 	void ReadResourcesL();
       
   133 
       
   134     /**
       
   135     * Creates formatted listbox item string from given drive information 
       
   136     * and appends it to iListBoxArray.
       
   137     *
       
   138     * @param aDriveInfo Drive information from which the lxx item string is
       
   139     *                   created.
       
   140     */
       
   141     void AddItemToLbxL( const TCFDDriveInfo &aDriveInfo );
       
   142 
       
   143     /**
       
   144     * Creates formatted listbox item and appends it to iListBoxArray.
       
   145     *
       
   146     * @param aDriveInfo Drive information from which the lxx item string is
       
   147     *                   created.
       
   148     */
       
   149     void AddPhoneItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   150     
       
   151     /**
       
   152     * Creates formatted listbox item and appends it to iListBoxArray.
       
   153     *
       
   154     * @param aDriveInfo Drive information from which the lxx item string is
       
   155     *                   created.
       
   156     */
       
   157     void AddMMCItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   158 
       
   159     /**
       
   160     * Creates formatted listbox item and appends it to iListBoxArray.
       
   161     *
       
   162     * @param aDriveInfo Drive information from which the lxx item string is
       
   163     *                   created.
       
   164     */
       
   165     void AddRemoteItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   166 
       
   167     /**
       
   168     * Creates formatted listbox item and appends it to iListBoxArray.
       
   169     *
       
   170     * @param aDriveInfo Drive information from which the lxx item string is
       
   171     *                   created.
       
   172     */
       
   173     void AddDefaultItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   174                 
       
   175     /**
       
   176     * Gets resource ID for resource item.
       
   177     * @param aLocStrIndex Index of the localized item.
       
   178     * @return ID of the resource item.
       
   179     */
       
   180     TInt ResourceIDForLayoutPopupMenuItem( TInt aLocStrIndex );
       
   181 
       
   182     /**
       
   183     * Gets resource ID for resource item.
       
   184     * @param aLocStrIndex Index of the localized item.
       
   185     * @return ID of the resource item.
       
   186     */
       
   187     TInt ResourceIDForLayoutSettingPageItem( TInt aLocStrIndex );
       
   188 
       
   189     /**
       
   190     * Gets resource ID for resource item.
       
   191     * @param aLocStrIndex Index of the localized item.
       
   192     * @return ID of the resource item.
       
   193     */
       
   194     TInt ResourceIDForLayoutDoublePopupItem( TInt aLocStrIndex );
       
   195 
       
   196 // Constructors and destructor
       
   197 
       
   198 	/**
       
   199 	* Second phase construct. Reads localised texts from resource.
       
   200 	*/
       
   201 	void ConstructL();
       
   202 
       
   203 	CAknMemorySelectionModel(
       
   204 		CCoeEnv* aCoeEnv,
       
   205 		MDesCArray* aDriveArray,
       
   206 		TBool aShowUnavailable,
       
   207 		TListBoxLayout aLayout );
       
   208 
       
   209 private: // Data
       
   210 
       
   211 	// Own: Array of items in listbox, decorated
       
   212 	RPointerArray<HBufC> iListBoxArray;
       
   213 
       
   214 	// Own: Array for localised texts, read from resource
       
   215 	RPointerArray<HBufC> iLocStringArray;
       
   216 
       
   217 	// Ref: Pointer to control environment
       
   218 	CCoeEnv* iCoeEnv;
       
   219 
       
   220 	// Ref: Array of drives to choose from
       
   221 	MDesCArray* iDriveArray;
       
   222 
       
   223 	// Own: Defines if unavailable drives are shown in list
       
   224 	TBool iShowUnavailable;
       
   225 
       
   226 	// Own: Defines layout of the items
       
   227 	TListBoxLayout iLayout;
       
   228 
       
   229 };
       
   230 
       
   231 #endif // C_AKNMEMORYSELECTIONMODEL_H