|
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 |
|
25 |
|
26 |
|
27 /* |
|
28 * ============================================================================ |
|
29 * Name : CAknFepPredictiveSettingList from AknFepPredictiveSettingList |
|
30 * ============================================================================ |
|
31 */ |
|
32 |
|
33 #include <barsread.h> |
|
34 #include <AvkonInternalCRKeys.h> |
|
35 #include <e32property.h> |
|
36 #include <PtiDefs.h> |
|
37 #include <aknfep.rsg> |
|
38 #include <AknFepGlobalEnums.h> |
|
39 #include <featmgr.h> |
|
40 #include <AknFepInternalPSKeys.h> |
|
41 |
|
42 #include "AknFepPredictiveSettingList.h" |
|
43 #include "AknFepPredictiveSettingData.h" |
|
44 #include "AknFepPredictiveSettingDialog.h" |
|
45 |
|
46 const TInt KFSQMode = 2; |
|
47 |
|
48 CAknFepMultiSelectionSettingItem::CAknFepMultiSelectionSettingItem ( |
|
49 TInt aResourceId, CAknFepPredictiveSettingData &aData, CCoeEnv* aCoeEnv ) |
|
50 : CAknBigSettingItemBase(aResourceId), iData(aData), iCoeEnv(aCoeEnv) |
|
51 { |
|
52 iItutIndex = -1; |
|
53 iQwertyIndex = -1; |
|
54 iHalfQwertyIndex = -1; |
|
55 } |
|
56 |
|
57 CAknFepMultiSelectionSettingItem::~CAknFepMultiSelectionSettingItem() |
|
58 { |
|
59 if (iSelection) |
|
60 { |
|
61 iSelection->ResetAndDestroy(); |
|
62 } |
|
63 delete iSelection; |
|
64 } |
|
65 |
|
66 void CAknFepMultiSelectionSettingItem::EditItemL( TBool /*aCalledFromMenu*/ ) |
|
67 { |
|
68 if(!iSelection) |
|
69 { |
|
70 iSelection = CreateSelectionItemListL(); |
|
71 } |
|
72 CAknCheckBoxSettingPage* settingPage = |
|
73 new( ELeave) CAknCheckBoxSettingPage( R_AUTOWORDCOMPLMULTI_PAGE, iSelection); |
|
74 |
|
75 SetSettingPage(settingPage); |
|
76 |
|
77 if( settingPage->ExecuteLD(CAknSettingPage::EUpdateWhenAccepted)) |
|
78 { |
|
79 StoreL(); |
|
80 } |
|
81 else |
|
82 { |
|
83 TInt physicalKeyboards = iData.PhysicalKeyboards(); |
|
84 |
|
85 if( iItutIndex > -1 ) |
|
86 { |
|
87 TBool selected = iData.AWCBitmask() & EKeyboardStyle12Key ? ETrue : EFalse; |
|
88 iSelection->At(iItutIndex)->SetSelectionStatus( selected ); |
|
89 } |
|
90 |
|
91 if( iQwertyIndex > -1 ) |
|
92 { |
|
93 TBool selected = iData.AWCBitmask() & EKeyboardStyleQwerty ? ETrue : EFalse; |
|
94 iSelection->At(iQwertyIndex)->SetSelectionStatus( selected ); |
|
95 } |
|
96 |
|
97 if( iHalfQwertyIndex > -1 ) |
|
98 { |
|
99 TBool selected = iData.AWCBitmask() & EKeyboardStyleHalfQwerty ? ETrue : EFalse; |
|
100 iSelection->At(iHalfQwertyIndex)->SetSelectionStatus( selected ); |
|
101 } |
|
102 } |
|
103 SetSettingPage(0); |
|
104 } |
|
105 |
|
106 void CAknFepMultiSelectionSettingItem::StoreL() |
|
107 { |
|
108 if(iSelection) |
|
109 { |
|
110 if ( iItutIndex > -1 ) |
|
111 { |
|
112 if(iSelection->At(iItutIndex)->SelectionStatus()) |
|
113 { |
|
114 iData.AWCBitmask() |= EKeyboardStyle12Key; |
|
115 } |
|
116 else |
|
117 { |
|
118 iData.AWCBitmask() &= ~EKeyboardStyle12Key; |
|
119 } |
|
120 } |
|
121 |
|
122 if( iHalfQwertyIndex > -1 ) |
|
123 { |
|
124 if(iSelection->At(iHalfQwertyIndex)->SelectionStatus()) |
|
125 { |
|
126 iData.AWCBitmask() |= EKeyboardStyleHalfQwerty; |
|
127 } |
|
128 else |
|
129 { |
|
130 iData.AWCBitmask() &= ~EKeyboardStyleHalfQwerty; |
|
131 } |
|
132 } |
|
133 if ( iQwertyIndex > -1 ) |
|
134 { |
|
135 if(iSelection->At(iQwertyIndex)->SelectionStatus()) |
|
136 { |
|
137 iData.AWCBitmask() |= EKeyboardStyleQwerty; |
|
138 } |
|
139 else |
|
140 { |
|
141 iData.AWCBitmask() &= ~EKeyboardStyleQwerty; |
|
142 } |
|
143 } |
|
144 } |
|
145 } |
|
146 |
|
147 void CAknFepMultiSelectionSettingItem::LoadL() |
|
148 { |
|
149 if(iSelection) |
|
150 { |
|
151 iSelection->ResetAndDestroy(); |
|
152 delete iSelection; |
|
153 iSelection = NULL; |
|
154 } |
|
155 iSelection = CreateSelectionItemListL(); |
|
156 } |
|
157 |
|
158 CSelectionItemList* CAknFepMultiSelectionSettingItem::CreateSelectionItemListL() |
|
159 { |
|
160 iItutIndex = -1; |
|
161 iQwertyIndex = -1; |
|
162 iHalfQwertyIndex = -1; |
|
163 |
|
164 CSelectionItemList* selection = new (ELeave) CSelectionItemList(2); |
|
165 CleanupStack::PushL( selection ); |
|
166 |
|
167 TInt physicalKeyboards = iData.PhysicalKeyboards(); |
|
168 TInt count = 0; |
|
169 |
|
170 TInt qwertyMask = EPhysicalKeyboardQwerty4x12 | EPhysicalKeyboardQwerty4x10 | |
|
171 EPhysicalKeyboardQwerty3x11 | EPhysicalKeyboardCustomQwerty; |
|
172 |
|
173 TBool supportVFSQ = FeatureManager::FeatureSupported( KFeatureIdVirtualFullscrQwertyInput ); |
|
174 |
|
175 if ( physicalKeyboards & EPhysicalKeyboard12key ) //itut |
|
176 { |
|
177 TBool active = iData.AWCBitmask() & EKeyboardStyle12Key ? ETrue : EFalse; |
|
178 HBufC* text = iCoeEnv->AllocReadResourceLC( R_AKNFEP_PRED_SETTING_ITUT ); |
|
179 iItutIndex = count++; |
|
180 |
|
181 CSelectableItem* item = new (ELeave) CSelectableItem( *text, active ); |
|
182 CleanupStack::PushL( item ); |
|
183 item->ConstructL(); |
|
184 selection->AppendL( item ); |
|
185 CleanupStack::Pop( item ); |
|
186 CleanupStack::PopAndDestroy( text ); |
|
187 } |
|
188 |
|
189 if ( ( physicalKeyboards & qwertyMask ) || supportVFSQ ) //4x12,4x10,3x11,custom, FSQ |
|
190 { |
|
191 TBool active = iData.AWCBitmask() & EKeyboardStyleQwerty ? ETrue : EFalse; |
|
192 HBufC* text = iCoeEnv->AllocReadResourceLC( R_AKNFEP_PRED_SETTING_QWERTY ); |
|
193 iQwertyIndex = count++; |
|
194 |
|
195 CSelectableItem* item = new (ELeave) CSelectableItem( *text, active ); |
|
196 CleanupStack::PushL( item ); |
|
197 item->ConstructL(); |
|
198 selection->AppendL( item ); |
|
199 CleanupStack::Pop( item ); |
|
200 CleanupStack::PopAndDestroy( text ); |
|
201 } |
|
202 |
|
203 if ( physicalKeyboards & EPhysicalKeyboardHalfQwerty ) //half qwerty |
|
204 { |
|
205 TBool active = iData.AWCBitmask() & EKeyboardStyleHalfQwerty ? ETrue : EFalse; |
|
206 HBufC* text = iCoeEnv->AllocReadResourceLC( R_AKNFEP_PRED_SETTING_HALF_QWERTY ); |
|
207 iHalfQwertyIndex = count++; |
|
208 |
|
209 CSelectableItem* item = new (ELeave) CSelectableItem( *text, active ); |
|
210 CleanupStack::PushL( item ); |
|
211 item->ConstructL(); |
|
212 selection->AppendL( item ); |
|
213 CleanupStack::Pop( item ); |
|
214 CleanupStack::PopAndDestroy( text ); |
|
215 } |
|
216 |
|
217 CleanupStack::Pop( selection ); |
|
218 |
|
219 return selection; |
|
220 } |
|
221 |
|
222 CAknFepPredictiveSettingList *CAknFepPredictiveSettingList::NewL(CAknFepPredictiveSettingData &aData, CAknFepPredictiveSettingDialog &aDialog) |
|
223 { |
|
224 CAknFepPredictiveSettingList* self = CAknFepPredictiveSettingList::NewLC(aData, aDialog); |
|
225 CleanupStack::Pop(self); |
|
226 return self; |
|
227 } |
|
228 |
|
229 CAknFepPredictiveSettingList *CAknFepPredictiveSettingList::NewLC(CAknFepPredictiveSettingData &aData, CAknFepPredictiveSettingDialog &aDialog) |
|
230 { |
|
231 CAknFepPredictiveSettingList* self = new (ELeave) CAknFepPredictiveSettingList(aData, aDialog); |
|
232 CleanupStack::PushL(self); |
|
233 return self; |
|
234 } |
|
235 |
|
236 CAknFepPredictiveSettingList::CAknFepPredictiveSettingList(CAknFepPredictiveSettingData &aData, CAknFepPredictiveSettingDialog &aDialog) : |
|
237 CAknSettingItemList(), |
|
238 iSettingsData(aData), |
|
239 iSettingsDialog(aDialog) |
|
240 { |
|
241 } |
|
242 |
|
243 CAknFepPredictiveSettingList::~CAknFepPredictiveSettingList() |
|
244 { |
|
245 // no specific destruction code required - no owned data |
|
246 } |
|
247 |
|
248 |
|
249 void CAknFepPredictiveSettingList::SizeChanged() |
|
250 { |
|
251 // if size changes, make sure component takes whole available space |
|
252 CEikFormattedCellListBox *listbox = ListBox(); |
|
253 |
|
254 if (listbox) |
|
255 { |
|
256 listbox->SetRect(Rect()); |
|
257 } |
|
258 } |
|
259 |
|
260 void CAknFepPredictiveSettingList::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
|
261 { |
|
262 TBool isSingleClick = iAvkonAppUi->IsSingleClickCompatible(); |
|
263 if( aEventType == EEventEnterKeyPressed || aEventType == EEventItemDoubleClicked |
|
264 || ( isSingleClick && ( aEventType == EEventItemSingleClicked ))) |
|
265 { |
|
266 iSettingsDialog.EditItemL(EFalse);//EditCurrentItemL(EFalse); |
|
267 } |
|
268 else |
|
269 { |
|
270 CAknSettingItemList::HandleListBoxEventL( aListBox,aEventType ); |
|
271 } |
|
272 } |
|
273 |
|
274 void CAknFepPredictiveSettingList::EditCurrentItemL(TBool aCalledFromMenu) |
|
275 { |
|
276 // invoke EditItemL on the current item |
|
277 TInt index = SettingItemArray()->ItemIndexFromVisibleIndex(ListBox()->CurrentItemIndex()); |
|
278 |
|
279 EditItemL(index, aCalledFromMenu); // invoked from menu,or not |
|
280 |
|
281 StoreSettingsL(); |
|
282 } |
|
283 |
|
284 CAknSettingItem * CAknFepPredictiveSettingList::CreateSettingItemL (TInt aIdentifier) |
|
285 { |
|
286 // method is used to create specific setting item as required at run-time. |
|
287 // aIdentifier is used to determine what kind of setting item should be |
|
288 // created |
|
289 CAknSettingItem* settingItem = NULL; |
|
290 TPtiKeyboardType keyboardLayout = iSettingsData.OwnerKeyboardType(); |
|
291 |
|
292 switch (aIdentifier) |
|
293 { |
|
294 case EAknFepCmdPredAutoComplSetting: |
|
295 { |
|
296 settingItem = new (ELeave) CAknBinaryPopupSettingItem ( |
|
297 aIdentifier, iSettingsData.AutoWordCompl()); |
|
298 if(DeviceHasMultipleKeyboards()) |
|
299 { |
|
300 settingItem->SetHidden(ETrue); |
|
301 } |
|
302 } |
|
303 break; |
|
304 case EAknFepCmdPredAutoComplMultiSetting: |
|
305 { |
|
306 settingItem = new (ELeave) CAknFepMultiSelectionSettingItem ( |
|
307 aIdentifier, iSettingsData, iCoeEnv ); |
|
308 if(!DeviceHasMultipleKeyboards()) |
|
309 { |
|
310 settingItem->SetHidden(ETrue); |
|
311 } |
|
312 } |
|
313 break; |
|
314 case EAknFepCmdPredNumberCandidateSetting: |
|
315 { |
|
316 settingItem = new (ELeave) CAknBinaryPopupSettingItem ( |
|
317 aIdentifier, |
|
318 iSettingsData.NumberCandidates()); |
|
319 |
|
320 TInt dialogState = 0; |
|
321 RProperty::Get( KPSUidAknFep, KAknFepSettingDialogState, dialogState ); |
|
322 //Remove Number Candidate item from setting dialog |
|
323 if ( dialogState == KFSQMode || |
|
324 keyboardLayout == EPtiKeyboard12Key || |
|
325 keyboardLayout == EPtiKeyboardHalfQwerty) |
|
326 { |
|
327 // When dialog state is 2, it means that the setting dialog is opened |
|
328 // for virtual qwerty keyboard |
|
329 settingItem->SetHidden(ETrue); |
|
330 } |
|
331 } |
|
332 break; |
|
333 case EAknFepCmdPredTypingCorrectionSetting: |
|
334 { |
|
335 settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem ( |
|
336 aIdentifier, |
|
337 iSettingsData.TypingCorrection()); |
|
338 // Disabled for ITU-T |
|
339 if(keyboardLayout == EPtiKeyboard12Key || keyboardLayout == EPtiKeyboardHalfQwerty) |
|
340 settingItem->SetHidden(ETrue); |
|
341 } |
|
342 break; |
|
343 case EAknFepCmdPredPrimaryCandidateSetting: |
|
344 { |
|
345 settingItem = new (ELeave) CAknBinaryPopupSettingItem ( |
|
346 aIdentifier, |
|
347 iSettingsData.PrimaryCandidate()); |
|
348 // Disabled for Half Qwerty and ITU-T |
|
349 if(keyboardLayout == EPtiKeyboardHalfQwerty || |
|
350 keyboardLayout == EPtiKeyboard12Key) |
|
351 settingItem->SetHidden(ETrue); |
|
352 } |
|
353 break; |
|
354 default: |
|
355 break; |
|
356 } |
|
357 |
|
358 return settingItem; |
|
359 } |
|
360 |
|
361 TBool CAknFepPredictiveSettingList::DeviceHasMultipleKeyboards() |
|
362 { |
|
363 TInt physicalKeyboards = iSettingsData.PhysicalKeyboards(); |
|
364 TBool firstFound = EFalse; |
|
365 for(TUint i = 0x01; i <= 0xF0; i = i << 1) |
|
366 { |
|
367 if(physicalKeyboards & i) |
|
368 { |
|
369 if (firstFound) |
|
370 { |
|
371 return ETrue; |
|
372 } |
|
373 else |
|
374 { |
|
375 firstFound = ETrue; |
|
376 } |
|
377 } |
|
378 } |
|
379 return EFalse; |
|
380 } |
|
381 |
|
382 void CAknFepPredictiveSettingList::HandleResourceChange(TInt aType) |
|
383 { |
|
384 CAknSettingItemList::HandleResourceChange(aType); |
|
385 // Check for keyboard layout change |
|
386 // If layout is changed, close settings with information note |
|
387 if(aType==KEikDynamicLayoutVariantSwitch) |
|
388 { |
|
389 TPtiKeyboardType keyboardLayout = iSettingsData.OwnerKeyboardType(); |
|
390 if(keyboardLayout == EPtiKeyboard12Key) |
|
391 { |
|
392 #ifndef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__ |
|
393 // Adding this under the flag would avoid flickering as settings page will be |
|
394 // dismissed if __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__ is defined |
|
395 // Number candidate |
|
396 SettingItemArray()->At(2)->SetHidden(ETrue); |
|
397 // Typing correction |
|
398 SettingItemArray()->At(3)->SetHidden(ETrue); |
|
399 // Primary Candidate |
|
400 SettingItemArray()->At(4)->SetHidden(ETrue); |
|
401 #endif |
|
402 } |
|
403 else if (keyboardLayout == EPtiKeyboardHalfQwerty) |
|
404 { |
|
405 // Number candidate |
|
406 SettingItemArray()->At(2)->SetHidden(ETrue); |
|
407 // Typing correction |
|
408 SettingItemArray()->At(3)->SetHidden(ETrue); |
|
409 // Primary Candidate |
|
410 SettingItemArray()->At(4)->SetHidden(ETrue); |
|
411 } |
|
412 else |
|
413 { |
|
414 // Number candidate |
|
415 SettingItemArray()->At(2)->SetHidden(EFalse); |
|
416 // Typing correction |
|
417 SettingItemArray()->At(3)->SetHidden(EFalse); |
|
418 // Primary Candidate |
|
419 SettingItemArray()->At(4)->SetHidden(EFalse); |
|
420 } |
|
421 |
|
422 TRAP_IGNORE( |
|
423 { |
|
424 HandleChangeInItemArrayOrVisibilityL(); |
|
425 }); |
|
426 |
|
427 } |
|
428 } |
|
429 |