39
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: Implementation of CDevEncUiSettingItemList.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
|
|
20 |
// Class include
|
|
21 |
#include "DevEncUiSettingItemList.h"
|
|
22 |
|
|
23 |
// System include
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <devencui.rsg>
|
|
26 |
|
|
27 |
// User include
|
|
28 |
|
|
29 |
// Constants
|
|
30 |
const TInt KOffTextIndex( 0 );
|
|
31 |
const TInt KOnTextIndex( 1 );
|
|
32 |
const TInt KOffEnumerationValue( 0 );
|
|
33 |
const TInt KOnEnumerationValue( 1 );
|
|
34 |
|
|
35 |
// ================= MEMBER FUNCTIONS =======================
|
|
36 |
|
|
37 |
// --------------------------------------------------------------------------
|
|
38 |
// CDevEncUiSettingItemList::CDevEncUiSettingItemList()
|
|
39 |
// --------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CDevEncUiSettingItemList::CDevEncUiSettingItemList()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
// --------------------------------------------------------------------------
|
|
46 |
// CDevEncUiSettingItemList::~CDevEncUiSettingItemList()
|
|
47 |
// --------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CDevEncUiSettingItemList::~CDevEncUiSettingItemList()
|
|
50 |
{
|
|
51 |
}
|
|
52 |
|
|
53 |
// --------------------------------------------------------------------------
|
|
54 |
// CDevEncUiSettingItemList::SizeChanged()
|
|
55 |
// --------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
void CDevEncUiSettingItemList::SizeChanged()
|
|
58 |
{
|
|
59 |
if ( ListBox() )
|
|
60 |
{
|
|
61 |
ListBox()->SetRect( Rect() );
|
|
62 |
ListBox()->HandleResourceChange( KEikDynamicLayoutVariantSwitch );
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
// --------------------------------------------------------------------------
|
|
67 |
// CDevEncUiSettingItemList::HandleResourceChange()
|
|
68 |
// --------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
void CDevEncUiSettingItemList::HandleResourceChange( TInt aType )
|
|
71 |
{
|
|
72 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
73 |
{
|
|
74 |
// do re-layout
|
|
75 |
if ( ListBox() )
|
|
76 |
{
|
|
77 |
ListBox()->SetRect( Rect() );
|
|
78 |
ListBox()->HandleResourceChange( aType );
|
|
79 |
}
|
|
80 |
}
|
|
81 |
}
|
|
82 |
|
|
83 |
// --------------------------------------------------------------------------
|
|
84 |
// CDevEncUiSettingItemList::CreateSettingItemL()
|
|
85 |
// --------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
CAknSettingItem* CDevEncUiSettingItemList::CreateSettingItemL( TInt aIdentifier )
|
|
88 |
{
|
|
89 |
CAknSettingItem* settingItem = NULL;
|
|
90 |
|
|
91 |
switch ( aIdentifier )
|
|
92 |
{
|
|
93 |
case EPhoneEncryptionSettingItem:
|
|
94 |
settingItem =
|
|
95 |
new ( ELeave ) CAknBinaryPopupSettingItem( aIdentifier,
|
|
96 |
iPhoneMemSetting );
|
|
97 |
break;
|
|
98 |
case EMemoryCardEncryptionSettingItem:
|
|
99 |
settingItem =
|
|
100 |
new ( ELeave ) CAknBinaryPopupSettingItem( aIdentifier,
|
|
101 |
iMmcSetting );
|
|
102 |
break;
|
|
103 |
}
|
|
104 |
return settingItem; // passing ownership
|
|
105 |
}
|
|
106 |
|
|
107 |
// --------------------------------------------------------------------------
|
|
108 |
// CDevEncUiSettingItemList::HandleListBoxEventL()
|
|
109 |
// --------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
void CDevEncUiSettingItemList::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
|
|
112 |
{
|
|
113 |
if ( aEventType == EEventItemSingleClicked )
|
|
114 |
{
|
|
115 |
TKeyEvent event;
|
|
116 |
event.iCode = EKeyEnter;
|
|
117 |
event.iScanCode = EStdKeyEnter;
|
|
118 |
event.iRepeats = 0;
|
|
119 |
iCoeEnv->SimulateKeyEventL( event, EEventKey );
|
|
120 |
return;
|
|
121 |
}
|
|
122 |
CAknSettingItemList::HandleListBoxEventL(aListBox, aEventType);
|
|
123 |
}
|
|
124 |
|
|
125 |
// --------------------------------------------------------------------------
|
|
126 |
// CDevEncUiSettingItemList::ChangeSelectedItemL()
|
|
127 |
// --------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
void CDevEncUiSettingItemList::ChangeSelectedItemL()
|
|
130 |
{
|
|
131 |
if ( ! ListBox() )
|
|
132 |
{
|
|
133 |
User::Leave( KErrNotFound );
|
|
134 |
}
|
|
135 |
EditItemL( ListBox()->CurrentItemIndex(), ETrue );
|
|
136 |
}
|
|
137 |
|
|
138 |
// --------------------------------------------------------------------------
|
|
139 |
// CDevEncUiSettingItemList::SelectedItem()
|
|
140 |
// --------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
TInt CDevEncUiSettingItemList::SelectedItem()
|
|
143 |
{
|
|
144 |
if ( ! ListBox() )
|
|
145 |
{
|
|
146 |
return -1;
|
|
147 |
}
|
|
148 |
return ListBox()->CurrentItemIndex();
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
// --------------------------------------------------------------------------
|
|
153 |
// CDevEncUiSettingItemList::EditItemL()
|
|
154 |
// --------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CDevEncUiSettingItemList::EditItemL( TInt aIndex, TBool aCalledFromMenu )
|
|
157 |
{
|
|
158 |
CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
|
|
159 |
(*SettingItemArray())[aIndex]->StoreL();
|
|
160 |
}
|
|
161 |
|
|
162 |
// --------------------------------------------------------------------------
|
|
163 |
// CDevEncUiSettingItemList::SetItemTextL()
|
|
164 |
// --------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
void CDevEncUiSettingItemList::SetItemTextL( TInt aIndex, const TDesC& aNewText )
|
|
167 |
{
|
|
168 |
// Sanity check
|
|
169 |
if ( aIndex > ( SettingItemArray()->Count() - 1 ) )
|
|
170 |
{
|
|
171 |
User::Leave( KErrOverflow );
|
|
172 |
}
|
|
173 |
// Get hold of the existing texts for the selected item
|
|
174 |
// The binary popup setting item has two texts, one for each setting.
|
|
175 |
// Just to be sure, we set them both.
|
|
176 |
CAknBinaryPopupSettingItem* settingItem =
|
|
177 |
reinterpret_cast<CAknBinaryPopupSettingItem*>
|
|
178 |
( ( *SettingItemArray() )[aIndex] );
|
|
179 |
CArrayPtr<CAknEnumeratedText>* textArray =
|
|
180 |
settingItem->EnumeratedTextArray();
|
|
181 |
CAknEnumeratedText* enumTextOn = textArray->At( KOnTextIndex );
|
|
182 |
CAknEnumeratedText* enumTextOff = textArray->At( KOffTextIndex );
|
|
183 |
|
|
184 |
// Delete the previous texts thoroughly
|
|
185 |
HBufC* prevTextOn = enumTextOn->Value();
|
|
186 |
HBufC* prevTextOff = enumTextOff->Value();
|
|
187 |
textArray->Delete( KOnTextIndex );
|
|
188 |
textArray->Delete( KOffTextIndex );
|
|
189 |
delete prevTextOn;
|
|
190 |
delete prevTextOff;
|
|
191 |
|
|
192 |
// Set the new enumeration values (matching the ones in the rss file)
|
|
193 |
enumTextOn->SetEnumerationValue( KOnEnumerationValue );
|
|
194 |
enumTextOff->SetEnumerationValue( KOffEnumerationValue );
|
|
195 |
|
|
196 |
// Set the new texts
|
|
197 |
enumTextOn->SetValue( aNewText.AllocL() ); // Ownership transferred to array
|
|
198 |
enumTextOff->SetValue( aNewText.AllocL() ); // Ownership transferred to array
|
|
199 |
textArray->AppendL( enumTextOn );
|
|
200 |
textArray->AppendL( enumTextOff );
|
|
201 |
|
|
202 |
// The list updates itself
|
|
203 |
HandleChangeInItemArrayOrVisibilityL();
|
|
204 |
}
|
|
205 |
|
|
206 |
// --------------------------------------------------------------------------
|
|
207 |
// CDevEncUiSettingItemList::SetItemStateL()
|
|
208 |
// --------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
void CDevEncUiSettingItemList::SetItemStateL( TInt aIndex, TBool aSetting )
|
|
211 |
{
|
|
212 |
if ( aIndex == EPhoneMemory )
|
|
213 |
{
|
|
214 |
iPhoneMemSetting = aSetting;
|
|
215 |
}
|
|
216 |
else
|
|
217 |
{
|
|
218 |
iMmcSetting = aSetting;
|
|
219 |
}
|
|
220 |
// Load the new value to the framework's internal data
|
|
221 |
( *SettingItemArray() )[ aIndex ]->LoadL();
|
|
222 |
}
|
|
223 |
|
|
224 |
// --------------------------------------------------------------------------
|
|
225 |
// CDevEncUiSettingItemList::ItemState()
|
|
226 |
// --------------------------------------------------------------------------
|
|
227 |
//
|
|
228 |
void CDevEncUiSettingItemList::ItemState( TInt aIndex, TBool& aSetting )
|
|
229 |
{
|
|
230 |
// Fetch the current value from the framework's internal data
|
|
231 |
if ( aIndex == EPhoneMemory )
|
|
232 |
{
|
|
233 |
aSetting = iPhoneMemSetting;
|
|
234 |
}
|
|
235 |
else
|
|
236 |
{
|
|
237 |
aSetting = iMmcSetting;
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
// END OF FILE
|