55
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 |
#include "settingsview.h"
|
|
19 |
#include "enginewrapper.h"
|
|
20 |
#include "loadgen.hrh"
|
|
21 |
#include "loadgen_loadattributes.h"
|
|
22 |
#include <hbmainwindow.h>
|
|
23 |
#include <hbview.h>
|
|
24 |
//#include <hbformitem.h>
|
|
25 |
#include <hbmenu.h>
|
|
26 |
#include <hbaction.h>
|
|
27 |
#include <hbmessagebox.h>
|
|
28 |
//#include <hbcommonnote.h>
|
|
29 |
#include <hbtoolbar.h>
|
|
30 |
#include <hbdataform.h>
|
|
31 |
#include <hbdataformmodelitem.h>
|
|
32 |
#include <hbdataformmodel.h>
|
|
33 |
#include <hbdataformviewitem.h>
|
|
34 |
#include <hbabstractviewitem.h>
|
|
35 |
#include <hbradiobuttonlist.h>
|
|
36 |
|
|
37 |
|
|
38 |
#include <QStringList>
|
|
39 |
|
|
40 |
QStringList PRIORITIES = (QStringList() << "Much less (-20)" << "Less (-10)" << "Normal (0)" << "More (10)"
|
|
41 |
<< "Much more (20)" << "Real time (30)" << "Abs. very low (100)" << "Abs. low (200)"
|
|
42 |
<< "Abs. backgr. (300)" << "Abs. foregr. (400)" << "Abs. high (500)");
|
|
43 |
QStringList LOADMODES = (QStringList() << "Yielding" << "Blocking");
|
|
44 |
QStringList CPULOADTYPES = (QStringList() << "Continuous" << "Periodic");
|
|
45 |
QStringList MEMSOURCES = (QStringList() << "RAM" << "C:" << "D:" << "E:" << "F:" << "G:" << "H:" << "J:" << "K:"
|
|
46 |
<< "L:" << "M:" << "N:");
|
|
47 |
QStringList MEMEATTYPES = (QStringList() << "Memory to eat" << "Memory to be left" << "Alternate min/max");
|
|
48 |
QStringList KEYPRESSTYPES = (QStringList() << "None" << "Arrow keys");
|
|
49 |
QStringList MESSAGETYPES = (QStringList() << "SMS" << "MMS");
|
|
50 |
|
|
51 |
|
|
52 |
SettingsView::SettingsView(HbView &mainView, HbMainWindow &parent, EngineWrapper &engine)
|
|
53 |
|
|
54 |
: mMainWindow(parent),
|
|
55 |
mMainView(mainView),
|
|
56 |
mEngineWrapper(engine),
|
|
57 |
mAmount(NULL),
|
|
58 |
mMinAmountToBeLeft(NULL),
|
|
59 |
mMaxAmountToBeLeft(NULL),
|
|
60 |
mLength(NULL),
|
|
61 |
mIdle(NULL),
|
|
62 |
mRandomVar(NULL)
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
SettingsView::~SettingsView()
|
|
67 |
{
|
|
68 |
|
|
69 |
}
|
|
70 |
|
|
71 |
// TODO HbDataFormModelItem data operations does not work correctly with WK38.
|
|
72 |
// Item data does not get updated correctly as set by initial settings(HbDataFormModelItem::RadioButtonListItem)
|
|
73 |
// or user settings.(HbDataFormModelItem::TextItem)
|
|
74 |
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
|
|
77 |
void SettingsView::open(const QString &settingsName, TLoadGenCommandIds cmdId)
|
|
78 |
{
|
|
79 |
mCmdId = cmdId;
|
|
80 |
// Remove main view from main window and add this view to main window
|
|
81 |
mMainWindow.addView(this);
|
|
82 |
mMainWindow.setCurrentView(this);
|
|
83 |
setTitle(settingsName);
|
|
84 |
|
|
85 |
//create toolbar showing launch popup
|
|
86 |
HbToolBar *toolBar = this->toolBar();
|
|
87 |
HbAction *actionOk = new HbAction("Ok", toolBar);
|
|
88 |
HbAction *actionCancel = new HbAction("Cancel", toolBar);
|
|
89 |
toolBar->addAction( actionOk );
|
|
90 |
toolBar->addAction( actionCancel );
|
|
91 |
|
|
92 |
//create setting form
|
|
93 |
mSettingForm = new HbDataForm();
|
|
94 |
|
|
95 |
//create a model class
|
|
96 |
mModel = new HbDataFormModel(this);
|
|
97 |
createItems(mModel, 0);
|
|
98 |
// Set created model to form
|
|
99 |
|
|
100 |
mSettingForm->setModel(mModel);
|
|
101 |
setWidget(mSettingForm);
|
|
102 |
loadAttributes();
|
|
103 |
|
|
104 |
connect(actionOk, SIGNAL(triggered()), this, SLOT(okExit()));
|
|
105 |
connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelled()));
|
|
106 |
connect(this, SIGNAL(aboutToClose()), this, SLOT(backButtonPressed()));
|
|
107 |
//connect(mSettingForm, SIGNAL(activated(const QModelIndex)), this, SLOT(dataItemDisplayed(const QModelIndex)));
|
|
108 |
|
|
109 |
show();
|
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
|
|
114 |
void SettingsView::createItems(HbDataFormModel *model,
|
|
115 |
HbDataFormModelItem *parent)
|
|
116 |
{
|
|
117 |
switch (mCmdId) {
|
|
118 |
case ELoadGenCmdNewLoadCPULoad: {
|
|
119 |
createCpuLoadItems(model, parent);
|
|
120 |
break;
|
|
121 |
}
|
|
122 |
case ELoadGenCmdNewLoadEatMemory: {
|
|
123 |
createEatMemoryItems(model, parent);
|
|
124 |
break;
|
|
125 |
}
|
|
126 |
case ELoadGenCmdNewLoadPhoneCall: {
|
|
127 |
createPhoneCallItems(model, parent);
|
|
128 |
break;
|
|
129 |
}
|
|
130 |
case ELoadGenCmdNewLoadNetConn: {
|
|
131 |
createNetConnItems(model, parent);
|
|
132 |
break;
|
|
133 |
}
|
|
134 |
case ELoadGenCmdNewLoadKeyPress:
|
|
135 |
case ELoadGenCmdNewLoadPointerEvent: {
|
|
136 |
createKeyOrPointerItems(model, parent);
|
|
137 |
break;
|
|
138 |
}
|
|
139 |
case ELoadGenCmdNewLoadMessages: {
|
|
140 |
createMessageItems(model, parent);
|
|
141 |
break;
|
|
142 |
}
|
|
143 |
case ELoadGenCmdNewLoadApplications: {
|
|
144 |
createAppsItems(model, parent);
|
|
145 |
break;
|
|
146 |
}
|
|
147 |
case ELoadGenCmdNewLoadPhotoCaptures: {
|
|
148 |
createPhotoItems(model, parent);
|
|
149 |
break;
|
|
150 |
}
|
|
151 |
case ELoadGenCmdNewLoadBluetooth: {
|
|
152 |
createBtItems(model, parent);
|
|
153 |
break;
|
|
154 |
}
|
|
155 |
default: {
|
|
156 |
break;
|
|
157 |
}
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
|
|
163 |
void SettingsView::createCpuLoadItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
164 |
{
|
|
165 |
|
|
166 |
mLoadSettings = parent;
|
|
167 |
//mLoadSettings = model->appendDataFormGroup(QString("CPU load settings"), parent);
|
|
168 |
|
|
169 |
// DataFormItem for priority selection
|
|
170 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
171 |
QString("Priority"),
|
|
172 |
mLoadSettings);
|
|
173 |
|
|
174 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
175 |
|
|
176 |
// DataFormItem for load mode selection
|
|
177 |
mLoadMode = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
178 |
QString("Load mode"),
|
|
179 |
mLoadSettings);
|
|
180 |
mLoadMode->setContentWidgetData(QString("items"), LOADMODES);
|
|
181 |
|
|
182 |
// DataFormItem for load type selection
|
|
183 |
mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
184 |
QString("Type"),
|
|
185 |
mLoadSettings);
|
|
186 |
mType->setContentWidgetData(QString("items"), CPULOADTYPES);
|
|
187 |
|
|
188 |
mSettingForm->addConnection(mType,SIGNAL(itemSelected(int)),this,SLOT(selectionChanged(int)));
|
|
189 |
}
|
|
190 |
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
|
|
193 |
void SettingsView::createEatMemoryItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
194 |
{
|
|
195 |
mLoadSettings = parent;
|
|
196 |
//mLoadSettings = model->appendDataFormGroup(QString("Eat memory settings"), parent);
|
|
197 |
|
|
198 |
// DataFormItem for priority selection
|
|
199 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
200 |
QString("Priority"),
|
|
201 |
mLoadSettings);
|
|
202 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
203 |
|
|
204 |
// DataFormItem for memory eat type selection
|
|
205 |
mSource = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
206 |
QString("Source"),
|
|
207 |
mLoadSettings);
|
|
208 |
mSource->setContentWidgetData(QString("items"), MEMSOURCES);
|
|
209 |
|
|
210 |
|
|
211 |
// DataFormItem for memory eat type selection
|
|
212 |
mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
213 |
QString("Type"),
|
|
214 |
mLoadSettings);
|
|
215 |
mType->setContentWidgetData(QString("items"), MEMEATTYPES);
|
|
216 |
|
|
217 |
// DataFormItem for idle length selection
|
|
218 |
mBuffer = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
219 |
QString("Buffer (B)"),
|
|
220 |
mLoadSettings);
|
|
221 |
mBuffer->setContentWidgetData("maximum" , 999999999);
|
|
222 |
mBuffer->setContentWidgetData("minimum", 0);
|
|
223 |
|
|
224 |
// DataFormItem for idle length selection
|
|
225 |
mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
226 |
QString("Idle after buffer (ms)"),
|
|
227 |
mLoadSettings);
|
|
228 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
229 |
mIdle->setContentWidgetData("minimum", 0);
|
|
230 |
|
|
231 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
232 |
QString("Random variance (%)"),
|
|
233 |
mLoadSettings);
|
|
234 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
235 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
236 |
|
|
237 |
mSettingForm->addConnection(mType,SIGNAL(itemSelected(int)),this,SLOT(selectionChanged(int)));
|
|
238 |
}
|
|
239 |
|
|
240 |
// ---------------------------------------------------------------------------
|
|
241 |
|
|
242 |
void SettingsView::createPhoneCallItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
243 |
{
|
|
244 |
|
|
245 |
mLoadSettings = parent;
|
|
246 |
//mLoadSettings = model->appendDataFormGroup(QString("Phone calls settings"), parent);
|
|
247 |
|
|
248 |
// DataFormItem for priority selection
|
|
249 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
250 |
QString("Priority"),
|
|
251 |
mLoadSettings);
|
|
252 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
253 |
|
|
254 |
mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
255 |
QString("Phone number:"),
|
|
256 |
mLoadSettings);
|
|
257 |
mDestination->setContentWidgetData("maximum" , 99999999999999999999.0 );
|
|
258 |
mDestination->setContentWidgetData("minimum", 0);
|
|
259 |
|
|
260 |
mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
261 |
QString("Length (ms)"),
|
|
262 |
mLoadSettings);
|
|
263 |
mLength->setContentWidgetData("maximum" , 999999999);
|
|
264 |
mLength->setContentWidgetData("minimum", 0);
|
|
265 |
|
|
266 |
// DataFormItem for idle length selection
|
|
267 |
mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
268 |
QString("Idle (ms)"),
|
|
269 |
mLoadSettings);
|
|
270 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
271 |
mIdle->setContentWidgetData("minimum", 0);
|
|
272 |
|
|
273 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
274 |
QString("Random variance (%)"),
|
|
275 |
mLoadSettings);
|
|
276 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
277 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
278 |
}
|
|
279 |
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
|
|
282 |
void SettingsView::createNetConnItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
283 |
{
|
|
284 |
|
|
285 |
//mLoadSettings = model->appendDataFormGroup(QString("Network conn. settings"), parent);
|
|
286 |
mLoadSettings = parent;
|
|
287 |
|
|
288 |
// DataFormItem for priority selection
|
|
289 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
290 |
QString("Priority"),
|
|
291 |
mLoadSettings);
|
|
292 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
293 |
|
|
294 |
mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
295 |
QString("Destination URL:"),
|
|
296 |
mLoadSettings);
|
|
297 |
|
|
298 |
// DataFormItem for idle length selection
|
|
299 |
mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
300 |
QString("Idle (ms)"),
|
|
301 |
mLoadSettings);
|
|
302 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
303 |
mIdle->setContentWidgetData("minimum", 0);
|
|
304 |
|
|
305 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
306 |
QString("Random variance (%)"),
|
|
307 |
mLoadSettings);
|
|
308 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
309 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
310 |
}
|
|
311 |
|
|
312 |
// ---------------------------------------------------------------------------
|
|
313 |
|
|
314 |
void SettingsView::createKeyOrPointerItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
315 |
{
|
|
316 |
QString settingsName;
|
|
317 |
if (mCmdId == ELoadGenCmdNewLoadPointerEvent) {
|
|
318 |
settingsName = "Pointer events settings";
|
|
319 |
}
|
|
320 |
else {
|
|
321 |
settingsName = "Key presses settings";
|
|
322 |
}
|
|
323 |
//mLoadSettings = model->appendDataFormGroup(settingsName, parent);
|
|
324 |
mLoadSettings = parent;
|
|
325 |
|
|
326 |
// DataFormItem for priority selection
|
|
327 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
328 |
QString("Priority"),
|
|
329 |
mLoadSettings);
|
|
330 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
331 |
|
|
332 |
|
|
333 |
// DataFormItem for heartbeat length selection
|
|
334 |
mHeartBeat = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
335 |
QString("Heartbeat (ms)"),
|
|
336 |
mLoadSettings);
|
|
337 |
mHeartBeat->setContentWidgetData("maximum" , 999999999);
|
|
338 |
mHeartBeat->setContentWidgetData("minimum", 0);
|
|
339 |
|
|
340 |
// Random variance
|
|
341 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
342 |
QString("Random variance (%)"),
|
|
343 |
mLoadSettings);
|
|
344 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
345 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
346 |
}
|
|
347 |
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
|
|
350 |
void SettingsView::createMessageItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
351 |
{
|
|
352 |
mLoadSettings = parent;
|
|
353 |
//mLoadSettings = model->appendDataFormGroup(QString("Messages settings"), parent);
|
|
354 |
|
|
355 |
// DataFormItem for priority selection
|
|
356 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
357 |
QString("Priority"),
|
|
358 |
mLoadSettings);
|
|
359 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
360 |
|
|
361 |
|
|
362 |
mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
363 |
QString("Type"),
|
|
364 |
mLoadSettings);
|
|
365 |
mType->setContentWidgetData(QString("items"), MESSAGETYPES);
|
|
366 |
|
|
367 |
|
|
368 |
mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
369 |
QString("Phone number:"),
|
|
370 |
mLoadSettings);
|
|
371 |
mDestination->setContentWidgetData("maximum" , 99999999999999999999.0 );
|
|
372 |
mDestination->setContentWidgetData("minimum", 0);
|
|
373 |
|
|
374 |
mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem,
|
|
375 |
QString("Maximum amount of messages"),
|
|
376 |
mLoadSettings);
|
|
377 |
mAmount->setContentWidgetData("maximum" , 1000);
|
|
378 |
mAmount->setContentWidgetData("minimum", 0);
|
|
379 |
|
|
380 |
mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
381 |
QString("Message length"),
|
|
382 |
mLoadSettings);
|
|
383 |
mLength->setContentWidgetData("maximum" , 999999999);
|
|
384 |
mLength->setContentWidgetData("minimum", 0);
|
|
385 |
|
|
386 |
// DataFormItem for idle length selection
|
|
387 |
mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
388 |
QString("Idle (ms)"),
|
|
389 |
mLoadSettings);
|
|
390 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
391 |
mIdle->setContentWidgetData("minimum", 0);
|
|
392 |
|
|
393 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
394 |
QString("Random variance (%)"),
|
|
395 |
mLoadSettings);
|
|
396 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
397 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
398 |
}
|
|
399 |
|
|
400 |
// ---------------------------------------------------------------------------
|
|
401 |
|
|
402 |
void SettingsView::createAppsItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
403 |
{
|
|
404 |
//mLoadSettings = model->appendDataFormGroup(QString("Applications settings"), parent);
|
|
405 |
mLoadSettings = parent;
|
|
406 |
|
|
407 |
// DataFormItem for priority selection
|
|
408 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
409 |
QString("Priority"),
|
|
410 |
mLoadSettings);
|
|
411 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
412 |
|
|
413 |
mMaxParallelApps = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
414 |
QString("Max parallel applications"),
|
|
415 |
mLoadSettings);
|
|
416 |
mMaxParallelApps->setContentWidgetData("maximum" , 100);
|
|
417 |
mMaxParallelApps->setContentWidgetData("minimum", 0);
|
|
418 |
|
|
419 |
|
|
420 |
// DataFormItem for launching interval length selection
|
|
421 |
mLaunchingInterval = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
422 |
QString("Launching interval (ms)"),
|
|
423 |
mLoadSettings);
|
|
424 |
mLaunchingInterval->setContentWidgetData("maximum" , 999999999);
|
|
425 |
mLaunchingInterval->setContentWidgetData("minimum", 0);
|
|
426 |
|
|
427 |
// DataFormItem for key press type selection
|
|
428 |
mKeyPressType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
429 |
QString("Key press type"),
|
|
430 |
mLoadSettings);
|
|
431 |
mKeyPressType->setContentWidgetData(QString("items"), KEYPRESSTYPES);
|
|
432 |
|
|
433 |
// DataFormItem for heartbeat length selection
|
|
434 |
mHeartBeat = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
435 |
QString("Key press interval (ms)"),
|
|
436 |
mLoadSettings);
|
|
437 |
mHeartBeat->setContentWidgetData("maximum" , 999999999);
|
|
438 |
mHeartBeat->setContentWidgetData("minimum", 0);
|
|
439 |
|
|
440 |
// Random variance
|
|
441 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
442 |
QString("Random variance (%)"),
|
|
443 |
mLoadSettings);
|
|
444 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
445 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
446 |
}
|
|
447 |
|
|
448 |
// ---------------------------------------------------------------------------
|
|
449 |
|
|
450 |
void SettingsView::createPhotoItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
451 |
{
|
|
452 |
//mLoadSettings = model->appendDataFormGroup(QString("Camera settings"), parent);
|
|
453 |
mLoadSettings = parent;
|
|
454 |
|
|
455 |
// DataFormItem for priority selection
|
|
456 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
457 |
QString("Priority"),
|
|
458 |
mLoadSettings);
|
|
459 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
460 |
|
|
461 |
|
|
462 |
// DataFormItem for idle length selection
|
|
463 |
mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
464 |
QString("Idle (ms)"),
|
|
465 |
mLoadSettings);
|
|
466 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
467 |
mIdle->setContentWidgetData("minimum", 0);
|
|
468 |
|
|
469 |
// Random variance
|
|
470 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
471 |
QString("Random variance (%)"),
|
|
472 |
mLoadSettings);
|
|
473 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
474 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
475 |
}
|
|
476 |
|
|
477 |
// ---------------------------------------------------------------------------
|
|
478 |
|
|
479 |
void SettingsView::createBtItems(HbDataFormModel *model, HbDataFormModelItem *parent)
|
|
480 |
{
|
|
481 |
//mLoadSettings = model->appendDataFormGroup(QString("Bluetooth settings"), parent);
|
|
482 |
mLoadSettings = parent;
|
|
483 |
|
|
484 |
// DataFormItem for priority selection
|
|
485 |
mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
486 |
QString("Priority"),
|
|
487 |
mLoadSettings);
|
|
488 |
mPriority->setContentWidgetData(QString("items"), PRIORITIES);
|
|
489 |
|
|
490 |
|
|
491 |
// DataFormItem for idle length selection
|
|
492 |
mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
493 |
QString("Idle (ms)"),
|
|
494 |
mLoadSettings);
|
|
495 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
496 |
mIdle->setContentWidgetData("minimum", 0);
|
|
497 |
|
|
498 |
// Random variance
|
|
499 |
mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
500 |
QString("Random variance (%)"),
|
|
501 |
mLoadSettings);
|
|
502 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
503 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
504 |
}
|
|
505 |
|
|
506 |
// ---------------------------------------------------------------------------
|
|
507 |
// Load attributes from engine & set the data into each form model item:
|
|
508 |
|
|
509 |
void SettingsView::loadAttributes()
|
|
510 |
{
|
|
511 |
switch (mCmdId)
|
|
512 |
{
|
|
513 |
case ELoadGenCmdNewLoadCPULoad: {
|
|
514 |
mCPULoadAttributes = mEngineWrapper.getCpuLoadAttributes();
|
|
515 |
mPriority->setContentWidgetData(QString("selected"), mCPULoadAttributes.mPriority);
|
|
516 |
mLoadMode->setContentWidgetData(QString("selected"), mCPULoadAttributes.mMode);
|
|
517 |
mType->setContentWidgetData(QString("selected"), mCPULoadAttributes.mType);
|
|
518 |
|
|
519 |
if (mCPULoadAttributes.mType == ECpuLoadTypePeriodic) { //if (mCPULoadAttributes.mMode == ECpuLoadTypePeriodic) {
|
|
520 |
// Create and append to model these items: Length, Idle, Random variance, if load type is peridodic.
|
|
521 |
|
|
522 |
// DataFormItem for load length selection
|
|
523 |
mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
524 |
QString("Length (ms)"),
|
|
525 |
mLoadSettings);
|
|
526 |
mLength->setContentWidgetData("maximum" , 999999999);
|
|
527 |
mLength->setContentWidgetData("minimum", 0);
|
|
528 |
|
|
529 |
|
|
530 |
// DataFormItem for load length selection
|
|
531 |
mIdle = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
532 |
QString("Idle (ms)"),
|
|
533 |
mLoadSettings);
|
|
534 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
535 |
mIdle->setContentWidgetData("minimum", 0);
|
|
536 |
|
|
537 |
mRandomVar = mModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
538 |
QString("Random variance (%)"),
|
|
539 |
mLoadSettings);
|
|
540 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
541 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
542 |
|
|
543 |
mLength->setContentWidgetData(QString("text"), mCPULoadAttributes.mLength);
|
|
544 |
mIdle->setContentWidgetData(QString("text"), mCPULoadAttributes.mIdle);
|
|
545 |
mRandomVar->setContentWidgetData(QString("text"), mCPULoadAttributes.mRandomVariance);
|
|
546 |
}
|
|
547 |
|
|
548 |
// if there's more than one cpu available in the system,
|
|
549 |
// insert possibility to select which cpu the load is generated to
|
|
550 |
if (mCPULoadAttributes.mCpuCount > 1)
|
|
551 |
{
|
|
552 |
QStringList cpuArray;
|
|
553 |
cpuArray.append("Free scheduling");
|
|
554 |
// add cpus to list:
|
|
555 |
for (int i = 0; i < mCPULoadAttributes.mCpuCount; i++)
|
|
556 |
{
|
|
557 |
QString cpu = QString("CPU%1").arg(i);
|
|
558 |
cpuArray.append(cpu);
|
|
559 |
}
|
|
560 |
// "All CPUs" means that one thread is started for each CPU.
|
|
561 |
cpuArray.append("All CPUs");
|
|
562 |
|
|
563 |
mCpu = mModel->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem,
|
|
564 |
QString("CPU"),
|
|
565 |
mLoadSettings);
|
|
566 |
mCpu->setContentWidgetData(QString("items"), cpuArray);
|
|
567 |
|
|
568 |
if (mCPULoadAttributes.mCpu < 0) {
|
|
569 |
mCpu->setContentWidgetData(QString("selected"), 0);
|
|
570 |
}
|
|
571 |
|
|
572 |
else if (mCPULoadAttributes.mCpu == KCPUSelection_AllCPUs) {
|
|
573 |
mCpu->setContentWidgetData(QString("selected"), cpuArray.count()-1);
|
|
574 |
}
|
|
575 |
// CPU is defined, set the correct CPU as default selection in query list
|
|
576 |
else {
|
|
577 |
// mCpu starts from zero (i.e. CPU0 is first CPU), but index zero
|
|
578 |
// in settings Ui form item is reserved for "Free scheduling", hence iCpu+1.
|
|
579 |
mCpu->setContentWidgetData(QString("selected"), mCPULoadAttributes.mCpu+1);
|
|
580 |
}
|
|
581 |
}
|
|
582 |
break;
|
|
583 |
}
|
|
584 |
case ELoadGenCmdNewLoadEatMemory: {
|
|
585 |
mMemoryEatAttributes = mEngineWrapper.getMemoryEatAttributes();
|
|
586 |
mPriority->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mPriority);
|
|
587 |
mSource->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mSource);
|
|
588 |
mType->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mType);
|
|
589 |
|
|
590 |
if (mMemoryEatAttributes.mType == EMemoryEatTypeWavy) {
|
|
591 |
mMinAmountToBeLeft = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem,
|
|
592 |
QString("Min to be left (B)"),
|
|
593 |
mLoadSettings);
|
|
594 |
mMinAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999);
|
|
595 |
mMinAmountToBeLeft->setContentWidgetData("minimum", 0);
|
|
596 |
|
|
597 |
mMaxAmountToBeLeft = mModel->insertDataFormItem(4, HbDataFormModelItem::TextItem,
|
|
598 |
QString("Max to be left (B)"),
|
|
599 |
mLoadSettings);
|
|
600 |
mMaxAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999);
|
|
601 |
mMaxAmountToBeLeft->setContentWidgetData("minimum", 0);
|
|
602 |
|
|
603 |
mMinAmountToBeLeft->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomMinDes);
|
|
604 |
mMaxAmountToBeLeft->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomMaxDes);
|
|
605 |
}
|
|
606 |
else if (mMemoryEatAttributes.mType == EMemoryEatTypeMemoryToEat ||
|
|
607 |
mMemoryEatAttributes.mType == EMemoryEatTypeMemoryToBeLeft ) {
|
|
608 |
mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem,
|
|
609 |
QString("Amout(B)"),
|
|
610 |
mLoadSettings);
|
|
611 |
mAmount->setContentWidgetData("maximum" , 999999999999999);
|
|
612 |
mAmount->setContentWidgetData("minimum", 0);
|
|
613 |
|
|
614 |
mAmount->setContentWidgetData(QString("text"), mMemoryEatAttributes.mAmount);
|
|
615 |
}
|
|
616 |
mBuffer->setContentWidgetData(QString("text"), mMemoryEatAttributes.mBuffer);
|
|
617 |
mIdle->setContentWidgetData(QString("text"), mMemoryEatAttributes.mIdle);
|
|
618 |
mRandomVar->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomVariance);
|
|
619 |
break;
|
|
620 |
}
|
|
621 |
case ELoadGenCmdNewLoadPhoneCall: {
|
|
622 |
mPhoneCallAttributes = mEngineWrapper.getPhoneCallAttributes();
|
|
623 |
mPriority->setContentWidgetData(QString("selected"), mPhoneCallAttributes.mPriority);
|
|
624 |
mDestination->setContentWidgetData(QString("text"), mPhoneCallAttributes.mDestination);
|
|
625 |
mLength->setContentWidgetData(QString("text"), mPhoneCallAttributes.mLength);
|
|
626 |
mIdle->setContentWidgetData(QString("text"), mPhoneCallAttributes.mIdle);
|
|
627 |
mRandomVar->setContentWidgetData(QString("text"), mPhoneCallAttributes.mRandomVariance);
|
|
628 |
break;
|
|
629 |
}
|
|
630 |
case ELoadGenCmdNewLoadNetConn: {
|
|
631 |
mNetConnAttributes = mEngineWrapper.getNetConnAttributes();
|
|
632 |
mPriority->setContentWidgetData(QString("selected"), mNetConnAttributes.mPriority);
|
|
633 |
mDestination->setContentWidgetData(QString("text"), mNetConnAttributes.mDestination);
|
|
634 |
mIdle->setContentWidgetData(QString("text"), mNetConnAttributes.mIdle);
|
|
635 |
mRandomVar->setContentWidgetData(QString("text"), mNetConnAttributes.mRandomVariance);
|
|
636 |
break;
|
|
637 |
}
|
|
638 |
case ELoadGenCmdNewLoadKeyPress: {
|
|
639 |
mKeyPressAttributes = mEngineWrapper.getKeyPressAttributes();
|
|
640 |
mPriority->setContentWidgetData(QString("selected"), mKeyPressAttributes.mPriority);
|
|
641 |
mHeartBeat->setContentWidgetData(QString("text"), mKeyPressAttributes.mHeartBeat);
|
|
642 |
mRandomVar->setContentWidgetData(QString("text"), mKeyPressAttributes.mRandomVariance);
|
|
643 |
break;
|
|
644 |
}
|
|
645 |
case ELoadGenCmdNewLoadPointerEvent: {
|
|
646 |
mPointerEventAttributes = mEngineWrapper.getPointerEventAttributes();
|
|
647 |
mPriority->setContentWidgetData(QString("selected"), mPointerEventAttributes.mPriority);
|
|
648 |
mHeartBeat->setContentWidgetData(QString("text"), mPointerEventAttributes.mHeartBeat);
|
|
649 |
mRandomVar->setContentWidgetData(QString("text"), mPointerEventAttributes.mRandomVariance);
|
|
650 |
break;
|
|
651 |
}
|
|
652 |
case ELoadGenCmdNewLoadMessages: {
|
|
653 |
mMessageAttributes = mEngineWrapper.getMessageAttributes();
|
|
654 |
mPriority->setContentWidgetData(QString("selected"), mMessageAttributes.mPriority);
|
|
655 |
mType->setContentWidgetData(QString("selected"), mMessageAttributes.mMessageType);
|
|
656 |
mDestination->setContentWidgetData(QString("text"), mMessageAttributes.mDestination);
|
|
657 |
mAmount->setContentWidgetData(QString("text"), mMessageAttributes.mAmount);
|
|
658 |
mLength->setContentWidgetData(QString("text"), mMessageAttributes.mLength);
|
|
659 |
mIdle->setContentWidgetData(QString("text"), mMessageAttributes.mIdle);
|
|
660 |
mRandomVar->setContentWidgetData(QString("text"), mMessageAttributes.mRandomVariance);
|
|
661 |
break;
|
|
662 |
}
|
|
663 |
case ELoadGenCmdNewLoadApplications: {
|
|
664 |
mApplicationsAttributes = mEngineWrapper.getApplicationsAttributes();
|
|
665 |
mPriority->setContentWidgetData(QString("selected"), mApplicationsAttributes.mPriority);
|
|
666 |
mMaxParallelApps->setContentWidgetData(QString("text"), mApplicationsAttributes.mMaxOpen);
|
|
667 |
mHeartBeat->setContentWidgetData(QString("text"), mApplicationsAttributes.mHeartBeat);
|
|
668 |
mLaunchingInterval->setContentWidgetData(QString("text"), mApplicationsAttributes.mLaunchingInterval);
|
|
669 |
mKeyPressType->setContentWidgetData(QString("selected"), mApplicationsAttributes.mKeyPressType);
|
|
670 |
mRandomVar->setContentWidgetData(QString("text"), mApplicationsAttributes.mRandomVariance);
|
|
671 |
break;
|
|
672 |
}
|
|
673 |
case ELoadGenCmdNewLoadPhotoCaptures: {
|
|
674 |
mPhotoCaptureAttributes = mEngineWrapper.getPhotoCaptureAttributes();
|
|
675 |
mPriority->setContentWidgetData(QString("selected"), mPhotoCaptureAttributes.mPriority);
|
|
676 |
mIdle->setContentWidgetData(QString("text"), mPhotoCaptureAttributes.mIdle);
|
|
677 |
mRandomVar->setContentWidgetData(QString("text"), mPhotoCaptureAttributes.mRandomVariance);
|
|
678 |
|
|
679 |
// if there's any cameras avaialable in system, construct form item for it/them:
|
|
680 |
if (mPhotoCaptureAttributes.mCameraCount > 0)
|
|
681 |
{
|
|
682 |
QStringList devices;
|
|
683 |
// add cameras to list:
|
|
684 |
for (int i = 0; i < mPhotoCaptureAttributes.mCameraCount; i++)
|
|
685 |
{
|
|
686 |
QString cam = QString("Camera %1").arg(i);
|
|
687 |
devices.append(cam);
|
|
688 |
}
|
|
689 |
mCamera = mModel->insertDataFormItem(1, HbDataFormModelItem::RadioButtonListItem,
|
|
690 |
QString("Device"),
|
|
691 |
mLoadSettings);
|
|
692 |
mCamera->setContentWidgetData(QString("items"), devices);
|
|
693 |
mCamera->setContentWidgetData(QString("selected"), mPhotoCaptureAttributes.mCamera);
|
|
694 |
}
|
|
695 |
break;
|
|
696 |
}
|
|
697 |
case ELoadGenCmdNewLoadBluetooth: {
|
|
698 |
mBluetoothAttributes = mEngineWrapper.getBluetoothAttributes();
|
|
699 |
mPriority->setContentWidgetData(QString("selected"), mBluetoothAttributes.mPriority);
|
|
700 |
mIdle->setContentWidgetData(QString("text"), mBluetoothAttributes.mIdle);
|
|
701 |
mRandomVar->setContentWidgetData(QString("text"), mBluetoothAttributes.mRandomVariance);
|
|
702 |
break;
|
|
703 |
}
|
|
704 |
|
|
705 |
default: {
|
|
706 |
break;
|
|
707 |
}
|
|
708 |
}
|
|
709 |
}
|
|
710 |
|
|
711 |
// ---------------------------------------------------------------------------
|
|
712 |
|
|
713 |
void SettingsView::setDefaultSettings()
|
|
714 |
{
|
|
715 |
|
|
716 |
}
|
|
717 |
|
|
718 |
// ---------------------------------------------------------------------------
|
|
719 |
|
|
720 |
void SettingsView::backButtonPressed()
|
|
721 |
{
|
|
722 |
okExit();
|
|
723 |
}
|
|
724 |
|
|
725 |
// ---------------------------------------------------------------------------
|
|
726 |
|
|
727 |
void SettingsView::saveSettings()
|
|
728 |
{
|
|
729 |
switch (mCmdId) {
|
|
730 |
case ELoadGenCmdNewLoadCPULoad: {
|
|
731 |
saveCpuLoadSettings();
|
|
732 |
break;
|
|
733 |
}
|
|
734 |
case ELoadGenCmdNewLoadEatMemory: {
|
|
735 |
saveEatMemorySettings();
|
|
736 |
break;
|
|
737 |
}
|
|
738 |
case ELoadGenCmdNewLoadPhoneCall: {
|
|
739 |
savePhoneCallSettings();
|
|
740 |
break;
|
|
741 |
}
|
|
742 |
case ELoadGenCmdNewLoadNetConn: {
|
|
743 |
saveNetConnSettings();
|
|
744 |
break;
|
|
745 |
}
|
|
746 |
case ELoadGenCmdNewLoadKeyPress: {
|
|
747 |
saveKeyPressSettings();
|
|
748 |
break;
|
|
749 |
}
|
|
750 |
case ELoadGenCmdNewLoadPointerEvent: {
|
|
751 |
savePointerEventSettings();
|
|
752 |
break;
|
|
753 |
}
|
|
754 |
case ELoadGenCmdNewLoadMessages: {
|
|
755 |
saveMessageSettings();
|
|
756 |
break;
|
|
757 |
}
|
|
758 |
case ELoadGenCmdNewLoadApplications: {
|
|
759 |
saveApplicationsSettings();
|
|
760 |
break;
|
|
761 |
}
|
|
762 |
case ELoadGenCmdNewLoadPhotoCaptures: {
|
|
763 |
savePhotoSettings();
|
|
764 |
break;
|
|
765 |
}
|
|
766 |
case ELoadGenCmdNewLoadBluetooth: {
|
|
767 |
saveBtSettings();
|
|
768 |
break;
|
|
769 |
}
|
|
770 |
default: {
|
|
771 |
break;
|
|
772 |
}
|
|
773 |
}
|
|
774 |
}
|
|
775 |
|
|
776 |
// ---------------------------------------------------------------------------
|
|
777 |
|
|
778 |
void SettingsView::saveCpuLoadSettings()
|
|
779 |
{
|
|
780 |
mCPULoadAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
781 |
mCPULoadAttributes.mMode = mLoadMode->contentWidgetData("selected").toInt();
|
|
782 |
mCPULoadAttributes.mType = mType->contentWidgetData("selected").toInt();
|
|
783 |
if (mType->contentWidgetData("selected").toInt() == ECpuLoadTypePeriodic) {
|
|
784 |
// TODO: remove temp checks if (mLength != NULL) etc. when HbDataFormModelItem bugs fixed.
|
|
785 |
if (mLength != NULL) {
|
|
786 |
mCPULoadAttributes.mLength = mLength->contentWidgetData("text").toInt();
|
|
787 |
}
|
|
788 |
if (mIdle != NULL) {
|
|
789 |
mCPULoadAttributes.mIdle = mIdle->contentWidgetData("text").toInt();
|
|
790 |
}
|
|
791 |
if (mRandomVar != NULL) {
|
|
792 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
793 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
794 |
{
|
|
795 |
mCPULoadAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
796 |
}
|
|
797 |
else
|
|
798 |
{
|
|
799 |
mCPULoadAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
800 |
}
|
|
801 |
}
|
|
802 |
}
|
|
803 |
|
|
804 |
// we are running in SMP environment
|
|
805 |
if (mCPULoadAttributes.mCpuCount > 1)
|
|
806 |
{
|
|
807 |
TInt currentValueIndex = mCpu->contentWidgetData("selected").toInt();
|
|
808 |
// user selected a specific CPU in which the load thread should be run in.
|
|
809 |
if (currentValueIndex == 0)
|
|
810 |
{
|
|
811 |
// User selected "Free scheduling"
|
|
812 |
mCPULoadAttributes.mCpu = KCPUSelection_FreeScheduling;
|
|
813 |
}
|
|
814 |
else if( currentValueIndex == (mCpu->childCount()-1) )
|
|
815 |
{
|
|
816 |
// User selected "All CPUs", which is the last item in the form radio button selection list
|
|
817 |
mCPULoadAttributes.mCpu = KCPUSelection_AllCPUs;
|
|
818 |
}
|
|
819 |
else
|
|
820 |
{
|
|
821 |
// mCpu should start from zero (CPU0 is the first cpu)
|
|
822 |
// but zero in Ui form item index means "Free scheduling". CPU0 in
|
|
823 |
// index of form radio button list is at index 1, hence -1.
|
|
824 |
mCPULoadAttributes.mCpu = currentValueIndex - 1;
|
|
825 |
}
|
|
826 |
}
|
|
827 |
|
|
828 |
|
|
829 |
}
|
|
830 |
|
|
831 |
// ---------------------------------------------------------------------------
|
|
832 |
|
|
833 |
void SettingsView::saveEatMemorySettings()
|
|
834 |
{
|
|
835 |
mMemoryEatAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
836 |
mMemoryEatAttributes.mSource = mSource->contentWidgetData("selected").toInt();
|
|
837 |
mMemoryEatAttributes.mType = mType->contentWidgetData("selected").toInt();
|
|
838 |
|
|
839 |
if (mType->contentWidgetData("selected").toInt() == EMemoryEatTypeWavy) {
|
|
840 |
// TODO: remove temp checks if (mLength != NULL) etc. when HbDataFormModelItem bugs fixed.
|
|
841 |
if (mMinAmountToBeLeft != NULL) {
|
|
842 |
mMemoryEatAttributes.mRandomMin =
|
|
843 |
mMinAmountToBeLeft->contentWidgetData("text").toInt();
|
|
844 |
}
|
|
845 |
if (mMaxAmountToBeLeft != NULL) {
|
|
846 |
mMemoryEatAttributes.mRandomMax =
|
|
847 |
mMaxAmountToBeLeft->contentWidgetData("text").toInt();
|
|
848 |
}
|
|
849 |
}
|
|
850 |
else if (mType->contentWidgetData("selected").toInt() == EMemoryEatTypeMemoryToEat ||
|
|
851 |
mType->contentWidgetData("selected").toInt() == EMemoryEatTypeMemoryToBeLeft) {
|
|
852 |
if (mAmount != NULL) {
|
|
853 |
//mMemoryEatAttributes.mAmount = mAmount->contentWidgetData("text").toInt();
|
|
854 |
mMemoryEatAttributes.mAmount = mAmount->contentWidgetData("text").toDouble();
|
|
855 |
}
|
|
856 |
}
|
|
857 |
mMemoryEatAttributes.mBuffer = mBuffer->contentWidgetData("text").toInt();
|
|
858 |
mMemoryEatAttributes.mIdle = mIdle->contentWidgetData("text").toInt();
|
|
859 |
|
|
860 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
861 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
862 |
{
|
|
863 |
mMemoryEatAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
864 |
}
|
|
865 |
else
|
|
866 |
{
|
|
867 |
mMemoryEatAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
868 |
}
|
|
869 |
|
|
870 |
// swap min- & max values if they are in wrong order
|
|
871 |
if (mMemoryEatAttributes.mRandomMin > mMemoryEatAttributes.mRandomMax)
|
|
872 |
{
|
|
873 |
qint64 temp(mMemoryEatAttributes.mRandomMin);
|
|
874 |
mMemoryEatAttributes.mRandomMin = mMemoryEatAttributes.mRandomMax;
|
|
875 |
mMemoryEatAttributes.mRandomMax = temp;
|
|
876 |
}
|
|
877 |
}
|
|
878 |
|
|
879 |
// ---------------------------------------------------------------------------
|
|
880 |
|
|
881 |
void SettingsView::savePhoneCallSettings()
|
|
882 |
{
|
|
883 |
mPhoneCallAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
884 |
mPhoneCallAttributes.mLength = mLength->contentWidgetData("text").toInt();
|
|
885 |
mPhoneCallAttributes.mIdle = mIdle->contentWidgetData("text").toInt();
|
|
886 |
|
|
887 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
888 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
889 |
{
|
|
890 |
mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
891 |
}
|
|
892 |
else
|
|
893 |
{
|
|
894 |
mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
895 |
}
|
|
896 |
|
|
897 |
|
|
898 |
mPhoneCallAttributes.mDestination = mDestination->contentWidgetData("text").toString();
|
|
899 |
}
|
|
900 |
|
|
901 |
// ---------------------------------------------------------------------------
|
|
902 |
|
|
903 |
void SettingsView::saveNetConnSettings()
|
|
904 |
{
|
|
905 |
mPhoneCallAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
906 |
mPhoneCallAttributes.mIdle = mIdle->contentWidgetData("text").toInt();
|
|
907 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
908 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
909 |
{
|
|
910 |
mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
911 |
}
|
|
912 |
else
|
|
913 |
{
|
|
914 |
mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
915 |
}
|
|
916 |
mPhoneCallAttributes.mDestination = mDestination->contentWidgetData("text").toString();
|
|
917 |
}
|
|
918 |
|
|
919 |
// ---------------------------------------------------------------------------
|
|
920 |
|
|
921 |
void SettingsView::saveKeyPressSettings()
|
|
922 |
{
|
|
923 |
mKeyPressAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
924 |
mKeyPressAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt();
|
|
925 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
926 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
927 |
{
|
|
928 |
mKeyPressAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
929 |
}
|
|
930 |
else
|
|
931 |
{
|
|
932 |
mKeyPressAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
933 |
}
|
|
934 |
|
|
935 |
}
|
|
936 |
|
|
937 |
// ---------------------------------------------------------------------------
|
|
938 |
|
|
939 |
void SettingsView::savePointerEventSettings()
|
|
940 |
{
|
|
941 |
mPointerEventAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
942 |
mPointerEventAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt();
|
|
943 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
944 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
945 |
{
|
|
946 |
mPointerEventAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
947 |
}
|
|
948 |
else
|
|
949 |
{
|
|
950 |
mPointerEventAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
951 |
}
|
|
952 |
|
|
953 |
}
|
|
954 |
|
|
955 |
// ---------------------------------------------------------------------------
|
|
956 |
|
|
957 |
void SettingsView::saveMessageSettings()
|
|
958 |
{
|
|
959 |
mMessageAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
960 |
mMessageAttributes.mMessageType = mType->contentWidgetData("selected").toInt();
|
|
961 |
mMessageAttributes.mDestination = mDestination->contentWidgetData("text").toString();
|
|
962 |
int amount = mAmount->contentWidgetData("text").toInt();
|
|
963 |
if( amount >=0 && amount <= mAmount->contentWidgetData("maximum").toInt() )
|
|
964 |
{
|
|
965 |
mMessageAttributes.mAmount = mAmount->contentWidgetData("text").toInt();
|
|
966 |
}
|
|
967 |
else
|
|
968 |
{
|
|
969 |
mMessageAttributes.mAmount = mAmount->contentWidgetData("maximum").toInt();
|
|
970 |
}
|
|
971 |
mMessageAttributes.mLength = mLength->contentWidgetData("text").toInt();
|
|
972 |
mMessageAttributes.mIdle = mIdle->contentWidgetData("text").toInt();
|
|
973 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
974 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
975 |
{
|
|
976 |
mMessageAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
977 |
}
|
|
978 |
else
|
|
979 |
{
|
|
980 |
mMessageAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
981 |
}
|
|
982 |
|
|
983 |
}
|
|
984 |
|
|
985 |
// ---------------------------------------------------------------------------
|
|
986 |
|
|
987 |
void SettingsView::saveApplicationsSettings()
|
|
988 |
{
|
|
989 |
mApplicationsAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
990 |
int maxApps = mMaxParallelApps->contentWidgetData("text").toInt();
|
|
991 |
if( maxApps >=0 && maxApps <= mMaxParallelApps->contentWidgetData("maximum").toInt() )
|
|
992 |
{
|
|
993 |
mApplicationsAttributes.mMaxOpen = mMaxParallelApps->contentWidgetData("text").toInt();
|
|
994 |
}
|
|
995 |
else
|
|
996 |
{
|
|
997 |
mApplicationsAttributes.mMaxOpen = mMaxParallelApps->contentWidgetData("maximum").toInt();
|
|
998 |
}
|
|
999 |
mApplicationsAttributes.mLaunchingInterval = mLaunchingInterval->contentWidgetData("text").toInt();
|
|
1000 |
mApplicationsAttributes.mKeyPressType = mKeyPressType->contentWidgetData("selected").toInt();
|
|
1001 |
mPointerEventAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt();
|
|
1002 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
1003 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
1004 |
{
|
|
1005 |
mApplicationsAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
1006 |
}
|
|
1007 |
else
|
|
1008 |
{
|
|
1009 |
mApplicationsAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
1010 |
}
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
// ---------------------------------------------------------------------------
|
|
1014 |
|
|
1015 |
void SettingsView::savePhotoSettings()
|
|
1016 |
{
|
|
1017 |
mPhotoCaptureAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
1018 |
mPhotoCaptureAttributes.mIdle = mIdle->contentWidgetData("text").toInt();
|
|
1019 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
1020 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
1021 |
{
|
|
1022 |
mPhotoCaptureAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
1023 |
}
|
|
1024 |
else
|
|
1025 |
{
|
|
1026 |
mPhotoCaptureAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
1027 |
}
|
|
1028 |
|
|
1029 |
// update only if there's more than one camera device available in the system,
|
|
1030 |
// for use case of one camera available, the selection cannot be changed by user.
|
|
1031 |
if (mPhotoCaptureAttributes.mCameraCount > 1)
|
|
1032 |
{
|
|
1033 |
mPhotoCaptureAttributes.mCamera = mCamera->contentWidgetData("selected").toInt();
|
|
1034 |
}
|
|
1035 |
}
|
|
1036 |
|
|
1037 |
// ---------------------------------------------------------------------------
|
|
1038 |
|
|
1039 |
void SettingsView::saveBtSettings()
|
|
1040 |
{
|
|
1041 |
mBluetoothAttributes.mPriority = mPriority->contentWidgetData("selected").toInt();
|
|
1042 |
mBluetoothAttributes.mIdle = mIdle->contentWidgetData("text").toInt();
|
|
1043 |
int randVar = mRandomVar->contentWidgetData("text").toInt();
|
|
1044 |
if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() )
|
|
1045 |
{
|
|
1046 |
mBluetoothAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt();
|
|
1047 |
}
|
|
1048 |
else
|
|
1049 |
{
|
|
1050 |
mBluetoothAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt();
|
|
1051 |
}
|
|
1052 |
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
// ---------------------------------------------------------------------------
|
|
1056 |
|
|
1057 |
void SettingsView::cancelled()
|
|
1058 |
{
|
|
1059 |
connect(this,
|
|
1060 |
SIGNAL(loadCanclled()),
|
|
1061 |
&mEngineWrapper,
|
|
1062 |
SLOT(loadSettingsCanclled()));
|
|
1063 |
emit loadCanclled();
|
|
1064 |
|
|
1065 |
mMainWindow.removeView(this);
|
|
1066 |
mMainWindow.setCurrentView(&mMainView, true);
|
|
1067 |
deleteLater();
|
|
1068 |
}
|
|
1069 |
|
|
1070 |
// ---------------------------------------------------------------------------
|
|
1071 |
|
|
1072 |
void SettingsView::okExit()
|
|
1073 |
{
|
|
1074 |
saveSettings();
|
|
1075 |
setLoadAttributes();
|
|
1076 |
connect(this,
|
|
1077 |
SIGNAL(loadCompleted(TLoadGenCommandIds)),
|
|
1078 |
&mEngineWrapper,
|
|
1079 |
SLOT(loadAddedOrEdited(TLoadGenCommandIds)));
|
|
1080 |
emit loadCompleted(mCmdId);
|
|
1081 |
|
|
1082 |
mMainWindow.removeView(this);
|
|
1083 |
mMainWindow.setCurrentView(&mMainView, true);
|
|
1084 |
deleteLater();
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
// ---------------------------------------------------------------------------
|
|
1088 |
|
|
1089 |
void SettingsView::setLoadAttributes()
|
|
1090 |
{
|
|
1091 |
switch (mCmdId) {
|
|
1092 |
case ELoadGenCmdNewLoadCPULoad: {
|
|
1093 |
mEngineWrapper.setCpuLoadAttributes(mCPULoadAttributes);
|
|
1094 |
break;
|
|
1095 |
}
|
|
1096 |
case ELoadGenCmdNewLoadEatMemory: {
|
|
1097 |
mEngineWrapper.setMemoryEatAttributes(mMemoryEatAttributes);
|
|
1098 |
break;
|
|
1099 |
}
|
|
1100 |
case ELoadGenCmdNewLoadPhoneCall: {
|
|
1101 |
mEngineWrapper.setPhoneCallAttributes(mPhoneCallAttributes);
|
|
1102 |
break;
|
|
1103 |
}
|
|
1104 |
case ELoadGenCmdNewLoadNetConn: {
|
|
1105 |
mEngineWrapper.setNetConnAttributes(mNetConnAttributes);
|
|
1106 |
break;
|
|
1107 |
}
|
|
1108 |
case ELoadGenCmdNewLoadKeyPress: {
|
|
1109 |
mEngineWrapper.setKeyPressAttributes(mKeyPressAttributes);
|
|
1110 |
break;
|
|
1111 |
}
|
|
1112 |
case ELoadGenCmdNewLoadPointerEvent: {
|
|
1113 |
mEngineWrapper.setPointerEventAttributes(mPointerEventAttributes);
|
|
1114 |
break;
|
|
1115 |
}
|
|
1116 |
case ELoadGenCmdNewLoadMessages: {
|
|
1117 |
mEngineWrapper.setMessageAttributes(mMessageAttributes);
|
|
1118 |
break;
|
|
1119 |
}
|
|
1120 |
case ELoadGenCmdNewLoadApplications: {
|
|
1121 |
mEngineWrapper.setApplicationsAttributes(mApplicationsAttributes);
|
|
1122 |
break;
|
|
1123 |
}
|
|
1124 |
case ELoadGenCmdNewLoadPhotoCaptures: {
|
|
1125 |
mEngineWrapper.setPhotoCaptureAttributes(mPhotoCaptureAttributes);
|
|
1126 |
break;
|
|
1127 |
}
|
|
1128 |
case ELoadGenCmdNewLoadBluetooth: {
|
|
1129 |
mEngineWrapper.setBluetoothAttributes(mBluetoothAttributes);
|
|
1130 |
break;
|
|
1131 |
}
|
|
1132 |
default: {
|
|
1133 |
break;
|
|
1134 |
}
|
|
1135 |
}
|
|
1136 |
}
|
|
1137 |
|
|
1138 |
// ---------------------------------------------------------------------------
|
|
1139 |
|
|
1140 |
void SettingsView::dataItemDisplayed(const QModelIndex &index)
|
|
1141 |
{
|
|
1142 |
HbDataFormViewItem *item = static_cast<HbDataFormViewItem*>(mSettingForm->itemByIndex(index));
|
|
1143 |
HbWidget *contentWidget = static_cast<HbWidget*>(item->dataItemContentWidget());
|
|
1144 |
switch(mCmdId){
|
|
1145 |
case ELoadGenCmdNewLoadCPULoad: {
|
|
1146 |
if (index.row() == 2) { // Cpu load type selection is in this row: periodic vs. continuous
|
|
1147 |
mModes = static_cast<HbRadioButtonList*>(contentWidget);
|
|
1148 |
connect(mModes , SIGNAL(itemSelected(int)), this, SLOT(selectionChanged(int)));
|
|
1149 |
}
|
|
1150 |
break;
|
|
1151 |
}
|
|
1152 |
case ELoadGenCmdNewLoadEatMemory: {
|
|
1153 |
// Memory eat type is in this row: mem to eat/ mem to be left vs. alternate min/max
|
|
1154 |
if (index.row() == 2) {
|
|
1155 |
mTypes = static_cast<HbRadioButtonList*>(contentWidget );
|
|
1156 |
connect(mTypes ,SIGNAL(itemSelected(int)), this,SLOT(selectionChanged(int)));
|
|
1157 |
}
|
|
1158 |
break;
|
|
1159 |
}
|
|
1160 |
}
|
|
1161 |
}
|
|
1162 |
|
|
1163 |
// ---------------------------------------------------------------------------
|
|
1164 |
|
|
1165 |
void SettingsView::selectionChanged(int index)
|
|
1166 |
{
|
|
1167 |
switch (mCmdId) {
|
|
1168 |
case ELoadGenCmdNewLoadCPULoad: {
|
|
1169 |
if (index == ECpuLoadTypePeriodic) {
|
|
1170 |
// if periodic selected, add Length, Idle and Random variance to settings,
|
|
1171 |
// if they does not exist yet.
|
|
1172 |
if (mLength == NULL) {
|
|
1173 |
mLength = mModel->insertDataFormItem(3,
|
|
1174 |
HbDataFormModelItem::TextItem,
|
|
1175 |
QString("Length (ms)"),
|
|
1176 |
mLoadSettings);
|
|
1177 |
mLength->setContentWidgetData("maximum" , 999999999);
|
|
1178 |
mLength->setContentWidgetData("minimum", 0);
|
|
1179 |
mLength->setContentWidgetData(QString("text"), mCPULoadAttributes.mLength);
|
|
1180 |
}
|
|
1181 |
if (mIdle == NULL) {
|
|
1182 |
// DataFormItem for load length selection
|
|
1183 |
mIdle = mModel->insertDataFormItem(4,
|
|
1184 |
HbDataFormModelItem::TextItem,
|
|
1185 |
QString("Idle (ms)"),
|
|
1186 |
mLoadSettings);
|
|
1187 |
mIdle->setContentWidgetData("maximum" , 999999999);
|
|
1188 |
mIdle->setContentWidgetData("minimum", 0);
|
|
1189 |
mIdle->setContentWidgetData(QString("text"), mCPULoadAttributes.mIdle);
|
|
1190 |
}
|
|
1191 |
if (mRandomVar == NULL) {
|
|
1192 |
mRandomVar = mModel->insertDataFormItem(5,
|
|
1193 |
HbDataFormModelItem::TextItem,
|
|
1194 |
QString("Random variance (%)"),
|
|
1195 |
mLoadSettings);
|
|
1196 |
mRandomVar->setContentWidgetData("maximum" , 100);
|
|
1197 |
mRandomVar->setContentWidgetData("minimum", 0);
|
|
1198 |
mRandomVar->setContentWidgetData(QString("text"), mCPULoadAttributes.mRandomVariance);
|
|
1199 |
}
|
|
1200 |
}
|
|
1201 |
else if (index == ECpuLoadTypeContinuous) {
|
|
1202 |
// if continuous selected, remove existing Length, Idle and Random variance from settings view:
|
|
1203 |
// if they does not exist do nothing.
|
|
1204 |
if (mLength != NULL) {
|
|
1205 |
mModel->removeItem(mLength);
|
|
1206 |
mLength = NULL;
|
|
1207 |
}
|
|
1208 |
if (mIdle != NULL) {
|
|
1209 |
mModel->removeItem(mIdle);
|
|
1210 |
mIdle = NULL;
|
|
1211 |
}
|
|
1212 |
if (mRandomVar != NULL) {
|
|
1213 |
mModel->removeItem(mRandomVar);
|
|
1214 |
mRandomVar = NULL;
|
|
1215 |
}
|
|
1216 |
}
|
|
1217 |
break;
|
|
1218 |
}
|
|
1219 |
case ELoadGenCmdNewLoadEatMemory: {
|
|
1220 |
if (index == EMemoryEatTypeWavy) {
|
|
1221 |
// remove one item, if exists.
|
|
1222 |
if (mAmount != NULL) {
|
|
1223 |
mModel->removeItem(mAmount);
|
|
1224 |
mAmount = NULL;
|
|
1225 |
}
|
|
1226 |
// insert two new item rows, if not exists.
|
|
1227 |
if (mMinAmountToBeLeft == NULL) {
|
|
1228 |
mMinAmountToBeLeft = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem,
|
|
1229 |
QString("Min to be left (B)"),
|
|
1230 |
mLoadSettings);
|
|
1231 |
mMinAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999);
|
|
1232 |
mMinAmountToBeLeft->setContentWidgetData("minimum", 0);
|
|
1233 |
mMinAmountToBeLeft->setContentWidgetData( QString("text"),mMemoryEatAttributes.mRandomMin );
|
|
1234 |
}
|
|
1235 |
if (mMaxAmountToBeLeft == NULL) {
|
|
1236 |
mMaxAmountToBeLeft = mModel->insertDataFormItem(4, HbDataFormModelItem::TextItem,
|
|
1237 |
QString("Max to be left (B)"),
|
|
1238 |
mLoadSettings);
|
|
1239 |
mMaxAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999);
|
|
1240 |
mMaxAmountToBeLeft->setContentWidgetData("minimum", 0);
|
|
1241 |
mMaxAmountToBeLeft->setContentWidgetData( QString("text"),mMemoryEatAttributes.mRandomMax );
|
|
1242 |
}
|
|
1243 |
}
|
|
1244 |
else if (index == EMemoryEatTypeMemoryToEat || index == EMemoryEatTypeMemoryToBeLeft) {
|
|
1245 |
// remove two item rows, if exists.
|
|
1246 |
if (mMinAmountToBeLeft != NULL) {
|
|
1247 |
mModel->removeItem(mMinAmountToBeLeft);
|
|
1248 |
mMinAmountToBeLeft = NULL;
|
|
1249 |
}
|
|
1250 |
if (mMaxAmountToBeLeft != NULL) {
|
|
1251 |
mModel->removeItem(mMaxAmountToBeLeft);
|
|
1252 |
mMaxAmountToBeLeft = NULL;
|
|
1253 |
}
|
|
1254 |
// insert one item, if not exists.
|
|
1255 |
if (mAmount == NULL) {
|
|
1256 |
mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem,
|
|
1257 |
QString("Amout(B)"),
|
|
1258 |
mLoadSettings);
|
|
1259 |
mAmount->setContentWidgetData("maximum" , 99999999999999);
|
|
1260 |
mAmount->setContentWidgetData("minimum", 0);
|
|
1261 |
mAmount->setContentWidgetData( QString("text"),mMemoryEatAttributes.mAmount );
|
|
1262 |
}
|
|
1263 |
}
|
|
1264 |
}
|
|
1265 |
default: {
|
|
1266 |
break;
|
|
1267 |
}
|
|
1268 |
}
|
|
1269 |
}
|
|
1270 |
|
|
1271 |
// ---------------------------------------------------------------------------
|