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