26
|
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 |
// INCLUDE FILES
|
|
21 |
#include "profiler_gui_samplersettingsviewdlg.h"
|
|
22 |
#include "profiler_gui_model.h"
|
|
23 |
#include "profiler_gui.hrh"
|
|
24 |
#include "profiler_gui_std.h"
|
|
25 |
#include <piprofilerui.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 |
// LITERALS
|
|
37 |
_LIT8(KCPUSamplerName, "gpp");
|
|
38 |
_LIT(KEmptySettingItem, "");
|
|
39 |
|
|
40 |
// ===================================== MEMBER FUNCTIONS =====================================
|
|
41 |
|
|
42 |
CProfilerSamplerSettingsViewDlg* CProfilerSamplerSettingsViewDlg::NewL(TSamplerAttributes& aSettings)
|
|
43 |
{
|
|
44 |
CProfilerSamplerSettingsViewDlg* self = new(ELeave) CProfilerSamplerSettingsViewDlg(aSettings);
|
|
45 |
CleanupStack::PushL(self);
|
|
46 |
self->ConstructL();
|
|
47 |
CleanupStack::Pop(self);
|
|
48 |
return self;
|
|
49 |
}
|
|
50 |
|
|
51 |
// --------------------------------------------------------------------------------------------
|
|
52 |
|
|
53 |
CProfilerSamplerSettingsViewDlg::~CProfilerSamplerSettingsViewDlg()
|
|
54 |
{
|
|
55 |
// restore default navi pane
|
|
56 |
if(iNaviContainer)
|
|
57 |
iNaviContainer->Pop();
|
|
58 |
|
|
59 |
if (iSettingItemArray)
|
|
60 |
{
|
|
61 |
iSettingItemArray->ResetAndDestroy();
|
|
62 |
delete iSettingItemArray;
|
|
63 |
}
|
|
64 |
|
|
65 |
}
|
|
66 |
|
|
67 |
// --------------------------------------------------------------------------------------------
|
|
68 |
|
|
69 |
CProfilerSamplerSettingsViewDlg::CProfilerSamplerSettingsViewDlg(TSamplerAttributes& aSettings)
|
|
70 |
: iSettings(aSettings)
|
|
71 |
{
|
|
72 |
}
|
|
73 |
|
|
74 |
// --------------------------------------------------------------------------------------------
|
|
75 |
|
|
76 |
void CProfilerSamplerSettingsViewDlg::ConstructL()
|
|
77 |
{
|
|
78 |
// construct a menu bar
|
|
79 |
CAknDialog::ConstructL(R_PROFILER_SAMPLER_SETTINGS_MENUBAR);
|
|
80 |
|
|
81 |
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
|
|
82 |
|
|
83 |
// set empty navi pane label
|
|
84 |
iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
|
|
85 |
iNaviContainer->PushDefaultL();
|
|
86 |
|
|
87 |
TBuf<64> settingsTitle;
|
|
88 |
|
|
89 |
settingsTitle.Zero();
|
|
90 |
settingsTitle.Copy(iSettings.iName);
|
|
91 |
|
|
92 |
// set title text
|
|
93 |
CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
94 |
tp->SetTextL( settingsTitle );
|
|
95 |
|
|
96 |
iItemCount = iSettings.iItemCount;
|
|
97 |
|
|
98 |
}
|
|
99 |
|
|
100 |
// --------------------------------------------------------------------------------------------
|
|
101 |
|
|
102 |
void CProfilerSamplerSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
|
|
103 |
{
|
|
104 |
switch (aEventType)
|
|
105 |
{
|
|
106 |
case EEventEnterKeyPressed:
|
|
107 |
case EEventItemDoubleClicked:
|
|
108 |
ShowSettingPageL(EFalse);
|
|
109 |
break;
|
|
110 |
default:
|
|
111 |
break;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
// --------------------------------------------------------------------------------------------
|
|
116 |
|
|
117 |
void CProfilerSamplerSettingsViewDlg::TabChangedL(TInt /*aIndex*/)
|
|
118 |
{
|
|
119 |
iListBox->SetCurrentItemIndex(0);
|
|
120 |
|
|
121 |
SetVisibilitiesOfSettingItemsL();
|
|
122 |
}
|
|
123 |
|
|
124 |
// --------------------------------------------------------------------------------------------
|
|
125 |
|
|
126 |
void CProfilerSamplerSettingsViewDlg::ProcessCommandL(TInt aCommandId)
|
|
127 |
{
|
|
128 |
CAknDialog::ProcessCommandL(aCommandId);
|
|
129 |
|
|
130 |
switch (aCommandId)
|
|
131 |
{
|
|
132 |
case EProfilerGuiCmdSettingsChange:
|
|
133 |
ShowSettingPageL(ETrue);
|
|
134 |
break;
|
|
135 |
case EProfilerGuiCmdSettingsExit:
|
|
136 |
TryExitL(EAknCmdExit);
|
|
137 |
break;
|
|
138 |
default:
|
|
139 |
break;
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
// --------------------------------------------------------------------------------------------
|
|
144 |
|
|
145 |
TKeyResponse CProfilerSamplerSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
|
146 |
{
|
|
147 |
|
|
148 |
return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
|
|
149 |
}
|
|
150 |
|
|
151 |
// --------------------------------------------------------------------------------------------
|
|
152 |
|
|
153 |
void CProfilerSamplerSettingsViewDlg::PreLayoutDynInitL()
|
|
154 |
{
|
|
155 |
iListBox = static_cast<CAknSettingStyleListBox*>( Control(EProfilerSamplerSettingItemList) );
|
|
156 |
iListBox->SetMopParent(this);
|
|
157 |
iListBox->CreateScrollBarFrameL(ETrue);
|
|
158 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
159 |
iListBox->SetListBoxObserver(this);
|
|
160 |
|
|
161 |
iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0);
|
|
162 |
|
|
163 |
CTextListBoxModel* model = iListBox->Model();
|
|
164 |
model->SetItemTextArray(iSettingItemArray);
|
|
165 |
model->SetOwnershipType(ELbmDoesNotOwnItemArray);
|
|
166 |
|
|
167 |
UpdateListBoxL();
|
|
168 |
}
|
|
169 |
|
|
170 |
// --------------------------------------------------------------------------------------------
|
|
171 |
|
|
172 |
TBool CProfilerSamplerSettingsViewDlg::OkToExitL(TInt aButtonId)
|
|
173 |
{
|
|
174 |
// save all settings when exiting, only numeric values are needed to saved since copied from TBuf
|
|
175 |
for(TInt i(1);i<iItemCount+1;i++)
|
|
176 |
{
|
|
177 |
if(iSettingItemArray->At(i)->IsHidden() == EFalse)
|
|
178 |
{
|
|
179 |
switch(i)
|
|
180 |
{
|
|
181 |
case 1:
|
|
182 |
{
|
|
183 |
// check if settings value type integer
|
|
184 |
if(iSettings.iSettingItem1.iType == TSettingItem::ESettingItemTypeInt)
|
|
185 |
{
|
|
186 |
iSettings.iSettingItem1.iValue.Num(iItemBuf[i]);
|
|
187 |
}
|
|
188 |
break;
|
|
189 |
}
|
|
190 |
case 2:
|
|
191 |
{
|
|
192 |
// check if settings value type integer
|
|
193 |
if(iSettings.iSettingItem2.iType == TSettingItem::ESettingItemTypeInt)
|
|
194 |
{
|
|
195 |
iSettings.iSettingItem2.iValue.Num(iItemBuf[i]);
|
|
196 |
}
|
|
197 |
break;
|
|
198 |
}
|
|
199 |
case 3:
|
|
200 |
{
|
|
201 |
// check if settings value type integer
|
|
202 |
if(iSettings.iSettingItem3.iType == TSettingItem::ESettingItemTypeInt)
|
|
203 |
{
|
|
204 |
iSettings.iSettingItem3.iValue.Num(iItemBuf[i]);
|
|
205 |
}
|
|
206 |
break;
|
|
207 |
}
|
|
208 |
case 4:
|
|
209 |
{
|
|
210 |
// check if settings value type integer
|
|
211 |
if(iSettings.iSettingItem4.iType == TSettingItem::ESettingItemTypeInt)
|
|
212 |
{
|
|
213 |
iSettings.iSettingItem4.iValue.Num(iItemBuf[i]);
|
|
214 |
}
|
|
215 |
|
|
216 |
break;
|
|
217 |
}
|
|
218 |
case 5:
|
|
219 |
{
|
|
220 |
// check if settings value type integer
|
|
221 |
if(iSettings.iSettingItem5.iType == TSettingItem::ESettingItemTypeInt)
|
|
222 |
{
|
|
223 |
iSettings.iSettingItem5.iValue.Num(iItemBuf[i]);
|
|
224 |
}
|
|
225 |
|
|
226 |
break;
|
|
227 |
}
|
|
228 |
case 6:
|
|
229 |
{
|
|
230 |
// check if settings value type integer
|
|
231 |
if(iSettings.iSettingItem6.iType == TSettingItem::ESettingItemTypeInt)
|
|
232 |
{
|
|
233 |
iSettings.iSettingItem6.iValue.Num(iItemBuf[i]);
|
|
234 |
}
|
|
235 |
|
|
236 |
break;
|
|
237 |
}
|
|
238 |
}
|
|
239 |
}
|
|
240 |
}
|
|
241 |
return CAknDialog::OkToExitL(aButtonId);
|
|
242 |
}
|
|
243 |
|
|
244 |
// --------------------------------------------------------------------------------------------
|
|
245 |
|
|
246 |
void CProfilerSamplerSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu)
|
|
247 |
{
|
|
248 |
TInt listIndex = iListBox->CurrentItemIndex();
|
|
249 |
TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex);
|
|
250 |
CAknSettingItem* item = iSettingItemArray->At(realIndex);
|
|
251 |
item->EditItemL(aCalledFromMenu);
|
|
252 |
item->StoreL();
|
|
253 |
SetVisibilitiesOfSettingItemsL();
|
|
254 |
DrawNow();
|
|
255 |
}
|
|
256 |
|
|
257 |
// --------------------------------------------------------------------------------------------
|
|
258 |
|
|
259 |
void CProfilerSamplerSettingsViewDlg::SetVisibilitiesOfSettingItemsL()
|
|
260 |
{
|
|
261 |
if (iSettingItemArray->Count() > 0)
|
|
262 |
{
|
|
263 |
if(iSettings.iSampleRate > 0)
|
|
264 |
{
|
|
265 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQuerySampleRate])->SetHidden(EFalse);
|
|
266 |
}
|
|
267 |
else
|
|
268 |
{
|
|
269 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQuerySampleRate])->SetHidden(ETrue);
|
|
270 |
}
|
|
271 |
if(iItemCount>0)
|
|
272 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem1])->SetHidden(EFalse);
|
|
273 |
if(iItemCount>1)
|
|
274 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem2])->SetHidden(EFalse);
|
|
275 |
if(iItemCount>2)
|
|
276 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem3])->SetHidden(EFalse);
|
|
277 |
if(iItemCount>3)
|
|
278 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem4])->SetHidden(EFalse);
|
|
279 |
if(iItemCount>4)
|
|
280 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem5])->SetHidden(EFalse);
|
|
281 |
if(iItemCount>5)
|
|
282 |
((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem6])->SetHidden(EFalse);
|
|
283 |
|
|
284 |
iSettingItemArray->RecalculateVisibleIndicesL();
|
|
285 |
iListBox->HandleItemAdditionL();
|
|
286 |
iListBox->UpdateScrollBarsL();
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
// --------------------------------------------------------------------------------------------
|
|
291 |
|
|
292 |
void CProfilerSamplerSettingsViewDlg::UpdateListBoxL()
|
|
293 |
{
|
|
294 |
iSettingItemArray->ResetAndDestroy();
|
|
295 |
|
|
296 |
// create items
|
|
297 |
TInt ordinal(0);
|
|
298 |
|
|
299 |
AddSettingItemL(EProfilerGuiGenericSamplerQuerySampleRate,
|
|
300 |
R_SAMPLE_RATE_SETTING_TITLE,
|
|
301 |
R_SAMPLER_RATE_SETTING_PAGE,
|
|
302 |
NULL,
|
|
303 |
ordinal++);
|
|
304 |
|
|
305 |
if(iItemCount>0)
|
|
306 |
AddSettingItemL(EProfilerGuiGenericSamplerQueryItem1,
|
|
307 |
R_ITEM1_SETTING_TITLE,
|
|
308 |
NULL,
|
|
309 |
NULL,
|
|
310 |
ordinal++);
|
|
311 |
if(iItemCount>1)
|
|
312 |
AddSettingItemL(EProfilerGuiGenericSamplerQueryItem2,
|
|
313 |
R_ITEM2_SETTING_TITLE,
|
|
314 |
NULL,
|
|
315 |
NULL,
|
|
316 |
ordinal++);
|
|
317 |
if(iItemCount>2)
|
|
318 |
AddSettingItemL(EProfilerGuiGenericSamplerQueryItem3,
|
|
319 |
R_ITEM3_SETTING_TITLE,
|
|
320 |
NULL,
|
|
321 |
NULL,
|
|
322 |
ordinal++);
|
|
323 |
if(iItemCount>3)
|
|
324 |
AddSettingItemL(EProfilerGuiGenericSamplerQueryItem4,
|
|
325 |
R_ITEM4_SETTING_TITLE,
|
|
326 |
NULL,
|
|
327 |
NULL,
|
|
328 |
ordinal++);
|
|
329 |
if(iItemCount>4)
|
|
330 |
AddSettingItemL(EProfilerGuiGenericSamplerQueryItem5,
|
|
331 |
R_ITEM5_SETTING_TITLE,
|
|
332 |
NULL,
|
|
333 |
NULL,
|
|
334 |
ordinal++);
|
|
335 |
if(iItemCount>5)
|
|
336 |
AddSettingItemL(EProfilerGuiGenericSamplerQueryItem6,
|
|
337 |
R_ITEM6_SETTING_TITLE,
|
|
338 |
NULL,
|
|
339 |
NULL,
|
|
340 |
ordinal++);
|
|
341 |
|
|
342 |
SetVisibilitiesOfSettingItemsL();
|
|
343 |
}
|
|
344 |
|
|
345 |
// --------------------------------------------------------------------------------------------
|
|
346 |
|
|
347 |
CAknSettingItem* CProfilerSamplerSettingsViewDlg::GetSettingItemL(TSettingItem& aItem, TInt aIndex, TInt& aSettingPageResource)
|
|
348 |
{
|
|
349 |
CAknSettingItem* settingItem = NULL;
|
|
350 |
|
|
351 |
// set default setting page dialog style resource
|
|
352 |
aSettingPageResource = R_GENERIC_TEXT_SETTING_PAGE;
|
|
353 |
|
|
354 |
// check if setting item type integer
|
|
355 |
if(aItem.iType == TSettingItem::ESettingItemTypeInt)
|
|
356 |
{
|
|
357 |
TLex* lex = new TLex(aItem.iValue);
|
|
358 |
// check if value valid
|
|
359 |
if(lex->Val(iItemBuf[aIndex]) != KErrNone)
|
|
360 |
{
|
|
361 |
// if value not valid set to 0
|
|
362 |
iItemBuf[aIndex] = 0;
|
|
363 |
}
|
|
364 |
settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aIndex, iItemBuf[aIndex]);
|
|
365 |
aSettingPageResource = R_NUMERIC_SETTING_PAGE;
|
|
366 |
delete lex;
|
|
367 |
return settingItem;
|
|
368 |
}
|
|
369 |
else // else manipulate as a text setting
|
|
370 |
{
|
|
371 |
settingItem = new(ELeave) CAknTextSettingItem(aIndex, aItem.iValue);
|
|
372 |
settingItem->SetEmptyItemTextL(KEmptySettingItem);
|
|
373 |
return settingItem;
|
|
374 |
}
|
|
375 |
}
|
|
376 |
|
|
377 |
// --------------------------------------------------------------------------------------------
|
|
378 |
|
|
379 |
void CProfilerSamplerSettingsViewDlg::AddSettingItemL(TInt aId,
|
|
380 |
TInt aTitleResource,
|
|
381 |
TInt aSettingPageResource,
|
|
382 |
TInt aAssociatedResource,
|
|
383 |
TInt aOrdinal)
|
|
384 |
{
|
|
385 |
// create a setting item
|
|
386 |
CAknSettingItem* settingItem = NULL;
|
|
387 |
|
|
388 |
TBuf<KMaxSettingUITextLength> ptr;
|
|
389 |
switch(aId)
|
|
390 |
{
|
|
391 |
case EProfilerGuiGenericSamplerQuerySampleRate:
|
|
392 |
{
|
|
393 |
settingItem = new (ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iSampleRate);
|
|
394 |
break;
|
|
395 |
}
|
|
396 |
case EProfilerGuiGenericSamplerQueryItem1:
|
|
397 |
{
|
|
398 |
ptr.Copy(iSettings.iSettingItem1.iUIText);
|
|
399 |
settingItem = GetSettingItemL(iSettings.iSettingItem1, aId, aSettingPageResource);
|
|
400 |
break;
|
|
401 |
}
|
|
402 |
case EProfilerGuiGenericSamplerQueryItem2:
|
|
403 |
{
|
|
404 |
ptr.Copy(iSettings.iSettingItem2.iUIText);
|
|
405 |
settingItem = GetSettingItemL(iSettings.iSettingItem2, aId, aSettingPageResource);
|
|
406 |
break;
|
|
407 |
}
|
|
408 |
case EProfilerGuiGenericSamplerQueryItem3:
|
|
409 |
{
|
|
410 |
ptr.Copy(iSettings.iSettingItem3.iUIText);
|
|
411 |
settingItem = GetSettingItemL(iSettings.iSettingItem3, aId, aSettingPageResource);
|
|
412 |
break;
|
|
413 |
}
|
|
414 |
case EProfilerGuiGenericSamplerQueryItem4:
|
|
415 |
{
|
|
416 |
ptr.Copy(iSettings.iSettingItem4.iUIText);
|
|
417 |
settingItem = GetSettingItemL(iSettings.iSettingItem4, aId, aSettingPageResource);
|
|
418 |
break;
|
|
419 |
}
|
|
420 |
case EProfilerGuiGenericSamplerQueryItem5:
|
|
421 |
{
|
|
422 |
ptr.Copy(iSettings.iSettingItem5.iUIText);
|
|
423 |
settingItem = GetSettingItemL(iSettings.iSettingItem5, aId, aSettingPageResource);
|
|
424 |
break;
|
|
425 |
}
|
|
426 |
case EProfilerGuiGenericSamplerQueryItem6:
|
|
427 |
{
|
|
428 |
ptr.Copy(iSettings.iSettingItem6.iUIText);
|
|
429 |
settingItem = GetSettingItemL(iSettings.iSettingItem6, aId, aSettingPageResource);
|
|
430 |
break;
|
|
431 |
}
|
|
432 |
default:
|
|
433 |
{
|
|
434 |
// Id not supported
|
|
435 |
User::Leave(KErrNotSupported);
|
|
436 |
break;
|
|
437 |
}
|
|
438 |
}
|
|
439 |
|
|
440 |
CleanupStack::PushL(settingItem);
|
|
441 |
|
|
442 |
// get title text
|
|
443 |
HBufC* itemTitle;
|
|
444 |
|
|
445 |
if( ptr.Compare(KNullDesC) == 0 )
|
|
446 |
{
|
|
447 |
itemTitle = StringLoader::LoadLC(aTitleResource);
|
|
448 |
|
|
449 |
// special case: check if CPU sampler
|
|
450 |
if(iSettings.iShortName.CompareF(KCPUSamplerName) == 0)
|
|
451 |
{
|
|
452 |
// change setting page using different value range, since > 10000 ms rates are too big
|
|
453 |
aSettingPageResource = R_CPU_SAMPLER_RATE_SETTING_PAGE;
|
|
454 |
}
|
|
455 |
|
|
456 |
// construct the setting item
|
|
457 |
settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource,
|
|
458 |
EAknCtPopupSettingList, NULL, aAssociatedResource);
|
|
459 |
// append the setting item to settingitem array
|
|
460 |
iSettingItemArray->InsertL(aOrdinal, settingItem);
|
|
461 |
|
|
462 |
CleanupStack::PopAndDestroy(); //itemTitle
|
|
463 |
}
|
|
464 |
else
|
|
465 |
{
|
|
466 |
// construct the setting item
|
|
467 |
settingItem->ConstructL(EFalse, aOrdinal, ptr, NULL, aSettingPageResource,
|
|
468 |
EAknCtPopupSettingList, NULL, aAssociatedResource);
|
|
469 |
|
|
470 |
// append the setting item to settingitem array
|
|
471 |
iSettingItemArray->InsertL(aOrdinal, settingItem);
|
|
472 |
}
|
|
473 |
|
|
474 |
CleanupStack::Pop(); //settingItem
|
|
475 |
}
|
|
476 |
|
|
477 |
// --------------------------------------------------------------------------------------------
|
|
478 |
// End of File
|
|
479 |
|