15 * class member functions. |
15 * class member functions. |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 #include <hbaction.h> |
19 #include <hbaction.h> |
20 #include <qgraphicswidget> |
20 #include <QgraphicsWidget> |
21 //#include <hblistview.h> |
21 |
22 #include <hblistwidget.h> |
22 #include <hblistwidget.h> |
23 #include <hblistviewitem.h> |
23 #include <hblistviewitem.h> |
24 #include <hblistwidgetitem.h> |
24 #include <hblistwidgetitem.h> |
25 #include <hbtoolbar.h> |
25 #include <hbtoolbar.h> |
26 #include <hbmenu.h> |
26 #include <hbmenu.h> |
27 #include <hbdocumentloader.h> |
27 #include <hbdocumentloader.h> |
28 #include <xqconversions.h> |
28 #include <xqconversions.h> |
29 #include <hbmessagebox.h> |
29 #include <hbmessagebox.h> |
|
30 #include <hbtextitem.h> |
30 |
31 |
31 #include "iaupdatemainview.h" |
32 #include "iaupdatemainview.h" |
32 #include "iaupdateengine.h" |
33 #include "iaupdateengine.h" |
33 #include "iaupdateagreement.h" |
34 #include "iaupdateagreement.h" |
34 #include "iaupdatedeputils.h" |
35 #include "iaupdatedeputils.h" |
|
36 #include "iaupdatedialogutil.h" |
|
37 #include "iaupdateversion.h" |
35 |
38 |
36 #include "iaupdatedebug.h" |
39 #include "iaupdatedebug.h" |
|
40 |
|
41 |
37 |
42 |
38 const int KKiloByte = 1024; |
43 const int KKiloByte = 1024; |
39 const int KMegaByte = 1024 * 1024; |
44 const int KMegaByte = 1024 * 1024; |
40 const int KMaxShownInKiloBytes = 10 * KMegaByte; |
45 const int KMaxShownInKiloBytes = 10 * KMegaByte; |
41 |
46 |
42 |
47 |
43 IAUpdateMainView::IAUpdateMainView(IAUpdateEngine *engine): |
48 IAUpdateMainView::IAUpdateMainView(IAUpdateEngine *engine): |
44 mEngine( engine ) |
49 mEngine(engine) |
45 { |
50 { |
|
51 mDialogUtil = NULL; |
|
52 mDialogState = NoDialog; |
|
53 mPrimaryAction = NULL; |
|
54 mNode = NULL; |
|
55 mSelectionUpdate = false; |
|
56 |
46 HbDocumentLoader loader; |
57 HbDocumentLoader loader; |
47 bool ok = false; |
58 bool ok = false; |
48 loader.load(":/xml/iaupdate_mainview.docml", &ok); |
59 loader.load(":/xml/iaupdate_mainview.docml", &ok); |
49 |
60 |
50 // Exit if the file format is invalid |
61 // Exit if the file format is invalid |
51 Q_ASSERT_X(ok, "Software update", "Invalid docml file"); |
62 Q_ASSERT_X(ok, "Software update", "Invalid docml file"); |
52 // Create the view from DocML |
63 // Create the view from DocML |
53 |
64 |
54 //QGraphicsWidget* widget = loader.findWidget("view"); |
|
55 HbView* widget = qobject_cast<HbView*>(loader.findWidget("view")); |
65 HbView* widget = qobject_cast<HbView*>(loader.findWidget("view")); |
56 Q_ASSERT_X(widget != 0, "Software update", "View not found"); |
66 Q_ASSERT_X(widget != 0, "Software update", "View not found"); |
57 QString viewTitle(widget->title()); |
67 QString viewTitle(widget->title()); |
58 // Set the IAUpdateMainView view to be the widget that was loaded from the xml |
68 // Set the IAUpdateMainView view to be the widget that was loaded from the xml |
59 setWidget(widget); |
69 setWidget(widget); |
72 |
82 |
73 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
83 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
74 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
84 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
75 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
85 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
76 |
86 |
77 //mListView = qobject_cast<HbListView*>( loader.findWidget("listView") ); |
|
78 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
87 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
79 //mListView = loader.findWidget("listWidget"); |
|
80 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
88 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
81 |
89 |
|
90 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
|
91 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
|
92 |
82 HbListViewItem *prototype = mListView->listItemPrototype(); |
93 HbListViewItem *prototype = mListView->listItemPrototype(); |
83 |
94 |
84 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
95 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
85 //prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
96 |
86 //prototype->setSecondaryTextRowCount(1,1); |
|
87 |
|
88 |
|
89 |
|
90 /*HbListWidgetItem* item = new HbListWidgetItem(); |
|
91 QStringList data; |
|
92 data << "Test application" << "Critical"; |
|
93 item->setData(QVariant(data), Qt::DisplayRole); |
|
94 mListWidget->addItem(item);*/ |
|
95 } |
97 } |
96 |
98 |
97 IAUpdateMainView::~IAUpdateMainView() |
99 IAUpdateMainView::~IAUpdateMainView() |
98 { |
100 { |
99 } |
101 } |
358 } |
360 } |
359 |
361 |
360 |
362 |
361 void IAUpdateMainView::handleSettings() |
363 void IAUpdateMainView::handleSettings() |
362 { |
364 { |
|
365 emit toSettingView(); |
363 } |
366 } |
364 |
367 |
365 void IAUpdateMainView::handleDisclaimer() |
368 void IAUpdateMainView::handleDisclaimer() |
366 { |
369 { |
367 CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); |
370 if (!mDialogUtil) |
368 agreement->ShowAgreementL(); |
371 { |
369 CleanupStack::PopAndDestroy( agreement); |
372 mDialogUtil = new IAUpdateDialogUtil(this); |
370 } |
373 } |
371 |
374 if (mDialogUtil) |
372 void IAUpdateMainView::handleSelectionChanged(QItemSelection itemSelection) |
375 { |
373 { |
376 HbAction *primaryAction = new HbAction("OK"); |
374 QModelIndexList indexList = itemSelection.indexes(); |
377 mDialogUtil->showAgreement(primaryAction); |
375 bool changedItemFound = false; |
378 } |
376 for (int i = 0; !changedItemFound && i < mAllNodes.Count(); ++i) |
379 } |
377 { |
380 |
378 bool currentlySelected = false; |
381 void IAUpdateMainView::handleDetails( HbAbstractViewItem * item, const QPointF & ) |
379 for (int j = 0; !currentlySelected && j < indexList.count(); ++j) |
382 { |
380 { |
383 |
381 //QModelIndex modelIndex = indexList.at(j); |
384 |
382 //modelIndex.row(); |
385 int ind = item->modelIndex().row(); |
383 if (i == indexList.at(j).row()) |
386 if (getNode(ind) != NULL) |
384 { |
387 { |
385 currentlySelected = true; |
388 showDetails(*getNode(ind)); |
386 } |
389 } |
387 } |
390 } |
388 if (currentlySelected != mAllNodes[i]->Base().IsSelected()) |
391 |
389 { |
392 |
|
393 void IAUpdateMainView::handleSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
|
394 { |
|
395 if (!mSelectionUpdate) |
|
396 { |
|
397 bool changedItemFound = false; |
|
398 QModelIndexList indexList = selected.indexes(); |
|
399 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
400 { |
390 changedItemFound = true; |
401 changedItemFound = true; |
391 markListItem(currentlySelected,i); |
402 markListItem(true, indexList.at(i).row()); |
|
403 } |
|
404 if (!changedItemFound) |
|
405 { |
|
406 indexList = deselected.indexes(); |
|
407 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
408 { |
|
409 changedItemFound = true; |
|
410 markListItem(false, indexList.at(i).row()); |
|
411 } |
|
412 } |
|
413 } |
|
414 } |
|
415 |
|
416 |
|
417 void IAUpdateMainView::dialogFinished(HbAction *action) |
|
418 { |
|
419 DialogState dialogState = mDialogState; |
|
420 mDialogState = NoDialog; |
|
421 |
|
422 switch ( dialogState ) |
|
423 { |
|
424 case Dependencies: |
|
425 if (action == mPrimaryAction) |
|
426 { |
|
427 updateSelectionsToNodeArray(*mNode,mMark); |
|
428 } |
392 updateSelectionsToList(); |
429 updateSelectionsToList(); |
393 } |
430 break; |
394 } |
431 case CannotOmit: |
395 |
432 break; |
396 } |
433 case Details: |
|
434 break; |
|
435 default: |
|
436 break; |
|
437 } |
|
438 } |
|
439 |
397 |
440 |
398 void IAUpdateMainView::getSelectedNodes(RPointerArray<MIAUpdateAnyNode> &selectedNodes) const |
441 void IAUpdateMainView::getSelectedNodes(RPointerArray<MIAUpdateAnyNode> &selectedNodes) const |
399 { |
442 { |
400 for (int i = 0; i < mAllNodes.Count(); ++i) |
443 for (int i = 0; i < mAllNodes.Count(); ++i) |
401 { |
444 { |
452 { |
496 { |
453 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*node, mAllNodes, deps)); |
497 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*node, mAllNodes, deps)); |
454 if (err != KErrNone) |
498 if (err != KErrNone) |
455 { |
499 { |
456 deps.Close(); |
500 deps.Close(); |
|
501 updateSelectionsToList(); |
457 return; |
502 return; |
458 } |
503 } |
459 if (!getMandatoryNodes(mands)) |
504 if (!getMandatoryNodes(mands)) |
460 { |
505 { |
461 // error when creating mandatory node list |
506 // error when creating mandatory node list |
462 mands.Close(); |
507 mands.Close(); |
|
508 updateSelectionsToList(); |
463 return; |
509 return; |
464 } |
510 } |
465 } |
511 } |
466 else |
512 else |
467 { |
513 { |
468 //mandatory item is not allowed to be unmarked |
514 //mandatory item is not allowed to be unmarked |
469 if (mAllNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
515 if (mAllNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
470 { |
516 { |
471 //show dialog |
517 //show dialog |
472 showUpdateCannotOmitDialog(); |
518 showUpdateCannotOmitDialog(); |
|
519 updateSelectionsToList(); |
473 return; |
520 return; |
474 } |
521 } |
475 |
522 |
476 //CleanupClosePushL( deps ); |
523 //CleanupClosePushL( deps ); |
477 TRAPD(err,IAUpdateDepUtils::GetDependantsL(*node, mAllNodes, deps)); |
524 TRAPD(err,IAUpdateDepUtils::GetDependantsL(*node, mAllNodes, deps)); |
478 if (err != KErrNone) |
525 if (err != KErrNone) |
479 { |
526 { |
480 deps.Close(); |
527 deps.Close(); |
|
528 updateSelectionsToList(); |
481 return; |
529 return; |
482 } |
530 } |
483 // item is not allowed to be unmarked if its dependant is mandatory |
531 // item is not allowed to be unmarked if its dependant is mandatory |
484 bool mandatoryDependantFound = false; |
532 bool mandatoryDependantFound = false; |
485 for(int i = 0; i < deps.Count() && !mandatoryDependantFound; i++) |
533 for(int i = 0; i < deps.Count() && !mandatoryDependantFound; i++) |
558 // depencencies of mandatory update are also selected without showing dialog |
607 // depencencies of mandatory update are also selected without showing dialog |
559 accepted = true; |
608 accepted = true; |
560 } |
609 } |
561 else |
610 else |
562 { |
611 { |
563 accepted = showDependenciesFoundDialog(text); |
612 mNode = node; |
564 } |
613 mMark = mark; |
565 } |
614 showDependenciesFoundDialog(text); |
566 |
615 return; |
|
616 } |
|
617 } |
567 if (accepted) |
618 if (accepted) |
568 { |
619 { |
569 for(int j = 0; j < depCount; j++) |
620 updateSelectionsToNodeArray(*node, mark); |
570 { |
621 } |
571 int depNodeInd = mAllNodes.Find(deps[j]); |
622 } |
572 mAllNodes[depNodeInd]->Base().SetSelected(mark); |
623 |
573 } |
624 } |
574 deps.Close(); |
625 updateSelectionsToList(); |
575 int nodeInd = mAllNodes.Find(node); |
626 } |
576 mAllNodes[nodeInd]->Base().SetSelected(mark); |
627 |
577 } |
628 void IAUpdateMainView::updateSelectionsToNodeArray(MIAUpdateNode &node, bool mark) |
578 else |
629 { |
579 { |
630 RPointerArray<MIAUpdateNode> deps; |
580 //user rejects the dependency dialog |
631 TInt err = KErrNone; |
581 deps.Close(); |
632 if (mark) |
582 if (mark) |
633 { |
583 { |
634 TRAP(err,IAUpdateDepUtils::GetDependenciesL(node, mAllNodes, deps)); |
584 mands.Close(); |
635 } |
585 } |
636 else |
586 return; |
637 { |
587 } |
638 TRAP(err,IAUpdateDepUtils::GetDependantsL(node, mAllNodes, deps)); |
588 |
639 } |
589 //mark all of the mandatory items |
640 if (err == KErrNone ) |
|
641 { |
|
642 int depCount = deps.Count(); |
|
643 for(int i = 0; i < depCount; i++) |
|
644 { |
|
645 int depNodeInd = mAllNodes.Find(deps[i]); |
|
646 mAllNodes[depNodeInd]->Base().SetSelected(mark); |
|
647 } |
|
648 deps.Close(); |
|
649 int nodeInd = mAllNodes.Find(&node); |
|
650 mAllNodes[nodeInd]->Base().SetSelected(mark); |
|
651 } |
|
652 |
|
653 //mark all of the mandatory items |
|
654 if ( mark ) |
|
655 { |
|
656 RPointerArray<MIAUpdateAnyNode> mands; |
|
657 if (getMandatoryNodes(mands)) |
|
658 { |
590 int mandCount = mands.Count(); |
659 int mandCount = mands.Count(); |
591 if (mandCount > 0 && mark) |
660 if (mandCount > 0) |
592 { |
661 { |
593 for(int j = 0; j < mandCount; j++) |
662 for(int i = 0; i < mandCount; i++) |
594 { |
663 { |
595 int mandNodeInd = mAllNodes.Find(mands[j]); |
664 int mandNodeInd = mAllNodes.Find(mands[i]); |
596 mAllNodes[mandNodeInd]->Base().SetSelected(mark); |
665 mAllNodes[mandNodeInd]->Base().SetSelected(mark); |
597 if (mAllNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
666 if (mAllNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
598 { |
667 { |
599 // mark also all dependencies of a mandatory item |
668 // mark also all dependencies of a mandatory item |
600 MIAUpdateNode* dependencyNode = static_cast<MIAUpdateNode*>(mAllNodes[mandNodeInd]); |
669 MIAUpdateNode* dependencyNode = static_cast<MIAUpdateNode*>(mAllNodes[mandNodeInd]); |
601 RPointerArray<MIAUpdateNode> dependencies; |
670 RPointerArray<MIAUpdateNode> dependencies; |
602 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*dependencyNode, mAllNodes, dependencies)); |
671 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*dependencyNode, mAllNodes, dependencies)); |
603 if (err) |
672 if (err) |
604 { |
673 { |
605 dependencies.Close(); |
674 dependencies.Close(); |
606 if (mark) |
675 mands.Close(); |
607 { |
|
608 mands.Close(); |
|
609 } |
|
610 return; |
676 return; |
611 } |
677 } |
612 for(int k = 0; k < dependencies.Count(); k++) |
678 for(int j = 0; j < dependencies.Count(); j++) |
613 { |
679 { |
614 int depNodeInd = mAllNodes.Find(dependencies[k]); |
680 int depNodeInd = mAllNodes.Find(dependencies[j]); |
615 mAllNodes[depNodeInd]->Base().SetSelected(true); |
681 mAllNodes[depNodeInd]->Base().SetSelected(true); |
616 } |
682 } |
617 dependencies.Close(); |
683 dependencies.Close(); |
618 } |
684 } |
619 } |
685 } |
620 } |
686 } |
621 if (mark) |
687 } |
622 { |
688 mands.Close(); |
623 mands.Close(); |
689 } |
624 } |
690 } |
625 } |
|
626 return; |
|
627 } |
|
628 return; |
|
629 } |
|
630 |
691 |
631 |
692 |
632 bool IAUpdateMainView::getMandatoryNodes(RPointerArray<MIAUpdateAnyNode> &mandNodes) const |
693 bool IAUpdateMainView::getMandatoryNodes(RPointerArray<MIAUpdateAnyNode> &mandNodes) const |
633 { |
694 { |
634 bool ret = true; |
695 bool ret = true; |
643 } |
704 } |
644 } |
705 } |
645 return ret; |
706 return ret; |
646 } |
707 } |
647 |
708 |
648 void IAUpdateMainView::showUpdateCannotOmitDialog() const |
709 void IAUpdateMainView::showUpdateCannotOmitDialog() |
649 { |
710 { |
650 HbMessageBox messageBox(HbMessageBox::MessageTypeInformation); |
711 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
651 messageBox.setText(QString("This required update cannot be omitted")); |
712 messageBox->setText(QString("This required update cannot be omitted")); |
652 HbAction okAction("Ok"); |
713 int actionCount = messageBox->actions().count(); |
653 messageBox.setPrimaryAction(&okAction); |
714 for (int i=actionCount-1; i >= 0; i--) |
654 messageBox.setTimeout(HbPopup::StandardTimeout); |
715 { |
655 messageBox.show(); |
716 messageBox->removeAction(messageBox->actions().at(i)); |
656 //messageBox.exec(); |
717 } |
657 } |
718 HbAction *okAction = NULL; |
658 |
719 okAction = new HbAction("Ok"); |
659 bool IAUpdateMainView::showDependenciesFoundDialog(QString &text) const |
720 messageBox->addAction(okAction); |
660 { |
721 messageBox->setTimeout(HbPopup::StandardTimeout); |
661 bool accepted = false; |
722 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
662 HbMessageBox messageBox(HbMessageBox::MessageTypeQuestion); |
723 mDialogState = CannotOmit; |
663 messageBox.setText(text); |
724 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
664 HbAction continueAction("Continue"); |
725 } |
665 messageBox.setPrimaryAction(&continueAction); |
726 |
666 HbAction cancelAction("Cancel"); |
727 void IAUpdateMainView::showDependenciesFoundDialog(QString &text) |
667 messageBox.setSecondaryAction(&cancelAction); |
728 { |
668 messageBox.setTimeout(HbPopup::NoTimeout); |
729 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
669 messageBox.show(); |
730 messageBox->setText(text); |
670 //HbAction *selectedAction = messageBox.exec(); |
731 int actionCount = messageBox->actions().count(); |
671 //if (selectedAction == messageBox.primaryAction()) |
732 for (int i=actionCount-1; i >= 0; i--) |
672 { |
733 { |
673 accepted = true; |
734 messageBox->removeAction(messageBox->actions().at(i)); |
674 } |
735 } |
675 return accepted; |
736 mPrimaryAction = NULL; |
|
737 mPrimaryAction = new HbAction("Continue"); |
|
738 HbAction *secondaryAction = NULL; |
|
739 secondaryAction = new HbAction("Cancel"); |
|
740 messageBox->addAction(mPrimaryAction); |
|
741 messageBox->addAction(secondaryAction); |
|
742 messageBox->setTimeout(HbPopup::NoTimeout); |
|
743 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
744 mDialogState = Dependencies; |
|
745 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
676 } |
746 } |
677 |
747 |
678 void IAUpdateMainView::updateSelectionsToList() |
748 void IAUpdateMainView::updateSelectionsToList() |
679 { |
749 { |
|
750 mSelectionUpdate = true; |
680 for(int i = 0; i < mAllNodes.Count(); ++i) |
751 for(int i = 0; i < mAllNodes.Count(); ++i) |
681 { |
752 { |
682 if ( mAllNodes[i]->Base().IsSelected() != mListView->selectionModel()->isSelected(mListView->model()->index(i,0))) |
753 if ( mAllNodes[i]->Base().IsSelected() != mListView->selectionModel()->isSelected(mListView->model()->index(i,0))) |
683 { |
754 { |
684 QItemSelectionModel::SelectionFlag selectionFlag; |
755 QItemSelectionModel::SelectionFlag selectionFlag; |
691 selectionFlag = QItemSelectionModel::Deselect; |
762 selectionFlag = QItemSelectionModel::Deselect; |
692 } |
763 } |
693 mListView->selectionModel()->select(mListView->model()->index(i,0),selectionFlag); |
764 mListView->selectionModel()->select(mListView->model()->index(i,0),selectionFlag); |
694 } |
765 } |
695 } |
766 } |
696 } |
767 mSelectionUpdate = false; |
697 |
768 } |
698 |
769 |
|
770 |
|
771 MIAUpdateAnyNode* IAUpdateMainView::getNode(int index) const |
|
772 { |
|
773 MIAUpdateAnyNode *currentNode = NULL; |
|
774 |
|
775 if (index >= 0 && index < mAllNodes.Count()) |
|
776 { |
|
777 currentNode = mAllNodes[index]; |
|
778 } |
|
779 return currentNode; |
|
780 } |
699 |
781 |
700 |
782 void IAUpdateMainView::showDetails(MIAUpdateAnyNode& node) |
701 |
783 { |
702 |
784 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
703 |
785 messageBox->setIconVisible(false); |
|
786 |
|
787 QString text; |
|
788 constructDetailsText(node,text); |
|
789 messageBox->setText(text); |
|
790 int actionCount = messageBox->actions().count(); |
|
791 |
|
792 for (int i=actionCount-1; i >= 0; i--) |
|
793 { |
|
794 messageBox->removeAction(messageBox->actions().at(i)); |
|
795 } |
|
796 HbAction *okAction = NULL; |
|
797 okAction = new HbAction("Ok"); |
|
798 messageBox->addAction(okAction); |
|
799 messageBox->setTimeout(HbPopup::NoTimeout); |
|
800 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
801 mDialogState = Details; |
|
802 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
|
803 } |
|
804 |
|
805 |
|
806 void IAUpdateMainView::constructDetailsText(MIAUpdateAnyNode &node, QString &text) |
|
807 { |
|
808 |
|
809 text.append(QString("Name:")); |
|
810 text.append(QString("<br />")); |
|
811 QString name = XQConversions::s60DescToQString(node.Base().Name()); |
|
812 text.append(name); |
|
813 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
814 { |
|
815 name.append(QString(" Device software")); |
|
816 } |
|
817 |
|
818 text.append(QString("<br />")); |
|
819 text.append(QString("<br />")); |
|
820 |
|
821 text.append(QString("Description:")); |
|
822 text.append(QString("<br />")); |
|
823 QString description; |
|
824 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
825 { |
|
826 description = QString("This update improves your device performance and brings you latest features."); |
|
827 } |
|
828 else |
|
829 { |
|
830 description = XQConversions::s60DescToQString(node.Base().Description()); |
|
831 } |
|
832 text.append(description); |
|
833 text.append(QString("<br />")); |
|
834 text.append(QString("<br />")); |
|
835 |
|
836 |
|
837 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
|
838 { |
|
839 MIAUpdateNode *iaupdateNode = static_cast<MIAUpdateNode*> (&node); |
|
840 if (iaupdateNode->Type()!= MIAUpdateNode::EPackageTypeServicePack) |
|
841 { |
|
842 text.append(QString("Version:")); |
|
843 text.append(QString("<br />")); |
|
844 QString textVersion; |
|
845 versionText(node.Base().Version(), textVersion); |
|
846 text.append(textVersion); |
|
847 text.append(QString("<br />")); |
|
848 text.append(QString("<br />")); |
|
849 } |
|
850 } |
|
851 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
852 { |
|
853 MIAUpdateFwNode *fwNode = static_cast<MIAUpdateFwNode*> (&node); |
|
854 text.append(QString("Version:")); |
|
855 text.append(QString("<br />")); |
|
856 QString textVersion = XQConversions::s60DescToQString(fwNode->FwVersion1()); |
|
857 text.append(textVersion); |
|
858 text.append(QString("<br />")); |
|
859 text.append(QString("<br />")); |
|
860 } |
|
861 |
|
862 int contentSize = node.Base().ContentSizeL(); |
|
863 if (contentSize > 0) |
|
864 { |
|
865 text.append(QString("Size:")); |
|
866 text.append(QString("<br />")); |
|
867 QString textFileSize; |
|
868 fileSizeText(contentSize, textFileSize); |
|
869 text.append(textFileSize); |
|
870 } |
|
871 } |
|
872 |
|
873 void IAUpdateMainView::versionText(const TIAUpdateVersion &version, QString &versionText) |
|
874 { |
|
875 QString stringMajor; |
|
876 stringMajor.setNum(version.iMajor); |
|
877 versionText.append(stringMajor); |
|
878 versionText.append(QString(".")); |
|
879 QString stringMinor; |
|
880 stringMinor.setNum(version.iMinor); |
|
881 versionText.append(stringMinor); |
|
882 versionText.append(QString("(")); |
|
883 QString stringBuild; |
|
884 stringBuild.setNum(version.iBuild); |
|
885 versionText.append(stringBuild); |
|
886 versionText.append(QString(")")); |
|
887 } |
|
888 |
|
889 void IAUpdateMainView::fileSizeText(int fileSize, QString &text) |
|
890 { |
|
891 int size = 0; |
|
892 QString stringUnit; |
|
893 |
|
894 if (fileSize >= KMaxShownInKiloBytes ) |
|
895 { |
|
896 stringUnit.append(" MB"); |
|
897 size = fileSize / KMegaByte; |
|
898 if ( fileSize % KMegaByte != 0 ) |
|
899 { |
|
900 size++; |
|
901 } |
|
902 } |
|
903 else |
|
904 { |
|
905 stringUnit.append(" kB"); |
|
906 size = fileSize / KKiloByte; |
|
907 if ( fileSize % KKiloByte != 0 ) |
|
908 { |
|
909 size++; |
|
910 } |
|
911 } |
|
912 text.setNum(size); |
|
913 text.append(stringUnit); |
|
914 } |