uifw/AvKon/aknconf/src/aknconfsettinglist.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 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  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <akntextsettingpage.h>
       
    21 #include <centralrepository.h>
       
    22 #include <aknphysicscrkeys.h>
       
    23 #include <bautils.h>
       
    24 
       
    25 #include "aknconfsettingitem.h"
       
    26 #include "aknconfsettinglist.h"
       
    27 #include "aknconf.hrh"
       
    28 #include <aknconf.rsg>
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CAknConfSettingList::~CAknConfSettingList()
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CAknConfSettingList::~CAknConfSettingList()
       
    37     {
       
    38     iEikonEnv->DeleteResourceFile( iResourceOffset );
       
    39     delete iCenRep;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CAknConfSettingList::SettingPageClosed()
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CAknConfSettingList::SettingPageClosed( TBool aOkPressed,
       
    47                                              const TInt& aValue,
       
    48                                              const TInt& aCenRepKey )
       
    49     {
       
    50     if ( aOkPressed )
       
    51         {
       
    52         if ( iCenRep )
       
    53             {
       
    54             iCenRep->Set( aCenRepKey, aValue );
       
    55             }
       
    56         DrawDeferred();
       
    57         }
       
    58     }
       
    59 
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CAknConfSettingList::CreateSettingItemL()
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CAknSettingItem* CAknConfSettingList::CreateSettingItemL( TInt aIdentifier )
       
    66     {
       
    67     CAknSettingItem* settingItem = NULL;
       
    68     TInt cenRepKey( 0 );
       
    69     TInt* settingValue( ValueFromCenRep( aIdentifier, cenRepKey ) );
       
    70     settingItem 
       
    71         =  new ( ELeave ) CAknConfSettingItem( 
       
    72                 this, *settingValue, aIdentifier, cenRepKey );
       
    73     return settingItem;
       
    74     }
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CAknConfSettingList::CAknConfSettingList()
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CAknConfSettingList::CAknConfSettingList()
       
    82     : iCenRep( NULL )
       
    83     {
       
    84     }
       
    85 
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CAknConfSettingList::ConstructL()
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CAknConfSettingList::ConstructL( const TUid& aCenRepUid,
       
    92         const TDesC& aResourceFile )
       
    93     {
       
    94     iCenRep = CRepository::NewL( aCenRepUid );
       
    95     TFileName resourceFile;
       
    96     resourceFile.Append( aResourceFile );
       
    97     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resourceFile );
       
    98     iResourceOffset = iEikonEnv->AddResourceFileL( resourceFile );
       
    99     }
       
   100 
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CAknConfSettingList::ValueFromCenRep()
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 TInt* CAknConfSettingList::ValueFromCenRep( const TInt& aId, 
       
   107                                             TInt& aCenRepKey )
       
   108     {
       
   109     aCenRepKey = 0;
       
   110     TInt* settingValue( DataValuePointer( aId, aCenRepKey ) );
       
   111     if ( !settingValue || !aCenRepKey )
       
   112         {
       
   113         return NULL;
       
   114         }
       
   115 
       
   116     TInt value( -1 );
       
   117     if ( iCenRep )
       
   118         {
       
   119         iCenRep->Get( aCenRepKey, value );
       
   120         }
       
   121     *settingValue = value;
       
   122     return settingValue;
       
   123     }
       
   124 // End of File