bluetoothengine/bthid/bthidkbdsettings/src/btkeyenumtextsettingitem.cpp
branchRCL_3
changeset 56 9386f31cc85b
parent 0 f63038272f30
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
       
     1 /*
       
     2 * Copyright (c) 2004 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 "btkeyenumtextsettingitem.h"
       
    20 #include "btkeyboard.hrh"
       
    21 #include "bthidsettingview.h"
       
    22 #include "bthidsettings.h"
       
    23 #include "debug.h"
       
    24 
       
    25 //-----------------------------------------------------------------------------
       
    26 // CBTKeyEnumTextSettingItem::CBTKeyEnumTextSettingItem
       
    27 //-----------------------------------------------------------------------------
       
    28 //
       
    29 CBTKeyEnumTextSettingItem::CBTKeyEnumTextSettingItem(
       
    30     TInt aResourceId, TInt& aValue, CBtHidSettings& aSettings, CBtHidSettingView* aBtHidSettingView) :
       
    31         CAknEnumeratedTextPopupSettingItem ( aResourceId, aValue ),
       
    32         iSettings(aSettings),
       
    33         iBtHidSettingView(aBtHidSettingView)
       
    34     {}
       
    35 
       
    36 
       
    37 //-----------------------------------------------------------------------------
       
    38 // CBTKeyEnumTextSettingItem::~CBTKeyEnumTextSettingItem
       
    39 //-----------------------------------------------------------------------------
       
    40 //
       
    41 CBTKeyEnumTextSettingItem::~CBTKeyEnumTextSettingItem()
       
    42     {}
       
    43 
       
    44 //-----------------------------------------------------------------------------
       
    45 // CBTKeyEnumTextSettingItem::HandleSettingPageEventL
       
    46 //-----------------------------------------------------------------------------
       
    47 //
       
    48 void CBTKeyEnumTextSettingItem::HandleSettingPageEventL(
       
    49     CAknSettingPage *aSettingPage, TAknSettingPageEvent aEventType)
       
    50     {
       
    51     switch( aEventType )
       
    52         {
       
    53         case EEventSettingOked:
       
    54             {
       
    55             TRACE_INFO(_L("[BTHID]\t CBTKeyEnumTextSettingItem::HandleSettingPageEventL: OK"));
       
    56             // Get the new index and new value
       
    57             TInt newIndex = QueryValue()->CurrentValueIndex();
       
    58             TInt newValue = EnumeratedTextArray()->At(newIndex)->EnumerationValue();
       
    59 
       
    60             // Reset the index to the initial value, so if we leave when
       
    61             // trying to use the new value and the user then selects cancel
       
    62             // the setting item won't set the new value on the display.
       
    63             QueryValue()->SetCurrentValueIndex(IndexFromValue(InternalValue()));
       
    64 
       
    65             switch ( Identifier() )
       
    66                 {
       
    67                 case EBTKeySettingLayout:
       
    68                     {
       
    69                     THidKeyboardLayoutId newLayout =
       
    70                         static_cast<THidKeyboardLayoutId>(newValue);
       
    71                     iSettings.SaveLayoutSettingL(newLayout);
       
    72                     iBtHidSettingView->SetCurrentLayoutL(newLayout);
       
    73                     }
       
    74                 break;
       
    75 
       
    76                 default:
       
    77                 break;
       
    78                 }
       
    79 
       
    80             // We have finished using the new value. Set the index to the new
       
    81             // value so the UI is updated when this function exits
       
    82             QueryValue()->SetCurrentValueIndex(newIndex);
       
    83 
       
    84             // store the setting page internal value to the external variable
       
    85             StoreL();
       
    86             break;
       
    87             }
       
    88         case EEventSettingCancelled:
       
    89             {
       
    90             TRACE_INFO(_L("[BTHID]\t CBTKeyEnumTextSettingItem::HandleSettingPageEventL: Cancel"));
       
    91             // Reset the index to the initial value
       
    92             QueryValue()->SetCurrentValueIndex(IndexFromValue(InternalValue()));
       
    93             break;
       
    94             }
       
    95         case EEventSettingChanged:
       
    96             {
       
    97             TRACE_INFO(_L("[BTHID]\t CBTKeyEnumTextSettingItem::HandleSettingPageEventL: Changed"));
       
    98             // Flow through
       
    99             }
       
   100         default:
       
   101             {
       
   102             //do nothing
       
   103             break;
       
   104             }
       
   105         }
       
   106     // call the base class handler to take care of other event types
       
   107     CAknSettingItem::HandleSettingPageEventL(aSettingPage, aEventType);
       
   108     }
       
   109 
       
   110