classicui_pub/tsrc/bc/apps/S60_SDK3.0/bctestcmdlg/src/CVRSettingsDialogMMCSupported.cpp
changeset 22 75713bee6484
parent 21 558113899881
child 26 62ef28f7b435
child 28 d33307312dfe
equal deleted inserted replaced
21:558113899881 22:75713bee6484
     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 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 #include <bctestcmdlg.rsg>
       
    25 #include <AknLists.h>
       
    26 #include "CVRSettingsDialogMMCSupported.h"
       
    27 #include <hlplch.h>
       
    28 
       
    29 #include <CAknMemorySelectionSettingItem.h>
       
    30 #include <aknnotewrappers.h>
       
    31 
       
    32 #include "bctestcmdlg.hrh"
       
    33 
       
    34 CVRSettingsDialog::~CVRSettingsDialog()
       
    35     {
       
    36 	iSettingItemArray.ResetAndDestroy();
       
    37     }
       
    38 
       
    39 CVRSettingsDialog* CVRSettingsDialog::NewL()
       
    40     {
       
    41     CVRSettingsDialog* self = new( ELeave ) CVRSettingsDialog;
       
    42 	CleanupStack::PushL( self );
       
    43 	self->ConstructL( R_VR_SETTINGS_MENUBAR );
       
    44 	CleanupStack::Pop();
       
    45     return self;
       
    46     }
       
    47 
       
    48 TBool CVRSettingsDialog::OkToExitL( TInt aButtonId )
       
    49 	{
       
    50 	if ( aButtonId == EAknSoftkeyOptions )
       
    51         {
       
    52         DisplayMenuL();
       
    53         return EFalse;
       
    54         }
       
    55 
       
    56 	TInt settingItemCount( iSettingItemArray.Count() );
       
    57 
       
    58 	for ( TInt i( 0 ); i < settingItemCount; i++ )
       
    59 		{
       
    60 		iSettingItemArray.At( i )->StoreL();
       
    61 		}
       
    62 
       
    63 	return ETrue;
       
    64 	}
       
    65 
       
    66 void CVRSettingsDialog::PreLayoutDynInitL()
       
    67 	{
       
    68 	// Convert the internal memory enumeration to CFD enumeration
       
    69 	CAknSettingStyleListBox* listBox = static_cast< CAknSettingStyleListBox* >
       
    70 										( Control( EVRSettingsListboxId ) );
       
    71 	User::LeaveIfNull( listBox );
       
    72 
       
    73     CAknSettingItem* settingItem;
       
    74     HBufC* itemTitle;
       
    75    	TInt id( 0 );
       
    76 
       
    77 	// Create the memo store item
       
    78 	settingItem =
       
    79 				new( ELeave ) CAknMemorySelectionSettingItem( 0, iMemoStore );
       
    80 	CleanupStack::PushL( settingItem );
       
    81 
       
    82 	// Set memo store item's title
       
    83 	itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_STORE );
       
    84 	settingItem->ConstructL( EFalse, id, *itemTitle, NULL, 0,
       
    85 													EAknCtPopupSettingList );
       
    86 	CleanupStack::PopAndDestroy();	// itemTitle
       
    87 
       
    88 	// Add memo store item to the settings array
       
    89 	iSettingItemArray.AppendL( settingItem );
       
    90 	CleanupStack::Pop();	// settingItem
       
    91 	id++;
       
    92 
       
    93 	CTextListBoxModel* model = listBox->Model();
       
    94 	model->SetItemTextArray( &iSettingItemArray );
       
    95 	// Ownership retained by us
       
    96 	model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    97 
       
    98 	iSettingItemArray.RecalculateVisibleIndicesL();
       
    99 	listBox->CreateScrollBarFrameL( ETrue );
       
   100 	listBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   101 						CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   102 	listBox->HandleItemAdditionL();
       
   103 	listBox->SetListBoxObserver( this );
       
   104 	listBox->UpdateScrollBarsL();
       
   105 
       
   106 	}
       
   107 
       
   108 void CVRSettingsDialog::HandleListBoxEventL( CEikListBox* aListBox,
       
   109 											 TListBoxEvent aEventType )
       
   110 	{
       
   111 	TInt index( aListBox->CurrentItemIndex() );
       
   112 		if ( index >=0 )	// index is -1 if there are no items in the list
       
   113 			{
       
   114 			iSettingItemArray.At( index )->EditItemL( 
       
   115 				aEventType == EEventEditingStarted );
       
   116 			aListBox->DrawItem( index );
       
   117 			}
       
   118 	}
       
   119 
       
   120 void CVRSettingsDialog::ProcessCommandL( TInt aCommandId )
       
   121 	{
       
   122 	HideMenu();
       
   123 	switch ( aCommandId )
       
   124 		{
       
   125 		case ECmdChange:
       
   126 			{
       
   127 			CEikListBox* listBox = static_cast< CEikListBox* >( Control( EVRSettingsListboxId ) );
       
   128 			HandleListBoxEventL( listBox, EEventEditingStarted );
       
   129 			break;
       
   130 			}
       
   131 		case EEikCmdExit:
       
   132 			{
       
   133 			TryExitL( EEikCmdExit );
       
   134 			CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId );
       
   135 			break;
       
   136 			}
       
   137 		default:
       
   138 			{
       
   139 			CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId );
       
   140 			break;
       
   141 			}
       
   142 		}
       
   143 	}