commonuis/CommonDialogs/inc/caknmemoryselectionmodelmultidrive.h
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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:  Model used in listbox of memory selection dialog.
       
    15 *                New model class to support multiple drives.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_AKNMEMORYSELECTIONMODELMULTIDRIVE_H
       
    22 #define C_AKNMEMORYSELECTIONMODELMULTIDRIVE_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 
       
    27 #include "maknmemoryselectionmodel.h"
       
    28 
       
    29 class CCoeEnv;
       
    30 class TCFDDriveInfo;
       
    31 
       
    32 /**
       
    33  *  A model class for memory selection. Model is derived from MDesCArray
       
    34  *  which provides an interface for list boxes to get items. Model has the
       
    35  *  responsibility to maintain a list of items for the listbox.
       
    36  *  This class supports multiple drives comparing CAknMemorySelectionModel.
       
    37  *
       
    38  *  @lib CommonDialogs.lib
       
    39  *  @since S60 5.0
       
    40  */
       
    41 NONSHARABLE_CLASS(CAknMemorySelectionModelMultiDrive)
       
    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 CAknMemorySelectionModelMultiDrive* NewL(
       
    54         CCoeEnv* aCoeEnv,
       
    55         MDesCArray* aDriveArray,
       
    56         MDesCArray* aDefaultFolderArray,
       
    57         TInt aIncludedMedias,
       
    58         TBool aShowUnavailable,
       
    59         TListBoxLayout aLayout );
       
    60 
       
    61     ~CAknMemorySelectionModelMultiDrive();
       
    62 
       
    63 // New functions
       
    64 
       
    65     /**
       
    66      * Gets listbox text of a memory at desired lbx index.
       
    67      * @param aIndex Index of the memory.
       
    68      * @param aItem A reference to a descriptor where the item is stored.
       
    69      */
       
    70     void GetItem( TInt aIndex, TDes& aItem );
       
    71 
       
    72 // Functions from base class MAknMemorySelectionModel
       
    73 
       
    74     /**
       
    75      * Update root path and default folder arrays
       
    76      */
       
    77     void UpdateDataArraysL();
       
    78 
       
    79     /**
       
    80      * Read root paths and default folders defined in resource.
       
    81      * @param aReader Is the resource reader;
       
    82      * @param aLocations Is the count of locations;
       
    83      */
       
    84     void ReadUserDefinedDataL( TResourceReader& aReader, TInt aLocations );
       
    85 
       
    86     /**
       
    87      * Updates items in listbox.
       
    88      */
       
    89     void UpdateItemsL();
       
    90 
       
    91     /**
       
    92      * Get path of a drive referenced by given listbox item index.
       
    93      * @param aLbxItemIndex Index of the listbox item.
       
    94      * @param aDrivePath A reference to a descriptor where the drive path is
       
    95      *        stored.
       
    96      */
       
    97     void GetDrive( TInt aLbxItemIndex, TDes& aDrivePath );
       
    98 
       
    99     /**
       
   100      * Check if there is any unavailable MMC (not inserted).
       
   101      *
       
   102      * @return ETrue There is at least one MMC unavailble.
       
   103      *         EFalse MMC inserted.
       
   104      */
       
   105     TBool HasUnavailbleMMC();
       
   106 
       
   107 // Functions from base class MDesCArray
       
   108 
       
   109     /**
       
   110      ** From MDesCArray.
       
   111      */
       
   112     TInt MdcaCount() const;
       
   113 
       
   114     /**
       
   115      ** From MDesCArray.
       
   116      */
       
   117     TPtrC MdcaPoint( TInt aIndex ) const;
       
   118 
       
   119 private:
       
   120 
       
   121 // Enumerations
       
   122 
       
   123     /**
       
   124      * Indexes to the memory icons owned by the listbox.
       
   125      */
       
   126     enum TMemIcons
       
   127         {
       
   128         EIconDeviceMemory = 0,
       
   129         EIconMMC,
       
   130         EIconMMCLocked,
       
   131         EIconMMCUnavailable,
       
   132         EIconRemoteDrive,
       
   133         EIconRemoteDriveActive, // Icon used in D-column if drive active
       
   134         EIconInternalMassStorage,
       
   135         EIconInternalMassStorageUnavailable
       
   136         };
       
   137 
       
   138     /**
       
   139      * Indexes to the localized memory texts (iLocStringArray).
       
   140      */
       
   141     enum TMemLocTexts
       
   142         {
       
   143         ETextDeviceMemory = 0,
       
   144         ETextMMCDefaultName,
       
   145         ETextMMCLocked,
       
   146         ETextMMCUnavailable,
       
   147         ETextRemoteDrive,
       
   148         ETextInternalMassStorage,
       
   149         ETextInternalMassStorageUnavailable,
       
   150         ETextMMCNamed,
       
   151         ETextCount // Count of the localized texts - must remain last!
       
   152         };
       
   153 
       
   154 // New functions
       
   155 
       
   156     /**
       
   157      * Reads localised texts from resource.
       
   158      */
       
   159     void ReadResourcesL();
       
   160 
       
   161     /**
       
   162      * Creates formatted listbox item string from given drive information
       
   163      * and appends it to iListBoxArray.
       
   164      *
       
   165      * @param aDriveInfo Drive information from which the lxx item string is
       
   166      *                   created.
       
   167      */
       
   168     void AddItemToLbxL( const TCFDDriveInfo &aDriveInfo );
       
   169 
       
   170     /**
       
   171      * Creates formatted listbox item and appends it to iListBoxArray.
       
   172      * This method is for device memory drives.
       
   173      *
       
   174      * @param aDriveInfo Drive information from which the lxx item string is
       
   175      *                   created.
       
   176      */
       
   177     void AddDeviceMemoryItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   178 
       
   179     /**
       
   180      * Creates formatted listbox item and appends it to iListBoxArray.
       
   181      * This method is for internal mass storage drives.
       
   182      *
       
   183      * @param aDriveInfo Drive information from which the lxx item string is
       
   184      *                   created.
       
   185      */
       
   186     void AddInternalStorageItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   187 
       
   188     /**
       
   189      * Creates formatted listbox item and appends it to iListBoxArray.
       
   190      * This method is for removable mass storage drives.
       
   191      *
       
   192      * @param aDriveInfo Drive information from which the lxx item string is
       
   193      *                   created.
       
   194      */
       
   195     void AddMMCItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   196 
       
   197     /**
       
   198      * Creates formatted listbox item and appends it to iListBoxArray.
       
   199      * This method is for remote drives.
       
   200      *
       
   201      * @param aDriveInfo Drive information from which the lxx item string is
       
   202      *                   created.
       
   203      */
       
   204     void AddRemoteItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   205 
       
   206     /**
       
   207      * Creates formatted listbox item and appends it to iListBoxArray.
       
   208      *
       
   209      * @param aDriveInfo Drive information from which the lxx item string is
       
   210      *                   created.
       
   211      */
       
   212     void AddDefaultItemToLbxL( const TCFDDriveInfo& aDriveInfo );
       
   213 
       
   214     /**
       
   215      * Gets resource ID for resource item.
       
   216      * @param aLocStrIndex Index of the localized item.
       
   217      * @return ID of the resource item.
       
   218      */
       
   219     TInt ResourceIDForLayoutPopupMenuItem( TInt aLocStrIndex );
       
   220 
       
   221     /**
       
   222      * Gets resource ID for resource item.
       
   223      * @param aLocStrIndex Index of the localized item.
       
   224      * @return ID of the resource item.
       
   225      */
       
   226     TInt ResourceIDForLayoutSettingPageItem( TInt aLocStrIndex );
       
   227 
       
   228     /**
       
   229      * Gets resource ID for resource item.
       
   230      * @param aLocStrIndex Index of the localized item.
       
   231      * @return ID of the resource item.
       
   232      */
       
   233     TInt ResourceIDForLayoutDoublePopupItem( TInt aLocStrIndex );
       
   234 
       
   235 // Constructors and destructor
       
   236 
       
   237     /**
       
   238      * Second phase construct. Reads localised texts from resource.
       
   239      */
       
   240     void ConstructL();
       
   241 
       
   242     CAknMemorySelectionModelMultiDrive(
       
   243         CCoeEnv* aCoeEnv,
       
   244         MDesCArray* aDriveArray,
       
   245         MDesCArray* aDefaultFolderArray,
       
   246         TInt aIncludedMedias,
       
   247         TBool aShowUnavailable,
       
   248         TListBoxLayout aLayout );
       
   249 
       
   250 private: // Data
       
   251 
       
   252     // Own: Array of items in listbox, decorated
       
   253     RPointerArray<HBufC> iListBoxArray;
       
   254 
       
   255     // Own: Array for localised texts, read from resource
       
   256     RPointerArray<HBufC> iLocStringArray;
       
   257 
       
   258     // Ref: Pointer to control environment
       
   259     CCoeEnv* iCoeEnv;
       
   260 
       
   261     // Ref: Array of drives to choose from
       
   262     MDesCArray* iDriveArray;
       
   263 
       
   264     /**
       
   265      * Ref: Array of default folder to choose from
       
   266      */
       
   267     MDesCArray* iDefaultFolderArray;
       
   268     
       
   269     /**
       
   270      * Indicate which media types of drives could be visible.
       
   271      */
       
   272     TInt iIncludedMedias;
       
   273     
       
   274     /**
       
   275      * Own: Array of drives in resource to choose from
       
   276      */
       
   277     CDesCArrayFlat* iDefDriveArray;
       
   278     
       
   279     /**
       
   280      * Own: Array of default folder in resource to choose from
       
   281      */
       
   282     CDesCArrayFlat* iDefDefaultFolderArray;
       
   283 
       
   284     // Own: Defines if unavailable drives are shown in list
       
   285     TBool iShowUnavailable;
       
   286 
       
   287     // Own: Defines layout of the items
       
   288     TListBoxLayout iLayout;
       
   289 
       
   290     /**
       
   291      * Indicate if there is any unavailable MMC
       
   292      */
       
   293     TBool iHasMMCUnavailable;
       
   294     };
       
   295 
       
   296 #endif // C_AKNMEMORYSELECTIONMODELMULTIDRIVE_H