71 HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2")); |
93 HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2")); |
72 |
94 |
73 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
95 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
74 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
96 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
75 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
97 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
76 |
98 |
77 //mListView = qobject_cast<HbListView*>( loader.findWidget("listView") ); |
99 mContent = qobject_cast< HbWidget*>( loader.findWidget("content") ); |
|
100 |
78 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
101 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
79 //mListView = loader.findWidget("listWidget"); |
|
80 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
102 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
81 |
103 |
|
104 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
|
105 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
|
106 |
82 HbListViewItem *prototype = mListView->listItemPrototype(); |
107 HbListViewItem *prototype = mListView->listItemPrototype(); |
83 |
108 |
84 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
109 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
85 //prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
110 |
86 //prototype->setSecondaryTextRowCount(1,1); |
111 HbDockWidget *dock = new HbDockWidget(this); |
87 |
112 HbWidget *dockContainer = new HbWidget(dock); |
88 |
113 QGraphicsLinearLayout *dockLayout = new QGraphicsLinearLayout(dockContainer); |
89 |
114 dockLayout->setOrientation(Qt::Vertical); |
90 /*HbListWidgetItem* item = new HbListWidgetItem(); |
115 dockContainer->setLayout(dockLayout); |
91 QStringList data; |
116 |
92 data << "Test application" << "Critical"; |
117 mSelections = new HbGroupBox(dockContainer); |
93 item->setData(QVariant(data), Qt::DisplayRole); |
118 mSelections->setHeading("Selected 0/0 (0 kB)"); |
94 mListWidget->addItem(item);*/ |
119 |
|
120 dockLayout->addItem( mSelections); |
|
121 |
|
122 dockLayout->addItem(toolBar); |
|
123 |
|
124 dock->setWidget(dockContainer); |
|
125 |
|
126 setDockWidget(dock); |
|
127 |
|
128 |
|
129 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::IAUpdateMainView() end"); |
95 } |
130 } |
96 |
131 |
97 IAUpdateMainView::~IAUpdateMainView() |
132 IAUpdateMainView::~IAUpdateMainView() |
98 { |
133 { |
|
134 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::~IAUpdateMainView() begin"); |
|
135 |
|
136 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::~IAUpdateMainView() end"); |
99 } |
137 } |
100 |
138 |
101 // ----------------------------------------------------------------------------- |
139 // ----------------------------------------------------------------------------- |
102 // IAUpdateMainView::refresh |
140 // IAUpdateMainView::refresh |
103 // Refreshes update list |
141 // Refreshes update list |
104 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
105 // |
143 // |
106 void IAUpdateMainView::refresh( const RPointerArray<MIAUpdateNode> &nodes, |
144 void IAUpdateMainView::refresh(const RPointerArray<MIAUpdateNode> &nodes, |
107 const RPointerArray<MIAUpdateFwNode> &fwNodes, |
145 const RPointerArray<MIAUpdateFwNode> &fwNodes, |
108 int /*error*/ ) |
146 int error) |
109 { |
147 { |
110 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh begin"); |
148 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() begin"); |
|
149 removeCurrentContentLayout(); |
|
150 |
|
151 refreshFirmwareUpdates(fwNodes); |
|
152 |
|
153 refreshApplicationUpdates(nodes); |
|
154 |
|
155 if (nodes.Count() == 0 && fwNodes.Count() == 0 && |
|
156 error != KErrCancel && error != KErrAbort) |
|
157 { |
|
158 if (!mContentDataForm) |
|
159 { |
|
160 mContentDataForm = new HbDataForm(mContent); |
|
161 } |
|
162 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
163 linearLayout->addItem(mContentDataForm); |
|
164 QString formText; |
|
165 |
|
166 if (error == KErrNone) |
|
167 { |
|
168 formText = QString("Applications are up to date"); |
|
169 } |
|
170 else |
|
171 { |
|
172 formText = QString("Refreshing failed. Try again later."); |
|
173 } |
|
174 mContentDataForm->setDescription(formText); |
|
175 } |
|
176 updateSelectionInfoInDock(); |
|
177 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() end"); |
|
178 } |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 void IAUpdateMainView::handleStartUpdate() |
|
184 { |
|
185 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() begin"); |
|
186 mEngine->StartUpdate(fotaSelected()); |
|
187 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() end"); |
|
188 } |
|
189 |
|
190 |
|
191 void IAUpdateMainView::handleSettings() |
|
192 { |
|
193 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSettings() begin"); |
|
194 emit toSettingView(); |
|
195 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSettings() end"); |
|
196 } |
|
197 |
|
198 void IAUpdateMainView::handleDisclaimer() |
|
199 { |
|
200 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() begin"); |
|
201 if (!mDialogUtil) |
|
202 { |
|
203 mDialogUtil = new IAUpdateDialogUtil(this); |
|
204 } |
|
205 if (mDialogUtil) |
|
206 { |
|
207 HbAction *primaryAction = new HbAction("OK"); |
|
208 mDialogUtil->showAgreement(primaryAction); |
|
209 } |
|
210 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() end"); |
|
211 } |
|
212 |
|
213 void IAUpdateMainView::handleDetails(HbAbstractViewItem * item, const QPointF &) |
|
214 { |
|
215 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDetails() begin"); |
|
216 int ind = item->modelIndex().row(); |
|
217 if (getApplicationNode(ind) != NULL) |
|
218 { |
|
219 showDetails(*getApplicationNode(ind)); |
|
220 } |
|
221 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDetails() end"); |
|
222 } |
|
223 |
|
224 void IAUpdateMainView::handleFotaDetails(HbAbstractViewItem *, const QPointF &) |
|
225 { |
|
226 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFotaDetails begin"); |
|
227 //only one FOTA item in a list, just use it |
|
228 for (int i = 0; i < mFwNodes.Count(); i++) |
|
229 { |
|
230 if (mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2) |
|
231 { |
|
232 showDetails(*mFwNodes[i]); |
|
233 } |
|
234 } |
|
235 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFotaDetails end"); |
|
236 } |
|
237 |
|
238 |
|
239 void IAUpdateMainView::handleSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
|
240 { |
|
241 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSelectionChanged begin"); |
|
242 if (!mSelectionUpdate) |
|
243 { |
|
244 bool changedItemFound = false; |
|
245 QModelIndexList indexList = selected.indexes(); |
|
246 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
247 { |
|
248 changedItemFound = true; |
|
249 markListItem(true, indexList.at(i).row()); |
|
250 } |
|
251 if (!changedItemFound) |
|
252 { |
|
253 indexList = deselected.indexes(); |
|
254 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
255 { |
|
256 changedItemFound = true; |
|
257 markListItem(false, indexList.at(i).row()); |
|
258 } |
|
259 } |
|
260 } |
|
261 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSelectionChanged end"); |
|
262 } |
|
263 |
|
264 void IAUpdateMainView::handleFwSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
|
265 { |
|
266 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFwSelectionChanged begin"); |
|
267 if (!mSelectionUpdate) |
|
268 { |
|
269 bool changedItemFound = false; |
|
270 QModelIndexList indexList = selected.indexes(); |
|
271 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
272 { |
|
273 changedItemFound = true; |
|
274 markFotaItem(true); |
|
275 } |
|
276 if (!changedItemFound) |
|
277 { |
|
278 indexList = deselected.indexes(); |
|
279 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
280 { |
|
281 changedItemFound = true; |
|
282 markFotaItem(false); |
|
283 } |
|
284 } |
|
285 } |
|
286 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFwSelectionChanged end"); |
|
287 } |
|
288 |
|
289 |
|
290 void IAUpdateMainView::dialogFinished(HbAction *action) |
|
291 { |
|
292 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::dialogFinished begin"); |
|
293 DialogState dialogState = mDialogState; |
|
294 mDialogState = NoDialog; |
|
295 |
|
296 switch ( dialogState ) |
|
297 { |
|
298 case Dependencies: |
|
299 if (action == mPrimaryAction) |
|
300 { |
|
301 updateSelectionsToNodeArray(*mNode,mMark); |
|
302 } |
|
303 updateSelectionsToList(); |
|
304 updateSelectionInfoInDock(); |
|
305 break; |
|
306 case CannotOmit: |
|
307 break; |
|
308 case Details: |
|
309 break; |
|
310 default: |
|
311 break; |
|
312 } |
|
313 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::dialogFinished end"); |
|
314 } |
|
315 |
|
316 bool IAUpdateMainView::fotaSelected() const |
|
317 { |
|
318 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fotaSelected() begin"); |
|
319 bool selected = false; |
|
320 for (int i = 0; i < mFwNodes.Count() && !selected; ++i) |
|
321 { |
|
322 if ( mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2 && mFwNodes[i]->Base().IsSelected() ) |
|
323 { |
|
324 selected = true; |
|
325 } |
|
326 } |
|
327 if (selected) |
|
328 { |
|
329 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fotaSelected() Fota item is selected"); |
|
330 } |
|
331 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fotaSelected() end"); |
|
332 return selected; |
|
333 } |
|
334 |
|
335 |
|
336 |
|
337 void IAUpdateMainView::markListItem(bool mark, int index) |
|
338 { |
|
339 IAUPDATE_TRACE_2("[IAUPDATE] IAUpdateMainView::markListItem() begin mark: %d index %d", mark, index); |
|
340 if (mark) |
|
341 { |
|
342 //It's Mark Command |
|
343 if (fotaSelected()) |
|
344 { |
|
345 //FOTA item is selected, unmark FOTA item |
|
346 //FOTA item and application update items can't be selected at the same time |
|
347 markFotaItem(false); |
|
348 } |
|
349 } |
111 |
350 |
112 mAllNodes.Reset(); |
351 bool accepted = false; |
113 |
352 |
114 if ( fwNodes.Count() > 0 ) |
353 if(index > -1) |
115 { |
354 { |
116 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh hard code importance"); |
355 accepted = true; |
117 //hardcode the importance of firmware as Critical |
356 MIAUpdateNode* node = mNodes[index]; |
118 for ( TInt i = 0; i < fwNodes.Count(); i++ ) |
357 RPointerArray<MIAUpdateNode> mands; |
119 { |
358 RPointerArray<MIAUpdateNode> deps; |
120 fwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical ); |
359 |
121 } |
360 if (mark) |
122 |
361 { |
123 //either NSU or FOTA available |
362 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*node, mNodes, deps)); |
124 if ( fwNodes.Count() == 1 ) |
363 if (err != KErrNone) |
125 { |
364 { |
126 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh either NSU or FOTA available"); |
365 deps.Close(); |
127 MIAUpdateAnyNode* node = fwNodes[0]; |
366 updateSelectionsToList(); |
128 mAllNodes.Append( node ); |
367 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
129 } |
368 return; |
130 |
369 } |
131 //both NSU and FOTA available, show only FOTA node |
370 if (!getMandatoryNodes(mands)) |
132 if ( fwNodes.Count() == 2 ) |
|
133 { |
|
134 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh both NSU and FOTA available"); |
|
135 MIAUpdateAnyNode* node1 = fwNodes[0]; |
|
136 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node1 ); |
|
137 if ( fwnode->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
138 { |
371 { |
139 mAllNodes.Append( node1 ); |
372 // error when creating mandatory node list |
|
373 mands.Close(); |
|
374 updateSelectionsToList(); |
|
375 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
376 return; |
|
377 } |
|
378 } |
|
379 else |
|
380 { |
|
381 //mandatory item is not allowed to be unmarked |
|
382 if (mNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
383 { |
|
384 //show dialog |
|
385 showUpdateCannotOmitDialog(); |
|
386 updateSelectionsToList(); |
|
387 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
388 return; |
|
389 } |
|
390 TRAPD(err,IAUpdateDepUtils::GetDependantsL(*node, mNodes, deps)); |
|
391 if (err != KErrNone) |
|
392 { |
|
393 deps.Close(); |
|
394 updateSelectionsToList(); |
|
395 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
396 return; |
|
397 } |
|
398 // item is not allowed to be unmarked if its dependant is mandatory |
|
399 bool mandatoryDependantFound = false; |
|
400 for(int i = 0; i < deps.Count() && !mandatoryDependantFound; i++) |
|
401 { |
|
402 if (deps[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
403 { |
|
404 mandatoryDependantFound = true; |
|
405 } |
|
406 } |
|
407 if (mandatoryDependantFound) |
|
408 { |
|
409 showUpdateCannotOmitDialog(); |
|
410 deps.Close(); |
|
411 updateSelectionsToList(); |
|
412 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
413 return; |
|
414 } |
|
415 } |
|
416 |
|
417 int depCount = deps.Count(); |
|
418 |
|
419 if (depCount > 0) |
|
420 { |
|
421 QString text; |
|
422 QString names; |
|
423 MIAUpdateNode* depNode = NULL; |
|
424 QString separator(","); |
|
425 |
|
426 for(int i = 0; i < depCount; i++) |
|
427 { |
|
428 depNode = deps[i]; |
|
429 if (i > 0) |
|
430 { |
|
431 names.append(separator); |
|
432 names.append(QString(" ")); |
|
433 } |
|
434 names.append(XQConversions::s60DescToQString(depNode->Base().Name())); |
|
435 } |
|
436 |
|
437 if (mark) |
|
438 { |
|
439 if (depCount > 1) |
|
440 { |
|
441 text.append("This update needs also updates "); |
|
442 text.append(names); |
|
443 text.append(" for working"); |
|
444 } |
|
445 else |
|
446 { |
|
447 text.append("This update needs also \""); |
|
448 text.append(names); |
|
449 text.append("\" for working"); |
|
450 } |
140 } |
451 } |
141 else |
452 else |
|
453 { |
|
454 if (depCount > 1) |
142 { |
455 { |
143 MIAUpdateAnyNode* node2 = fwNodes[1]; |
456 text.append("Updates "); |
144 mAllNodes.Append( node2 ); |
457 text.append(names); |
|
458 text.append(" need this update for working"); |
|
459 } |
|
460 else |
|
461 { |
|
462 text.append("Update \""); |
|
463 text.append(names); |
|
464 text.append("\" needs this update for working"); |
|
465 } |
|
466 } |
|
467 |
|
468 if (mark && mNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
469 { |
|
470 // depencencies of mandatory update are also selected without showing dialog |
|
471 accepted = true; |
|
472 } |
|
473 else |
|
474 { |
|
475 mNode = node; |
|
476 mMark = mark; |
|
477 accepted = false; |
|
478 showDependenciesFoundDialog(text); |
|
479 } |
|
480 } |
|
481 if (accepted) |
|
482 { |
|
483 updateSelectionsToNodeArray(*node, mark); |
|
484 } |
|
485 } |
|
486 if (accepted) |
|
487 { |
|
488 updateSelectionsToList(); |
|
489 updateSelectionInfoInDock(); |
|
490 } |
|
491 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() end"); |
|
492 } |
|
493 |
|
494 |
|
495 void IAUpdateMainView::markFotaItem(bool mark) |
|
496 { |
|
497 IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateMainView::markFotaItem() begin mark: %d", mark); |
|
498 if (mark) |
|
499 { |
|
500 //It's Mark Command |
|
501 |
|
502 //if some of application update item(s) are selected, unmark them |
|
503 //FOTA item and application update items can't be selected at the same time |
|
504 bool deselected = false; |
|
505 for (int i = 0; i < mNodes.Count(); ++i) |
|
506 { |
|
507 if (mNodes[i]->Base().IsSelected()) |
|
508 { |
|
509 mNodes[i]->Base().SetSelected(false); |
|
510 } |
|
511 } |
|
512 if (deselected) |
|
513 { |
|
514 // umnmarked items to be updated also to UI |
|
515 updateSelectionsToList(); |
|
516 } |
|
517 } |
|
518 for (int j = 0; j < mFwNodes.Count(); ++j) |
|
519 { |
|
520 if (mFwNodes[j]->FwType() == MIAUpdateFwNode::EFotaDp2) |
|
521 { |
|
522 mFwNodes[j]->Base().SetSelected(mark); |
|
523 if (mark) |
|
524 { |
|
525 mFwListView->selectionModel()->select(mFwListView->model()->index(0,0),QItemSelectionModel::Select); |
|
526 } |
|
527 else |
|
528 { |
|
529 mFwListView->selectionModel()->select(mFwListView->model()->index(0,0),QItemSelectionModel::Deselect); |
|
530 } |
|
531 } |
|
532 } |
|
533 updateSelectionInfoInDock(); |
|
534 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markFotaItem() end"); |
|
535 } |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 void IAUpdateMainView::updateSelectionsToNodeArray(MIAUpdateNode &node, bool mark) |
|
542 { |
|
543 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToNodeArray() begin"); |
|
544 RPointerArray<MIAUpdateNode> deps; |
|
545 TInt err = KErrNone; |
|
546 if (mark) |
|
547 { |
|
548 TRAP(err,IAUpdateDepUtils::GetDependenciesL(node, mNodes, deps)); |
|
549 } |
|
550 else |
|
551 { |
|
552 TRAP(err,IAUpdateDepUtils::GetDependantsL(node, mNodes, deps)); |
|
553 } |
|
554 if (err == KErrNone ) |
|
555 { |
|
556 int depCount = deps.Count(); |
|
557 for(int i = 0; i < depCount; i++) |
|
558 { |
|
559 int depNodeInd = mNodes.Find(deps[i]); |
|
560 mNodes[depNodeInd]->Base().SetSelected(mark); |
|
561 } |
|
562 deps.Close(); |
|
563 int nodeInd = mNodes.Find(&node); |
|
564 mNodes[nodeInd]->Base().SetSelected(mark); |
|
565 } |
|
566 |
|
567 //mark all of the mandatory items |
|
568 if ( mark ) |
|
569 { |
|
570 RPointerArray<MIAUpdateNode> mands; |
|
571 if (getMandatoryNodes(mands)) |
|
572 { |
|
573 int mandCount = mands.Count(); |
|
574 if (mandCount > 0) |
|
575 { |
|
576 for(int i = 0; i < mandCount; i++) |
|
577 { |
|
578 int mandNodeInd = mNodes.Find(mands[i]); |
|
579 mNodes[mandNodeInd]->Base().SetSelected(mark); |
|
580 if (mNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
|
581 { |
|
582 // mark also all dependencies of a mandatory item |
|
583 MIAUpdateNode* dependencyNode = mNodes[mandNodeInd]; |
|
584 RPointerArray<MIAUpdateNode> dependencies; |
|
585 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*dependencyNode, mNodes, dependencies)); |
|
586 if (err) |
|
587 { |
|
588 dependencies.Close(); |
|
589 mands.Close(); |
|
590 return; |
|
591 } |
|
592 for(int j = 0; j < dependencies.Count(); j++) |
|
593 { |
|
594 int depNodeInd = mNodes.Find(dependencies[j]); |
|
595 mNodes[depNodeInd]->Base().SetSelected(true); |
|
596 } |
|
597 dependencies.Close(); |
|
598 } |
145 } |
599 } |
146 } |
600 } |
147 } |
601 } |
148 |
602 mands.Close(); |
149 |
603 } |
150 for( int i = 0; i < nodes.Count(); ++i ) |
604 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToNodeArray() end"); |
151 { |
605 } |
152 MIAUpdateAnyNode* node = nodes[i]; |
606 |
153 mAllNodes.Append( node ); |
607 |
154 } |
608 bool IAUpdateMainView::getMandatoryNodes(RPointerArray<MIAUpdateNode> &mandNodes) const |
|
609 { |
|
610 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getMandatoryNodes() begin"); |
|
611 bool ret = true; |
|
612 for(int i = 0; i < mNodes.Count(); ++i) |
|
613 { |
|
614 if (mNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
615 { |
|
616 if (mandNodes.Append(mNodes[i]) != KErrNone) |
|
617 { |
|
618 ret = false; |
|
619 } |
|
620 } |
|
621 } |
|
622 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getMandatoryNodes() end"); |
|
623 return ret; |
|
624 } |
|
625 |
|
626 void IAUpdateMainView::showUpdateCannotOmitDialog() |
|
627 { |
|
628 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showUpdateCannotOmitDialog() begin"); |
|
629 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
630 messageBox->setText(QString("This required update cannot be omitted")); |
|
631 int actionCount = messageBox->actions().count(); |
|
632 for (int i=actionCount-1; i >= 0; i--) |
|
633 { |
|
634 messageBox->removeAction(messageBox->actions().at(i)); |
|
635 } |
|
636 HbAction *okAction = NULL; |
|
637 okAction = new HbAction("Ok"); |
|
638 messageBox->addAction(okAction); |
|
639 messageBox->setTimeout(HbPopup::StandardTimeout); |
|
640 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
641 mDialogState = CannotOmit; |
|
642 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
|
643 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showUpdateCannotOmitDialog() end"); |
|
644 } |
|
645 |
|
646 void IAUpdateMainView::showDependenciesFoundDialog(QString &text) |
|
647 { |
|
648 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDependenciesFoundDialog() begin"); |
|
649 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
650 HbLabel *label = new HbLabel(messageBox); |
|
651 label->setHtml(QString("Depencencies")); |
|
652 messageBox->setHeadingWidget(label); |
|
653 //messageBox->setIconVisible(false); |
155 |
654 |
|
655 messageBox->setText(text); |
|
656 int actionCount = messageBox->actions().count(); |
|
657 for (int i=actionCount-1; i >= 0; i--) |
|
658 { |
|
659 messageBox->removeAction(messageBox->actions().at(i)); |
|
660 } |
|
661 mPrimaryAction = NULL; |
|
662 mPrimaryAction = new HbAction("Continue"); |
|
663 HbAction *secondaryAction = NULL; |
|
664 secondaryAction = new HbAction("Cancel"); |
|
665 messageBox->addAction(mPrimaryAction); |
|
666 messageBox->addAction(secondaryAction); |
|
667 messageBox->setTimeout(HbPopup::NoTimeout); |
|
668 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
669 mDialogState = Dependencies; |
|
670 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
|
671 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDependenciesFoundDialog() end"); |
|
672 } |
|
673 |
|
674 void IAUpdateMainView::updateSelectionsToList() |
|
675 { |
|
676 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToList() begin"); |
|
677 mSelectionUpdate = true; |
|
678 for(int i = 0; i < mNodes.Count(); ++i) |
|
679 { |
|
680 if ( mNodes[i]->Base().IsSelected() != mListView->selectionModel()->isSelected(mListView->model()->index(i,0))) |
|
681 { |
|
682 QItemSelectionModel::SelectionFlag selectionFlag; |
|
683 if ( mNodes[i]->Base().IsSelected()) |
|
684 { |
|
685 selectionFlag = QItemSelectionModel::Select; |
|
686 } |
|
687 else |
|
688 { |
|
689 selectionFlag = QItemSelectionModel::Deselect; |
|
690 } |
|
691 mListView->selectionModel()->select(mListView->model()->index(i,0),selectionFlag); |
|
692 } |
|
693 } |
|
694 mSelectionUpdate = false; |
|
695 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToList() end"); |
|
696 } |
|
697 |
|
698 |
|
699 MIAUpdateNode* IAUpdateMainView::getApplicationNode(int index) const |
|
700 { |
|
701 IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateMainView::getApplicationNode() begin index: %d", index); |
|
702 MIAUpdateNode *currentNode = NULL; |
|
703 |
|
704 if (index >= 0 && index < mNodes.Count()) |
|
705 { |
|
706 currentNode = mNodes[index]; |
|
707 } |
|
708 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getApplicationNode() end"); |
|
709 return currentNode; |
|
710 } |
|
711 |
|
712 void IAUpdateMainView::showDetails(MIAUpdateAnyNode& node) |
|
713 { |
|
714 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDetails() begin"); |
|
715 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
716 HbLabel *label = new HbLabel(messageBox); |
|
717 label->setHtml(QString("Details")); |
|
718 messageBox->setHeadingWidget(label); |
|
719 |
|
720 messageBox->setIconVisible(false); |
|
721 |
|
722 QString text; |
|
723 constructDetailsText(node,text); |
|
724 messageBox->setText(text); |
|
725 messageBox->setTimeout(HbPopup::NoTimeout); |
|
726 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
727 mDialogState = Details; |
|
728 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
|
729 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDetails() end"); |
|
730 } |
|
731 |
|
732 |
|
733 void IAUpdateMainView::constructDetailsText(MIAUpdateAnyNode &node, QString &text) |
|
734 { |
|
735 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::constructDetailsText() begin"); |
|
736 text.append(QString("Name:")); |
|
737 text.append(QString("<br />")); |
|
738 QString name = XQConversions::s60DescToQString(node.Base().Name()); |
|
739 text.append(name); |
|
740 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
741 { |
|
742 name.append(QString(" Device software")); |
|
743 } |
|
744 |
|
745 text.append(QString("<br />")); |
|
746 text.append(QString("<br />")); |
|
747 |
|
748 text.append(QString("Description:")); |
|
749 text.append(QString("<br />")); |
|
750 QString description; |
|
751 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
752 { |
|
753 description = QString("This update improves your device performance and brings you latest features."); |
|
754 } |
|
755 else |
|
756 { |
|
757 description = XQConversions::s60DescToQString(node.Base().Description()); |
|
758 } |
|
759 text.append(description); |
|
760 text.append(QString("<br />")); |
|
761 text.append(QString("<br />")); |
|
762 |
|
763 |
|
764 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
|
765 { |
|
766 MIAUpdateNode *iaupdateNode = static_cast<MIAUpdateNode*> (&node); |
|
767 if (iaupdateNode->Type()!= MIAUpdateNode::EPackageTypeServicePack) |
|
768 { |
|
769 text.append(QString("Version:")); |
|
770 text.append(QString("<br />")); |
|
771 QString textVersion; |
|
772 versionText(node.Base().Version(), textVersion); |
|
773 text.append(textVersion); |
|
774 text.append(QString("<br />")); |
|
775 text.append(QString("<br />")); |
|
776 } |
|
777 } |
|
778 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
779 { |
|
780 MIAUpdateFwNode *fwNode = static_cast<MIAUpdateFwNode*> (&node); |
|
781 text.append(QString("Version:")); |
|
782 text.append(QString("<br />")); |
|
783 QString textVersion = XQConversions::s60DescToQString(fwNode->FwVersion1()); |
|
784 text.append(textVersion); |
|
785 text.append(QString("<br />")); |
|
786 text.append(QString("<br />")); |
|
787 } |
|
788 |
|
789 int contentSize = node.Base().ContentSizeL(); |
|
790 if (contentSize > 0) |
|
791 { |
|
792 text.append(QString("Size:")); |
|
793 text.append(QString("<br />")); |
|
794 QString textFileSize; |
|
795 fileSizeText(contentSize, textFileSize); |
|
796 text.append(textFileSize); |
|
797 } |
|
798 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::constructDetailsText() end"); |
|
799 } |
|
800 |
|
801 void IAUpdateMainView::versionText(const TIAUpdateVersion &version, QString &versionText) |
|
802 { |
|
803 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::versionText() begin"); |
|
804 QString stringMajor; |
|
805 stringMajor.setNum(version.iMajor); |
|
806 versionText.append(stringMajor); |
|
807 versionText.append(QString(".")); |
|
808 QString stringMinor; |
|
809 stringMinor.setNum(version.iMinor); |
|
810 versionText.append(stringMinor); |
|
811 versionText.append(QString("(")); |
|
812 QString stringBuild; |
|
813 stringBuild.setNum(version.iBuild); |
|
814 versionText.append(stringBuild); |
|
815 versionText.append(QString(")")); |
|
816 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::versionText() end"); |
|
817 } |
|
818 |
|
819 void IAUpdateMainView::fileSizeText(int fileSize, QString &text) |
|
820 { |
|
821 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() begin"); |
|
822 int size = 0; |
|
823 QString stringUnit; |
|
824 |
|
825 if (fileSize >= KMaxShownInKiloBytes ) |
|
826 { |
|
827 stringUnit.append(" MB"); |
|
828 size = fileSize / KMegaByte; |
|
829 if ( fileSize % KMegaByte != 0 ) |
|
830 { |
|
831 size++; |
|
832 } |
|
833 } |
|
834 else |
|
835 { |
|
836 stringUnit.append(" kB"); |
|
837 size = fileSize / KKiloByte; |
|
838 if ( fileSize % KKiloByte != 0 ) |
|
839 { |
|
840 size++; |
|
841 } |
|
842 } |
|
843 text.setNum(size); |
|
844 text.append(stringUnit); |
|
845 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() end"); |
|
846 } |
|
847 |
|
848 void IAUpdateMainView::setImportance(MIAUpdateAnyNode *node, QString &importanceDescription) |
|
849 { |
|
850 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::setImportance() begin"); |
|
851 int sizeInBytes = node->Base().ContentSizeL(); |
|
852 int size = 0; |
|
853 bool shownInMegabytes = false; |
|
854 if (sizeInBytes >= KMaxShownInKiloBytes) |
|
855 { |
|
856 shownInMegabytes = true; |
|
857 size = sizeInBytes / KMegaByte; |
|
858 if (sizeInBytes % KMegaByte != 0) |
|
859 { |
|
860 size++; |
|
861 } |
|
862 } |
|
863 else |
|
864 { |
|
865 size = sizeInBytes / KKiloByte; |
|
866 if (sizeInBytes % KKiloByte != 0) |
|
867 { |
|
868 size++; |
|
869 } |
|
870 } |
|
871 QString sizeString; |
|
872 sizeString.setNum(size); |
|
873 switch(node->Base().Importance()) |
|
874 { |
|
875 case MIAUpdateBaseNode::EMandatory: |
|
876 { |
|
877 importanceDescription = "Required "; |
|
878 importanceDescription.append(sizeString); |
|
879 if (shownInMegabytes) |
|
880 { |
|
881 importanceDescription.append(" MB" ); |
|
882 } |
|
883 else |
|
884 { |
|
885 importanceDescription.append(" kB" ); |
|
886 } |
|
887 break; |
|
888 } |
|
889 |
|
890 case MIAUpdateBaseNode::ECritical: |
|
891 { |
|
892 bool isNSU = false; |
|
893 if(node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
894 { |
|
895 MIAUpdateFwNode *fwnode = static_cast<MIAUpdateFwNode*>(node); |
|
896 if (fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) |
|
897 { |
|
898 isNSU = true; |
|
899 } |
|
900 } |
|
901 importanceDescription = "Important "; |
|
902 if (!size || isNSU) |
|
903 { |
|
904 //for firmware when size info is not provided by server |
|
905 } |
|
906 else |
|
907 { |
|
908 importanceDescription.append(sizeString); |
|
909 if (shownInMegabytes) |
|
910 { |
|
911 importanceDescription.append(" MB" ); |
|
912 } |
|
913 else |
|
914 { |
|
915 importanceDescription.append(" kB" ); |
|
916 } |
|
917 } |
|
918 break; |
|
919 } |
|
920 |
|
921 case MIAUpdateBaseNode::ERecommended: |
|
922 { |
|
923 importanceDescription = "Recommended "; |
|
924 importanceDescription.append(sizeString); |
|
925 if (shownInMegabytes) |
|
926 { |
|
927 importanceDescription.append(" MB" ); |
|
928 } |
|
929 else |
|
930 { |
|
931 importanceDescription.append(" kB" ); |
|
932 } |
|
933 break; |
|
934 } |
|
935 |
|
936 case MIAUpdateBaseNode::ENormal: |
|
937 { |
|
938 importanceDescription = "Optional "; |
|
939 importanceDescription.append(sizeString); |
|
940 if (shownInMegabytes) |
|
941 { |
|
942 importanceDescription.append(" MB" ); |
|
943 } |
|
944 else |
|
945 { |
|
946 importanceDescription.append(" kB" ); |
|
947 } |
|
948 break; |
|
949 } |
|
950 |
|
951 default: |
|
952 { |
|
953 break; |
|
954 } |
|
955 } |
|
956 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::setImportance() end"); |
|
957 } |
|
958 |
|
959 void IAUpdateMainView::removeCurrentContentLayout() |
|
960 { |
|
961 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() begin"); |
|
962 int itemCount = mContent->layout()->count(); |
|
963 for (int i = 0; i < itemCount; i++) |
|
964 { |
|
965 mContent->layout()->removeAt(i); |
|
966 } |
|
967 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() end"); |
|
968 } |
|
969 |
|
970 void IAUpdateMainView::refreshFirmwareUpdates(const RPointerArray<MIAUpdateFwNode> &fwNodes) |
|
971 { |
|
972 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFirmwareUpdates() begin"); |
|
973 mFwNodes.Reset(); |
|
974 |
|
975 for (int i = 0; i < fwNodes.Count(); i++) |
|
976 { |
|
977 MIAUpdateFwNode *fwnode = (fwNodes[i]); |
|
978 mFwNodes.Append(fwnode); |
|
979 fwnode->Base().SetImportance(MIAUpdateBaseNode::ECritical); |
|
980 if (fwnode->FwType() == MIAUpdateFwNode::EFotaDp2) |
|
981 { |
|
982 refreshFotaUpdate(*fwnode ); |
|
983 } |
|
984 else if (fwNodes.Count() == 1 && fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) |
|
985 { |
|
986 refreshNsuUpdate(); |
|
987 } |
|
988 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFirmwareUpdates() end"); |
|
989 } |
|
990 } |
|
991 |
|
992 void IAUpdateMainView::refreshFotaUpdate(MIAUpdateFwNode& fwNode) |
|
993 { |
|
994 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() begin"); |
|
995 if (!mFwListView) |
|
996 { |
|
997 mFwListView = new HbListWidget(mContent); |
|
998 mFwListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
|
999 connect( mFwListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
|
1000 this, SLOT( handleFotaDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
|
1001 mFwListView->listItemPrototype()->setGraphicsSize(HbListViewItem::LargeIcon); |
|
1002 mFwListView->listItemPrototype()->setStretchingStyle(HbListViewItem::NoStretching); |
|
1003 connect(mFwListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
|
1004 this, SLOT(handleFwSelectionChanged(QItemSelection,QItemSelection))); |
|
1005 } |
|
1006 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
1007 linearLayout->addItem(mFwListView); |
|
1008 mFwListView->clear(); |
|
1009 QItemSelectionModel *selectionModel = mFwListView->selectionModel(); |
|
1010 selectionModel->clear(); |
|
1011 HbListWidgetItem *fwItem = new HbListWidgetItem(); |
|
1012 QString name(XQConversions::s60DescToQString(fwNode.Base().Name())); |
|
1013 name.append(" DEVICE SOFTWARE"); |
|
1014 fwItem->setText(name); |
|
1015 QString importanceDescription; |
|
1016 setImportance(&fwNode, importanceDescription); |
|
1017 fwItem->setSecondaryText(importanceDescription); |
|
1018 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
|
1019 fwItem->setIcon(icon); |
|
1020 if (fwNode.Base().IsSelected()) |
|
1021 { |
|
1022 QModelIndex modelIndex = mFwListView->model()->index(0,0); |
|
1023 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
|
1024 } |
|
1025 mFwListView->addItem(fwItem); |
|
1026 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() end"); |
|
1027 } |
|
1028 |
|
1029 void IAUpdateMainView::refreshNsuUpdate() |
|
1030 { |
|
1031 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() begin"); |
|
1032 if (!mFwNSUGroupBox) |
|
1033 { |
|
1034 mFwNSUGroupBox = new HbGroupBox(mContent); |
|
1035 mFwNSUGroupBox->setHeading("Device software available"); |
|
1036 HbDataForm *dataForm = new HbDataForm(mFwNSUGroupBox); |
|
1037 mFwNSUGroupBox->setContentWidget(dataForm); |
|
1038 dataForm->setDescription("Use your PC to update the device software ([version %L]) from address www.nokia.com/softwareupdate"); |
|
1039 } |
|
1040 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
1041 linearLayout->addItem(mFwNSUGroupBox); |
|
1042 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() end"); |
|
1043 } |
|
1044 |
|
1045 void IAUpdateMainView::refreshApplicationUpdates(const RPointerArray<MIAUpdateNode> &nodes) |
|
1046 { |
|
1047 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshApplicationUpdates() begin"); |
|
1048 if (nodes.Count() > 0) |
|
1049 { |
|
1050 if (!mApplicationUpdatesGroupBox) |
|
1051 { |
|
1052 mApplicationUpdatesGroupBox = new HbGroupBox(mContent); |
|
1053 mApplicationUpdatesGroupBox->setHeading("Application updates"); |
|
1054 } |
|
1055 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
1056 linearLayout->addItem(mApplicationUpdatesGroupBox); |
|
1057 linearLayout->addItem(mListView); |
|
1058 } |
156 mListView->clear(); |
1059 mListView->clear(); |
157 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
1060 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
158 selectionModel->clear(); |
1061 selectionModel->clear(); |
159 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
1062 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
160 |
1063 mNodes.Reset(); |
161 for( int j = 0; j < mAllNodes.Count(); ++j ) |
1064 for(int i = 0; i < nodes.Count(); ++i) |
162 { |
1065 { |
163 MIAUpdateAnyNode* node = mAllNodes[j]; |
1066 MIAUpdateNode *node = nodes[i]; |
164 int sizeInBytes = node->Base().ContentSizeL(); |
1067 mNodes.Append(node); |
165 |
|
166 int size = 0; |
|
167 TBool shownInMegabytes = EFalse; |
|
168 if ( sizeInBytes >= KMaxShownInKiloBytes ) |
|
169 { |
|
170 shownInMegabytes = ETrue; |
|
171 size = sizeInBytes / KMegaByte; |
|
172 if ( sizeInBytes % KMegaByte != 0 ) |
|
173 { |
|
174 size++; |
|
175 } |
|
176 } |
|
177 else |
|
178 { |
|
179 size = sizeInBytes / KKiloByte; |
|
180 if ( sizeInBytes % KKiloByte != 0 ) |
|
181 { |
|
182 size++; |
|
183 } |
|
184 } |
|
185 QString sizeString; |
|
186 sizeString.setNum(size); |
|
187 QString importanceDescription; |
1068 QString importanceDescription; |
188 switch( node->Base().Importance() ) |
1069 MIAUpdateNode::TUIUpdateState uiState = node->UiState(); |
189 { |
1070 if (uiState == MIAUpdateNode::ENormal) |
190 case MIAUpdateBaseNode::EMandatory: |
1071 { |
191 { |
1072 setImportance(node, importanceDescription); |
192 importanceDescription = "Required "; |
1073 } |
193 importanceDescription.append(sizeString); |
1074 else if (uiState == MIAUpdateNode::EUpdated) |
194 if ( shownInMegabytes ) |
1075 { |
195 { |
1076 importanceDescription = "Updated"; |
196 importanceDescription.append(" MB" ); |
1077 } |
197 } |
1078 else if (uiState == MIAUpdateNode::EFailed) |
198 else |
1079 { |
199 { |
1080 importanceDescription = "Failed"; |
200 importanceDescription.append(" kB" ); |
1081 } |
201 } |
1082 else if (uiState == MIAUpdateNode::EDownloaded) |
202 break; |
1083 { |
203 } |
1084 importanceDescription = "Downloaded"; |
204 |
1085 } |
205 |
1086 HbListWidgetItem *item = new HbListWidgetItem(); |
206 case MIAUpdateBaseNode::ECritical: |
1087 QString name; |
207 { |
1088 if (uiState == MIAUpdateNode::EDownloading) |
208 bool isNSU = false; |
1089 { |
209 if( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
1090 name = QString("Downloading "); |
210 { |
1091 } |
211 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node ); |
1092 else if (uiState == MIAUpdateNode::EInstalling) |
212 if ( fwnode->FwType() == MIAUpdateFwNode::EFotiNsu ) |
1093 { |
213 { |
1094 name = QString("Installing "); |
214 isNSU = true; |
1095 } |
215 } |
1096 name.append(XQConversions::s60DescToQString(node->Base().Name())); |
216 } |
1097 item->setText(name); |
217 |
1098 item->setSecondaryText(importanceDescription); |
218 importanceDescription = "Important "; |
1099 item->setIcon(icon); |
219 if ( !size || isNSU ) |
1100 mListView->addItem(item); |
220 { |
1101 |
221 //for firmware when size info is not provided by server |
1102 if (node->Base().IsSelected()) |
222 } |
1103 { |
223 else |
1104 int count = mListView->count(); |
224 { |
1105 QModelIndex modelIndex = mListView->model()->index(count-1,0); |
225 importanceDescription.append(sizeString); |
1106 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
226 if ( shownInMegabytes ) |
1107 } |
227 { |
1108 } |
228 importanceDescription.append(" MB" ); |
1109 if (!mSelectionConnect) |
229 } |
1110 { |
230 else |
1111 mSelectionConnect = connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
231 { |
1112 this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); |
232 importanceDescription.append(" kB" ); |
1113 } |
233 } |
1114 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshApplicationUpdates() end"); |
234 } |
1115 } |
235 |
1116 |
236 break; |
1117 void IAUpdateMainView::updateSelectionInfoInDock() |
237 } |
1118 { |
238 |
1119 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionInfoInDock() begin"); |
239 case MIAUpdateBaseNode::ERecommended: |
1120 int countOfSelectedItems = 0; |
240 { |
1121 int countOfAllItems = 0; |
241 importanceDescription = "Recommended "; |
1122 int selectedSizeInBytes = 0; |
242 importanceDescription.append(sizeString); |
1123 for (int i = 0; i < mFwNodes.Count(); ++i) |
243 if ( shownInMegabytes ) |
1124 { |
244 { |
1125 if (mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2) |
245 importanceDescription.append(" MB" ); |
1126 { |
246 } |
1127 countOfAllItems++; |
247 else |
1128 if (mFwNodes[i]->Base().IsSelected()) |
248 { |
1129 { |
249 importanceDescription.append(" kB" ); |
1130 countOfSelectedItems++; |
250 } |
1131 selectedSizeInBytes += mFwNodes[i]->Base().ContentSizeL(); |
251 break; |
1132 } |
252 } |
1133 } |
253 |
1134 } |
254 case MIAUpdateBaseNode::ENormal: |
1135 countOfAllItems += mNodes.Count(); |
255 { |
1136 for (int j = 0; j < mNodes.Count(); ++j) |
256 importanceDescription = "Optional "; |
1137 { |
257 importanceDescription.append(sizeString); |
1138 if (mNodes[j]->Base().IsSelected()) |
258 if ( shownInMegabytes ) |
1139 { |
259 { |
1140 countOfSelectedItems++; |
260 importanceDescription.append(" MB" ); |
1141 selectedSizeInBytes += mNodes[j]->Base().ContentSizeL(); |
261 } |
1142 } |
262 else |
1143 } |
263 { |
1144 |
264 importanceDescription.append(" kB" ); |
1145 int selectedSize = 0; |
265 } |
1146 QString unit; |
266 break; |
1147 if (selectedSizeInBytes >= KMaxShownInKiloBytes) |
267 } |
1148 { |
268 |
1149 unit = "MB"; |
269 default: |
1150 selectedSize = selectedSizeInBytes / KMegaByte; |
270 { |
1151 if (selectedSizeInBytes % KMegaByte != 0) |
271 break; |
1152 { |
272 } |
1153 selectedSize++; |
273 } |
1154 } |
274 |
1155 } |
275 //AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
1156 else |
276 |
1157 { |
277 HbListWidgetItem *item = new HbListWidgetItem(); |
1158 unit = "kB"; |
278 QString name = XQConversions::s60DescToQString(node->Base().Name()); |
1159 selectedSize = selectedSizeInBytes / KKiloByte; |
279 if ( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
1160 if (selectedSizeInBytes % KKiloByte != 0) |
280 { |
1161 { |
281 name.append(" DEVICE SOFTWARE"); |
1162 selectedSize++; |
282 } |
1163 } |
283 item->setText(name); |
1164 } |
284 item->setSecondaryText(importanceDescription); |
1165 QString selectionString; |
285 item->setIcon(icon); |
1166 selectionString.append("Selected "); |
286 mListView->addItem(item); |
1167 QString numText; |
287 |
1168 numText.setNum(countOfSelectedItems); |
288 if ( node->Base().IsSelected() ) |
1169 selectionString.append(numText); |
289 { |
1170 selectionString.append("/"); |
290 int count = mListView->count(); |
1171 numText.setNum(countOfAllItems); |
291 QModelIndex modelIndex = mListView->model()->index(count-1,0); |
1172 selectionString.append(numText); |
292 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
1173 if (selectedSize > 0) |
293 } |
1174 { |
294 |
1175 selectionString.append(" ("); |
295 |
1176 numText.setNum(selectedSize); |
296 |
1177 selectionString.append(numText); |
297 /*if ( nodes.Count() == 0 ) |
1178 selectionString.append(" "); |
298 { |
1179 selectionString.append(unit); |
299 HBufC* emptyText = NULL; |
1180 selectionString.append(")"); |
300 if ( aError ) |
1181 } |
301 { |
1182 mSelections->setHeading(selectionString); |
302 if ( aError == KErrCancel || aError == KErrAbort ) |
1183 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionInfoInDock() end"); |
303 { |
1184 } |
304 emptyText = KNullDesC().AllocLC(); |
|
305 } |
|
306 else |
|
307 { |
|
308 emptyText = StringLoader::LoadLC( R_IAUPDATE_REFRESH_FAILED ); |
|
309 } |
|
310 } |
|
311 else |
|
312 { |
|
313 emptyText = StringLoader::LoadLC( R_IAUPDATE_TEXT_NO_UPDATES ); |
|
314 } |
|
315 |
|
316 iListBox->View()->SetListEmptyTextL( *emptyText ); |
|
317 CleanupStack::PopAndDestroy( emptyText ); |
|
318 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
319 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
|
320 } |
|
321 else |
|
322 { |
|
323 if ( iListBox->CurrentItemIndex() == KErrNotFound ) |
|
324 { |
|
325 iListBox->SetCurrentItemIndex( aNodes.Count() - 1 ); |
|
326 } |
|
327 }*/ |
|
328 |
|
329 //iListBox->HandleItemAdditionL(); |
|
330 } |
|
331 connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
|
332 this, SLOT(handleSelectionChanged(QItemSelection))); |
|
333 |
|
334 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh end"); |
|
335 } |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 void IAUpdateMainView::handleStartUpdate() |
|
341 { |
|
342 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() begin"); |
|
343 bool firmwareUpdate = false; |
|
344 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
345 getSelectedNodes(selectedNodes); |
|
346 if (selectedNodes.Count() > 0) |
|
347 { |
|
348 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
349 { |
|
350 //the marking logic will make sure firmware won't be marked with normal sis updates |
|
351 //at the same time. |
|
352 firmwareUpdate = true; |
|
353 } |
|
354 } |
|
355 selectedNodes.Close(); |
|
356 //mEngine->StartUpdate(firmwareUpdate); |
|
357 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() end"); |
|
358 } |
|
359 |
|
360 |
|
361 void IAUpdateMainView::handleSettings() |
|
362 { |
|
363 } |
|
364 |
|
365 void IAUpdateMainView::handleDisclaimer() |
|
366 { |
|
367 CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); |
|
368 agreement->ShowAgreementL(); |
|
369 CleanupStack::PopAndDestroy( agreement); |
|
370 } |
|
371 |
|
372 void IAUpdateMainView::handleSelectionChanged(QItemSelection itemSelection) |
|
373 { |
|
374 QModelIndexList indexList = itemSelection.indexes(); |
|
375 bool changedItemFound = false; |
|
376 for (int i = 0; !changedItemFound && i < mAllNodes.Count(); ++i) |
|
377 { |
|
378 bool currentlySelected = false; |
|
379 for (int j = 0; !currentlySelected && j < indexList.count(); ++j) |
|
380 { |
|
381 //QModelIndex modelIndex = indexList.at(j); |
|
382 //modelIndex.row(); |
|
383 if (i == indexList.at(j).row()) |
|
384 { |
|
385 currentlySelected = true; |
|
386 } |
|
387 } |
|
388 if (currentlySelected != mAllNodes[i]->Base().IsSelected()) |
|
389 { |
|
390 changedItemFound = true; |
|
391 markListItem(currentlySelected,i); |
|
392 updateSelectionsToList(); |
|
393 } |
|
394 } |
|
395 |
|
396 } |
|
397 |
|
398 void IAUpdateMainView::getSelectedNodes(RPointerArray<MIAUpdateAnyNode> &selectedNodes) const |
|
399 { |
|
400 for (int i = 0; i < mAllNodes.Count(); ++i) |
|
401 { |
|
402 if (mAllNodes[i]->Base().IsSelected()) |
|
403 { |
|
404 selectedNodes.Append(mAllNodes[i]); |
|
405 } |
|
406 } |
|
407 } |
|
408 |
|
409 void IAUpdateMainView::markListItem(bool mark, int index) |
|
410 { |
|
411 if (mark) |
|
412 { |
|
413 //It's Mark Command |
|
414 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
415 getSelectedNodes(selectedNodes); |
|
416 |
|
417 //There are selected items already and type are different with the current one |
|
418 if (selectedNodes.Count() > 0 && (mAllNodes[index]->NodeType() != selectedNodes[0]->NodeType())) |
|
419 { |
|
420 // firmware item and normal sis items can't be selected at the same time |
|
421 // unmark the selected nodes. |
|
422 for (int i = 0; i < selectedNodes.Count(); i++) |
|
423 { |
|
424 int index = mAllNodes.Find(selectedNodes[i]); |
|
425 mAllNodes[index]->Base().SetSelected(false); |
|
426 } |
|
427 } |
|
428 selectedNodes.Close(); |
|
429 } |
|
430 |
|
431 //there is no selected items or the type is the same with the current one |
|
432 |
|
433 if (mAllNodes[index]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
434 { |
|
435 mAllNodes[index]->Base().SetSelected(mark); |
|
436 return; |
|
437 } |
|
438 |
|
439 if (mAllNodes[index]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal ) |
|
440 { |
|
441 bool accepted = false; |
|
442 |
|
443 if(index > -1) |
|
444 { |
|
445 accepted = true; |
|
446 |
|
447 MIAUpdateNode* node = static_cast<MIAUpdateNode*>(mAllNodes[index]); |
|
448 RPointerArray<MIAUpdateAnyNode> mands; |
|
449 RPointerArray<MIAUpdateNode> deps; |
|
450 |
|
451 if (mark) |
|
452 { |
|
453 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*node, mAllNodes, deps)); |
|
454 if (err != KErrNone) |
|
455 { |
|
456 deps.Close(); |
|
457 return; |
|
458 } |
|
459 if (!getMandatoryNodes(mands)) |
|
460 { |
|
461 // error when creating mandatory node list |
|
462 mands.Close(); |
|
463 return; |
|
464 } |
|
465 } |
|
466 else |
|
467 { |
|
468 //mandatory item is not allowed to be unmarked |
|
469 if (mAllNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
470 { |
|
471 //show dialog |
|
472 showUpdateCannotOmitDialog(); |
|
473 return; |
|
474 } |
|
475 |
|
476 //CleanupClosePushL( deps ); |
|
477 TRAPD(err,IAUpdateDepUtils::GetDependantsL(*node, mAllNodes, deps)); |
|
478 if (err != KErrNone) |
|
479 { |
|
480 deps.Close(); |
|
481 return; |
|
482 } |
|
483 // item is not allowed to be unmarked if its dependant is mandatory |
|
484 bool mandatoryDependantFound = false; |
|
485 for(int i = 0; i < deps.Count() && !mandatoryDependantFound; i++) |
|
486 { |
|
487 if (deps[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
488 { |
|
489 mandatoryDependantFound = true; |
|
490 } |
|
491 } |
|
492 if (mandatoryDependantFound) |
|
493 { |
|
494 showUpdateCannotOmitDialog(); |
|
495 deps.Close(); |
|
496 return; |
|
497 } |
|
498 } |
|
499 |
|
500 int depCount = deps.Count(); |
|
501 |
|
502 if (depCount > 0) |
|
503 { |
|
504 QString text; |
|
505 QString names; |
|
506 MIAUpdateNode* depNode = NULL; |
|
507 QString separator(","); |
|
508 |
|
509 for(int i = 0; i < depCount; i++) |
|
510 { |
|
511 depNode = deps[i]; |
|
512 if (i > 0) |
|
513 { |
|
514 names.append(separator); |
|
515 names.append(QString(" ")); |
|
516 } |
|
517 names.append(XQConversions::s60DescToQString(depNode->Base().Name())); |
|
518 } |
|
519 |
|
520 |
|
521 if (mark) |
|
522 { |
|
523 if (depCount > 1) |
|
524 { |
|
525 text.append("This update needs also updates "); |
|
526 text.append(names); |
|
527 text.append(" for working"); |
|
528 //resourceId = R_IAUPDATE_DEPENDENCY_MARK_MANY; |
|
529 } |
|
530 else |
|
531 { |
|
532 text.append("This update needs also \""); |
|
533 text.append(names); |
|
534 text.append("\" for working"); |
|
535 //resourceId = R_IAUPDATE_DEPENDENCY_MARK_ONE; |
|
536 } |
|
537 } |
|
538 else |
|
539 { |
|
540 if (depCount > 1) |
|
541 { |
|
542 text.append("Updates "); |
|
543 text.append(names); |
|
544 text.append(" need this update for working"); |
|
545 //resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_MANY; |
|
546 } |
|
547 else |
|
548 { |
|
549 text.append("Update \""); |
|
550 text.append(names); |
|
551 text.append("\" needs this update for working"); |
|
552 //resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_ONE; |
|
553 } |
|
554 } |
|
555 |
|
556 if (mark && mAllNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
557 { |
|
558 // depencencies of mandatory update are also selected without showing dialog |
|
559 accepted = true; |
|
560 } |
|
561 else |
|
562 { |
|
563 accepted = showDependenciesFoundDialog(text); |
|
564 } |
|
565 } |
|
566 |
|
567 if (accepted) |
|
568 { |
|
569 for(int j = 0; j < depCount; j++) |
|
570 { |
|
571 int depNodeInd = mAllNodes.Find(deps[j]); |
|
572 mAllNodes[depNodeInd]->Base().SetSelected(mark); |
|
573 } |
|
574 deps.Close(); |
|
575 int nodeInd = mAllNodes.Find(node); |
|
576 mAllNodes[nodeInd]->Base().SetSelected(mark); |
|
577 } |
|
578 else |
|
579 { |
|
580 //user rejects the dependency dialog |
|
581 deps.Close(); |
|
582 if (mark) |
|
583 { |
|
584 mands.Close(); |
|
585 } |
|
586 return; |
|
587 } |
|
588 |
|
589 //mark all of the mandatory items |
|
590 int mandCount = mands.Count(); |
|
591 if (mandCount > 0 && mark) |
|
592 { |
|
593 for(int j = 0; j < mandCount; j++) |
|
594 { |
|
595 int mandNodeInd = mAllNodes.Find(mands[j]); |
|
596 mAllNodes[mandNodeInd]->Base().SetSelected(mark); |
|
597 if (mAllNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
|
598 { |
|
599 // mark also all dependencies of a mandatory item |
|
600 MIAUpdateNode* dependencyNode = static_cast<MIAUpdateNode*>(mAllNodes[mandNodeInd]); |
|
601 RPointerArray<MIAUpdateNode> dependencies; |
|
602 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*dependencyNode, mAllNodes, dependencies)); |
|
603 if (err) |
|
604 { |
|
605 dependencies.Close(); |
|
606 if (mark) |
|
607 { |
|
608 mands.Close(); |
|
609 } |
|
610 return; |
|
611 } |
|
612 for(int k = 0; k < dependencies.Count(); k++) |
|
613 { |
|
614 int depNodeInd = mAllNodes.Find(dependencies[k]); |
|
615 mAllNodes[depNodeInd]->Base().SetSelected(true); |
|
616 } |
|
617 dependencies.Close(); |
|
618 } |
|
619 } |
|
620 } |
|
621 if (mark) |
|
622 { |
|
623 mands.Close(); |
|
624 } |
|
625 } |
|
626 return; |
|
627 } |
|
628 return; |
|
629 } |
|
630 |
|
631 |
|
632 bool IAUpdateMainView::getMandatoryNodes(RPointerArray<MIAUpdateAnyNode> &mandNodes) const |
|
633 { |
|
634 bool ret = true; |
|
635 for(int i = 0; i < mAllNodes.Count(); ++i) |
|
636 { |
|
637 if (mAllNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
638 { |
|
639 if (mandNodes.Append(mAllNodes[i]) != KErrNone) |
|
640 { |
|
641 ret = false; |
|
642 } |
|
643 } |
|
644 } |
|
645 return ret; |
|
646 } |
|
647 |
|
648 void IAUpdateMainView::showUpdateCannotOmitDialog() const |
|
649 { |
|
650 HbMessageBox messageBox(HbMessageBox::MessageTypeInformation); |
|
651 messageBox.setText(QString("This required update cannot be omitted")); |
|
652 HbAction okAction("Ok"); |
|
653 messageBox.setPrimaryAction(&okAction); |
|
654 messageBox.setTimeout(HbPopup::StandardTimeout); |
|
655 messageBox.show(); |
|
656 //messageBox.exec(); |
|
657 } |
|
658 |
|
659 bool IAUpdateMainView::showDependenciesFoundDialog(QString &text) const |
|
660 { |
|
661 bool accepted = false; |
|
662 HbMessageBox messageBox(HbMessageBox::MessageTypeQuestion); |
|
663 messageBox.setText(text); |
|
664 HbAction continueAction("Continue"); |
|
665 messageBox.setPrimaryAction(&continueAction); |
|
666 HbAction cancelAction("Cancel"); |
|
667 messageBox.setSecondaryAction(&cancelAction); |
|
668 messageBox.setTimeout(HbPopup::NoTimeout); |
|
669 messageBox.show(); |
|
670 //HbAction *selectedAction = messageBox.exec(); |
|
671 //if (selectedAction == messageBox.primaryAction()) |
|
672 { |
|
673 accepted = true; |
|
674 } |
|
675 return accepted; |
|
676 } |
|
677 |
|
678 void IAUpdateMainView::updateSelectionsToList() |
|
679 { |
|
680 for(int i = 0; i < mAllNodes.Count(); ++i) |
|
681 { |
|
682 if ( mAllNodes[i]->Base().IsSelected() != mListView->selectionModel()->isSelected(mListView->model()->index(i,0))) |
|
683 { |
|
684 QItemSelectionModel::SelectionFlag selectionFlag; |
|
685 if ( mAllNodes[i]->Base().IsSelected()) |
|
686 { |
|
687 selectionFlag = QItemSelectionModel::Select; |
|
688 } |
|
689 else |
|
690 { |
|
691 selectionFlag = QItemSelectionModel::Deselect; |
|
692 } |
|
693 mListView->selectionModel()->select(mListView->model()->index(i,0),selectionFlag); |
|
694 } |
|
695 } |
|
696 } |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|