|
1 #include <e32debug.h> |
|
2 |
|
3 #ifdef _DEBUG |
|
4 #define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y ); |
|
5 #else |
|
6 #define RDEBUG( x, y ) |
|
7 #endif |
|
8 |
|
9 #include <devicelockaccessapi.h> |
|
10 #include <secuicodequerydialog.h> |
|
11 #include <gsmerror.h> |
|
12 #include <secuisecuritysettings.h> |
|
13 #include <secui.h> |
|
14 #include <secuisecurityhandler.h> |
|
15 #include <keyguardaccessapi.h> |
|
16 #include <avkondomainpskeys.h> // KPSUidAvkonDomain, KAknKeyguardStatus, TAknKeyguardStatus |
|
17 #include <startupdomainpskeys.h> // KStartupSecurityCodeQueryStatus |
|
18 #include <coreapplicationuisdomainpskeys.h> // KCoreAppUIsAutolockStatus |
|
19 #include <hwrmdomainpskeys.h> |
|
20 #include <settingsinternalcrkeys.h> |
|
21 #include <keylockpolicyapi.h> |
|
22 #include <etelmm.h> |
|
23 #include <rmmcustomapi.h> |
|
24 #include <securitynotification.h> |
|
25 #include <centralrepository.h> |
|
26 |
|
27 const TInt KPhoneIndex(0); |
|
28 const TInt KTriesToConnectServer(2); |
|
29 const TInt KTimeBeforeRetryingServerConnection(50000); |
|
30 const TUid KAutolockUid = |
|
31 { |
|
32 0x100059B5 |
|
33 }; |
|
34 #include <Etel3rdParty.h> |
|
35 |
|
36 _LIT( KMmTsyModuleName, "PhoneTsy"); |
|
37 |
|
38 #include <QStandardItemModel> |
|
39 #include <QStandardItem> |
|
40 #include <QTextStream> |
|
41 #include <QFile> |
|
42 #include <QFileInfo> |
|
43 #include <QIODevice> |
|
44 #include <QGraphicsTextItem> |
|
45 #include <QGraphicsLinearLayout> |
|
46 #include <QDirModel> |
|
47 #include <QFileSystemWatcher> |
|
48 #include <QItemSelectionModel> |
|
49 #include <QBrush> |
|
50 #include <QPointer> |
|
51 #include <QDebug> |
|
52 #include <QTimer> |
|
53 #include <QFileSystemModel> |
|
54 |
|
55 #include <hbapplication.h> |
|
56 #include <hbmainwindow.h> |
|
57 #include <hbinstance.h> |
|
58 #include <hbnamespace.h> |
|
59 #include <hbaction.h> |
|
60 #include <hbmenu.h> |
|
61 #include <hbtoolbar.h> |
|
62 #include <hblabel.h> |
|
63 #include <hbglobal.h> |
|
64 #include <hbicon.h> |
|
65 #include <hbview.h> |
|
66 #include <hbpushbutton.h> |
|
67 #include <hbtextitem.h> |
|
68 #include <hbdataformmodel.h> |
|
69 #ifdef HB_EFFECTS |
|
70 #include <hbeffect.h> |
|
71 #endif // HB_EFFECTS |
|
72 #include <hbtreeview.h> |
|
73 #include <hbtreeviewitem.h> |
|
74 #include <hbinputdialog.h> |
|
75 #include <hbframebackground.h> |
|
76 #include <hbnotificationdialog.h> |
|
77 #include <hbmodeliterator.h> |
|
78 |
|
79 #include "../../Autolock/PubSub/securityuisprivatepskeys.h" |
|
80 |
|
81 #include "contentwidget.h" |
|
82 #include "dirviewitem.h" |
|
83 #include "mailtreeviewitem.h" |
|
84 #include "modelfactory.h" |
|
85 #include "treedataform.h" |
|
86 #include "greenoddviewitem.h" |
|
87 #include "brownevenviewitem.h" |
|
88 |
|
89 // model names for submenu |
|
90 const QStringList KModelNames = (QStringList() << "Default" << "Simple" << "Deep" << "Flat" << /*"Mail" <<*/"Mixed" << "QDirModel" << "QFileSystemModel" << "GreenOddBrownEven"); |
|
91 |
|
92 // orientation submenu items |
|
93 const QStringList TextStyles = (QStringList() << "Primary" << "Secondary"); |
|
94 const QStringList CustomWidgets = (QStringList() << "Empty" << "Zoom slider" << "Volume Slider" << "Progress bar" << "Button" << "Text Editor"); |
|
95 const QStringList LeftColumnWidgets = (QStringList() << "Empty" << "Icon" << "Text"); |
|
96 const QStringList RightColumnWidgets = (QStringList() << "Empty" << "Icon" << "Text"); |
|
97 const QStringList MiddleColumnWidgets = (QStringList() << "Empty" << "Four Small Icons" << "Three Large Icons" << "Label" << "Zoom slider" << "Volume Slider" << "Progress bar" |
|
98 << "Button" << "Text Editor"); |
|
99 |
|
100 // Custom role for storing the tree item depth. |
|
101 const int KMyCustomDepthRole = Qt::UserRole + 18; |
|
102 |
|
103 class BannerLabel : public HbLabel |
|
104 { |
|
105 public: |
|
106 BannerLabel(QGraphicsItem *parent) : |
|
107 HbLabel(parent) |
|
108 { |
|
109 QFont currentfont(font()); |
|
110 currentfont.setBold(true); |
|
111 currentfont.setPixelSize(18); |
|
112 setFont(currentfont); |
|
113 setAlignment(Qt::AlignCenter); |
|
114 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
115 } |
|
116 |
|
117 protected: |
|
118 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
119 { |
|
120 QPen oldPen = painter->pen(); |
|
121 painter->setPen(QPen(QColor(200, 200, 200, 150))); |
|
122 painter->setBrush(QBrush(QColor(200, 200, 200, 150), Qt::SolidPattern)); |
|
123 painter->drawRect(option->rect); |
|
124 painter->setPen(oldPen); |
|
125 HbLabel::paint(painter, option, widget); |
|
126 } |
|
127 }; |
|
128 |
|
129 class HbFileSystemTreeView : public HbTreeView |
|
130 { |
|
131 |
|
132 public: |
|
133 explicit HbFileSystemTreeView(QGraphicsItem *parent = 0) : |
|
134 HbTreeView(parent) |
|
135 { |
|
136 } |
|
137 |
|
138 virtual ~HbFileSystemTreeView() |
|
139 { |
|
140 } |
|
141 |
|
142 protected: |
|
143 virtual void emitActivated(const QModelIndex &modelIndex); |
|
144 |
|
145 protected slots: |
|
146 virtual void modelLayoutChanged(); |
|
147 |
|
148 private: |
|
149 QPersistentModelIndex mTopIndex; |
|
150 |
|
151 }; |
|
152 |
|
153 void HbFileSystemTreeView::emitActivated(const QModelIndex &modelIndex) |
|
154 { |
|
155 QList<HbAbstractViewItem *> visibleItems = this->visibleItems(); |
|
156 int count = visibleItems.count(); |
|
157 if (count > 0) |
|
158 { |
|
159 mTopIndex = visibleItems.at(0)->modelIndex(); |
|
160 } |
|
161 else |
|
162 { |
|
163 mTopIndex = QPersistentModelIndex(); |
|
164 } |
|
165 emit activated(modelIndex); |
|
166 } |
|
167 |
|
168 void HbFileSystemTreeView::modelLayoutChanged() |
|
169 { |
|
170 if (!mTopIndex.isValid()) |
|
171 { |
|
172 mTopIndex = modelIterator()->nextIndex(rootIndex()); |
|
173 } |
|
174 scrollTo(mTopIndex, HbAbstractItemView::PositionAtTop); |
|
175 } |
|
176 |
|
177 // ======== MEMBER FUNCTIONS ======== |
|
178 ContentWidget::ContentWidget(QString& imagesDir, HbMainWindow *mainWindow) : |
|
179 HbView(0), mImagesDir(imagesDir), mWindow(mainWindow), mTreeView(0), mRemoveModelAction(0), mFileWatcher(0), mModelType(noModel), mMainMenu(0), mCountAdded(0), mMute(false), |
|
180 mSoftKeyQuitAction(new HbAction(Hb::QuitNaviAction, this)), mSoftKeyConfirmAction(new HbAction(Hb::ConfirmNaviAction, this)), mSoftKeyBackAction(new HbAction( |
|
181 Hb::BackNaviAction, this)), mSoftKeyDoneAction(new HbAction(Hb::DoneNaviAction, this)), mInfoLabel(new BannerLabel(this)), mMainlayout(0), mForm(0), |
|
182 mDetailView(0), mTextOfNewItem("Added item"), mScrollHint(HbAbstractItemView::EnsureVisible), mDepth(1), mPopupModel(0), mTimer(0), mItemsToAdd(0) |
|
183 { |
|
184 mSoftKeyQuitAction->setText("Quit"); |
|
185 connect(mSoftKeyQuitAction, SIGNAL(triggered()), this, SLOT(backButtonClicked())); |
|
186 connect(mSoftKeyConfirmAction, SIGNAL(triggered()), this, SLOT(confirmDelete())); |
|
187 mSoftKeyBackAction->setText("Back"); |
|
188 connect(mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(backButtonClicked())); |
|
189 |
|
190 setNavigationAction( mSoftKeyQuitAction); |
|
191 |
|
192 mMainlayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
193 mMainlayout->setContentsMargins(0, 0, 0, 0); |
|
194 setLayout( mMainlayout); |
|
195 |
|
196 updateTextLabel(0); |
|
197 mInfoLabel->hide(); |
|
198 |
|
199 // parameter can be whatever at initialisation phase except, if populateFileSystemModel is populated |
|
200 createAndInitTreeView( treeModelSimple); |
|
201 populateTreeModelSimple(); |
|
202 |
|
203 setMainMenu(); |
|
204 |
|
205 #ifdef HB_EFFECTS |
|
206 HbEffect::add("listItem", ":RadioButtonList/resources/animation.xml"); |
|
207 #endif // HB_EFFECTS |
|
208 } |
|
209 |
|
210 ContentWidget::~ContentWidget() |
|
211 { |
|
212 if (mModelType == dirModel) |
|
213 { |
|
214 // Model is owned by ContentWidget. |
|
215 delete mTreeView->model(); |
|
216 } |
|
217 } |
|
218 |
|
219 void ContentWidget::changeMirroring() |
|
220 { |
|
221 if (HbApplication::layoutDirection() == Qt::LeftToRight) |
|
222 { |
|
223 HbApplication::setLayoutDirection(Qt::RightToLeft); |
|
224 mMirroring->setText("Turn mirroring off"); |
|
225 } |
|
226 else |
|
227 { |
|
228 HbApplication::setLayoutDirection(Qt::LeftToRight); |
|
229 mMirroring->setText("Turn mirroring on"); |
|
230 } |
|
231 } |
|
232 |
|
233 void ContentWidget::scrollToTarget() |
|
234 { |
|
235 if (mTreeView) |
|
236 { |
|
237 mTreeView->scrollTo(mTarget, mScrollHint); |
|
238 } |
|
239 } |
|
240 |
|
241 void ContentWidget::changeOrientation() |
|
242 { |
|
243 if (mainWindow()->orientation() == Qt::Vertical) |
|
244 { |
|
245 mWindow->setOrientation(Qt::Horizontal); |
|
246 mOrientationSwitch->setText("Change to portrait"); |
|
247 } |
|
248 else |
|
249 { |
|
250 mWindow->setOrientation(Qt::Vertical); |
|
251 mOrientationSwitch->setText("Change to landscape"); |
|
252 } |
|
253 } |
|
254 |
|
255 void ContentWidget::showSettings() |
|
256 { |
|
257 mWindow->removeView(this); |
|
258 |
|
259 mForm = new TreeDataForm(*mTreeView, this); |
|
260 mForm->setHeading("Tree Settings"); |
|
261 |
|
262 HbView *newView = mWindow->addView(mForm); |
|
263 newView->setNavigationAction(mSoftKeyBackAction); |
|
264 postEvents(); |
|
265 |
|
266 mForm->setInputData(ViewFuteDataForm::Settings, ViewFuteDataForm::ScrollHint, mScrollHint); |
|
267 mForm->setDepth(mDepth); |
|
268 mForm->setDirViewItemEnabled(mModelType == dirModel); |
|
269 |
|
270 mForm->setIndentation(mTreeView->indentation()); |
|
271 |
|
272 mForm->populateSettings(); |
|
273 HbDataFormModel *settingsFormModel = mForm->dataModel(); |
|
274 mForm->setModel(settingsFormModel); |
|
275 } |
|
276 |
|
277 void ContentWidget::keyPressEvent(QKeyEvent *event) |
|
278 { |
|
279 if (event->key() == Qt::Key_H) |
|
280 { |
|
281 mWindow->setOrientation(Qt::Horizontal); |
|
282 event->accept(); |
|
283 } |
|
284 else if (event->key() == Qt::Key_V) |
|
285 { |
|
286 mWindow->setOrientation(Qt::Vertical); |
|
287 event->accept(); |
|
288 } |
|
289 else if (event->key() == Qt::Key_S) |
|
290 { |
|
291 mTreeView->scrollTo(mTreeView->model()->index(0, 0), mScrollHint); |
|
292 } |
|
293 else if (event->key() == Qt::Key_R) |
|
294 { |
|
295 qreal left, top, right, bottom = 0; |
|
296 mMainlayout->getContentsMargins(&left, &top, &right, &bottom); |
|
297 if (left != 0) |
|
298 { |
|
299 mMainlayout->setContentsMargins(0, 0, 0, 0); |
|
300 } |
|
301 else |
|
302 { |
|
303 mMainlayout->setContentsMargins(9, 9, 9, 9); |
|
304 } |
|
305 } |
|
306 else |
|
307 { |
|
308 HbView::keyPressEvent(event); |
|
309 } |
|
310 } |
|
311 |
|
312 void ContentWidget::refresh() |
|
313 { |
|
314 if (mTreeView && qobject_cast<QDirModel *> (mTreeView->model())) |
|
315 { |
|
316 qobject_cast<QDirModel *> (mTreeView->model())->refresh(); |
|
317 } |
|
318 } |
|
319 |
|
320 void ContentWidget::removeModel() |
|
321 { |
|
322 mRemoveModelAction->setEnabled(false); |
|
323 |
|
324 if (mModelType != noModel) |
|
325 { |
|
326 delete mTreeView->model(); |
|
327 mTreeView->setModel(0); |
|
328 } |
|
329 mModelType = noModel; |
|
330 mTarget = QModelIndex(); |
|
331 } |
|
332 |
|
333 void ContentWidget::launchInPopup() |
|
334 { |
|
335 mPopupModel = ModelFactory::populateTreeModelMixed(); |
|
336 |
|
337 HbTreeView *popupTree = new HbTreeView(); |
|
338 popupTree->setItemPixmapCacheEnabled(true); |
|
339 |
|
340 popupTree->setIndentation(0); |
|
341 popupTree->setModel(mPopupModel); |
|
342 |
|
343 // inherit some properties from view |
|
344 if (mTreeView) |
|
345 { |
|
346 popupTree->setSelectionMode(mTreeView->selectionMode()); |
|
347 } |
|
348 |
|
349 HbDialog *popup = new HbDialog(); |
|
350 connect(popup, SIGNAL(aboutToClose()), this, SLOT(aboutToClose())); |
|
351 popup->setAttribute(Qt::WA_DeleteOnClose); |
|
352 popup->setDismissPolicy(HbPopup::TapOutside); |
|
353 popup->setTimeout(HbPopup::NoTimeout); |
|
354 HbLabel *label = new HbLabel(tr("View in popup")); |
|
355 popup->setHeadingWidget(label); |
|
356 popup->setContentWidget(popupTree); |
|
357 if (mWindow->orientation() == Qt::Vertical) |
|
358 { |
|
359 popup->setMinimumWidth(2 * mWindow->layoutRect().width() / 3); |
|
360 } |
|
361 else |
|
362 { |
|
363 popup->setMinimumWidth(mWindow->layoutRect().width() / 2); |
|
364 } |
|
365 |
|
366 popup->show(); |
|
367 } |
|
368 |
|
369 void ContentWidget::changeModel(HbAction* action) |
|
370 { |
|
371 // removeModel resets mModelType |
|
372 removeModel(); |
|
373 int modelType = action->data().toInt(); |
|
374 if (modelType != noModel) |
|
375 { |
|
376 createAndInitTreeView(modelType); |
|
377 |
|
378 mRemoveModelAction->setEnabled(true); |
|
379 |
|
380 switch (modelType) |
|
381 { |
|
382 case treeModelDefault: |
|
383 populateTreeModelDefault(); |
|
384 break; |
|
385 case treeModelSimple: |
|
386 populateTreeModelSimple(); |
|
387 break; |
|
388 case treeModelDeep: |
|
389 populateTreeModelDeep(); |
|
390 break; |
|
391 case treeModelFlat: |
|
392 populateTreeModelFlat(); |
|
393 break; |
|
394 /*case treeModelMail: |
|
395 populateTreeModelMail(); |
|
396 break;*/ |
|
397 case treeModelMixed: |
|
398 populateTreeModelMixed(); |
|
399 break; |
|
400 case dirModel: |
|
401 populateDirModel(); |
|
402 break; |
|
403 case fileSystemModel: |
|
404 populateFileSystemModel(); |
|
405 break; |
|
406 case greenOddBrownEvenModel: |
|
407 populateGreenOddBrownEvenModel(); |
|
408 break; |
|
409 default: |
|
410 // error |
|
411 break; |
|
412 } |
|
413 expand(mTreeView->model(), mTreeView->rootIndex(), mDepth); |
|
414 } |
|
415 resetItemManagementMenu(); |
|
416 } |
|
417 |
|
418 void ContentWidget::editItem(HbAction* action) |
|
419 { |
|
420 int itemOperation = action->data().toInt(); |
|
421 |
|
422 switch (itemOperation) |
|
423 { |
|
424 case addItemOperation: |
|
425 addItem(); |
|
426 break; |
|
427 case changeItemOperation: |
|
428 changeItem(); |
|
429 break; |
|
430 case removeItemOperation: |
|
431 removeItems(); |
|
432 break; |
|
433 case removeAllItemsOperation: |
|
434 removeAllItems(); |
|
435 break; |
|
436 case expandAllOperation: |
|
437 expandAll(); |
|
438 break; |
|
439 case collapseAllOperation: |
|
440 collapseAll(); |
|
441 break; |
|
442 case autoInsertOneOperation: |
|
443 autoInsertOne(); |
|
444 break; |
|
445 case autoRemoveOneOperation: |
|
446 autoRemoveOne(); |
|
447 break; |
|
448 case simulateVisible: |
|
449 // just checkable item - nothing to do |
|
450 break; |
|
451 case resetDuringSimulation: |
|
452 // just checkable item - nothing to do |
|
453 break; |
|
454 case simulateMultipleFastInsertsOperation: |
|
455 simulateMultipleFastInserts(); |
|
456 break; |
|
457 case simulateMultipleFastRemovalsOperation: |
|
458 simulateMultipleFastRemovals(); |
|
459 break; |
|
460 case selectAll: |
|
461 mTreeView->selectAll(); |
|
462 break; |
|
463 case unselect: |
|
464 mTreeView->clearSelection(); |
|
465 break; |
|
466 default: |
|
467 // error |
|
468 break; |
|
469 } |
|
470 } |
|
471 |
|
472 void ContentWidget::insertItemAboveTarget() |
|
473 { |
|
474 if (mTarget.isValid()) |
|
475 { |
|
476 //bool ok = false; |
|
477 //QString text = HbInputDialog::getText("Enter item text:", mTextOfNewItem, &ok); |
|
478 HbInputDialog ::queryText("Enter item text:",this ,SLOT(insertItemAboveTargetClosed(int)),mTextOfNewItem); |
|
479 //if (ok) { |
|
480 // mTextOfNewItem = text; |
|
481 |
|
482 // QStandardItemModel* model = qobject_cast<QStandardItemModel *>(mTreeView->model()); |
|
483 // int row = mTarget.row(); |
|
484 // model->insertRow(row, mTarget.parent()); |
|
485 |
|
486 // Set text. |
|
487 // if (mTextOfNewItem != QString()) { |
|
488 // QModelIndex index = model->index(row, 0, mTarget.parent()); |
|
489 // QStandardItem* newItem = model->itemFromIndex(index); |
|
490 // newItem->setText(mTextOfNewItem); |
|
491 // } |
|
492 //} |
|
493 } |
|
494 } |
|
495 |
|
496 void ContentWidget::insertItemBelowTarget() |
|
497 { |
|
498 if (mTarget.isValid()) |
|
499 { |
|
500 //bool ok = false; |
|
501 //QString text = HbInputDialog::getText("Enter item text:", mTextOfNewItem, &ok); |
|
502 HbInputDialog ::queryText("Enter item text:",this ,SLOT(insertItemBelowTargetClosed(int)),mTextOfNewItem); |
|
503 //if (ok) { |
|
504 // mTextOfNewItem = text; |
|
505 |
|
506 // QStandardItemModel* model = qobject_cast<QStandardItemModel *>(mTreeView->model()); |
|
507 // int row = mTarget.row() + 1; |
|
508 // model->insertRow(row, mTarget.parent()); |
|
509 |
|
510 // Set text. |
|
511 // if (mTextOfNewItem != QString()) { |
|
512 // QModelIndex index = model->index(row, 0, mTarget.parent()); |
|
513 // QStandardItem* newItem = model->itemFromIndex(index); |
|
514 // newItem->setText(mTextOfNewItem); |
|
515 // } |
|
516 //} |
|
517 } |
|
518 } |
|
519 |
|
520 void ContentWidget::populateTreeModelDefault() |
|
521 { |
|
522 if (mTreeView) |
|
523 { |
|
524 delete mTreeView->model(); |
|
525 |
|
526 QStandardItemModel* model = ModelFactory::populateTreeModelDefault(); |
|
527 mTreeView->setModel(model, new HbTreeViewItem); |
|
528 mTreeView->setIndentation(-1); |
|
529 |
|
530 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
531 |
|
532 mModelType = treeModelDefault; |
|
533 } |
|
534 } |
|
535 |
|
536 void ContentWidget::populateTreeModelSimple() |
|
537 { |
|
538 if (mTreeView) |
|
539 { |
|
540 delete mTreeView->model(); |
|
541 |
|
542 // Keeps following line here: it is easiest debugable model |
|
543 //QStandardItemModel* model = ModelFactory::populateTreeModelSimpleOfSimplest(); |
|
544 QStandardItemModel* model = ModelFactory::populateTreeModelSimple(); |
|
545 mTreeView->setModel(model, new HbTreeViewItem); |
|
546 mTreeView->setIndentation(-1); |
|
547 |
|
548 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
549 |
|
550 mModelType = treeModelSimple; |
|
551 } |
|
552 } |
|
553 |
|
554 void ContentWidget::populateGreenOddBrownEvenModel() |
|
555 { |
|
556 if (mTreeView) |
|
557 { |
|
558 delete mTreeView->model(); |
|
559 |
|
560 QStandardItemModel* model = ModelFactory::populateGreenOddBrownEvenModel(); |
|
561 |
|
562 QList<HbAbstractViewItem *> prototypes; |
|
563 HbListViewItem *prototype1 = new HbTreeViewItem(mTreeView); |
|
564 prototype1->resize(0, 0); |
|
565 prototypes.append(prototype1); |
|
566 |
|
567 GreenOddViewItem *prototype2 = new GreenOddViewItem(mTreeView); |
|
568 prototype2->resize(0, 0); |
|
569 prototypes.append(prototype2); |
|
570 |
|
571 BrownEvenViewItem *prototype3 = new BrownEvenViewItem(mTreeView); |
|
572 prototype3->resize(0, 0); |
|
573 prototypes.append(prototype3); |
|
574 |
|
575 mTreeView->setItemPrototypes(prototypes); |
|
576 mTreeView->setIndentation(-1); |
|
577 |
|
578 mTreeView->setModel(model); |
|
579 |
|
580 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
581 |
|
582 mModelType = greenOddBrownEvenModel; |
|
583 } |
|
584 } |
|
585 |
|
586 void ContentWidget::populateTreeModelDeep() |
|
587 { |
|
588 if (mTreeView) |
|
589 { |
|
590 delete mTreeView->model(); |
|
591 |
|
592 QStandardItemModel* model = ModelFactory::populateTreeModelDeep(); |
|
593 mTreeView->setModel(model, new HbTreeViewItem); |
|
594 mTreeView->setIndentation(-1); |
|
595 |
|
596 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
597 |
|
598 mModelType = treeModelDeep; |
|
599 } |
|
600 } |
|
601 |
|
602 void ContentWidget::populateTreeModelFlat() |
|
603 { |
|
604 if (mTreeView) |
|
605 { |
|
606 delete mTreeView->model(); |
|
607 mTreeView->setItemRecycling(true); |
|
608 |
|
609 QStandardItemModel* model = ModelFactory::populateTreeModelFlat(); |
|
610 mTreeView->setModel(model, new HbTreeViewItem); |
|
611 mTreeView->setIndentation(-1); |
|
612 |
|
613 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
614 |
|
615 mModelType = treeModelFlat; |
|
616 } |
|
617 } |
|
618 |
|
619 /*void ContentWidget::populateTreeModelMail() |
|
620 { |
|
621 if (mTreeView) { |
|
622 delete mTreeView->model(); |
|
623 mTreeView->setItemRecycling(true); |
|
624 |
|
625 QStandardItemModel* model = ModelFactory::populateTreeModelMail(); |
|
626 mTreeView->setModel(model, new MailTreeViewItem); |
|
627 mTreeView->setIndentation(0); |
|
628 |
|
629 connect(mTreeView->selectionModel(), |
|
630 SIGNAL(selectionChanged(QItemSelection, QItemSelection)), |
|
631 this, |
|
632 SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
633 |
|
634 mModelType = treeModelMail; |
|
635 } |
|
636 }*/ |
|
637 |
|
638 void ContentWidget::populateDirModel() |
|
639 { |
|
640 if (mTreeView) |
|
641 { |
|
642 delete mTreeView->model(); |
|
643 |
|
644 QDirModel* model = new QDirModel(); |
|
645 model->setSorting(QDir::DirsFirst); |
|
646 |
|
647 mTreeView->setModel(model, new HbTreeViewItem); |
|
648 mTreeView->setIndentation(-1); |
|
649 |
|
650 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
651 |
|
652 if (!mFileWatcher) |
|
653 { |
|
654 mFileWatcher = new QFileSystemWatcher(); |
|
655 mFileWatcher->addPath(mImagesDir); |
|
656 connect(mFileWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(refresh())); |
|
657 connect(mFileWatcher, SIGNAL(fileChanged(QString)), this, SLOT(refresh())); |
|
658 } |
|
659 mModelType = dirModel; |
|
660 } |
|
661 } |
|
662 |
|
663 void ContentWidget::populateFileSystemModel() |
|
664 { |
|
665 if (mTreeView) |
|
666 { |
|
667 delete mTreeView->model(); |
|
668 |
|
669 QFileSystemModel* model = new QFileSystemModel(); |
|
670 QString myComputer = model->myComputer().toString(); |
|
671 model->setRootPath(myComputer); |
|
672 mTreeView->setModel(model, new HbTreeViewItem); |
|
673 mTreeView->setIndentation(-1); |
|
674 |
|
675 QDir dir(""); |
|
676 QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); |
|
677 int count = 0; |
|
678 for (int i = 0; i < count; i++) |
|
679 { |
|
680 model->setRootPath(dirs.at(i)); |
|
681 } |
|
682 |
|
683 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
684 |
|
685 mModelType = fileSystemModel; |
|
686 } |
|
687 } |
|
688 |
|
689 void ContentWidget::populateTreeModelMixed() |
|
690 { |
|
691 if (mTreeView) |
|
692 { |
|
693 delete mTreeView->model(); |
|
694 mTreeView->setItemRecycling(true); |
|
695 |
|
696 QStandardItemModel* model = ModelFactory::populateTreeModelMixed(); |
|
697 mTreeView->setModel(model, new HbTreeViewItem); |
|
698 |
|
699 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
700 |
|
701 mModelType = treeModelMixed; |
|
702 } |
|
703 } |
|
704 |
|
705 void ContentWidget::setMainMenu() |
|
706 { |
|
707 if (!mMainMenu) |
|
708 { |
|
709 mMainMenu = new HbMenu(); |
|
710 |
|
711 // ----------------------------------------- |
|
712 // Submenu for selecting/removing the model. |
|
713 // ----------------------------------------- |
|
714 HbMenu *subMenu = mMainMenu->addMenu("Model"); |
|
715 connect(subMenu, SIGNAL(triggered(HbAction*)),this, SLOT(changeModel(HbAction*))); |
|
716 |
|
717 int i(noModel); |
|
718 HbAction *action = subMenu->addAction("Remove Model"); |
|
719 action->setData(QVariant(i)); |
|
720 mRemoveModelAction = action; |
|
721 |
|
722 QString temporaryString; |
|
723 foreach (temporaryString , KModelNames) |
|
724 { |
|
725 HbAction *subAction = subMenu->addAction(temporaryString); |
|
726 i++; |
|
727 subAction->setData ( QVariant(i) ); |
|
728 } |
|
729 |
|
730 // Settings menuitem. |
|
731 HbAction *settingsAction = mMainMenu->addAction("Settings"); |
|
732 connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings())); |
|
733 |
|
734 // ------------------------- |
|
735 // Submenu for editing item. |
|
736 // ------------------------- |
|
737 mItemSubMenu = mMainMenu->addMenu("Item"); |
|
738 connect(mItemSubMenu, SIGNAL(triggered(HbAction*)),this, SLOT(editItem(HbAction*))); |
|
739 |
|
740 HbAction* subMenuAction = mItemSubMenu->addAction("Add"); |
|
741 subMenuAction->setData((int) addItemOperation); |
|
742 |
|
743 subMenuAction = mItemSubMenu->addAction("Change"); |
|
744 subMenuAction->setData((int) changeItemOperation); |
|
745 |
|
746 subMenuAction = mItemSubMenu->addAction("Remove"); |
|
747 subMenuAction->setData((int) removeItemOperation); |
|
748 |
|
749 subMenuAction = mItemSubMenu->addAction("Remove All"); |
|
750 subMenuAction->setData((int) removeAllItemsOperation); |
|
751 |
|
752 subMenuAction = mItemSubMenu->addAction("Expand All"); |
|
753 subMenuAction->setData((int) expandAllOperation); |
|
754 |
|
755 subMenuAction = mItemSubMenu->addAction("Colapse All"); |
|
756 subMenuAction->setData((int) collapseAllOperation); |
|
757 |
|
758 subMenuAction = mItemSubMenu->addAction("Insert one in 3 sec"); |
|
759 subMenuAction->setData((int) autoInsertOneOperation); |
|
760 |
|
761 subMenuAction = mItemSubMenu->addAction("Remove one in 3 sec"); |
|
762 subMenuAction->setData((int) autoRemoveOneOperation); |
|
763 |
|
764 subMenuAction = mItemSubMenu->addAction("Simulate visible items"); |
|
765 subMenuAction->setCheckable(true); |
|
766 subMenuAction->setData((int) simulateVisible); |
|
767 mCheckableItemActions.insert(simulateVisible, subMenuAction); |
|
768 |
|
769 subMenuAction = mItemSubMenu->addAction("Reset during simulation"); |
|
770 subMenuAction->setCheckable(true); |
|
771 subMenuAction->setData((int) resetDuringSimulation); |
|
772 mCheckableItemActions.insert(resetDuringSimulation, subMenuAction); |
|
773 |
|
774 subMenuAction = mItemSubMenu->addAction("Simulate fast inserts"); |
|
775 subMenuAction->setData((int) simulateMultipleFastInsertsOperation); |
|
776 |
|
777 subMenuAction = mItemSubMenu->addAction("Simulate fast removals"); |
|
778 subMenuAction->setData((int) simulateMultipleFastRemovalsOperation); |
|
779 |
|
780 subMenuAction = mItemSubMenu->addAction("Select all"); |
|
781 subMenuAction->setData((int) selectAll); |
|
782 |
|
783 subMenuAction = mItemSubMenu->addAction("Clear selected"); |
|
784 subMenuAction->setData((int) unselect); |
|
785 |
|
786 // --------------------------- |
|
787 // Submenu for target actions. |
|
788 // --------------------------- |
|
789 mTargetActionsSubMenu = mMainMenu->addMenu("Target item"); |
|
790 |
|
791 mScrollToAction = mTargetActionsSubMenu->addAction("Scroll to it"); |
|
792 connect(mScrollToAction, SIGNAL(triggered()), this, SLOT(scrollToTarget())); |
|
793 |
|
794 mInsertAboveTargetAction = mTargetActionsSubMenu->addAction("Insert item above"); |
|
795 connect(mInsertAboveTargetAction, SIGNAL(triggered()), this, SLOT(insertItemAboveTarget())); |
|
796 |
|
797 mInsertBelowTargetAction = mTargetActionsSubMenu->addAction("Insert item below"); |
|
798 connect(mInsertBelowTargetAction, SIGNAL(triggered()), this, SLOT(insertItemBelowTarget())); |
|
799 |
|
800 mInsertBelowTargetAction = mTargetActionsSubMenu->addAction("Expand folder"); |
|
801 connect(mInsertBelowTargetAction, SIGNAL(triggered()), this, SLOT(expandTargetItem())); |
|
802 |
|
803 mInsertBelowTargetAction = mTargetActionsSubMenu->addAction("Collapse folder"); |
|
804 connect(mInsertBelowTargetAction, SIGNAL(triggered()), this, SLOT(collapseTargetItem())); |
|
805 |
|
806 // --------------------------- |
|
807 // Submenu for popup |
|
808 // --------------------------- |
|
809 HbMenu *optionsSubMenu = mMainMenu->addMenu("Popup test"); |
|
810 |
|
811 HbAction *item1 = optionsSubMenu->addAction("Launch into Popup"); |
|
812 connect(item1, SIGNAL(triggered()), this, SLOT(launchInPopup())); |
|
813 |
|
814 // Landscape/portrait menuitem. |
|
815 mOrientationSwitch = mMainMenu->addAction("Change to landscape"); |
|
816 connect(mOrientationSwitch, SIGNAL(triggered()), this, SLOT(changeOrientation())); |
|
817 |
|
818 // Mirroring menuitem. |
|
819 mMirroring = mMainMenu->addAction("Turn mirroring on"); |
|
820 connect(mMirroring, SIGNAL(triggered()), this, SLOT(changeMirroring())); |
|
821 |
|
822 resetItemManagementMenu(); |
|
823 } |
|
824 |
|
825 // HbView takes the ownership. |
|
826 setMenu( mMainMenu); |
|
827 } |
|
828 |
|
829 void ContentWidget::addItem() |
|
830 { |
|
831 if ((mModelType != dirModel) && (mModelType != noModel)) |
|
832 { |
|
833 mWindow->removeView(this); |
|
834 mForm = new TreeDataForm(*mTreeView, this); |
|
835 HbView *newView = mWindow->addView(mForm); |
|
836 newView->setNavigationAction(mSoftKeyBackAction); |
|
837 |
|
838 postEvents(); |
|
839 |
|
840 mForm->setHeading("New Item"); |
|
841 mForm->populateAddItem(); |
|
842 } |
|
843 } |
|
844 |
|
845 void ContentWidget::doAddItem() |
|
846 { |
|
847 postEvents(); |
|
848 QList<QStandardItem *> items = mForm->getStandardItems(); |
|
849 if (items.count() > 0) |
|
850 { |
|
851 foreach (QStandardItem *item, items) |
|
852 { |
|
853 doAddItem(-1, item); |
|
854 } |
|
855 mTreeView->scrollTo(items.at(0)->index(), mScrollHint); |
|
856 } |
|
857 } |
|
858 |
|
859 void ContentWidget::doAddItem(int pos, QStandardItem *item) |
|
860 { |
|
861 if (item) |
|
862 { |
|
863 QStandardItemModel *model = static_cast<QStandardItemModel *> (mTreeView->model()); |
|
864 |
|
865 QModelIndex index; |
|
866 if (pos == -1) |
|
867 { |
|
868 index = mTreeView->currentIndex(); |
|
869 } |
|
870 else |
|
871 { |
|
872 index = mTreeView->modelIterator()->index(pos); |
|
873 } |
|
874 |
|
875 if (index.isValid()) |
|
876 { |
|
877 QStandardItem *parent = model->itemFromIndex(index); |
|
878 parent->setChild(parent->rowCount(), item); |
|
879 } |
|
880 else |
|
881 { |
|
882 model->appendRow(item); |
|
883 } |
|
884 |
|
885 expandUpwards(mTreeView->model(), item->index()); |
|
886 } |
|
887 } |
|
888 |
|
889 void ContentWidget::changeItem() |
|
890 { |
|
891 QStandardItemModel *model = static_cast<QStandardItemModel *> (mTreeView->model()); |
|
892 QStandardItem *item = model->itemFromIndex(mTreeView->currentIndex()); |
|
893 QVariant value = item->data(Qt::DisplayRole); |
|
894 if (value.isValid()) |
|
895 { |
|
896 if (value.canConvert<QString> ()) |
|
897 { |
|
898 item->setData("First text changed, isn't it?", Qt::DisplayRole); |
|
899 } |
|
900 else if (value.canConvert<QStringList> ()) |
|
901 { |
|
902 QStringList strings = value.toStringList(); |
|
903 if (strings.count()) |
|
904 { |
|
905 strings.removeAt(0); |
|
906 } |
|
907 strings.insert(0, "First text changed, isn't it?"); |
|
908 item->setData(strings, Qt::DisplayRole); |
|
909 } |
|
910 } |
|
911 } |
|
912 |
|
913 void ContentWidget::removeItems() |
|
914 { |
|
915 if (mTreeView->selectionMode() != HbAbstractItemView::MultiSelection) |
|
916 { |
|
917 mTreeView->setSelectionMode(HbAbstractItemView::MultiSelection); |
|
918 } |
|
919 |
|
920 setNavigationAction( mSoftKeyConfirmAction); |
|
921 |
|
922 mMainlayout->insertItem(0, mInfoLabel); |
|
923 mInfoLabel->show(); |
|
924 |
|
925 mItemSubMenu->menuAction()->setEnabled(false); |
|
926 } |
|
927 |
|
928 void ContentWidget::doRemoveItems() |
|
929 { |
|
930 QStandardItemModel *model = static_cast<QStandardItemModel *> (mTreeView->model()); |
|
931 QItemSelectionModel *selectionModel = mTreeView->selectionModel(); |
|
932 QModelIndexList indexes = selectionModel->selectedIndexes(); |
|
933 |
|
934 // For debug: For each model index to be deleted, calculate and save the depth in the tree. |
|
935 foreach (QModelIndex index, indexes) |
|
936 { |
|
937 int depth = calculateDepth(index); |
|
938 QStandardItem *item = model->itemFromIndex(index); |
|
939 item->setData(depth, KMyCustomDepthRole); |
|
940 } |
|
941 |
|
942 int count = indexes.count(); |
|
943 |
|
944 // Create a copy of the selected indexes but using the persistent model indices. |
|
945 QVector<QPersistentModelIndex> persistentIndexes(count); |
|
946 qCopy(indexes.begin(), indexes.end(), persistentIndexes.begin()); |
|
947 |
|
948 // For debug: Print the content of the list. |
|
949 for (int i = 0; i < count; i++) |
|
950 { |
|
951 QPersistentModelIndex index = persistentIndexes.at(i); |
|
952 int depth = index.data(KMyCustomDepthRole).toInt(); |
|
953 qDebug() << "Item:" << i << index << ", Depth:" << depth; |
|
954 } |
|
955 |
|
956 // Delete all items by using persistent model indices, which cannot get invalid |
|
957 // during the deletion process (i.e. no need to sort them). |
|
958 for (int i = 0; i < count; i++) |
|
959 { |
|
960 QPersistentModelIndex persistentIndex = persistentIndexes.at(i); |
|
961 model->removeRow(persistentIndex.row(), persistentIndex.parent()); |
|
962 } |
|
963 } |
|
964 |
|
965 void ContentWidget::removeAllItems() |
|
966 { |
|
967 QStandardItemModel *newModel = new QStandardItemModel; |
|
968 mTreeView->setModel(newModel, new HbTreeViewItem); |
|
969 } |
|
970 |
|
971 void ContentWidget::expandAll() |
|
972 { |
|
973 RDEBUG("0", 0); |
|
974 |
|
975 HbModelIterator *modelIterator = mTreeView->modelIterator(); |
|
976 QModelIndex index = modelIterator->nextIndex(QModelIndex()); |
|
977 while (index.isValid()) |
|
978 { |
|
979 mTreeView->setExpanded(index, true); |
|
980 index = modelIterator->nextIndex(index); |
|
981 } |
|
982 } |
|
983 |
|
984 void ContentWidget::collapseAll() |
|
985 { |
|
986 RDEBUG("0", 0); |
|
987 |
|
988 HbModelIterator *modelIterator = mTreeView->modelIterator(); |
|
989 QModelIndex index = modelIterator->previousIndex(QModelIndex()); |
|
990 while (index.isValid() && index != modelIterator->rootIndex()) |
|
991 { |
|
992 mTreeView->setExpanded(index, false); |
|
993 index = modelIterator->previousIndex(index); |
|
994 } |
|
995 } |
|
996 |
|
997 void ContentWidget::resetItemManagementMenu() |
|
998 { |
|
999 bool enabled = false; |
|
1000 if ((mModelType != dirModel) && (mModelType != noModel)) |
|
1001 { |
|
1002 enabled = true; |
|
1003 } |
|
1004 mItemSubMenu->menuAction()->setEnabled(enabled); |
|
1005 } |
|
1006 |
|
1007 void ContentWidget::doCommand(int index) |
|
1008 { |
|
1009 TInt ret = KErrNone; |
|
1010 RDEBUG("index", index); |
|
1011 int itemValue = index; |
|
1012 switch (itemValue) |
|
1013 { |
|
1014 /////////////////////// |
|
1015 case 00: |
|
1016 { |
|
1017 RDEBUG("Nothing to do. String selected", itemValue); |
|
1018 } |
|
1019 break; |
|
1020 case 01: |
|
1021 { |
|
1022 RDEBUG("DeviceLockOff", 0); |
|
1023 CDevicelockAccessApi* iDevicelockAccess = CDevicelockAccessApi::NewL(); |
|
1024 RDEBUG("0", 0); |
|
1025 ret = iDevicelockAccess->DisableDevicelock(); |
|
1026 RDEBUG("ret", ret); |
|
1027 delete iDevicelockAccess; |
|
1028 } |
|
1029 break; |
|
1030 case 02: |
|
1031 { |
|
1032 CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL(); |
|
1033 RDEBUG("KeyguardOn+Note", 0); |
|
1034 ret = iKeyguardAccess->EnableKeyguard(ETrue); |
|
1035 RDEBUG("ret", ret); |
|
1036 delete iKeyguardAccess; |
|
1037 } |
|
1038 break; |
|
1039 case 03: |
|
1040 { |
|
1041 RDEBUG("KeyguardOff", 0); |
|
1042 CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL(); |
|
1043 RDEBUG("0", 0); |
|
1044 ret = iKeyguardAccess->DisableKeyguard(ETrue); |
|
1045 RDEBUG("ret", ret); |
|
1046 delete iKeyguardAccess; |
|
1047 } |
|
1048 break; |
|
1049 case 04: |
|
1050 { |
|
1051 RDEBUG("OfferDevicelock", 0); |
|
1052 CDevicelockAccessApi* iDevicelockAccess = CDevicelockAccessApi::NewL(); |
|
1053 RDEBUG("0", 0); |
|
1054 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 12345 ); |
|
1055 ret = iDevicelockAccess->OfferDevicelock(); |
|
1056 RDEBUG("ret", ret); |
|
1057 delete iDevicelockAccess; |
|
1058 } |
|
1059 break; |
|
1060 case 05: |
|
1061 { |
|
1062 RDEBUG("KeyguardOn-Note", 0); |
|
1063 CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL(); |
|
1064 RDEBUG("0", 0); |
|
1065 ret = iKeyguardAccess->EnableKeyguard(EFalse); |
|
1066 RDEBUG("ret", ret); |
|
1067 delete iKeyguardAccess; |
|
1068 } |
|
1069 break; |
|
1070 case 06: |
|
1071 { |
|
1072 RDEBUG("Wait20-DeviceLockOff", 0); |
|
1073 for (int ii = 20; ii > 0; ii--) |
|
1074 { |
|
1075 RDebug::Printf("%s %s (%u) ii=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ii); |
|
1076 User::After(1000 * 1000); |
|
1077 } |
|
1078 CDevicelockAccessApi* iDevicelockAccess = CDevicelockAccessApi::NewL(); |
|
1079 RDEBUG("0", 0); |
|
1080 ret = iDevicelockAccess->DisableDevicelock(); |
|
1081 RDEBUG("ret", ret); |
|
1082 delete iDevicelockAccess; |
|
1083 } |
|
1084 break; |
|
1085 case 07: |
|
1086 { |
|
1087 RDEBUG("Wait20-KeyguardOff", 0); |
|
1088 for (int ii = 20; ii > 0; ii--) |
|
1089 { |
|
1090 RDebug::Printf("%s %s (%u) ii=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ii); |
|
1091 User::After(1000 * 1000); |
|
1092 } |
|
1093 CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL(); |
|
1094 RDEBUG("0", 0); |
|
1095 ret = iKeyguardAccess->DisableKeyguard(ETrue); |
|
1096 RDEBUG("ret", ret); |
|
1097 delete iKeyguardAccess; |
|
1098 } |
|
1099 break; |
|
1100 case 0x08: |
|
1101 { |
|
1102 RDEBUG("Wait20-ShowKeysLockedNote", 0); |
|
1103 for (int ii = 20; ii > 0; ii--) |
|
1104 { |
|
1105 RDebug::Printf("%s %s (%u) ii=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ii); |
|
1106 User::After(1000 * 1000); |
|
1107 } |
|
1108 CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL(); |
|
1109 RDEBUG("0", 0); |
|
1110 ret = iKeyguardAccess->ShowKeysLockedNote(); |
|
1111 RDEBUG("ret", ret); |
|
1112 delete iKeyguardAccess; |
|
1113 } |
|
1114 break; |
|
1115 |
|
1116 case 0x09: |
|
1117 { |
|
1118 RDEBUG("DeviceLockOn", 0); |
|
1119 CDevicelockAccessApi* iDevicelockAccess = CDevicelockAccessApi::NewL(); |
|
1120 RDEBUG("0", 0); |
|
1121 ret = iDevicelockAccess->EnableDevicelock(EDevicelockManual); |
|
1122 RDEBUG("0", 0); |
|
1123 delete iDevicelockAccess; |
|
1124 } |
|
1125 break; |
|
1126 /////////////////////// |
|
1127 case 10: |
|
1128 { |
|
1129 RDEBUG("Call1", 0); |
|
1130 TBuf<0x100> title; |
|
1131 title.Zero(); |
|
1132 HBufC* stringHolder = CSecuritySettings::TranslateLC(_L("txt_devicelocking_dialog_lock_code"), 0); // old txt_pin_code_dialog_sec_code. Perhaps txt_devicelocking_dialog_lock_code_unlock |
|
1133 title.Append(stringHolder->Des()); |
|
1134 CleanupStack::PopAndDestroy(stringHolder); |
|
1135 RDEBUG("0", 0); |
|
1136 |
|
1137 TBuf<0x100> title2; |
|
1138 title2.Zero(); |
|
1139 HBufC* stringHolder2 = CSecuritySettings::TranslateLC(_L("not_found"), 0); // old txt_pin_code_dialog_sec_code. Perhaps txt_devicelocking_dialog_lock_code_unlock |
|
1140 title2.Append(stringHolder2->Des()); |
|
1141 CleanupStack::PopAndDestroy(stringHolder2); |
|
1142 RDEBUG("0", 0); |
|
1143 |
|
1144 CTelephony *iTelephony = CTelephony::NewL(); |
|
1145 CTelephony::TTelNumber telNumber(_L("+358504821987")); |
|
1146 |
|
1147 CTelephony::TCallId iCallId; |
|
1148 CTelephony::TCallParamsV1 callParams; |
|
1149 callParams.iIdRestrict = CTelephony::ESendMyId; |
|
1150 CTelephony::TCallParamsV1Pckg callParamsPckg(callParams); |
|
1151 TRequestStatus stat; |
|
1152 iTelephony->DialNewCall(stat, callParamsPckg, telNumber, iCallId); |
|
1153 User::WaitForRequest(stat); |
|
1154 delete iTelephony; |
|
1155 |
|
1156 RDEBUG("0", 0); |
|
1157 } |
|
1158 break; |
|
1159 case 11: |
|
1160 { |
|
1161 RDEBUG("ChangePinL", 0); |
|
1162 CSecuritySettings* iSecSettings; |
|
1163 iSecSettings = CSecuritySettings::NewL(); |
|
1164 TSecUi::InitializeLibL(); |
|
1165 RDEBUG("0", 0); |
|
1166 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1167 ret = KErrNone; |
|
1168 iSecSettings->ChangePinL(); |
|
1169 RDEBUG("0", 0); |
|
1170 TSecUi::UnInitializeLib(); |
|
1171 RDEBUG("0", 0); |
|
1172 delete iSecSettings; |
|
1173 } |
|
1174 break; |
|
1175 case 12: |
|
1176 { |
|
1177 RDEBUG("IsLockEnabledL", 0); |
|
1178 CSecuritySettings* iSecSettings; |
|
1179 iSecSettings = CSecuritySettings::NewL(); |
|
1180 RDEBUG("0", 0); |
|
1181 TSecUi::InitializeLibL(); |
|
1182 RDEBUG("0", 0); |
|
1183 |
|
1184 RDEBUG("RMobilePhone::ELockPhoneDevice", RMobilePhone::ELockPhoneDevice); |
|
1185 ret = iSecSettings->IsLockEnabledL(RMobilePhone::ELockPhoneDevice); // 0 |
|
1186 RDEBUG("ret", ret); |
|
1187 |
|
1188 RDEBUG("RMobilePhone::ELockPhoneDevice", RMobilePhone::ELockICC); |
|
1189 ret = iSecSettings->IsLockEnabledL(RMobilePhone::ELockICC); // 1 |
|
1190 RDEBUG("ret", ret); |
|
1191 |
|
1192 RDEBUG("RMobilePhone::ELockPhoneDevice", RMobilePhone::ELockPhoneToICC); |
|
1193 ret = iSecSettings->IsLockEnabledL(RMobilePhone::ELockPhoneToICC); // 2 |
|
1194 RDEBUG("ret", ret); |
|
1195 |
|
1196 RDEBUG("RMobilePhone::ELockPhoneDevice", RMobilePhone::ELockPin2); |
|
1197 ret = iSecSettings->IsLockEnabledL(RMobilePhone::ELockPin2); // 5 |
|
1198 RDEBUG("ret", ret); |
|
1199 |
|
1200 RDEBUG("RMobilePhone::ELockPhoneDevice", RMobilePhone::ELockUniversalPin); |
|
1201 ret = iSecSettings->IsLockEnabledL(RMobilePhone::ELockUniversalPin); // 9 |
|
1202 RDEBUG("ret", ret); |
|
1203 |
|
1204 RDEBUG("0", 0); |
|
1205 TSecUi::UnInitializeLib(); |
|
1206 RDEBUG("0", 0); |
|
1207 delete iSecSettings; |
|
1208 RDEBUG("end", 0x99); |
|
1209 } |
|
1210 break; |
|
1211 case 13: |
|
1212 { |
|
1213 RDEBUG("AskSecCodeL", 0); |
|
1214 CSecuritySettings* iSecSettings; |
|
1215 iSecSettings = CSecuritySettings::NewL(); |
|
1216 TSecUi::InitializeLibL(); |
|
1217 RDEBUG("0", 0); |
|
1218 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1219 ret = KErrNone; |
|
1220 ret = iSecSettings->AskSecCodeL(); |
|
1221 RDEBUG("ret", ret); |
|
1222 TSecUi::UnInitializeLib(); |
|
1223 RDEBUG("0", 0); |
|
1224 delete iSecSettings; |
|
1225 } |
|
1226 break; |
|
1227 case 14: |
|
1228 { |
|
1229 RDEBUG("AskPin2L", 0); |
|
1230 CSecuritySettings* iSecSettings; |
|
1231 iSecSettings = CSecuritySettings::NewL(); |
|
1232 TSecUi::InitializeLibL(); |
|
1233 RDEBUG("0", 0); |
|
1234 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1235 ret = KErrNone; |
|
1236 ret = iSecSettings->AskPin2L(); |
|
1237 RDEBUG("ret", ret); |
|
1238 TSecUi::UnInitializeLib(); |
|
1239 RDEBUG("0", 0); |
|
1240 delete iSecSettings; |
|
1241 } |
|
1242 break; |
|
1243 case 15: |
|
1244 { |
|
1245 RDEBUG("GetFdnMode", 0); |
|
1246 RMobilePhone::TMobilePhoneFdnStatus fdnMode; |
|
1247 CSecuritySettings* iSecSettings; |
|
1248 iSecSettings = CSecuritySettings::NewL(); |
|
1249 TSecUi::InitializeLibL(); |
|
1250 RDEBUG("0", 0); |
|
1251 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1252 ret = KErrNone; |
|
1253 ret = iSecSettings->GetFdnMode(fdnMode); |
|
1254 RDEBUG("ret", ret); |
|
1255 TSecUi::UnInitializeLib(); |
|
1256 RDEBUG("0", 0); |
|
1257 delete iSecSettings; |
|
1258 } |
|
1259 break; |
|
1260 case 16: |
|
1261 { |
|
1262 RDEBUG("IsUpinBlocked", 0); |
|
1263 CSecuritySettings* iSecSettings; |
|
1264 iSecSettings = CSecuritySettings::NewL(); |
|
1265 TSecUi::InitializeLibL(); |
|
1266 RDEBUG("0", 0); |
|
1267 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1268 ret = KErrNone; |
|
1269 ret = iSecSettings->IsUpinBlocked(); |
|
1270 RDEBUG("ret", ret); |
|
1271 TSecUi::UnInitializeLib(); |
|
1272 RDEBUG("0", 0); |
|
1273 delete iSecSettings; |
|
1274 } |
|
1275 break; |
|
1276 case 17: |
|
1277 { |
|
1278 RDEBUG("ChangeSecCodeL", 0); |
|
1279 CSecuritySettings* iSecSettings; |
|
1280 iSecSettings = CSecuritySettings::NewL(); |
|
1281 TSecUi::InitializeLibL(); |
|
1282 RDEBUG("0", 0); |
|
1283 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1284 ret = KErrNone; |
|
1285 iSecSettings->ChangeSecCodeL(); |
|
1286 RDEBUG("ret", ret); |
|
1287 TSecUi::UnInitializeLib(); |
|
1288 RDEBUG("0", 0); |
|
1289 delete iSecSettings; |
|
1290 } |
|
1291 break; |
|
1292 case 18: |
|
1293 { |
|
1294 RDEBUG("ChangeAutoLockPeriodL=30", 0); |
|
1295 CSecuritySettings* iSecSettings; |
|
1296 iSecSettings = CSecuritySettings::NewL(); |
|
1297 TSecUi::InitializeLibL(); |
|
1298 RDEBUG("0", 0); |
|
1299 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1300 ret = KErrNone; |
|
1301 ret = iSecSettings->ChangeAutoLockPeriodL(30); |
|
1302 RDEBUG("ret", ret); |
|
1303 TSecUi::UnInitializeLib(); |
|
1304 RDEBUG("0", 0); |
|
1305 delete iSecSettings; |
|
1306 } |
|
1307 break; |
|
1308 case 19: |
|
1309 { |
|
1310 RDEBUG("ChangeAutoLockPeriodL=00", 0); |
|
1311 CSecuritySettings* iSecSettings; |
|
1312 iSecSettings = CSecuritySettings::NewL(); |
|
1313 TSecUi::InitializeLibL(); |
|
1314 RDEBUG("0", 0); |
|
1315 // TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1316 ret = KErrNone; |
|
1317 ret = iSecSettings->ChangeAutoLockPeriodL(0); |
|
1318 RDEBUG("ret", ret); |
|
1319 TSecUi::UnInitializeLib(); |
|
1320 RDEBUG("0", 0); |
|
1321 delete iSecSettings; |
|
1322 } |
|
1323 break; |
|
1324 /////////////////////// |
|
1325 case 20: |
|
1326 { |
|
1327 RDEBUG("Notif.EPin1Required", 0); |
|
1328 static const TUid KSecurityNotifierUid = |
|
1329 { |
|
1330 0x10005988 |
|
1331 }; |
|
1332 TInt err(KErrGeneral); |
|
1333 err=err; |
|
1334 RNotifier iNotifier; |
|
1335 err = iNotifier.Connect(); |
|
1336 RDEBUG("0", 0); |
|
1337 TSecurityNotificationPckg iParams; |
|
1338 iParams().iEvent = 2; // EPin1Required |
|
1339 RDEBUG("0", 0); |
|
1340 iParams().iStartup = ETrue; |
|
1341 TPckgBuf<TInt> iPinResult; |
|
1342 TRequestStatus stat; |
|
1343 RDEBUG("0", 0); |
|
1344 iNotifier.StartNotifierAndGetResponse(stat, KSecurityNotifierUid, iParams, iPinResult); |
|
1345 RDEBUG("0", 0); |
|
1346 User::WaitForRequest(stat); |
|
1347 RDEBUG("0", 0); |
|
1348 err = stat.Int(); |
|
1349 RDEBUG("err", 0); |
|
1350 err = iNotifier.CancelNotifier(KSecurityNotifierUid); |
|
1351 RDEBUG("err", err); |
|
1352 iNotifier.Close(); |
|
1353 err = iPinResult(); |
|
1354 RDEBUG("err", err); |
|
1355 } |
|
1356 break; |
|
1357 case 21: |
|
1358 { |
|
1359 RDEBUG("EPin1Required", 0); |
|
1360 RMobilePhone iPhone; |
|
1361 |
|
1362 TInt err( KErrGeneral); |
|
1363 err=err; |
|
1364 TInt thisTry( 0); |
|
1365 RTelServer iTelServer; |
|
1366 RMmCustomAPI iCustomPhone; |
|
1367 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1368 { |
|
1369 User::After( KTimeBeforeRetryingServerConnection ); |
|
1370 } |
|
1371 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1372 RTelServer::TPhoneInfo PhoneInfo; |
|
1373 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
1374 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
1375 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
1376 err = iCustomPhone.Open( iPhone ) ; |
|
1377 RDEBUG("err", err); |
|
1378 |
|
1379 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
1380 // TSecUi::InitializeLibL(); |
|
1381 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
1382 iEvent = RMobilePhone::EPin1Required; |
|
1383 TInt result = KErrNone; |
|
1384 RDEBUG("iEvent", iEvent); |
|
1385 handler->HandleEventL(iEvent, result); |
|
1386 RDEBUG("result", result); |
|
1387 TSecUi::UnInitializeLib(); |
|
1388 delete handler; |
|
1389 RDEBUG("end", 0x99); |
|
1390 } |
|
1391 case 22: |
|
1392 { |
|
1393 RDEBUG("EPin2Required", 0); |
|
1394 RMobilePhone iPhone; |
|
1395 |
|
1396 TInt err( KErrGeneral); |
|
1397 err=err; |
|
1398 TInt thisTry( 0); |
|
1399 RTelServer iTelServer; |
|
1400 RMmCustomAPI iCustomPhone; |
|
1401 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1402 { |
|
1403 User::After( KTimeBeforeRetryingServerConnection ); |
|
1404 } |
|
1405 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1406 RTelServer::TPhoneInfo PhoneInfo; |
|
1407 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
1408 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
1409 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
1410 err = iCustomPhone.Open( iPhone ) ; |
|
1411 RDEBUG("err", err); |
|
1412 |
|
1413 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
1414 // TSecUi::InitializeLibL(); |
|
1415 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
1416 iEvent = RMobilePhone::EPin2Required; |
|
1417 TInt result = KErrNone; |
|
1418 RDEBUG("iEvent", iEvent); |
|
1419 handler->HandleEventL(iEvent, result); |
|
1420 RDEBUG("result", result); |
|
1421 TSecUi::UnInitializeLib(); |
|
1422 delete handler; |
|
1423 RDEBUG("end", 0x99); |
|
1424 } |
|
1425 case 23: |
|
1426 { |
|
1427 RDEBUG("EPhonePasswordRequired", 0); |
|
1428 RMobilePhone iPhone; |
|
1429 |
|
1430 TInt err( KErrGeneral); |
|
1431 err=err; |
|
1432 TInt thisTry( 0); |
|
1433 RTelServer iTelServer; |
|
1434 RMmCustomAPI iCustomPhone; |
|
1435 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1436 { |
|
1437 User::After( KTimeBeforeRetryingServerConnection ); |
|
1438 } |
|
1439 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1440 RTelServer::TPhoneInfo PhoneInfo; |
|
1441 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
1442 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
1443 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
1444 err = iCustomPhone.Open( iPhone ) ; |
|
1445 RDEBUG("err", err); |
|
1446 |
|
1447 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
1448 // TSecUi::InitializeLibL(); |
|
1449 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
1450 iEvent = RMobilePhone::EPhonePasswordRequired; |
|
1451 TInt result = KErrNone; |
|
1452 RDEBUG("iEvent", iEvent); |
|
1453 handler->HandleEventL(iEvent, result); |
|
1454 RDEBUG("result", result); |
|
1455 TSecUi::UnInitializeLib(); |
|
1456 delete handler; |
|
1457 RDEBUG("end", 0x99); |
|
1458 } |
|
1459 case 24: |
|
1460 { |
|
1461 RDEBUG("EPuk1Required", 0); |
|
1462 RMobilePhone iPhone; |
|
1463 |
|
1464 TInt err( KErrGeneral); |
|
1465 err=err; |
|
1466 TInt thisTry( 0); |
|
1467 RTelServer iTelServer; |
|
1468 RMmCustomAPI iCustomPhone; |
|
1469 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1470 { |
|
1471 User::After( KTimeBeforeRetryingServerConnection ); |
|
1472 } |
|
1473 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1474 RTelServer::TPhoneInfo PhoneInfo; |
|
1475 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
1476 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
1477 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
1478 err = iCustomPhone.Open( iPhone ) ; |
|
1479 RDEBUG("err", err); |
|
1480 |
|
1481 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
1482 // TSecUi::InitializeLibL(); |
|
1483 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
1484 iEvent = RMobilePhone::EPuk1Required; |
|
1485 TInt result = KErrNone; |
|
1486 RDEBUG("iEvent", iEvent); |
|
1487 handler->HandleEventL(iEvent, result); |
|
1488 RDEBUG("result", result); |
|
1489 TSecUi::UnInitializeLib(); |
|
1490 delete handler; |
|
1491 RDEBUG("end", 0x99); |
|
1492 } |
|
1493 case 25: |
|
1494 { |
|
1495 RDEBUG("EPuk2Required", 0); |
|
1496 RMobilePhone iPhone; |
|
1497 |
|
1498 TInt err( KErrGeneral); |
|
1499 err=err; |
|
1500 TInt thisTry( 0); |
|
1501 RTelServer iTelServer; |
|
1502 RMmCustomAPI iCustomPhone; |
|
1503 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1504 { |
|
1505 User::After( KTimeBeforeRetryingServerConnection ); |
|
1506 } |
|
1507 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1508 RTelServer::TPhoneInfo PhoneInfo; |
|
1509 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
1510 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
1511 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
1512 err = iCustomPhone.Open( iPhone ) ; |
|
1513 RDEBUG("err", err); |
|
1514 |
|
1515 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
1516 // TSecUi::InitializeLibL(); |
|
1517 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
1518 iEvent = RMobilePhone::EPuk2Required; |
|
1519 TInt result = KErrNone; |
|
1520 RDEBUG("iEvent", iEvent); |
|
1521 handler->HandleEventL(iEvent, result); |
|
1522 RDEBUG("result", result); |
|
1523 TSecUi::UnInitializeLib(); |
|
1524 delete handler; |
|
1525 RDEBUG("end", 0x99); |
|
1526 } |
|
1527 case 26: |
|
1528 { |
|
1529 RDEBUG("EUniversalPinRequired", 0); |
|
1530 RMobilePhone iPhone; |
|
1531 |
|
1532 TInt err( KErrGeneral); |
|
1533 err=err; |
|
1534 TInt thisTry( 0); |
|
1535 RTelServer iTelServer; |
|
1536 RMmCustomAPI iCustomPhone; |
|
1537 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1538 { |
|
1539 User::After( KTimeBeforeRetryingServerConnection ); |
|
1540 } |
|
1541 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1542 RTelServer::TPhoneInfo PhoneInfo; |
|
1543 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
1544 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
1545 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
1546 err = iCustomPhone.Open( iPhone ) ; |
|
1547 RDEBUG("err", err); |
|
1548 |
|
1549 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
1550 // TSecUi::InitializeLibL(); |
|
1551 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
1552 iEvent = RMobilePhone::EUniversalPinRequired; |
|
1553 TInt result = KErrNone; |
|
1554 RDEBUG("iEvent", iEvent); |
|
1555 handler->HandleEventL(iEvent, result); |
|
1556 RDEBUG("result", result); |
|
1557 TSecUi::UnInitializeLib(); |
|
1558 delete handler; |
|
1559 RDEBUG("end", 0x99); |
|
1560 } |
|
1561 case 27: |
|
1562 { |
|
1563 RDEBUG("EUniversalPukRequired", 0); |
|
1564 RMobilePhone iPhone; |
|
1565 |
|
1566 TInt err( KErrGeneral); |
|
1567 err=err; |
|
1568 TInt thisTry( 0); |
|
1569 RTelServer iTelServer; |
|
1570 RMmCustomAPI iCustomPhone; |
|
1571 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1572 { |
|
1573 User::After( KTimeBeforeRetryingServerConnection ); |
|
1574 } |
|
1575 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1576 RTelServer::TPhoneInfo PhoneInfo; |
|
1577 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
1578 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
1579 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
1580 err = iCustomPhone.Open( iPhone ) ; |
|
1581 RDEBUG("err", err); |
|
1582 |
|
1583 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
1584 // TSecUi::InitializeLibL(); |
|
1585 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
1586 iEvent = RMobilePhone::EUniversalPukRequired; |
|
1587 TInt result = KErrNone; |
|
1588 RDEBUG("iEvent", iEvent); |
|
1589 handler->HandleEventL(iEvent, result); |
|
1590 RDEBUG("result", result); |
|
1591 TSecUi::UnInitializeLib(); |
|
1592 delete handler; |
|
1593 RDEBUG("end", 0x99); |
|
1594 } |
|
1595 |
|
1596 /////////////////////// |
|
1597 case 31: |
|
1598 RDEBUG("0", 0) |
|
1599 ; |
|
1600 break; |
|
1601 |
|
1602 /////////////////////// |
|
1603 case 40: |
|
1604 { |
|
1605 RDEBUG("KAknKeyguardStatus=8", 0); |
|
1606 TInt val = -1; |
|
1607 ret = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, 8); |
|
1608 RDEBUG("ret", ret); |
|
1609 RDEBUG("0", 0); |
|
1610 ret = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, val); |
|
1611 RDEBUG("ret", ret); |
|
1612 RDEBUG("val", val); |
|
1613 } |
|
1614 break; |
|
1615 case 41: |
|
1616 { |
|
1617 RDEBUG("Pass=1234", 0); |
|
1618 TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 1234 ); |
|
1619 RDEBUG("errProp", errProp); |
|
1620 RDEBUG("KSecurityUIsTestCode", KSecurityUIsTestCode); |
|
1621 } |
|
1622 break; |
|
1623 case 42: |
|
1624 { |
|
1625 RDEBUG("Pass=12345", 0); |
|
1626 TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 12345 ); |
|
1627 RDEBUG("errProp", errProp); |
|
1628 RDEBUG("KSecurityUIsTestCode", KSecurityUIsTestCode); |
|
1629 } |
|
1630 break; |
|
1631 case 43: |
|
1632 { |
|
1633 RDEBUG("Pass=20499", 0); |
|
1634 TInt errProp = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 20499 ); |
|
1635 RDEBUG("errProp", errProp); |
|
1636 RDEBUG("KSecurityUIsTestCode", KSecurityUIsTestCode); |
|
1637 } |
|
1638 break; |
|
1639 case 44: |
|
1640 { |
|
1641 RDEBUG("Read-Prop", 0); |
|
1642 TInt val = -1; |
|
1643 ret = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, val); |
|
1644 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1645 RDebug::Printf( "%s %s (%u) KCoreAppUIsAutolockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1646 |
|
1647 ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLights, val); |
|
1648 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1649 RDebug::Printf( "%s %s (%u) KSecurityUIsLights=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1650 |
|
1651 ret = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, val); |
|
1652 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1653 RDebug::Printf( "%s %s (%u) KAknKeyguardStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1654 |
|
1655 ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, val); |
|
1656 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1657 RDebug::Printf( "%s %s (%u) KSecurityUIsDismissDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1658 |
|
1659 ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, val); |
|
1660 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1661 RDebug::Printf( "%s %s (%u) KSecurityUIsSecUIOriginatedQuery=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1662 |
|
1663 ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, val); |
|
1664 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1665 RDebug::Printf( "%s %s (%u) KSecurityUIsLockInitiatorTimeHigh=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1666 |
|
1667 ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, val); |
|
1668 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1669 RDebug::Printf( "%s %s (%u) KSecurityUIsLockInitiatorTimeLow=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1670 |
|
1671 ret = RProperty::Get(KPSUidHWRM, KHWRMGripStatus, val); |
|
1672 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1673 RDebug::Printf( "%s %s (%u) KHWRMGripStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1674 |
|
1675 ret = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, val); |
|
1676 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1677 RDebug::Printf( "%s %s (%u) KAknKeyguardStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, val ); |
|
1678 } |
|
1679 break; |
|
1680 case 45: |
|
1681 { |
|
1682 RDEBUG("Read-Prop8", 0); |
|
1683 mItemsToAdd = -1; |
|
1684 if(mTimer) |
|
1685 { |
|
1686 RDEBUG("stop", 0); |
|
1687 mTimer->stop(); |
|
1688 } |
|
1689 else |
|
1690 { |
|
1691 RDEBUG("new", 0); |
|
1692 mTimer = new QTimer(this); |
|
1693 } |
|
1694 RDEBUG("1", 1); |
|
1695 mTimer->setSingleShot(false); |
|
1696 RDEBUG("2", 2); |
|
1697 connect(mTimer, SIGNAL(timeout()), this, SLOT(addOneToModel())); |
|
1698 RDEBUG("3", 3); |
|
1699 mTimer->start(1000); |
|
1700 RDEBUG("4", 4); |
|
1701 } |
|
1702 break; |
|
1703 case 46: |
|
1704 { |
|
1705 RDEBUG("Stop-Prop8", 0); |
|
1706 mItemsToAdd = -1; |
|
1707 if(mTimer) |
|
1708 { |
|
1709 RDEBUG("stop", 1); |
|
1710 mTimer->stop(); |
|
1711 } |
|
1712 RDEBUG("done Stop-Prop8", 0x99); |
|
1713 } |
|
1714 break; |
|
1715 case 47: |
|
1716 { |
|
1717 RDEBUG("EAutolockOff", 0); |
|
1718 TInt val = -1; |
|
1719 TInt errProp = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff); |
|
1720 RDEBUG("errProp", errProp); |
|
1721 RDEBUG("KCoreAppUIsAutolockStatus EAutolockOff", EAutolockOff); |
|
1722 errProp = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, val); |
|
1723 RDEBUG("errProp", errProp); |
|
1724 RDEBUG("val", val); |
|
1725 } |
|
1726 break; |
|
1727 case 48: |
|
1728 { |
|
1729 RDEBUG("EManualLocked", 0); |
|
1730 TInt val = -1; |
|
1731 TInt errProp = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked); |
|
1732 RDEBUG("errProp", errProp); |
|
1733 RDEBUG("KCoreAppUIsAutolockStatus EManualLocked", EManualLocked); |
|
1734 errProp = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, val); |
|
1735 RDEBUG("errProp", errProp); |
|
1736 RDEBUG("val", val); |
|
1737 } |
|
1738 break; |
|
1739 case 49: |
|
1740 { |
|
1741 RDEBUG("EAutolockStatusUninitialized", 0); |
|
1742 TInt val = -1; |
|
1743 TInt errProp = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockStatusUninitialized); |
|
1744 RDEBUG("errProp", errProp); |
|
1745 RDEBUG("KCoreAppUIsAutolockStatus EAutolockStatusUninitialized", EAutolockStatusUninitialized); |
|
1746 errProp = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, val); |
|
1747 RDEBUG("errProp", errProp); |
|
1748 RDEBUG("val", val); |
|
1749 } |
|
1750 break; |
|
1751 /////////////////////// |
|
1752 case 50: |
|
1753 { |
|
1754 RDEBUG("KeyguardTime=0s", 0); |
|
1755 CRepository* repository = NULL; |
|
1756 TInt keyguardTime = 0; |
|
1757 TInt cRresult = 0; |
|
1758 cRresult = cRresult; |
|
1759 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1760 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1761 RDEBUG("cRresult", cRresult); |
|
1762 RDEBUG("keyguardTime", keyguardTime); |
|
1763 repository->Set(KSettingsAutomaticKeyguardTime, 0); // in seconds |
|
1764 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1765 RDEBUG("cRresult", cRresult); |
|
1766 RDEBUG("keyguardTime", keyguardTime); |
|
1767 delete repository; |
|
1768 } |
|
1769 break; |
|
1770 case 51: |
|
1771 { |
|
1772 RDEBUG("KeyguardTime=10s", 0); |
|
1773 CRepository* repository = NULL; |
|
1774 TInt keyguardTime = 0; |
|
1775 TInt cRresult = 0; |
|
1776 cRresult = cRresult; |
|
1777 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1778 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1779 RDEBUG("cRresult", cRresult); |
|
1780 RDEBUG("keyguardTime", keyguardTime); |
|
1781 repository->Set(KSettingsAutomaticKeyguardTime, 10); // in seconds |
|
1782 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1783 RDEBUG("cRresult", cRresult); |
|
1784 RDEBUG("keyguardTime", keyguardTime); |
|
1785 delete repository; |
|
1786 } |
|
1787 break; |
|
1788 case 52: |
|
1789 { |
|
1790 RDEBUG("KeyguardTime=30s", 0); |
|
1791 CRepository* repository = NULL; |
|
1792 TInt keyguardTime = 0; |
|
1793 TInt cRresult = 0; |
|
1794 cRresult = cRresult; |
|
1795 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1796 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1797 RDEBUG("cRresult", cRresult); |
|
1798 RDEBUG("keyguardTime", keyguardTime); |
|
1799 repository->Set(KSettingsAutomaticKeyguardTime, 30); // in seconds |
|
1800 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1801 RDEBUG("cRresult", cRresult); |
|
1802 RDEBUG("keyguardTime", keyguardTime); |
|
1803 delete repository; |
|
1804 } |
|
1805 break; |
|
1806 case 53: |
|
1807 { |
|
1808 RDEBUG("KeyguardTime=10+60s", 0); |
|
1809 CRepository* repository = NULL; |
|
1810 TInt keyguardTime = 0; |
|
1811 TInt cRresult = 0; |
|
1812 cRresult = cRresult; |
|
1813 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1814 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1815 RDEBUG("cRresult", cRresult); |
|
1816 RDEBUG("keyguardTime", keyguardTime); |
|
1817 repository->Set(KSettingsAutomaticKeyguardTime, 10+60); // in seconds |
|
1818 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1819 RDEBUG("cRresult", cRresult); |
|
1820 RDEBUG("keyguardTime", keyguardTime); |
|
1821 delete repository; |
|
1822 } |
|
1823 break; |
|
1824 case 54: |
|
1825 { |
|
1826 RDEBUG("AutoLockTime=0m", 0); |
|
1827 CRepository* repository = NULL; |
|
1828 TInt lockTime = 0; |
|
1829 TInt cRresult = 0; |
|
1830 cRresult = cRresult; |
|
1831 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1832 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1833 RDEBUG("cRresult", cRresult); |
|
1834 RDEBUG("lockTime", lockTime); |
|
1835 repository->Set(KSettingsAutoLockTime, 0); // in minutes |
|
1836 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1837 RDEBUG("cRresult", cRresult); |
|
1838 RDEBUG("lockTime", lockTime); |
|
1839 delete repository; |
|
1840 } |
|
1841 break; |
|
1842 case 55: |
|
1843 { |
|
1844 RDEBUG("AutoLockTime=1m", 0); |
|
1845 CRepository* repository = NULL; |
|
1846 TInt lockTime = 0; |
|
1847 TInt cRresult = 0; |
|
1848 cRresult = cRresult; |
|
1849 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1850 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1851 RDEBUG("cRresult", cRresult); |
|
1852 RDEBUG("lockTime", lockTime); |
|
1853 repository->Set(KSettingsAutoLockTime, 1); // in minutes |
|
1854 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1855 RDEBUG("cRresult", cRresult); |
|
1856 RDEBUG("lockTime", lockTime); |
|
1857 delete repository; |
|
1858 } |
|
1859 break; |
|
1860 case 56: |
|
1861 { |
|
1862 RDEBUG("AutoLockTime=2m", 0); |
|
1863 CRepository* repository = NULL; |
|
1864 TInt lockTime = 0; |
|
1865 TInt cRresult = 0; |
|
1866 cRresult = cRresult; |
|
1867 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1868 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1869 RDEBUG("cRresult", cRresult); |
|
1870 RDEBUG("lockTime", lockTime); |
|
1871 repository->Set(KSettingsAutoLockTime, 2); // in minutes |
|
1872 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1873 RDEBUG("cRresult", cRresult); |
|
1874 RDEBUG("lockTime", lockTime); |
|
1875 delete repository; |
|
1876 } |
|
1877 break; |
|
1878 case 57: |
|
1879 { |
|
1880 RDEBUG("AutoLockTime=65535m", 0); |
|
1881 CRepository* repository = NULL; |
|
1882 TInt lockTime = 0; |
|
1883 TInt cRresult = 0; |
|
1884 cRresult = cRresult; |
|
1885 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1886 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1887 RDEBUG("cRresult", cRresult); |
|
1888 RDEBUG("lockTime", lockTime); |
|
1889 repository->Set(KSettingsAutoLockTime, 65535); // in minutes |
|
1890 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1891 RDEBUG("cRresult", cRresult); |
|
1892 RDEBUG("lockTime", lockTime); |
|
1893 delete repository; |
|
1894 } |
|
1895 break; |
|
1896 case 58: |
|
1897 { |
|
1898 RDEBUG("read", 0); |
|
1899 CRepository* repository = NULL; |
|
1900 TInt keyguardTime = 0; |
|
1901 TInt cRresult = 0; |
|
1902 cRresult = cRresult; |
|
1903 repository = CRepository::NewL(KCRUidSecuritySettings); |
|
1904 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
1905 RDEBUG("cRresult", cRresult); |
|
1906 RDEBUG("lockTime", keyguardTime); |
|
1907 TInt lockTime = 0; |
|
1908 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes |
|
1909 RDEBUG("cRresult", cRresult); |
|
1910 RDEBUG("lockTime", lockTime); |
|
1911 delete repository; |
|
1912 } |
|
1913 break; |
|
1914 /////////////////////// |
|
1915 case 60: |
|
1916 { |
|
1917 RDEBUG("Wait30+Cancel_P&S", 0); |
|
1918 mItemsToAddExt = 61; |
|
1919 if(mTimerExt) |
|
1920 { |
|
1921 RDEBUG("stop", 0); |
|
1922 mTimerExt->stop(); |
|
1923 } |
|
1924 else |
|
1925 { |
|
1926 RDEBUG("new", 0); |
|
1927 mTimerExt = new QTimer(this); |
|
1928 } |
|
1929 RDEBUG("1", 1); |
|
1930 mTimerExt->setSingleShot(true); |
|
1931 RDEBUG("2", 2); |
|
1932 connect(mTimerExt, SIGNAL(timeout()), this, SLOT(addOneToModelExt())); |
|
1933 RDEBUG("3", 3); |
|
1934 mTimerExt->start(1000); |
|
1935 RDEBUG("4", 4); |
|
1936 } |
|
1937 break; |
|
1938 case 61: |
|
1939 { |
|
1940 RDEBUG("Cancel_P&S", 0); |
|
1941 TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn ); |
|
1942 RDEBUG("err", err); |
|
1943 for(int ii=5;ii>0;ii--) |
|
1944 { |
|
1945 RDEBUG("ii", ii); |
|
1946 User::After(1000*1000); |
|
1947 } |
|
1948 } |
|
1949 break; |
|
1950 case 62: |
|
1951 { |
|
1952 RDEBUG("TSecUi::InitializeLibL", 0); |
|
1953 TSecUi::InitializeLibL(); |
|
1954 RDEBUG("0", 0); |
|
1955 } |
|
1956 case 63: |
|
1957 { |
|
1958 RDEBUG("TSecUi::UnInitializeLib", 0); |
|
1959 TSecUi::UnInitializeLib(); |
|
1960 RDEBUG("0", 0); |
|
1961 } |
|
1962 case 64: |
|
1963 { |
|
1964 RDEBUG("Wait30+Cancel_P&S", 0); |
|
1965 mItemsToAddExt = 61; |
|
1966 if(mTimerExt) |
|
1967 { |
|
1968 RDEBUG("stop", 0); |
|
1969 mTimerExt->stop(); |
|
1970 } |
|
1971 else |
|
1972 { |
|
1973 RDEBUG("new", 0); |
|
1974 mTimerExt = new QTimer(this); |
|
1975 } |
|
1976 RDEBUG("1", 1); |
|
1977 mTimerExt->setSingleShot(true); |
|
1978 RDEBUG("2", 2); |
|
1979 connect(mTimerExt, SIGNAL(timeout()), this, SLOT(addOneToModelExt())); |
|
1980 RDEBUG("3", 3); |
|
1981 mTimerExt->start(1000); |
|
1982 RDEBUG("4", 4); |
|
1983 } |
|
1984 case 65: |
|
1985 { |
|
1986 RDEBUG("CancelSecCodeQuery", 0); |
|
1987 RMobilePhone iPhone; |
|
1988 |
|
1989 TInt err = KErrGeneral; |
|
1990 err = err; |
|
1991 TInt thisTry( 0); |
|
1992 RTelServer iTelServer; |
|
1993 RMmCustomAPI iCustomPhone; |
|
1994 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
1995 { |
|
1996 User::After( KTimeBeforeRetryingServerConnection ); |
|
1997 } |
|
1998 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1999 RTelServer::TPhoneInfo PhoneInfo; |
|
2000 err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ; |
|
2001 err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ; |
|
2002 err = iPhone.Open( iTelServer, PhoneInfo.iName ) ; |
|
2003 err = iCustomPhone.Open( iPhone ) ; |
|
2004 RDEBUG("err", err); |
|
2005 |
|
2006 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
|
2007 TInt result = KErrNone; |
|
2008 result = result; |
|
2009 RDEBUG("err", err); |
|
2010 handler->CancelSecCodeQuery(); |
|
2011 RDEBUG("0", 0); |
|
2012 delete handler; |
|
2013 RDEBUG("end", 0x99); |
|
2014 } |
|
2015 case 66: |
|
2016 { |
|
2017 RDEBUG("not supported EStdKeyDeviceF", 0); |
|
2018 /* |
|
2019 TApaTaskList tasklist( iCoeEnv->WsSession() ); |
|
2020 TApaTask autolocktask = tasklist.FindApp( KAutolockUid ); |
|
2021 if ( autolocktask.Exists() ) |
|
2022 { |
|
2023 TKeyEvent keyEvent; |
|
2024 RDebug::Printf( "%s %s (%u) EStdKeyDeviceF=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStdKeyDeviceF ); // 0xb3 |
|
2025 keyEvent.iCode = EStdKeyDeviceF; |
|
2026 keyEvent.iScanCode = EKeyDeviceF; |
|
2027 keyEvent.iRepeats = 0; |
|
2028 autolocktask.SendKey( keyEvent ); |
|
2029 } |
|
2030 */ |
|
2031 RDEBUG("-1", -1); |
|
2032 } |
|
2033 /////////////////////// |
|
2034 default: |
|
2035 RDEBUG("default itemValue", itemValue) |
|
2036 ; |
|
2037 break; |
|
2038 } |
|
2039 RDEBUG("real end", 0x99) |
|
2040 } |
|
2041 void ContentWidget::itemActivated(const QModelIndex& index) |
|
2042 { |
|
2043 TInt ret = KErrNone; |
|
2044 ret = ret; |
|
2045 RDEBUG("0", 0); |
|
2046 HbTreeViewItem *viewItem = qobject_cast<HbTreeViewItem*> (mTreeView->itemByIndex(index)); |
|
2047 RDEBUG("0", 0); |
|
2048 QStandardItemModel *model = static_cast<QStandardItemModel*> (mTreeView->model()); |
|
2049 QStandardItem *myItem = model->itemFromIndex(index); |
|
2050 QString itemText = myItem->text(); |
|
2051 itemText = itemText.left(2); |
|
2052 int itemValue = itemText.toInt(); |
|
2053 doCommand(itemValue); |
|
2054 } |
|
2055 |
|
2056 void ContentWidget::backButtonClicked() |
|
2057 { |
|
2058 RDEBUG("0", 0); |
|
2059 |
|
2060 if (mWindow->currentView() != this) |
|
2061 { |
|
2062 if (mForm) |
|
2063 { |
|
2064 postEvents(); |
|
2065 if (mForm->action() == ViewFuteDataForm::Settings) |
|
2066 { |
|
2067 doSettings(); |
|
2068 } |
|
2069 else if (mForm->action() == ViewFuteDataForm::AddItem) |
|
2070 { |
|
2071 doAddItem(); |
|
2072 } |
|
2073 mWindow->removeView(mForm); |
|
2074 mForm->deleteLater(); |
|
2075 mForm = 0; |
|
2076 } |
|
2077 |
|
2078 mWindow->addView(this); |
|
2079 postEvents(); |
|
2080 } |
|
2081 else |
|
2082 { |
|
2083 qApp->quit(); |
|
2084 } |
|
2085 } |
|
2086 |
|
2087 void ContentWidget::confirmDelete() |
|
2088 { |
|
2089 RDEBUG("0", 0); |
|
2090 |
|
2091 doRemoveItems(); |
|
2092 |
|
2093 mInfoLabel->hide(); |
|
2094 mMainlayout->removeItem(mInfoLabel); |
|
2095 mTreeView->setSelectionMode(HbAbstractItemView::NoSelection); |
|
2096 setNavigationAction( mSoftKeyQuitAction); |
|
2097 |
|
2098 mItemSubMenu->menuAction()->setEnabled(true); |
|
2099 } |
|
2100 |
|
2101 void ContentWidget::createAndInitTreeView(int newModelType) |
|
2102 { |
|
2103 RDEBUG("0", 0); |
|
2104 |
|
2105 bool treeViewChange = false; |
|
2106 if (mModelType == fileSystemModel || newModelType == fileSystemModel) |
|
2107 { |
|
2108 treeViewChange = true; |
|
2109 } |
|
2110 if (!mTreeView || treeViewChange) |
|
2111 { |
|
2112 if (mTreeView) |
|
2113 { |
|
2114 resetTreeView(); |
|
2115 } |
|
2116 if (newModelType == fileSystemModel) |
|
2117 { |
|
2118 mTreeView = new HbFileSystemTreeView(this); |
|
2119 } |
|
2120 else |
|
2121 { |
|
2122 mTreeView = new HbTreeView(this); |
|
2123 } |
|
2124 initTreeView(); |
|
2125 } |
|
2126 } |
|
2127 |
|
2128 void ContentWidget::initTreeView() |
|
2129 { |
|
2130 RDEBUG("0", 0); |
|
2131 |
|
2132 connect(mTreeView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); |
|
2133 |
|
2134 connect(mTreeView, |
|
2135 SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), |
|
2136 this, |
|
2137 SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); |
|
2138 |
|
2139 if (mTreeView->selectionModel()) |
|
2140 { |
|
2141 connect(mTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); |
|
2142 } |
|
2143 |
|
2144 setMenu( mMainMenu); |
|
2145 |
|
2146 mTreeView->setFocus(); |
|
2147 mTreeView->setLongPressEnabled(true); |
|
2148 mTreeView->setItemPixmapCacheEnabled(true); |
|
2149 |
|
2150 if (mMainlayout) |
|
2151 { |
|
2152 mMainlayout->addItem(mTreeView); |
|
2153 } |
|
2154 } |
|
2155 |
|
2156 void ContentWidget::resetTreeView() |
|
2157 { |
|
2158 RDEBUG("0", 0); |
|
2159 |
|
2160 delete mTreeView->model(); |
|
2161 |
|
2162 disconnect(mTreeView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated())); |
|
2163 |
|
2164 mMainlayout->removeItem(mTreeView); |
|
2165 |
|
2166 delete mTreeView; |
|
2167 mTreeView = 0; |
|
2168 mTarget = QModelIndex(); |
|
2169 } |
|
2170 |
|
2171 Q_DECLARE_METATYPE( QModelIndex) |
|
2172 void ContentWidget::setTargetItemActionTriggered() |
|
2173 { |
|
2174 RDEBUG("0", 0); |
|
2175 |
|
2176 QAction *action = qobject_cast<QAction *> (sender()); |
|
2177 if (action) |
|
2178 { |
|
2179 mTarget = action->data().value<QModelIndex> (); |
|
2180 if (mTarget.isValid()) |
|
2181 { |
|
2182 HbNotificationDialog *popup = new HbNotificationDialog; |
|
2183 popup->setText("Target set successfully."); |
|
2184 popup->setTimeout(700); |
|
2185 popup->setAttribute(Qt::WA_DeleteOnClose); |
|
2186 popup->show(); |
|
2187 } |
|
2188 } |
|
2189 } |
|
2190 |
|
2191 void ContentWidget::setRootItemActionTriggered() |
|
2192 { |
|
2193 RDEBUG("0", 0); |
|
2194 |
|
2195 QAction *action = qobject_cast<QAction *> (sender()); |
|
2196 if (action) |
|
2197 { |
|
2198 QModelIndex index = action->data().value<QModelIndex> (); |
|
2199 mTreeView->setRootIndex(index); |
|
2200 if (index.isValid()) |
|
2201 { |
|
2202 HbNotificationDialog *popup = new HbNotificationDialog; |
|
2203 popup->setText("Root item set successfully."); |
|
2204 popup->setTimeout(700); |
|
2205 popup->setAttribute(Qt::WA_DeleteOnClose); |
|
2206 popup->show(); |
|
2207 } |
|
2208 mTarget = QModelIndex(); |
|
2209 } |
|
2210 } |
|
2211 |
|
2212 void ContentWidget::onLongPressed(HbAbstractViewItem* listViewItem, const QPointF& coords) |
|
2213 { |
|
2214 RDEBUG("0", 0); |
|
2215 |
|
2216 Q_UNUSED(listViewItem); |
|
2217 |
|
2218 HbMenu *contextMenu = new HbMenu(); |
|
2219 HbAction *contextAction1 = contextMenu->addAction("Set as target item"); |
|
2220 HbAction *contextAction2 = contextMenu->addAction("Set as root item"); |
|
2221 |
|
2222 QVariant modelIndex = qVariantFromValue(listViewItem->modelIndex()); |
|
2223 contextAction1->setData(modelIndex); |
|
2224 contextAction2->setData(modelIndex); |
|
2225 |
|
2226 connect(contextAction1, SIGNAL(triggered()), SLOT(setTargetItemActionTriggered())); |
|
2227 connect(contextAction2, SIGNAL(triggered()), SLOT(setRootItemActionTriggered())); |
|
2228 |
|
2229 contextMenu->setAttribute(Qt::WA_DeleteOnClose); |
|
2230 contextMenu->setPreferredPos(coords); |
|
2231 contextMenu->show(); |
|
2232 } |
|
2233 |
|
2234 void ContentWidget::selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) |
|
2235 { |
|
2236 Q_UNUSED(selected) |
|
2237 Q_UNUSED(deselected) |
|
2238 QItemSelectionModel *selectionModel = mTreeView->selectionModel(); |
|
2239 QModelIndexList indexes = selectionModel->selectedIndexes(); |
|
2240 updateTextLabel(indexes.count()); |
|
2241 } |
|
2242 |
|
2243 void ContentWidget::updateTextLabel(int count) |
|
2244 { |
|
2245 RDEBUG("0", 0); |
|
2246 |
|
2247 if (count == 0) |
|
2248 { |
|
2249 mInfoLabel->setPlainText("No items selected"); |
|
2250 } |
|
2251 else |
|
2252 { |
|
2253 QString text = QString::number(count); |
|
2254 text.append(" items selected"); |
|
2255 mInfoLabel->setPlainText(text); |
|
2256 } |
|
2257 } |
|
2258 |
|
2259 void ContentWidget::doSettings() |
|
2260 { |
|
2261 RDEBUG("0", 0); |
|
2262 |
|
2263 mForm->resolveSettingsResults(); |
|
2264 mScrollHint = mForm->getScrollHint(); |
|
2265 |
|
2266 int mDepthTemp = mDepth; |
|
2267 mDepth = mForm->getDepth(); |
|
2268 if (mDepthTemp != mDepth) |
|
2269 { |
|
2270 collapse(mTreeView->model(), mTreeView->rootIndex(), mDepth); |
|
2271 expand(mTreeView->model(), mTreeView->rootIndex(), mDepth); |
|
2272 } |
|
2273 } |
|
2274 |
|
2275 int ContentWidget::calculateDepth(QModelIndex m) const |
|
2276 { |
|
2277 int depth = 1; |
|
2278 RDEBUG("0", 0); |
|
2279 |
|
2280 while (m.parent() != QModelIndex()) |
|
2281 { |
|
2282 depth++; |
|
2283 m = m.parent(); |
|
2284 } |
|
2285 return depth; |
|
2286 } |
|
2287 |
|
2288 void ContentWidget::expand(const QAbstractItemModel *model, const QModelIndex &parent, int depth) |
|
2289 { |
|
2290 RDEBUG("0", 0); |
|
2291 |
|
2292 if (model && depth > 1 && (parent == mTreeView->rootIndex() || parent.isValid())) |
|
2293 { |
|
2294 int rows = model->rowCount(parent); |
|
2295 for (int j = 0; j < rows; j++) |
|
2296 { |
|
2297 QModelIndex index = model->index(j, 0, parent); |
|
2298 if (index.isValid() && model->rowCount(index) > 0) |
|
2299 { |
|
2300 if (!mTreeView->isExpanded(index)) |
|
2301 { |
|
2302 mTreeView->setExpanded(index, true); |
|
2303 } |
|
2304 expand(model, index, depth - 1); |
|
2305 } |
|
2306 } |
|
2307 } |
|
2308 } |
|
2309 |
|
2310 void ContentWidget::expandUpwards(const QAbstractItemModel *model, const QModelIndex &index) |
|
2311 { |
|
2312 RDEBUG("0", 0); |
|
2313 |
|
2314 if (model && index != mTreeView->rootIndex() && index.isValid()) |
|
2315 { |
|
2316 if (!mTreeView->isExpanded(index)) |
|
2317 { |
|
2318 mTreeView->setExpanded(index, true); |
|
2319 } |
|
2320 expandUpwards(model, index.parent()); |
|
2321 } |
|
2322 } |
|
2323 |
|
2324 void ContentWidget::collapse(const QAbstractItemModel *model, const QModelIndex &parent, int depth) |
|
2325 { |
|
2326 RDEBUG("0", 0); |
|
2327 |
|
2328 if (model && depth >= 1 && (parent == mTreeView->rootIndex() || parent.isValid())) |
|
2329 { |
|
2330 int rows = model->rowCount(parent); |
|
2331 for (int j = 0; j < rows; j++) |
|
2332 { |
|
2333 QModelIndex index = model->index(j, 0, parent); |
|
2334 if (index.isValid() && model->rowCount(index) > 0) |
|
2335 { |
|
2336 if (calculateDepth(index) >= depth && mTreeView->isExpanded(index)) |
|
2337 { |
|
2338 mTreeView->setExpanded(index, false); |
|
2339 } |
|
2340 collapse(model, index, depth); |
|
2341 } |
|
2342 } |
|
2343 } |
|
2344 } |
|
2345 |
|
2346 void ContentWidget::postEvents() |
|
2347 { |
|
2348 RDEBUG("0", 0); |
|
2349 |
|
2350 // When widgets are added or removed from main window text items |
|
2351 // get font change event, which layout everything again. |
|
2352 // Use case add item & scroll hint PositionAtBottom fails, |
|
2353 // if those posted events are not flushed first. |
|
2354 |
|
2355 //TODO: to be wholly when proved that problmes putting following into comments are not too big |
|
2356 //QCoreApplication::sendPostedEvents(); |
|
2357 //QCoreApplication::sendPostedEvents(); |
|
2358 //QCoreApplication::sendPostedEvents(); |
|
2359 } |
|
2360 |
|
2361 void ContentWidget::aboutToClose() |
|
2362 { |
|
2363 delete mPopupModel; |
|
2364 mPopupModel = 0; |
|
2365 } |
|
2366 |
|
2367 void ContentWidget::autoInsertOne() |
|
2368 { |
|
2369 RDEBUG("0", 0); |
|
2370 |
|
2371 // add item to model after three seconds |
|
2372 QTimer *timer = new QTimer(this); |
|
2373 timer->setSingleShot(true); |
|
2374 connect(timer, SIGNAL(timeout()), this, SLOT(addOneToModel())); |
|
2375 timer->start(3000); |
|
2376 } |
|
2377 void ContentWidget::autoRemoveOne() |
|
2378 { |
|
2379 // remove item from model after three seconds |
|
2380 QModelIndex index = mTreeView->currentIndex(); |
|
2381 if (!index.isValid()) |
|
2382 { |
|
2383 QAbstractItemModel *model = mTreeView->model(); |
|
2384 index = model->index((model->rowCount() / 2), 0, mTreeView->rootIndex()); |
|
2385 } |
|
2386 |
|
2387 mItemsToRemove.clear(); |
|
2388 mItemsToRemove.append(index); |
|
2389 |
|
2390 QTimer *timer = new QTimer(this); |
|
2391 timer->setSingleShot(true); |
|
2392 connect(timer, SIGNAL(timeout()), this, SLOT(removeFromModel())); |
|
2393 timer->start(3000); |
|
2394 } |
|
2395 |
|
2396 void ContentWidget::addOneToModel() |
|
2397 { |
|
2398 RDEBUG("mItemsToAdd", mItemsToAdd); |
|
2399 if(mItemsToAdd>0) |
|
2400 mItemsToAdd--; |
|
2401 if(mItemsToAdd==0) |
|
2402 return; |
|
2403 |
|
2404 TInt ret=KErrNone; |
|
2405 ret = ret; |
|
2406 TInt val=-1; |
|
2407 ret = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, val); |
|
2408 RDEBUG("KCoreAppUIsAutolockStatus", val); |
|
2409 ret = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, val); |
|
2410 RDEBUG("KAknKeyguardStatus", val); |
|
2411 ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLights, val); |
|
2412 RDEBUG("KSecurityUIsLights", val); |
|
2413 ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, val); |
|
2414 RDEBUG("KSecurityUIsSecUIOriginatedQuery", val); |
|
2415 } |
|
2416 |
|
2417 void ContentWidget::addOneToModelExt() |
|
2418 { |
|
2419 RDEBUG("mItemsToAddExt", mItemsToAddExt); |
|
2420 if(mItemsToAddExt>0) |
|
2421 mItemsToAddExt--; |
|
2422 if(mItemsToAddExt==0) |
|
2423 return; |
|
2424 |
|
2425 TInt ret=KErrNone; |
|
2426 ret=ret; |
|
2427 TInt val=-1; |
|
2428 val=val; |
|
2429 doCommand(mItemsToAddExt); |
|
2430 } |
|
2431 |
|
2432 void ContentWidget::removeFromModel() |
|
2433 { |
|
2434 if (mItemsToRemove.count() > 0) |
|
2435 { |
|
2436 int count = mItemsToRemove.count(); |
|
2437 |
|
2438 for (int i = 0; i < count; ++i) |
|
2439 { |
|
2440 mTreeView->model()->removeRow(mItemsToRemove.takeLast().row()); |
|
2441 } |
|
2442 } |
|
2443 } |
|
2444 |
|
2445 void ContentWidget::simulateMultipleFastInserts() |
|
2446 { |
|
2447 RDEBUG("0", 0); |
|
2448 |
|
2449 if (!mTimer) |
|
2450 { |
|
2451 mTimer = new QTimer(this); |
|
2452 connect(mTimer, SIGNAL(timeout()), this, SLOT(timerReadyForInsert())); |
|
2453 } |
|
2454 mItemsToAdd = 50; |
|
2455 mTimer->start(100); |
|
2456 |
|
2457 } |
|
2458 |
|
2459 void ContentWidget::simulateMultipleFastRemovals() |
|
2460 { |
|
2461 if (!mTimer) |
|
2462 { |
|
2463 mTimer = new QTimer(this); |
|
2464 connect(mTimer, SIGNAL(timeout()), this, SLOT(timerReadyForRemoval())); |
|
2465 } |
|
2466 mItemsToAdd = 50; |
|
2467 |
|
2468 mTimer->start(100); |
|
2469 |
|
2470 } |
|
2471 |
|
2472 void ContentWidget::timerReadyForRemoval() |
|
2473 { |
|
2474 RDEBUG("0", 0); |
|
2475 |
|
2476 if (mItemsToAdd == 10) |
|
2477 { |
|
2478 HbAction *action = mCheckableItemActions.value(resetDuringSimulation); |
|
2479 if (action) |
|
2480 { |
|
2481 if (action->isChecked() && mTreeView->model()) |
|
2482 { |
|
2483 mItemsToAdd--; |
|
2484 mTreeView->reset(); |
|
2485 return; |
|
2486 } |
|
2487 } |
|
2488 } |
|
2489 |
|
2490 if (mItemsToAdd > 0 && mTreeView->model() && mTreeView->model()->rowCount() > 0) |
|
2491 { |
|
2492 int pos = 0; |
|
2493 bool removeVisible = false; |
|
2494 HbAction *action = mCheckableItemActions.value(simulateVisible); |
|
2495 if (action) |
|
2496 { |
|
2497 removeVisible = action->isChecked(); |
|
2498 } |
|
2499 |
|
2500 if (removeVisible) |
|
2501 { |
|
2502 QList<HbAbstractViewItem *> visibleItems = mTreeView->visibleItems(); |
|
2503 if (visibleItems.count()) |
|
2504 { |
|
2505 pos = rand() % visibleItems.count(); |
|
2506 pos = visibleItems.at(pos)->modelIndex().row(); |
|
2507 } |
|
2508 } |
|
2509 else if (mTreeView->model()->rowCount() > 0) |
|
2510 { |
|
2511 pos = rand() % mTreeView->model()->rowCount(); |
|
2512 } |
|
2513 |
|
2514 mTimer->setInterval(2 + rand() % 10); |
|
2515 mTreeView->model()->removeRows(pos, 1); |
|
2516 mItemsToAdd--; |
|
2517 } |
|
2518 else |
|
2519 { |
|
2520 mTimer->stop(); |
|
2521 delete mTimer; |
|
2522 mTimer = 0; |
|
2523 } |
|
2524 } |
|
2525 |
|
2526 void ContentWidget::timerReadyForInsert() |
|
2527 { |
|
2528 RDEBUG("0", 0); |
|
2529 |
|
2530 if (mItemsToAdd == 10) |
|
2531 { |
|
2532 HbAction *action = mCheckableItemActions.value(resetDuringSimulation); |
|
2533 if (action) |
|
2534 { |
|
2535 if (action->isChecked() && mTreeView->model()) |
|
2536 { |
|
2537 mItemsToAdd--; |
|
2538 mTreeView->reset(); |
|
2539 return; |
|
2540 } |
|
2541 } |
|
2542 } |
|
2543 |
|
2544 if (mItemsToAdd > 0 && mTreeView->model()) |
|
2545 { |
|
2546 int pos = 0; |
|
2547 |
|
2548 bool insertAsVisible = false; |
|
2549 HbAction *action = mCheckableItemActions.value(simulateVisible); |
|
2550 if (action) |
|
2551 { |
|
2552 insertAsVisible = action->isChecked(); |
|
2553 } |
|
2554 |
|
2555 if (insertAsVisible) |
|
2556 { |
|
2557 QList<HbAbstractViewItem *> visibleItems = mTreeView->visibleItems(); |
|
2558 if (visibleItems.count()) |
|
2559 { |
|
2560 pos = rand() % visibleItems.count(); |
|
2561 pos = visibleItems.at(pos)->modelIndex().row(); |
|
2562 } |
|
2563 } |
|
2564 else if (mTreeView->model()->rowCount() > 0) |
|
2565 { |
|
2566 pos = rand() % mTreeView->model()->rowCount(); |
|
2567 } |
|
2568 |
|
2569 mTimer->setInterval(2 + rand() % 10); |
|
2570 |
|
2571 if (mModelType == treeModelMixed) |
|
2572 { |
|
2573 QStandardItem *item = new QStandardItem; |
|
2574 |
|
2575 if (rand() % 7) |
|
2576 { |
|
2577 QString text; |
|
2578 QVariantList strings; |
|
2579 HbIcon icon(QString(":/demo/remixevent")); |
|
2580 if (rand() % 10) |
|
2581 { |
|
2582 text = "text " + QString::number(strings.size() + 1); |
|
2583 for (int i = rand() % 5; i > 0; i--) |
|
2584 { |
|
2585 text.append(" and"); |
|
2586 }; |
|
2587 strings << text; |
|
2588 } |
|
2589 if (rand() % 5) |
|
2590 { |
|
2591 text = "text " + QString::number(strings.size() + 1); |
|
2592 for (int i = rand() % 20; i > 0; i--) |
|
2593 { |
|
2594 text.append(" and"); |
|
2595 }; |
|
2596 strings << text; |
|
2597 } |
|
2598 if (rand() % 3) |
|
2599 { |
|
2600 text = "text " + QString::number(strings.size() + 1); |
|
2601 for (int i = rand() % 30; i > 0; i--) |
|
2602 { |
|
2603 text.append(" and"); |
|
2604 }; |
|
2605 strings << text; |
|
2606 } |
|
2607 QVariantList icons; |
|
2608 |
|
2609 if (rand() % 15) |
|
2610 { |
|
2611 icons << icon; |
|
2612 } |
|
2613 else |
|
2614 { |
|
2615 icons << QVariant(); |
|
2616 } |
|
2617 |
|
2618 if (rand() % 5) |
|
2619 { |
|
2620 icons << icon; |
|
2621 } |
|
2622 item->setData(icons, Qt::DecorationRole); |
|
2623 item->setData(strings, Qt::DisplayRole); |
|
2624 } |
|
2625 else |
|
2626 { |
|
2627 // separator |
|
2628 item->setData(Hb::SeparatorItem, Hb::ItemTypeRole); |
|
2629 item->setData(QVariant("Separator"), Qt::DisplayRole); |
|
2630 } |
|
2631 mItemsToAdd--; |
|
2632 doAddItem(pos, item); |
|
2633 } |
|
2634 else if (mModelType != dirModel) |
|
2635 { |
|
2636 QStandardItem *item = new QStandardItem(); |
|
2637 item->setData(mItemsToAdd == 1 ? QString("Simulated item %1 - last item!!!").arg(mItemsToAdd--) : QString("Simulated item %1").arg(mItemsToAdd--), Qt::DisplayRole); |
|
2638 doAddItem(pos, item); |
|
2639 } |
|
2640 } |
|
2641 else |
|
2642 { |
|
2643 mTimer->stop(); |
|
2644 delete mTimer; |
|
2645 mTimer = 0; |
|
2646 } |
|
2647 } |
|
2648 |
|
2649 void ContentWidget::insertItemAboveTargetClosed(int action) |
|
2650 { |
|
2651 RDEBUG("0", 0); |
|
2652 |
|
2653 HbInputDialog *dlg = static_cast<HbInputDialog*> (sender()); |
|
2654 QString text = dlg->value().toString(); |
|
2655 //if(dlg->actions().first() == action) { |
|
2656 if (action == HbDialog::Accepted) |
|
2657 { |
|
2658 mTextOfNewItem = text; |
|
2659 |
|
2660 QStandardItemModel* model = qobject_cast<QStandardItemModel *> (mTreeView->model()); |
|
2661 int row = mTarget.row(); |
|
2662 model->insertRow(row, mTarget.parent()); |
|
2663 |
|
2664 // Set text. |
|
2665 if (mTextOfNewItem != QString()) |
|
2666 { |
|
2667 QModelIndex index = model->index(row, 0, mTarget.parent()); |
|
2668 QStandardItem* newItem = model->itemFromIndex(index); |
|
2669 newItem->setText(mTextOfNewItem); |
|
2670 } |
|
2671 } |
|
2672 else if (action == HbDialog::Rejected) |
|
2673 { |
|
2674 return; |
|
2675 } |
|
2676 } |
|
2677 |
|
2678 void ContentWidget::insertItemBelowTargetClosed(int action) |
|
2679 { |
|
2680 HbInputDialog *dlg = static_cast<HbInputDialog*> (sender()); |
|
2681 QString text = dlg->value().toString(); |
|
2682 // if(dlg->actions().first() == action) { |
|
2683 if (action == HbDialog::Accepted) |
|
2684 { |
|
2685 mTextOfNewItem = text; |
|
2686 |
|
2687 QStandardItemModel* model = qobject_cast<QStandardItemModel *> (mTreeView->model()); |
|
2688 int row = mTarget.row() + 1; |
|
2689 model->insertRow(row, mTarget.parent()); |
|
2690 |
|
2691 // Set text. |
|
2692 if (mTextOfNewItem != QString()) |
|
2693 { |
|
2694 QModelIndex index = model->index(row, 0, mTarget.parent()); |
|
2695 QStandardItem* newItem = model->itemFromIndex(index); |
|
2696 newItem->setText(mTextOfNewItem); |
|
2697 } |
|
2698 } |
|
2699 else if (action == HbDialog::Rejected) |
|
2700 return; |
|
2701 |
|
2702 } |
|
2703 |
|
2704 void ContentWidget::expandTargetItem() |
|
2705 { |
|
2706 if (!mTreeView->isExpanded(mTarget)) |
|
2707 { |
|
2708 mTreeView->setExpanded(mTarget, true); |
|
2709 } |
|
2710 expand(mTreeView->model(), mTarget, 999); |
|
2711 |
|
2712 } |
|
2713 |
|
2714 void ContentWidget::collapseTargetItem() |
|
2715 { |
|
2716 if (mTreeView->isExpanded(mTarget)) |
|
2717 { |
|
2718 mTreeView->setExpanded(mTarget, false); |
|
2719 } |
|
2720 collapse(mTreeView->model(), mTarget, 999); |
|
2721 } |
|
2722 |
|
2723 // TODO |
|
2724 /* |
|
2725 verify Autolock is running |
|
2726 |
|
2727 |
|
2728 */ |