|
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 // INCLUDE FILES |
|
20 #include "perfmon_settingsviewdlg.h" |
|
21 #include "perfmon_model.h" |
|
22 #include "perfmon.hrh" |
|
23 #include "perfmon_std.h" |
|
24 #include "perfmon_powerlistener.h" |
|
25 #include <perfmon.rsg> |
|
26 |
|
27 #include <aknsettingitemlist.h> |
|
28 #include <CAknMemorySelectionSettingItem.h> |
|
29 #include <aknlists.h> |
|
30 #include <akntitle.h> |
|
31 #include <aknnavi.h> |
|
32 #include <aknnavide.h> |
|
33 #include <StringLoader.h> |
|
34 #include <aknnotewrappers.h> |
|
35 |
|
36 // ===================================== MEMBER FUNCTIONS ===================================== |
|
37 |
|
38 CPerfMonSettingsViewDlg* CPerfMonSettingsViewDlg::NewL(TPerfMonSettings& aSettings) |
|
39 { |
|
40 CPerfMonSettingsViewDlg* self = new(ELeave) CPerfMonSettingsViewDlg(aSettings); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop(self); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // -------------------------------------------------------------------------------------------- |
|
48 |
|
49 CPerfMonSettingsViewDlg::~CPerfMonSettingsViewDlg() |
|
50 { |
|
51 // restore default navi pane by popping the tab group from stack |
|
52 if (iNaviContainer) |
|
53 iNaviContainer->Pop(); |
|
54 |
|
55 if (iSettingItemArray) |
|
56 { |
|
57 iSettingItemArray->ResetAndDestroy(); |
|
58 delete iSettingItemArray; |
|
59 } |
|
60 |
|
61 delete iDecoratedTabGroup; |
|
62 } |
|
63 |
|
64 // -------------------------------------------------------------------------------------------- |
|
65 |
|
66 CPerfMonSettingsViewDlg::CPerfMonSettingsViewDlg(TPerfMonSettings& aSettings) : iSettings(aSettings) |
|
67 { |
|
68 } |
|
69 |
|
70 // -------------------------------------------------------------------------------------------- |
|
71 |
|
72 void CPerfMonSettingsViewDlg::ConstructL() |
|
73 { |
|
74 // construct a menu bar |
|
75 CAknDialog::ConstructL(R_PERFMON_SETTINGS_MENUBAR); |
|
76 |
|
77 // get pointer to status pane |
|
78 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
79 |
|
80 // set title text |
|
81 CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
82 tp->SetTextL( _L("Settings") ); |
|
83 |
|
84 // create a new tab group |
|
85 iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); |
|
86 iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this); |
|
87 iTabGroup = static_cast<CAknTabGroup*>(iDecoratedTabGroup->DecoratedControl()); |
|
88 iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); |
|
89 |
|
90 // add tabs |
|
91 iTabGroup->AddTabL(ETabSettingsGeneral, _L("General")); |
|
92 iTabGroup->AddTabL(ETabSettingsDataPopup, _L("Data popup")); |
|
93 iTabGroup->AddTabL(ETabSettingsGraphs, _L("Graphs")); |
|
94 iTabGroup->AddTabL(ETabSettingsLogging, _L("Logging")); |
|
95 iTabGroup->SetActiveTabByIndex(ETabSettingsGeneral); |
|
96 |
|
97 // add new tab group to stack |
|
98 iNaviContainer->PushL( *iDecoratedTabGroup ); |
|
99 } |
|
100 |
|
101 // -------------------------------------------------------------------------------------------- |
|
102 |
|
103 void CPerfMonSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
104 { |
|
105 switch (aEventType) |
|
106 { |
|
107 case EEventEnterKeyPressed: |
|
108 case EEventItemDoubleClicked: |
|
109 ShowSettingPageL(EFalse); |
|
110 break; |
|
111 default: |
|
112 break; |
|
113 } |
|
114 } |
|
115 |
|
116 // -------------------------------------------------------------------------------------------- |
|
117 |
|
118 void CPerfMonSettingsViewDlg::TabChangedL(TInt /*aIndex*/) |
|
119 { |
|
120 iListBox->SetCurrentItemIndex(0); |
|
121 |
|
122 SetVisibilitiesOfSettingItemsL(); |
|
123 } |
|
124 |
|
125 // -------------------------------------------------------------------------------------------- |
|
126 |
|
127 void CPerfMonSettingsViewDlg::ProcessCommandL(TInt aCommandId) |
|
128 { |
|
129 CAknDialog::ProcessCommandL(aCommandId); |
|
130 |
|
131 switch (aCommandId) |
|
132 { |
|
133 case EPerfMonCmdSettingsChange: |
|
134 ShowSettingPageL(ETrue); |
|
135 break; |
|
136 case EPerfMonCmdSettingsExit: |
|
137 TryExitL(EAknCmdExit); |
|
138 break; |
|
139 default: |
|
140 break; |
|
141 } |
|
142 } |
|
143 |
|
144 // -------------------------------------------------------------------------------------------- |
|
145 |
|
146 TKeyResponse CPerfMonSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
147 { |
|
148 if (iTabGroup == NULL) |
|
149 { |
|
150 return EKeyWasNotConsumed; |
|
151 } |
|
152 |
|
153 TInt active = iTabGroup->ActiveTabIndex(); |
|
154 TInt count = iTabGroup->TabCount(); |
|
155 |
|
156 switch ( aKeyEvent.iCode ) |
|
157 { |
|
158 case EKeyLeftArrow: |
|
159 if (active > 0) |
|
160 { |
|
161 active--; |
|
162 iTabGroup->SetActiveTabByIndex(active); |
|
163 TabChangedL(active); |
|
164 } |
|
165 break; |
|
166 |
|
167 case EKeyRightArrow: |
|
168 if((active + 1) < count) |
|
169 { |
|
170 active++; |
|
171 iTabGroup->SetActiveTabByIndex(active); |
|
172 TabChangedL(active); |
|
173 } |
|
174 break; |
|
175 } |
|
176 |
|
177 return CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
178 } |
|
179 |
|
180 // -------------------------------------------------------------------------------------------- |
|
181 |
|
182 void CPerfMonSettingsViewDlg::PreLayoutDynInitL() |
|
183 { |
|
184 iListBox = static_cast<CAknSettingStyleListBox*>( Control(EPerfMonSettingItemList) ); |
|
185 iListBox->SetMopParent(this); |
|
186 iListBox->CreateScrollBarFrameL(ETrue); |
|
187 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
188 iListBox->SetListBoxObserver(this); |
|
189 |
|
190 iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0); |
|
191 |
|
192 CTextListBoxModel* model = iListBox->Model(); |
|
193 model->SetItemTextArray(iSettingItemArray); |
|
194 model->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
195 |
|
196 UpdateListBoxL(); |
|
197 } |
|
198 |
|
199 // -------------------------------------------------------------------------------------------- |
|
200 |
|
201 TBool CPerfMonSettingsViewDlg::OkToExitL(TInt aButtonId) |
|
202 { |
|
203 return CAknDialog::OkToExitL(aButtonId); |
|
204 } |
|
205 |
|
206 // -------------------------------------------------------------------------------------------- |
|
207 |
|
208 void CPerfMonSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu) |
|
209 { |
|
210 TInt listIndex = iListBox->CurrentItemIndex(); |
|
211 TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex); |
|
212 CAknSettingItem* item = iSettingItemArray->At(realIndex); |
|
213 item->EditItemL(aCalledFromMenu); |
|
214 item->StoreL(); |
|
215 SetVisibilitiesOfSettingItemsL(); |
|
216 DrawNow(); |
|
217 } |
|
218 |
|
219 // -------------------------------------------------------------------------------------------- |
|
220 |
|
221 void CPerfMonSettingsViewDlg::SetVisibilitiesOfSettingItemsL() |
|
222 { |
|
223 if (iSettingItemArray->Count() > 0) |
|
224 { |
|
225 switch (iTabGroup->ActiveTabIndex()) |
|
226 { |
|
227 case ETabSettingsGeneral: |
|
228 { |
|
229 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(EFalse); |
|
230 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(EFalse); |
|
231 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(EFalse); |
|
232 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(EFalse); |
|
233 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(EFalse); |
|
234 if (CPerfMonPowerListener::IsSupported()) |
|
235 ((*iSettingItemArray)[ESettingListItemPowerMonitoringEnabled])->SetHidden(EFalse); |
|
236 else |
|
237 ((*iSettingItemArray)[ESettingListItemPowerMonitoringEnabled])->SetHidden(ETrue); |
|
238 |
|
239 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue); |
|
240 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue); |
|
241 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue); |
|
242 |
|
243 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue); |
|
244 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue); |
|
245 |
|
246 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue); |
|
247 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue); |
|
248 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue); |
|
249 |
|
250 break; |
|
251 } |
|
252 |
|
253 case ETabSettingsDataPopup: |
|
254 { |
|
255 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue); |
|
256 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue); |
|
257 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue); |
|
258 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue); |
|
259 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue); |
|
260 ((*iSettingItemArray)[ESettingListItemPowerMonitoringEnabled])->SetHidden(ETrue); |
|
261 |
|
262 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(EFalse); |
|
263 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(EFalse); |
|
264 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(EFalse); |
|
265 |
|
266 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue); |
|
267 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue); |
|
268 |
|
269 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue); |
|
270 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue); |
|
271 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue); |
|
272 |
|
273 break; |
|
274 } |
|
275 |
|
276 case ETabSettingsGraphs: |
|
277 { |
|
278 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue); |
|
279 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue); |
|
280 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue); |
|
281 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue); |
|
282 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue); |
|
283 ((*iSettingItemArray)[ESettingListItemPowerMonitoringEnabled])->SetHidden(ETrue); |
|
284 |
|
285 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue); |
|
286 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue); |
|
287 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue); |
|
288 |
|
289 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(EFalse); |
|
290 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(EFalse); |
|
291 |
|
292 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue); |
|
293 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue); |
|
294 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue); |
|
295 |
|
296 break; |
|
297 } |
|
298 |
|
299 case ETabSettingsLogging: |
|
300 { |
|
301 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue); |
|
302 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue); |
|
303 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue); |
|
304 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue); |
|
305 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue); |
|
306 ((*iSettingItemArray)[ESettingListItemPowerMonitoringEnabled])->SetHidden(ETrue); |
|
307 |
|
308 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue); |
|
309 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue); |
|
310 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue); |
|
311 |
|
312 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue); |
|
313 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue); |
|
314 |
|
315 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(EFalse); |
|
316 |
|
317 if (iSettings.iLoggingMode == ELoggingModeLogFile || iSettings.iLoggingMode == ELoggingModeRDebugLogFile) |
|
318 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(EFalse); |
|
319 else |
|
320 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue); |
|
321 |
|
322 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(EFalse); |
|
323 |
|
324 break; |
|
325 } |
|
326 |
|
327 default: |
|
328 User::Panic(_L("TabIOOB"), 50); |
|
329 break; |
|
330 } |
|
331 |
|
332 iSettingItemArray->RecalculateVisibleIndicesL(); |
|
333 iListBox->HandleItemAdditionL(); |
|
334 iListBox->UpdateScrollBarsL(); |
|
335 } |
|
336 } |
|
337 |
|
338 // -------------------------------------------------------------------------------------------- |
|
339 |
|
340 void CPerfMonSettingsViewDlg::UpdateListBoxL() |
|
341 { |
|
342 iSettingItemArray->ResetAndDestroy(); |
|
343 |
|
344 // create items |
|
345 TInt ordinal(0); |
|
346 |
|
347 AddSettingItemL(ESettingListItemHeartBeat, |
|
348 R_HEARTBEAT_SETTING_TITLE, |
|
349 R_HEARTBEAT_SETTING_PAGE, |
|
350 NULL, |
|
351 ordinal++); |
|
352 |
|
353 AddSettingItemL(ESettingListItemMaxSamples, |
|
354 R_MAXSAMPLES_SETTING_TITLE, |
|
355 R_MAXSAMPLES_SETTING_PAGE, |
|
356 NULL, |
|
357 ordinal++); |
|
358 |
|
359 AddSettingItemL(ESettingListItemPriority, |
|
360 R_PRIORITY_SETTING_TITLE, |
|
361 R_PRIORITY_SETTING_PAGE, |
|
362 R_PRIORITY_SETTING_TEXTS, |
|
363 ordinal++); |
|
364 |
|
365 AddSettingItemL(ESettingListItemCPUMode, |
|
366 R_CPUMODE_SETTING_TITLE, |
|
367 R_CPUMODE_SETTING_PAGE, |
|
368 R_CPUMODE_SETTING_TEXTS, |
|
369 ordinal++); |
|
370 |
|
371 AddSettingItemL(ESettingListItemKeepBackLightOn, |
|
372 R_KEEPBACKLIGHTON_SETTING_TITLE, |
|
373 R_BINARY_SETTING_PAGE, |
|
374 R_YESNO_BINARYSELECTION_TEXTS, |
|
375 ordinal++); |
|
376 |
|
377 AddSettingItemL(ESettingListItemPowerMonitoringEnabled, |
|
378 R_POWERMONITORINGENABLED_SETTING_TITLE, |
|
379 R_BINARY_SETTING_PAGE, |
|
380 R_YESNO_BINARYSELECTION_TEXTS, |
|
381 ordinal++); |
|
382 // |
|
383 AddSettingItemL(ESettingListItemDataPopupVisbility, |
|
384 R_DATAPOPUPVISIBILITY_SETTING_TITLE, |
|
385 R_DATAPOPUPVISIBILITY_SETTING_PAGE, |
|
386 R_DATAPOPUPVISIBILITY_SETTING_TEXTS, |
|
387 ordinal++); |
|
388 |
|
389 AddSettingItemL(ESettingListItemDataPopupLocation, |
|
390 R_DATAPOPUPLOCATION_SETTING_TITLE, |
|
391 R_DATAPOPUPLOCATION_SETTING_PAGE, |
|
392 R_DATAPOPUPLOCATION_SETTING_TEXTS, |
|
393 ordinal++); |
|
394 |
|
395 AddSettingItemL(ESettingListItemDataPopupSources, |
|
396 R_SOURCES_SETTING_TITLE, |
|
397 R_SOURCES_SETTING_PAGE, |
|
398 NULL, |
|
399 ordinal++); |
|
400 // |
|
401 AddSettingItemL(ESettingListItemGraphsVerticalBarPeriod, |
|
402 R_GRAPHSVERTICALBAR_SETTING_TITLE, |
|
403 R_GRAPHSVERTICALBAR_SETTING_PAGE, |
|
404 NULL, |
|
405 ordinal++); |
|
406 |
|
407 AddSettingItemL(ESettingListItemGraphsSources, |
|
408 R_SOURCES_SETTING_TITLE, |
|
409 R_SOURCES_SETTING_PAGE, |
|
410 NULL, |
|
411 ordinal++); |
|
412 // |
|
413 AddSettingItemL(ESettingListItemLoggingMode, |
|
414 R_LOGGINGMODE_SETTING_TITLE, |
|
415 R_LOGGINGMODE_SETTING_PAGE, |
|
416 R_LOGGINGMODE_SETTING_TEXTS, |
|
417 ordinal++); |
|
418 |
|
419 AddSettingItemL(ESettingListItemLoggingFilePath, |
|
420 R_LOGGINGFILEPATH_SETTING_TITLE, |
|
421 R_LOGGINGFILEPATH_SETTING_PAGE, |
|
422 NULL, |
|
423 ordinal++); |
|
424 |
|
425 AddSettingItemL(ESettingListItemLoggingSources, |
|
426 R_SOURCES_SETTING_TITLE, |
|
427 R_SOURCES_SETTING_PAGE, |
|
428 NULL, |
|
429 ordinal++); |
|
430 |
|
431 SetVisibilitiesOfSettingItemsL(); |
|
432 } |
|
433 |
|
434 // -------------------------------------------------------------------------------------------- |
|
435 |
|
436 void CPerfMonSettingsViewDlg::AddSettingItemL(TInt aId, |
|
437 TInt aTitleResource, |
|
438 TInt aSettingPageResource, |
|
439 TInt aAssociatedResource, |
|
440 TInt aOrdinal) |
|
441 { |
|
442 // create a setting item |
|
443 CAknSettingItem* settingItem = NULL; |
|
444 |
|
445 switch (aId) |
|
446 { |
|
447 case ESettingListItemHeartBeat: |
|
448 settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iHeartBeat); |
|
449 break; |
|
450 |
|
451 case ESettingListItemMaxSamples: |
|
452 settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iMaxSamples); |
|
453 break; |
|
454 |
|
455 case ESettingListItemPriority: |
|
456 settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iPriority); |
|
457 break; |
|
458 |
|
459 case ESettingListItemCPUMode: |
|
460 settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iCPUMode); |
|
461 break; |
|
462 |
|
463 case ESettingListItemKeepBackLightOn: |
|
464 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iKeepBacklightOn); |
|
465 break; |
|
466 |
|
467 case ESettingListItemPowerMonitoringEnabled: |
|
468 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iPowerMonitoringEnabled); |
|
469 break; |
|
470 |
|
471 case ESettingListItemDataPopupVisbility: |
|
472 settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupVisibility); |
|
473 break; |
|
474 |
|
475 case ESettingListItemDataPopupLocation: |
|
476 settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupLocation); |
|
477 break; |
|
478 |
|
479 case ESettingListItemDataPopupSources: |
|
480 settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iDataPopupSources); |
|
481 break; |
|
482 |
|
483 case ESettingListItemGraphsVerticalBarPeriod: |
|
484 settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iGraphsVerticalBarPeriod); |
|
485 break; |
|
486 |
|
487 case ESettingListItemGraphsSources: |
|
488 settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iGraphsSources); |
|
489 break; |
|
490 |
|
491 case ESettingListItemLoggingMode: |
|
492 settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iLoggingMode); |
|
493 break; |
|
494 |
|
495 case ESettingListItemLoggingFilePath: |
|
496 settingItem = new(ELeave) CAknTextSettingItem(aId, iSettings.iLoggingFilePath); |
|
497 break; |
|
498 |
|
499 case ESettingListItemLoggingSources: |
|
500 settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iLoggingSources); |
|
501 break; |
|
502 |
|
503 default: |
|
504 User::Panic(_L("NotSetItem"), 50); |
|
505 break; |
|
506 } |
|
507 |
|
508 CleanupStack::PushL(settingItem); |
|
509 |
|
510 // get title text |
|
511 HBufC* itemTitle = StringLoader::LoadLC(aTitleResource); |
|
512 |
|
513 // construct the setting item |
|
514 settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource, |
|
515 EAknCtPopupSettingList, NULL, aAssociatedResource); |
|
516 |
|
517 // append the setting item to settingitem array |
|
518 iSettingItemArray->InsertL(aOrdinal, settingItem); |
|
519 |
|
520 CleanupStack::PopAndDestroy(); //itemTitle |
|
521 CleanupStack::Pop(); //settingItem |
|
522 } |
|
523 |
|
524 |
|
525 // -------------------------------------------------------------------------------------------- |
|
526 // -------------------------------------------------------------------------------------------- |
|
527 |
|
528 CSourceSelectionCheckBoxSettingItem::CSourceSelectionCheckBoxSettingItem( TInt aIdentifier, TPerfMonSources& aMemoryInUse ): |
|
529 CAknSettingItem(aIdentifier), iExternalSources( aMemoryInUse ) |
|
530 { |
|
531 } |
|
532 |
|
533 CSourceSelectionCheckBoxSettingItem::~CSourceSelectionCheckBoxSettingItem() |
|
534 { |
|
535 delete iSettingText; |
|
536 |
|
537 if( iItemArray ) |
|
538 { |
|
539 iItemArray->ResetAndDestroy(); |
|
540 delete iItemArray; |
|
541 } |
|
542 } |
|
543 |
|
544 void CSourceSelectionCheckBoxSettingItem::AddNewItemToArrayL(const TDesC& aLabel) |
|
545 { |
|
546 TBuf<64> buf; |
|
547 buf.Copy(aLabel); |
|
548 |
|
549 CSelectableItem* item = new(ELeave) CSelectableItem(buf, EFalse); |
|
550 CleanupStack::PushL(item); |
|
551 item->ConstructL(); |
|
552 iItemArray->AppendL(item); // Ownership is transferred |
|
553 CleanupStack::Pop(); // item |
|
554 } |
|
555 |
|
556 void CSourceSelectionCheckBoxSettingItem::CompleteConstructionL() |
|
557 { |
|
558 SetEmptyItemTextL(_L("Nothing selected")); |
|
559 |
|
560 iItemArray = new(ELeave) CSelectionItemList(16); |
|
561 AddNewItemToArrayL(_L("CPU")); |
|
562 AddNewItemToArrayL(_L("RAM")); |
|
563 AddNewItemToArrayL(_L("C:")); |
|
564 AddNewItemToArrayL(_L("D:")); |
|
565 AddNewItemToArrayL(_L("E:")); |
|
566 AddNewItemToArrayL(_L("F:")); |
|
567 AddNewItemToArrayL(_L("G:")); |
|
568 AddNewItemToArrayL(_L("H:")); |
|
569 AddNewItemToArrayL(_L("I:")); |
|
570 AddNewItemToArrayL(_L("Power")); |
|
571 |
|
572 __ASSERT_ALWAYS(ESourcesLength==iItemArray->Count(), User::Panic(_L("Src.mismatch"),443)); |
|
573 } |
|
574 |
|
575 // transfer settings to the variables defined in the constructor |
|
576 void CSourceSelectionCheckBoxSettingItem::StoreL() |
|
577 { |
|
578 for (TInt i=0; i<ESourcesLength; i++) |
|
579 { |
|
580 iExternalSources.iSrcEnabled[i] = iItemArray->At(i)->SelectionStatus(); |
|
581 } |
|
582 } |
|
583 |
|
584 // load settings from the variables defined in the constructor to our internal variables |
|
585 void CSourceSelectionCheckBoxSettingItem::LoadL() |
|
586 { |
|
587 for (TInt i=0; i<ESourcesLength; i++) |
|
588 { |
|
589 iItemArray->At(i)->SetSelectionStatus( iExternalSources.iSrcEnabled[i] ); |
|
590 } |
|
591 } |
|
592 |
|
593 // returns the text shown in the setting item list |
|
594 const TDesC& CSourceSelectionCheckBoxSettingItem::SettingTextL() |
|
595 { |
|
596 TBuf<32> settingText; |
|
597 |
|
598 if (iItemArray->At(ESourceCPU)->SelectionStatus()) |
|
599 settingText.Append(_L("CPU ")); |
|
600 if (iItemArray->At(ESourceRAM)->SelectionStatus()) |
|
601 settingText.Append(_L("RAM ")); |
|
602 if (iItemArray->At(ESourceC)->SelectionStatus()) |
|
603 settingText.Append(_L("C: ")); |
|
604 if (iItemArray->At(ESourceD)->SelectionStatus()) |
|
605 settingText.Append(_L("D: ")); |
|
606 if (iItemArray->At(ESourceE)->SelectionStatus()) |
|
607 settingText.Append(_L("E: ")); |
|
608 if (iItemArray->At(ESourceF)->SelectionStatus()) |
|
609 settingText.Append(_L("F: ")); |
|
610 if (iItemArray->At(ESourceG)->SelectionStatus()) |
|
611 settingText.Append(_L("G: ")); |
|
612 if (iItemArray->At(ESourceH)->SelectionStatus()) |
|
613 settingText.Append(_L("H: ")); |
|
614 if (iItemArray->At(ESourceI)->SelectionStatus()) |
|
615 settingText.Append(_L("I: ")); |
|
616 if (iItemArray->At(ESourcePwr)->SelectionStatus()) |
|
617 settingText.Append(_L("Power ")); |
|
618 settingText.TrimAll(); |
|
619 |
|
620 if (iSettingText) |
|
621 { |
|
622 delete iSettingText; |
|
623 iSettingText = NULL; |
|
624 } |
|
625 |
|
626 iSettingText = HBufC::NewL(settingText.Length()); |
|
627 iSettingText->Des().Copy(settingText); |
|
628 |
|
629 if ( iSettingText->Length() > 0 ) |
|
630 return *iSettingText; |
|
631 else |
|
632 return EmptyItemText(); |
|
633 } |
|
634 |
|
635 |
|
636 // launches the setting page |
|
637 void CSourceSelectionCheckBoxSettingItem::EditItemL(TBool /*aCalledFromMenu*/) |
|
638 { |
|
639 CSourceSelectionCheckBoxSettingPage* dlg = new(ELeave) CSourceSelectionCheckBoxSettingPage(SettingPageResourceId(), iItemArray); |
|
640 |
|
641 SetSettingPage( dlg ); |
|
642 SettingPage()->SetSettingPageObserver(this); |
|
643 |
|
644 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
645 SetSettingPage(0); // it is deleted now |
|
646 } |
|
647 |
|
648 |
|
649 // handles setting page events |
|
650 void CSourceSelectionCheckBoxSettingItem::HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType ) |
|
651 { |
|
652 switch( aEventType ) |
|
653 { |
|
654 case EEventSettingCancelled: |
|
655 { |
|
656 // If setting is cancelled, load old values |
|
657 LoadL(); |
|
658 break; |
|
659 } |
|
660 case EEventSettingChanged: |
|
661 { |
|
662 // If setting has changed, update CBA visibility |
|
663 static_cast<CSourceSelectionCheckBoxSettingPage*>( aSettingPage )->UpdateCba(); |
|
664 break; |
|
665 } |
|
666 default: |
|
667 { |
|
668 break; |
|
669 } |
|
670 } |
|
671 CAknSettingItem::HandleSettingPageEventL( aSettingPage, aEventType ); |
|
672 } |
|
673 |
|
674 // -------------------------------------------------------------------------------------------- |
|
675 // -------------------------------------------------------------------------------------------- |
|
676 |
|
677 CSourceSelectionCheckBoxSettingPage::CSourceSelectionCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray ) |
|
678 : CAknCheckBoxSettingPage( aResourceID, aItemArray ) |
|
679 { |
|
680 } |
|
681 |
|
682 void CSourceSelectionCheckBoxSettingPage::UpdateCba() |
|
683 { |
|
684 // Cache the pointer to button group container |
|
685 CEikButtonGroupContainer* cba = Cba(); |
|
686 // Left softkey should be visible if there are items selected, |
|
687 // i.e. the selection index array has items. |
|
688 TBool visible( ListBoxControl()->View()->SelectionIndexes()->Count() > 0 ); |
|
689 // Resolve left softkey command id |
|
690 TInt leftId( cba->ButtonGroup()->CommandId( 0 ) ); |
|
691 // Check if left softkey visibility has changed |
|
692 if( visible != cba->IsCommandVisible( leftId ) ) |
|
693 { |
|
694 // Left softkey visibility has changed, update it |
|
695 cba->MakeCommandVisible( leftId, visible ); |
|
696 } |
|
697 } |
|
698 |
|
699 // -------------------------------------------------------------------------------------------- |
|
700 // -------------------------------------------------------------------------------------------- |
|
701 |
|
702 // End of File |