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 "mainview.h"
|
|
19 |
#include "enginewrapper.h"
|
|
20 |
#include "notifications.h"
|
|
21 |
#include "loadgen.hrh"
|
|
22 |
#include <hblabel.h>
|
|
23 |
#include <hbmenu.h>
|
|
24 |
#include <hbaction.h>
|
|
25 |
#include <hbmessagebox.h>
|
|
26 |
#include <hbmainwindow.h>
|
|
27 |
#include <hbapplication.h>
|
|
28 |
//#include <hbcommonnote.h>
|
|
29 |
//#include <hbconfirmationquery.h>
|
|
30 |
#include <hbprogressdialog.h>
|
|
31 |
#include <hbtextedit.h>
|
|
32 |
#include <hblistview.h>
|
|
33 |
#include <hbselectiondialog.h>
|
|
34 |
#include <hbtoolbar.h>
|
|
35 |
|
|
36 |
#include <QGraphicsLinearLayout>
|
|
37 |
#include <QStandardItemModel>
|
|
38 |
#include <QStandardItem>
|
|
39 |
#include <QSignalMapper>
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
|
|
43 |
MainView::MainView(HbMainWindow &mainWindow) :
|
|
44 |
mMainWindow(mainWindow),
|
|
45 |
mEngineWrapper(0),
|
|
46 |
mIsLoadListEmpty(true),
|
|
47 |
mStopAll(NULL),
|
|
48 |
mSuspendAll(NULL),
|
|
49 |
mResumeAll(NULL),
|
|
50 |
mPrevExpandedItem(-1)
|
|
51 |
|
|
52 |
{
|
|
53 |
}
|
|
54 |
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
|
|
57 |
MainView::~MainView()
|
|
58 |
{
|
|
59 |
if (mEngineWrapper != 0) {
|
|
60 |
delete mEngineWrapper;
|
|
61 |
}
|
|
62 |
delete mListModel;
|
|
63 |
delete mListView;
|
|
64 |
delete mSm;
|
|
65 |
}
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
|
|
69 |
void MainView::init(HbApplication &app)
|
|
70 |
{
|
|
71 |
//this->setTitle("Load Gener.");
|
|
72 |
this->setTitle("Load Generator");
|
|
73 |
mEngineWrapper = new EngineWrapper(mMainWindow, *this);
|
|
74 |
int error = mEngineWrapper->init();
|
|
75 |
Q_ASSERT_X(error == 1, "LoadGen", "Engine initialization failed");
|
|
76 |
createMenu(app);
|
|
77 |
loadListIinit();
|
|
78 |
|
|
79 |
|
|
80 |
//create toolbar showing launch popup
|
|
81 |
HbToolBar *toolBar = this->toolBar();
|
|
82 |
|
|
83 |
|
|
84 |
HbIcon newLoadIcon(QString(":/newload.svg"));
|
|
85 |
newLoadIcon.setFlags(newLoadIcon.flags() | HbIcon::Colorized );
|
|
86 |
HbIcon pauseIcon(QString(":/pause.svg"));
|
|
87 |
pauseIcon.setFlags(pauseIcon.flags() | HbIcon::Colorized );
|
|
88 |
HbIcon playIcon(QString(":/play.svg"));
|
|
89 |
playIcon.setFlags(playIcon.flags() | HbIcon::Colorized );
|
|
90 |
HbIcon stopIcon(QString(":/cross.svg"));
|
|
91 |
stopIcon.setFlags(stopIcon.flags() | HbIcon::Colorized );
|
|
92 |
|
|
93 |
HbAction *actionNewLoad = new HbAction(newLoadIcon,"", toolBar);
|
|
94 |
HbAction *actionSuspendAll = new HbAction(pauseIcon,"", toolBar);
|
|
95 |
HbAction *actionResumeAll = new HbAction(playIcon,"", toolBar);
|
|
96 |
HbAction *actionStopAll = new HbAction(stopIcon,"", toolBar);
|
|
97 |
|
|
98 |
toolBar->addAction( actionNewLoad );
|
|
99 |
toolBar->addAction( actionSuspendAll );
|
|
100 |
toolBar->addAction( actionResumeAll );
|
|
101 |
toolBar->addAction( actionStopAll );
|
|
102 |
|
|
103 |
toolBar->adjustSize();
|
|
104 |
//toolBar->childrenBoundingRect(). //adjustSize();
|
|
105 |
connect(actionNewLoad, SIGNAL( triggered() ), this, SLOT( NewLoad() ));
|
|
106 |
connect(actionSuspendAll, SIGNAL( triggered() ), this, SLOT( suspendAllLoads() ));
|
|
107 |
connect(actionResumeAll, SIGNAL(triggered()), this, SLOT( resumeAllLoads() ));
|
|
108 |
connect(actionStopAll, SIGNAL(triggered()), this, SLOT( stopAllLoads() ));
|
|
109 |
}
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
|
|
113 |
void MainView::createMenu(HbApplication &app)
|
|
114 |
{
|
|
115 |
HbMenu *menu = this->menu();
|
|
116 |
|
|
117 |
// signal mapper for identifying the different command actions
|
|
118 |
// in executeCommand() handler function:
|
|
119 |
mSm = new QSignalMapper(this);
|
|
120 |
connect(mSm, SIGNAL(mapped(int)), this, SLOT(executeMenuCommand(int)));
|
|
121 |
|
|
122 |
if (menu != NULL) {
|
|
123 |
// Temp work-around for menu item bug in Orbit Wk38,
|
|
124 |
// sub menu cannot contain more than 6 functional action items!
|
|
125 |
// two sub menus created to fix this problem.
|
|
126 |
mLoadSubMenu1 = menu->addMenu("New loads");
|
|
127 |
//mLoadSubMenu2 = menu->addMenu("More new loads");
|
|
128 |
mCpuLoadAction = mLoadSubMenu1->addAction("CPU load");
|
|
129 |
connect(mCpuLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
130 |
mSm->setMapping(mCpuLoadAction, ELoadGenCmdNewLoadCPULoad);
|
|
131 |
|
|
132 |
mMemoryEatLoadAction = mLoadSubMenu1->addAction("Eat memory");
|
|
133 |
connect(mMemoryEatLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
134 |
mSm->setMapping(mMemoryEatLoadAction, ELoadGenCmdNewLoadEatMemory);
|
|
135 |
|
|
136 |
mPhoneCallLoadAction = mLoadSubMenu1->addAction("Phone calls");
|
|
137 |
connect(mPhoneCallLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
138 |
mSm->setMapping(mPhoneCallLoadAction, ELoadGenCmdNewLoadPhoneCall);
|
|
139 |
|
|
140 |
mMessagesLoadAction = mLoadSubMenu1->addAction("Messages");
|
|
141 |
connect(mMessagesLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
142 |
mSm->setMapping(mMessagesLoadAction, ELoadGenCmdNewLoadMessages);
|
|
143 |
//TODO to be fixed using replacement for downloadmanager
|
|
144 |
|
|
145 |
mNetConnLoadAction = mLoadSubMenu1->addAction("Network conn.");
|
|
146 |
connect(mNetConnLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
147 |
mSm->setMapping(mNetConnLoadAction, ELoadGenCmdNewLoadNetConn);
|
|
148 |
|
|
149 |
//mKeyPressLoadAction = mLoadSubMenu2->addAction("Key presses");
|
|
150 |
mKeyPressLoadAction = mLoadSubMenu1->addAction("Key presses");
|
|
151 |
connect(mKeyPressLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
152 |
mSm->setMapping(mKeyPressLoadAction, ELoadGenCmdNewLoadKeyPress);
|
|
153 |
|
|
154 |
//mAppsLoadAction = mLoadSubMenu2->addAction("Applications");
|
|
155 |
mAppsLoadAction = mLoadSubMenu1->addAction("Applications");
|
|
156 |
connect(mAppsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
157 |
mSm->setMapping(mAppsLoadAction, ELoadGenCmdNewLoadApplications);
|
|
158 |
|
|
159 |
//mPhotoCapturesLoadAction = mLoadSubMenu2->addAction("Photo captures");
|
|
160 |
mPhotoCapturesLoadAction = mLoadSubMenu1->addAction("Photo captures");
|
|
161 |
connect(mPhotoCapturesLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
162 |
mSm->setMapping(mPhotoCapturesLoadAction, ELoadGenCmdNewLoadPhotoCaptures);
|
|
163 |
|
|
164 |
//mBtActionsLoadAction = mLoadSubMenu2->addAction("Bluetooth actions");
|
|
165 |
mBtActionsLoadAction = mLoadSubMenu1->addAction("Bluetooth actions");
|
|
166 |
connect(mBtActionsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
167 |
mSm->setMapping(mBtActionsLoadAction, ELoadGenCmdNewLoadBluetooth);
|
|
168 |
|
|
169 |
//mPointerEventsLoadAction = mLoadSubMenu2->addAction("Pointer events");
|
|
170 |
mPointerEventsLoadAction = mLoadSubMenu1->addAction("Pointer events");
|
|
171 |
connect(mPointerEventsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map()));
|
|
172 |
mSm->setMapping(mPointerEventsLoadAction, ELoadGenCmdNewLoadPointerEvent);
|
|
173 |
|
|
174 |
mActionPerfMon = menu->addAction("Launch PerfMon");
|
|
175 |
connect(mActionPerfMon, SIGNAL(triggered()), this, SLOT( launchPerfMon()));
|
|
176 |
|
|
177 |
mActionAbout = menu->addAction("About");
|
|
178 |
connect(mActionAbout, SIGNAL(triggered()), this, SLOT( showAboutPopup()));
|
|
179 |
|
|
180 |
mActionExit = menu->addAction("Exit");
|
|
181 |
connect(mActionExit, SIGNAL(triggered()), &app, SLOT(quit()));
|
|
182 |
|
|
183 |
// menu dynamic update
|
|
184 |
connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
|
185 |
}
|
|
186 |
}
|
|
187 |
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
|
|
190 |
void MainView::loadListIinit()
|
|
191 |
{
|
|
192 |
if(mListItemExpanded.count())
|
|
193 |
{
|
|
194 |
mListItemExpanded.clear();
|
|
195 |
}
|
|
196 |
// Create list view and model for it
|
|
197 |
mListView = new HbListView(this);
|
|
198 |
mListView->setItemPrototype( new LoadGenListItem( *mEngineWrapper, mListView ) );
|
|
199 |
mListModel = new QStandardItemModel(this);
|
|
200 |
mListModel->setItemPrototype(new LoadGenLoadItem());
|
|
201 |
mListView->setModel(mListModel);
|
|
202 |
mListView->setSelectionMode(HbListView::NoSelection);
|
|
203 |
mListView->setVisible( false ); //HighlightMode(HbItemHighlight::Hidden);
|
|
204 |
|
|
205 |
connect(mListView,
|
|
206 |
SIGNAL(longPressed(HbAbstractViewItem*, QPointF)),
|
|
207 |
this,
|
|
208 |
SLOT(handleLoadListEvent(HbAbstractViewItem*, QPointF)));
|
|
209 |
|
|
210 |
connect(mListView, SIGNAL( activated( const QModelIndex& ) ), this, SLOT( activated( const QModelIndex& )));
|
|
211 |
|
|
212 |
|
|
213 |
// Create layout and add list view there:
|
|
214 |
QGraphicsLinearLayout *mainlayout = new QGraphicsLinearLayout(Qt::Vertical, this);
|
|
215 |
mainlayout->addItem(mListView);
|
|
216 |
mainlayout->setAlignment(mListView, Qt::AlignCenter);
|
|
217 |
setLayout(mainlayout);
|
|
218 |
}
|
|
219 |
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
|
|
222 |
void MainView::showAboutPopup()
|
|
223 |
{
|
|
224 |
Notifications::about();
|
|
225 |
}
|
|
226 |
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
|
|
229 |
void MainView::executeMenuCommand(int cmd)
|
|
230 |
{
|
|
231 |
mEngineWrapper->startNewLoad(cmd);
|
|
232 |
}
|
|
233 |
|
|
234 |
// ---------------------------------------------------------------------------
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
void MainView::activated( const QModelIndex& index)
|
|
239 |
{
|
|
240 |
LoadGenListItem* listItem = qobject_cast<LoadGenListItem*>( mListView->viewItem( index.row() ) );
|
|
241 |
|
|
242 |
if( listItem )
|
|
243 |
{
|
|
244 |
if( mPrevExpandedItem == index.row() || mPrevExpandedItem == -1 )
|
|
245 |
{
|
|
246 |
LoadGenLoadItem* item = (LoadGenLoadItem*)(mListModel->item( index.row(), index.column() ));
|
|
247 |
item->setExpanded( !item->getExpandedState() );
|
|
248 |
mPrevExpandedItem = index.row();
|
|
249 |
}
|
|
250 |
else
|
|
251 |
{
|
|
252 |
LoadGenLoadItem* item = (LoadGenLoadItem*)(mListModel->item( index.row(), index.column() ));
|
|
253 |
item->setExpanded( !item->getExpandedState() );
|
|
254 |
LoadGenLoadItem* prevItem = (LoadGenLoadItem*)(mListModel->item( mPrevExpandedItem, 0 ));
|
|
255 |
if( prevItem ) //in case the load was stopped
|
|
256 |
{
|
|
257 |
if(prevItem->getExpandedState())
|
|
258 |
{
|
|
259 |
prevItem->setExpanded( !prevItem->getExpandedState() );
|
|
260 |
}
|
|
261 |
mPrevExpandedItem = index.row();
|
|
262 |
}
|
|
263 |
|
|
264 |
}
|
|
265 |
|
|
266 |
mListView->reset();
|
|
267 |
}
|
|
268 |
}
|
|
269 |
/*
|
|
270 |
LoadGenLoadItem* item = (LoadGenLoadItem*)(mListModel->item( index.row(), index.column() ));
|
|
271 |
item->setExpanded( !item->getExpandedState() );
|
|
272 |
//close previous expanded item
|
|
273 |
if( mPrevExpandedItem == -1 )
|
|
274 |
{
|
|
275 |
mPrevExpandedItem = index.row();
|
|
276 |
}
|
|
277 |
else if( mPrevExpandedItem != index.row() )
|
|
278 |
{
|
|
279 |
LoadGenLoadItem* prevItem = (LoadGenLoadItem*)(mListModel->item( mPrevExpandedItem, 0 ));
|
|
280 |
if( prevItem ) //in case that was stopped
|
|
281 |
{
|
|
282 |
prevItem->setExpanded( !prevItem->getExpandedState() );
|
|
283 |
mPrevExpandedItem = index.row();
|
|
284 |
}
|
|
285 |
else
|
|
286 |
{
|
|
287 |
mPrevExpandedItem = -1;
|
|
288 |
}
|
|
289 |
}
|
|
290 |
mListView->reset();
|
|
291 |
*/
|
|
292 |
// ---------------------------------------------------------------------------
|
|
293 |
|
|
294 |
void MainView::handleLoadListEvent(HbAbstractViewItem */*listViewItem*/, const QPointF &/*coords*/)
|
|
295 |
{
|
|
296 |
const QStringList items = (QStringList() << "Stop" << "Resume/Suspend" << "Edit");
|
|
297 |
HbSelectionDialog *dlg = new HbSelectionDialog();
|
|
298 |
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
|
299 |
dlg->setStringItems(items);
|
|
300 |
dlg->setSelectionMode(HbAbstractItemView::SingleSelection);
|
|
301 |
dlg->open(this, SLOT(ItemActionPopupClosed(HbAction*)));
|
|
302 |
}
|
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
|
|
306 |
void MainView::ItemActionPopupClosed(HbAction* action)
|
|
307 |
{
|
|
308 |
HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
|
|
309 |
if(!action && dlg->selectedItems().count()){
|
|
310 |
int userSelectionIndex = dlg->selectedItems().at(0).toInt();
|
|
311 |
// all operations for selected list item only. Query selected load list item index from model.
|
|
312 |
if (userSelectionIndex == 0) {
|
|
313 |
// stop selected load from the load list:
|
|
314 |
stopLoad(false);
|
|
315 |
}
|
|
316 |
else if (userSelectionIndex == 1) {
|
|
317 |
// Suspend or Resume
|
|
318 |
mEngineWrapper->suspendOrResumeSelectedOrHighlightedItems();
|
|
319 |
}
|
|
320 |
else {
|
|
321 |
// current selected row number from the load list.
|
|
322 |
int selectedRow = mListView->selectionModel()->currentIndex().row();
|
|
323 |
// edit load setttings:
|
|
324 |
mEngineWrapper->loadEdit(selectedRow);
|
|
325 |
}
|
|
326 |
}
|
|
327 |
}
|
|
328 |
|
|
329 |
void MainView::LoadEdit()
|
|
330 |
{
|
|
331 |
int selectedRow = mListView->selectionModel()->currentIndex().row();
|
|
332 |
|
|
333 |
mEngineWrapper->loadEdit(selectedRow);
|
|
334 |
}
|
|
335 |
// --------------------------------------------------------------------------
|
|
336 |
|
|
337 |
void MainView::stopAllLoads()
|
|
338 |
{
|
|
339 |
stopLoad(true);
|
|
340 |
}
|
|
341 |
|
|
342 |
// ---------------------------------------------------------------------------
|
|
343 |
|
|
344 |
bool MainView::stopLoad(bool stopAll)
|
|
345 |
{
|
|
346 |
int success = false;
|
|
347 |
if (mListView != NULL) {
|
|
348 |
if (stopAll == true) {
|
|
349 |
success = mEngineWrapper->stopLoad(stopAll);
|
|
350 |
mIsLoadListEmpty = true;
|
|
351 |
}
|
|
352 |
else {
|
|
353 |
success = mEngineWrapper->stopLoad(stopAll);
|
|
354 |
}
|
|
355 |
}
|
|
356 |
return success;
|
|
357 |
}
|
|
358 |
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
|
|
361 |
void MainView::updateMenu()
|
|
362 |
{
|
|
363 |
if (mIsLoadListEmpty != true) {
|
|
364 |
if (mStopAll == NULL) {
|
|
365 |
mStopAll = new HbAction("Stop all", menu());
|
|
366 |
connect(mStopAll, SIGNAL(triggered()), this, SLOT(stopAllLoads()));
|
|
367 |
menu()->insertAction(mActionAbout, mStopAll);
|
|
368 |
}
|
|
369 |
else{
|
|
370 |
mStopAll->setVisible(true);
|
|
371 |
}
|
|
372 |
if (mSuspendAll == NULL) {
|
|
373 |
mSuspendAll = new HbAction("Suspend all", menu());
|
|
374 |
connect(mSuspendAll, SIGNAL(triggered()), this, SLOT(suspendAllLoads()));
|
|
375 |
menu()->insertAction(mActionAbout, mSuspendAll);
|
|
376 |
}
|
|
377 |
else{
|
|
378 |
mSuspendAll->setVisible(true);
|
|
379 |
}
|
|
380 |
if (mResumeAll == NULL) {
|
|
381 |
mResumeAll = new HbAction("Resume all", menu());
|
|
382 |
connect(mResumeAll, SIGNAL(triggered()), this, SLOT(resumeAllLoads()));
|
|
383 |
menu()->insertAction(mActionAbout, mResumeAll);
|
|
384 |
}
|
|
385 |
else{
|
|
386 |
mResumeAll->setVisible(true);
|
|
387 |
}
|
|
388 |
}
|
|
389 |
else if (mIsLoadListEmpty == true) {
|
|
390 |
if (mStopAll != NULL && mStopAll->text() == "Stop all") {
|
|
391 |
mStopAll->setVisible(false);
|
|
392 |
}
|
|
393 |
if (mSuspendAll != NULL && mSuspendAll->text() == "Suspend all") {
|
|
394 |
mSuspendAll->setVisible(false);
|
|
395 |
}
|
|
396 |
if (mResumeAll != NULL && mResumeAll->text() == "Resume all") {
|
|
397 |
mSuspendAll->setVisible(false);
|
|
398 |
}
|
|
399 |
}
|
|
400 |
}
|
|
401 |
|
|
402 |
|
|
403 |
// ---------------------------------------------------------------------------
|
|
404 |
|
|
405 |
int MainView::currentItemIndex()
|
|
406 |
{
|
|
407 |
return mListView->selectionModel()->currentIndex().row();
|
|
408 |
}
|
|
409 |
|
|
410 |
// ---------------------------------------------------------------------------
|
|
411 |
|
|
412 |
void MainView::setCurrentItemIndex(int index)
|
|
413 |
{
|
|
414 |
QModelIndex newIndex = mListView->model()->index(index, 0);
|
|
415 |
mListView->selectionModel()->setCurrentIndex(newIndex,
|
|
416 |
QItemSelectionModel::SelectCurrent);
|
|
417 |
//mListView->setCurrentIndex( index ); //setCurrentRow(index);
|
|
418 |
}
|
|
419 |
|
|
420 |
// ---------------------------------------------------------------------------
|
|
421 |
|
|
422 |
void MainView::launchPerfMon()
|
|
423 |
{
|
|
424 |
mEngineWrapper->launchPerfMonApp();
|
|
425 |
}
|
|
426 |
|
|
427 |
// ---------------------------------------------------------------------------
|
|
428 |
|
|
429 |
QList<int> MainView::listSelectionIndexes()
|
|
430 |
{
|
|
431 |
QList<int> indices;
|
|
432 |
if (mListView != NULL) {
|
|
433 |
QItemSelectionModel *selectionModel = mListView->selectionModel();
|
|
434 |
if (selectionModel->hasSelection()) {
|
|
435 |
QModelIndexList modelIndexes = selectionModel->selectedIndexes();
|
|
436 |
QModelIndex index;
|
|
437 |
foreach (index, modelIndexes) {
|
|
438 |
indices.append(index.row());
|
|
439 |
}
|
|
440 |
}
|
|
441 |
}
|
|
442 |
return indices;
|
|
443 |
}
|
|
444 |
|
|
445 |
// --------------------------------------------------------------------------------------------
|
|
446 |
|
|
447 |
void MainView::NewLoad()
|
|
448 |
{
|
|
449 |
const QStringList items = (QStringList() << "CPU Load" << "Eat memory" << "Phone calls" << "Messages" << "Network conn." << "Key presses" << "Applications" << "Photo captures" << "Bluetooth actions" << "Pointer events" );
|
|
450 |
HbSelectionDialog *dlg = new HbSelectionDialog();
|
|
451 |
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
|
452 |
dlg->setStringItems(items);
|
|
453 |
dlg->setSelectionMode(HbAbstractItemView::SingleSelection);
|
|
454 |
dlg->open(this, SLOT(loadActionPopupClosed(HbAction*)));
|
|
455 |
}
|
|
456 |
|
|
457 |
|
|
458 |
void MainView::loadActionPopupClosed(HbAction* action)
|
|
459 |
{
|
|
460 |
HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
|
|
461 |
if(!action && dlg->selectedItems().count()){
|
|
462 |
int userSelectionIndex = dlg->selectedItems().at(0).toInt();
|
|
463 |
// all operations for selected list item only. Query selected load list item index from model.
|
|
464 |
if (userSelectionIndex == 0) {
|
|
465 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadCPULoad);
|
|
466 |
}
|
|
467 |
if (userSelectionIndex == 1) {
|
|
468 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadEatMemory);
|
|
469 |
}
|
|
470 |
if (userSelectionIndex == 2) {
|
|
471 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadPhoneCall);
|
|
472 |
}
|
|
473 |
if (userSelectionIndex == 3) {
|
|
474 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadMessages);
|
|
475 |
}
|
|
476 |
if (userSelectionIndex == 4) {
|
|
477 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadNetConn);
|
|
478 |
}
|
|
479 |
if (userSelectionIndex == 5) {
|
|
480 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadKeyPress);
|
|
481 |
}
|
|
482 |
if (userSelectionIndex == 6) {
|
|
483 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadApplications);
|
|
484 |
}
|
|
485 |
if (userSelectionIndex == 7) {
|
|
486 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadPhotoCaptures);
|
|
487 |
}
|
|
488 |
if (userSelectionIndex == 8) {
|
|
489 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadBluetooth);
|
|
490 |
}
|
|
491 |
if (userSelectionIndex == 9) {
|
|
492 |
mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadPointerEvent);
|
|
493 |
}
|
|
494 |
|
|
495 |
}
|
|
496 |
}
|
|
497 |
|
|
498 |
// --------------------------------------------------------------------------------------------
|
|
499 |
void MainView::suspendAllLoads()
|
|
500 |
{
|
|
501 |
mEngineWrapper->suspendAllLoadItems();
|
|
502 |
}
|
|
503 |
|
|
504 |
// ---------------------------------------------------------------------------
|
|
505 |
|
|
506 |
void MainView::resumeAllLoads()
|
|
507 |
{
|
|
508 |
mEngineWrapper->resumeAllLoadItems();
|
|
509 |
}
|
|
510 |
|
|
511 |
void MainView::clearListSelection()
|
|
512 |
{
|
|
513 |
if (mListView != NULL) {
|
|
514 |
mListView->clearSelection();
|
|
515 |
}
|
|
516 |
}
|
|
517 |
|
|
518 |
// ---------------------------------------------------------------------------
|
|
519 |
|
|
520 |
void MainView::setLoadListData(QStringList& items)
|
|
521 |
{
|
|
522 |
QString loadItem;
|
|
523 |
QString iconName;
|
|
524 |
mListItemExpanded.clear();
|
|
525 |
|
|
526 |
if (mListView) {
|
|
527 |
mListView->setSelectionMode(HbListView::MultiSelection);
|
|
528 |
mListView->setVisible(true); //setHighlightMode(HbItemHighlight::AlwaysVisible);
|
|
529 |
mListModel->clear();
|
|
530 |
}
|
|
531 |
if (items.count() > 0) {
|
|
532 |
mIsLoadListEmpty = false;
|
|
533 |
}
|
|
534 |
else if (items.count() == 0) {
|
|
535 |
mIsLoadListEmpty = true;
|
|
536 |
}
|
|
537 |
for (int i = 0; i < items.count(); i++) {
|
|
538 |
|
|
539 |
LoadGenLoadItem *item = new LoadGenLoadItem();
|
|
540 |
//QStandardItem *item = new QStandardItem();
|
|
541 |
|
|
542 |
loadItem = items.at(i);
|
|
543 |
if (loadItem.startsWith("1")) {
|
|
544 |
iconName = ":/paused.svg";
|
|
545 |
item->setSuspended(true);
|
|
546 |
}
|
|
547 |
else {
|
|
548 |
iconName = ":/active.svg";
|
|
549 |
item->setSuspended(false);
|
|
550 |
}
|
|
551 |
// remove icon indicator info from string
|
|
552 |
// to show in load in load list
|
|
553 |
loadItem.remove(0,2);
|
|
554 |
item->setText(loadItem);
|
|
555 |
item->setIcon(QIcon(iconName));
|
|
556 |
if(i == mPrevExpandedItem)
|
|
557 |
{
|
|
558 |
item->setExpanded(false);
|
|
559 |
//item->setExpanded(true);
|
|
560 |
}
|
|
561 |
else
|
|
562 |
{
|
|
563 |
item->setExpanded(false);
|
|
564 |
}
|
|
565 |
// set new load to correct row in load list
|
|
566 |
mListModel->appendRow(item); //insertRow(i, item);
|
|
567 |
}
|
|
568 |
}
|
|
569 |
|
|
570 |
// ---------------------------------------------------------------------------
|