camerauis/cameraapp/generic/src/CamSceneListBoxModel.cpp
changeset 19 d9aefe59d544
parent 3 8b2d6d0384b0
child 21 fa6d9f75d6a6
child 28 3075d9b614e6
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
     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:  Scene list box model*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CamSceneListBoxModel.h"
       
    21 #include "CamCaptureSetupListItem.h"
       
    22 #include "CamUtility.h"
       
    23 #include <cameraapp.rsg>
       
    24 #include <vgacamsettings.rsg> 
       
    25 
       
    26 #include <barsread.h>
       
    27 #include <aknlayoutscalable_apps.cdl.h>
       
    28 
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CCamSceneListBoxModel::CCamSceneListBoxModel
       
    34 // C++ default constructor can NOT contain any code, that
       
    35 // might leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CCamSceneListBoxModel::CCamSceneListBoxModel( 
       
    39     CCamAppController& aController,
       
    40     TCamCameraMode aMode,
       
    41     RPointerArray<HBufC>& aSummaryTitleTextArray,
       
    42     RPointerArray<HBufC>& aSummaryDescriptionTextArray,
       
    43     TBool aUserBaseScenes )
       
    44   : CCamCaptureSetupListBoxModel( aController, ETrue ),
       
    45     iMode( aMode ),
       
    46     iSummaryTitleTextArray( aSummaryTitleTextArray ),
       
    47     iSummaryDescriptionTextArray( aSummaryDescriptionTextArray ),
       
    48     iUserBaseScenes( aUserBaseScenes ),
       
    49     iController( aController )
       
    50   {
       
    51   }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CCamSceneListBoxModel::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CCamSceneListBoxModel::ConstructL( TRect aListBoxRect )
       
    59   {
       
    60   ReadLayoutData( aListBoxRect );  
       
    61   GetDataFromResourceL();
       
    62   }
       
    63 
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // GetDataFromResourceL
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 void
       
    70 CCamSceneListBoxModel::GetDataFromResourceL()
       
    71   {
       
    72   TInt resource = KErrNotFound;
       
    73   
       
    74   if( ECamControllerVideo == iMode )
       
    75     {
       
    76     resource = R_CAM_CAPTURE_SETUP_LIST_VIDEO_SHOOTING_MODE;
       
    77     }
       
    78   else
       
    79     {
       
    80     if( iUserBaseScenes )
       
    81       resource = R_CAM_CAPTURE_SETUP_LIST_USER_SCENE_SHOOTING_MODE;
       
    82     else
       
    83       resource = R_CAM_CAPTURE_SETUP_LIST_PHOTO_SHOOTING_MODE;
       
    84     }
       
    85 
       
    86   if( KErrNotFound != resource )
       
    87     {
       
    88     GetScenesDataL( resource );
       
    89     }
       
    90   }
       
    91 
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CCamSceneListBoxModel::GetScenesDataL
       
    95 // Load up data and descriptions for supported 
       
    96 // -----------------------------------------------------------------------------
       
    97 //   
       
    98 void CCamSceneListBoxModel::GetScenesDataL( TInt aArrayResourceId )
       
    99   {
       
   100 
       
   101   // create array from resource
       
   102   TResourceReader reader;
       
   103   CEikonEnv::Static()->CreateResourceReaderLC( reader, aArrayResourceId );
       
   104   const TInt count = reader.ReadInt16();
       
   105     
       
   106     // for each entry in the resource array, create a new list item
       
   107   TInt i;
       
   108   for ( i = 0; i < count; i++ )
       
   109     {
       
   110     CCamCaptureSetupListItem* listItem = 
       
   111       CCamCaptureSetupListItem::NewLC( reader, iIconLayoutData );
       
   112     
       
   113     TInt sceneVal = listItem->ItemValue();                      
       
   114     if( IsSupportedScene( sceneVal ) )
       
   115       {
       
   116       iItemArray.AppendL( listItem );
       
   117       CleanupStack::Pop( listItem );
       
   118       }
       
   119     else
       
   120       {
       
   121       CleanupStack::PopAndDestroy( listItem );
       
   122       }
       
   123     }    
       
   124   CleanupStack::PopAndDestroy(); // reader
       
   125   }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CCamSceneListBoxModel::IsSupportedScene
       
   129 // Check if a specific scene is supported by current product
       
   130 // -----------------------------------------------------------------------------
       
   131 // 
       
   132 TBool CCamSceneListBoxModel::IsSupportedScene( TInt aItem )
       
   133   {
       
   134   TBool  imageMode = (ECamControllerImage == iMode);
       
   135     
       
   136   // Scene must be in supported scenes list.
       
   137   TBool supported = iController.IsSceneSupported( aItem, imageMode );
       
   138   
       
   139   // Still, user scene is never supported in user scene base list.
       
   140   TBool userException = (ECamSceneUser == aItem && iUserBaseScenes );
       
   141 
       
   142   if( supported && !userException )
       
   143     {
       
   144     return ETrue;
       
   145     }
       
   146   else
       
   147     {
       
   148     return EFalse;
       
   149     }
       
   150   }
       
   151   
       
   152 // -----------------------------------------------------------------------------
       
   153 // CCamSceneListBoxModel::NewLC
       
   154 // Two-phased constructor.
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 CCamSceneListBoxModel* 
       
   158 CCamSceneListBoxModel::NewLC( 
       
   159     CCamAppController& aController,
       
   160     TCamCameraMode aMode, 
       
   161     RPointerArray<HBufC>& aSummaryTitleTextArray,
       
   162     RPointerArray<HBufC>& aSummaryDescriptionTextArray,
       
   163     TBool aUserBaseScenes,
       
   164     TRect aListBoxRect )
       
   165   {
       
   166   CCamSceneListBoxModel* self = 
       
   167       new( ELeave ) CCamSceneListBoxModel( aController, 
       
   168                                            aMode,
       
   169                                            aSummaryTitleTextArray, 
       
   170                                            aSummaryDescriptionTextArray,
       
   171                                            aUserBaseScenes );
       
   172     
       
   173   CleanupStack::PushL( self );
       
   174   self->ConstructL( aListBoxRect );
       
   175   return self;
       
   176   }
       
   177 
       
   178     
       
   179 // Destructor
       
   180 CCamSceneListBoxModel::~CCamSceneListBoxModel()
       
   181   {
       
   182   }
       
   183 
       
   184 
       
   185 //  End of File