19 #include <hbaction.h> |
19 #include <hbaction.h> |
20 #include <QGraphicsWidget> |
20 #include <QGraphicsWidget> |
21 #include <QGraphicsLayout> |
21 #include <QGraphicsLayout> |
22 #include <QGraphicsLayoutItem> |
22 #include <QGraphicsLayoutItem> |
23 #include <QGraphicsLinearLayout> |
23 #include <QGraphicsLinearLayout> |
|
24 #include <QSizeF> |
24 |
25 |
25 #include <hbdockwidget.h> |
26 #include <hbdockwidget.h> |
26 #include <hblistwidget.h> |
27 #include <HbListView> |
27 #include <hblistviewitem.h> |
28 #include <hblistviewitem.h> |
28 #include <hblistwidgetitem.h> |
29 #include <hblistwidgetitem.h> |
29 #include <hbtoolbar.h> |
30 #include <hbtoolbar.h> |
30 #include <hbmenu.h> |
31 #include <hbmenu.h> |
31 #include <hbdocumentloader.h> |
32 #include <hbdocumentloader.h> |
32 #include <xqconversions.h> |
33 #include <xqconversions.h> |
33 #include <hbmessagebox.h> |
34 #include <hbmessagebox.h> |
34 #include <hblabel.h> |
35 #include <hblabel.h> |
35 #include <hbgroupbox.h> |
36 #include <hbgroupbox.h> |
36 #include <hbdataform.h> |
37 #include <HbDataForm> |
|
38 #include <HbLabel> |
37 #include <hbtranslator.h> |
39 #include <hbtranslator.h> |
|
40 #include <HbStyleLoader> |
|
41 #include <HbIconItem> |
|
42 #include <HbIconAnimationManager> |
|
43 #include <HbIconAnimator> |
|
44 #include <hbparameterlengthlimiter.h> |
38 |
45 |
39 #include "iaupdatemainview.h" |
46 #include "iaupdatemainview.h" |
40 #include "iaupdateengine.h" |
47 #include "iaupdateengine.h" |
41 #include "iaupdateagreement.h" |
48 #include "iaupdateagreement.h" |
42 #include "iaupdatedeputils.h" |
49 #include "iaupdatedeputils.h" |
43 #include "iaupdatedialogutil.h" |
50 #include "iaupdatedialogutil.h" |
44 #include "iaupdateversion.h" |
51 #include "iaupdateversion.h" |
|
52 #include "iaupdateapplistmodel.h" |
|
53 #include "iaupdateapplistitem.h" |
|
54 #include "iaupdateuicontroller.h" |
45 |
55 |
46 #include "iaupdatedebug.h" |
56 #include "iaupdatedebug.h" |
47 |
57 |
48 |
58 |
49 |
59 |
50 const int KKiloByte = 1024; |
60 const int KKiloByte = 1024; |
51 const int KMegaByte = 1024 * 1024; |
61 const int KMegaByte = 1024 * 1024; |
52 const int KMaxShownInKiloBytes = 10 * KMegaByte; |
62 const int KMaxShownInKiloBytes = 10 * KMegaByte; |
53 const QString KTranslationsPath = "/resource/qt/translations/"; |
63 const QString KTranslationsPath = "/resource/qt/translations/"; |
54 const QString KTranslationsFile = "swupdate"; |
64 const QString KTranslationsFile = "swupdate"; |
|
65 |
|
66 const QString ANIMATION_ICON("qtg_anim_loading"); |
|
67 const QString ANIMATION_FILE("qtg_anim_loading.axml"); |
55 |
68 |
56 |
69 |
57 IAUpdateMainView::IAUpdateMainView(IAUpdateEngine *engine): |
70 IAUpdateMainView::IAUpdateMainView(IAUpdateEngine *engine): |
58 mEngine(engine) |
71 mEngine(engine) |
59 { |
72 { |
92 |
109 |
93 HbMenu *menu = qobject_cast< HbMenu*>( loader.findWidget("viewMenu") ); |
110 HbMenu *menu = qobject_cast< HbMenu*>( loader.findWidget("viewMenu") ); |
94 setMenu(menu); |
111 setMenu(menu); |
95 |
112 |
96 //Get the Action objects from the docml file |
113 //Get the Action objects from the docml file |
97 HbAction *action = qobject_cast<HbAction*>(loader.findObject("action")); |
114 mActionStartUpdate = qobject_cast<HbAction*>(loader.findObject("action")); |
98 HbAction *action_1 = qobject_cast<HbAction*>(loader.findObject("action_1")); |
115 mActionSettings = qobject_cast<HbAction*>(loader.findObject("action_1")); |
99 HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2")); |
116 mActionDisclaimer = qobject_cast<HbAction*>(loader.findObject("action_2")); |
100 |
117 mActionCancelRefresh = qobject_cast<HbAction*>(loader.findObject("action_3")); |
101 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
118 mActionCancelUpdate = qobject_cast<HbAction*>(loader.findObject("action_4")); |
102 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
119 |
103 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
120 |
|
121 connect(mActionStartUpdate, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
|
122 connect(mActionSettings, SIGNAL(triggered()), this, SLOT(handleSettings())); |
|
123 connect(mActionDisclaimer, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
|
124 connect(mActionCancelRefresh, SIGNAL(triggered()), this, SLOT(handleCancelRefresh())); |
|
125 connect(mActionCancelUpdate, SIGNAL(triggered()), this, SLOT(handleCancelUpdate())); |
|
126 |
|
127 mActionStartUpdate->setDisabled(true); |
|
128 |
|
129 mActionCancelRefresh->setVisible(false); |
|
130 mActionCancelUpdate->setVisible(false); |
104 |
131 |
105 mContent = qobject_cast< HbWidget*>( loader.findWidget("content") ); |
132 mContent = qobject_cast< HbWidget*>( loader.findWidget("content") ); |
106 |
133 |
107 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
134 //mListView = qobject_cast<HbListView*>( loader.findWidget("listWidget") ); |
108 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
135 mListView = new HbListView(mContent); |
|
136 mListView->setSelectionMode(HbAbstractItemView::MultiSelection); |
|
137 |
|
138 //mListView->setLayoutName("iaupdate_progress"); |
|
139 HbStyleLoader::registerFilePath(":/layout/"); |
109 |
140 |
110 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
141 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
111 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
142 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
112 |
143 |
113 HbListViewItem *prototype = mListView->listItemPrototype(); |
144 IAUpdateAppListModel *model = new IAUpdateAppListModel(); |
114 |
145 |
|
146 //HbListViewItem *prototype = mListView->listItemPrototype(); |
|
147 |
|
148 HbListViewItem *prototype = new IAUpdateAppListItem(mListView); |
115 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
149 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
|
150 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
|
151 |
|
152 mListView->setModel(model, prototype); |
116 |
153 |
117 HbDockWidget *dock = new HbDockWidget(this); |
154 HbDockWidget *dock = new HbDockWidget(this); |
118 HbWidget *dockContainer = new HbWidget(dock); |
155 HbWidget *dockContainer = new HbWidget(dock); |
119 QGraphicsLinearLayout *dockLayout = new QGraphicsLinearLayout(dockContainer); |
156 QGraphicsLinearLayout *dockLayout = new QGraphicsLinearLayout(dockContainer); |
120 dockLayout->setOrientation(Qt::Vertical); |
157 dockLayout->setOrientation(Qt::Vertical); |
121 dockContainer->setLayout(dockLayout); |
158 dockContainer->setLayout(dockLayout); |
122 |
159 |
123 mSelections = new HbGroupBox(dockContainer); |
160 mSelections = new HbGroupBox(dockContainer); |
124 mSelections->setHeading("Selected 0/0 (0 kB)"); |
161 |
125 //QString selectedString = QString(hbTrId("txt_software_subhead_selected_1l_2l_3l_kb")).arg(0).arg(0).arg(0); |
162 QString selectedString = |
126 //mSelections->setHeading(selectedString); |
163 QString(hbTrId("txt_software_subhead_selected_1l_2l_3l_kb")).arg(0).arg(0).arg(0); |
127 |
164 mSelections->setHeading(selectedString); |
128 dockLayout->addItem( mSelections); |
165 |
|
166 dockLayout->addItem(mSelections); |
129 |
167 |
130 dockLayout->addItem(toolBar); |
168 dockLayout->addItem(toolBar); |
131 |
169 |
132 dock->setWidget(dockContainer); |
170 dock->setWidget(dockContainer); |
133 |
171 |
165 { |
203 { |
166 if (!mContentDataForm) |
204 if (!mContentDataForm) |
167 { |
205 { |
168 mContentDataForm = new HbDataForm(mContent); |
206 mContentDataForm = new HbDataForm(mContent); |
169 } |
207 } |
|
208 else |
|
209 { |
|
210 mContentDataForm->setVisible(true); |
|
211 } |
170 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
212 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
171 linearLayout->addItem(mContentDataForm); |
213 linearLayout->addItem(mContentDataForm); |
172 QString formText; |
214 QString formText; |
173 |
215 |
174 if (error == KErrNone) |
216 if (error == KErrNone) |
175 { |
217 { |
176 formText = QString("Applications are up to date"); |
218 formText = |
177 //formText = hbTrId("txt_software_formlabel_applications_are_up_to_date"); |
219 hbTrId("txt_software_formlabel_applications_are_up_to_date"); |
178 } |
220 } |
179 else |
221 else |
180 { |
222 { |
181 formText = QString("Refreshing failed. Try again later."); |
223 formText = |
|
224 hbTrId("txt_software_formlabel_refreshing_failed_try_agai"); |
182 } |
225 } |
183 mContentDataForm->setDescription(formText); |
226 mContentDataForm->setDescription(formText); |
184 } |
227 } |
185 updateSelectionInfoInDock(); |
228 updateSelectionInfoInDock(); |
|
229 |
|
230 if (!mUpdating) |
|
231 { |
|
232 mActionStartUpdate->setEnabled(countOfSelections() > 0); |
|
233 } |
186 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() end"); |
234 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() end"); |
187 } |
235 } |
188 |
236 |
189 |
237 void IAUpdateMainView::refreshProgress() |
190 |
238 { |
|
239 IAUpdateAppListModel *model = NULL; |
|
240 model = (IAUpdateAppListModel*) mListView->model(); |
|
241 if (model) |
|
242 { |
|
243 model->refreshProgress(); |
|
244 } |
|
245 } |
|
246 |
|
247 void IAUpdateMainView::startRefreshingAnimation() |
|
248 { |
|
249 removeCurrentContentLayout(); |
|
250 |
|
251 mActionDisclaimer->setVisible(false); |
|
252 mActionSettings->setVisible(false); |
|
253 mActionCancelRefresh->setVisible(true); |
|
254 |
|
255 |
|
256 if (!mLabel) |
|
257 { |
|
258 mLabel = new HbLabel(mContent); |
|
259 } |
|
260 else |
|
261 { |
|
262 mLabel->setVisible(true); |
|
263 } |
|
264 |
|
265 QString formText; |
|
266 formText = hbTrId("txt_software_formlabel_refreshing_updates_list"); |
|
267 mLabel->setPlainText(formText); |
|
268 mLabel->setAlignment(Qt::AlignHCenter); |
|
269 |
|
270 |
|
271 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
272 linearLayout->addStretch(); |
|
273 linearLayout->addItem(mLabel); |
|
274 |
|
275 |
|
276 if (!mAnimationIconItem) |
|
277 { |
|
278 mAnimationIconItem = new HbIconItem(ANIMATION_ICON,mContent); |
|
279 } |
|
280 else |
|
281 { |
|
282 mAnimationIconItem->setVisible(true); |
|
283 } |
|
284 mAnimationIconItem->setAlignment(Qt::AlignHCenter ); |
|
285 linearLayout->addItem(mAnimationIconItem); |
|
286 linearLayout->addStretch(); |
|
287 |
|
288 HbIconAnimationManager::global()->addDefinitionFile(ANIMATION_FILE); |
|
289 |
|
290 mAnimationIconItem->animator().startAnimation(); |
|
291 } |
|
292 |
|
293 void IAUpdateMainView::stopRefreshingAnimation() |
|
294 { |
|
295 mActionDisclaimer->setVisible(true); |
|
296 mActionSettings->setVisible(true); |
|
297 mActionCancelRefresh->setVisible(false); |
|
298 |
|
299 mAnimationIconItem->animator().stopAnimation(); |
|
300 } |
|
301 |
|
302 void IAUpdateMainView::updateCompleted() |
|
303 { |
|
304 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateCompleted() begin"); |
|
305 mUpdating = false; |
|
306 mActionStartUpdate->setEnabled(countOfSelections() > 0); |
|
307 mActionDisclaimer->setVisible(true); |
|
308 mActionSettings->setVisible(true); |
|
309 mActionCancelUpdate->setVisible(false); |
|
310 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
|
311 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
|
312 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateCompleted() end"); |
|
313 } |
191 |
314 |
192 void IAUpdateMainView::handleStartUpdate() |
315 void IAUpdateMainView::handleStartUpdate() |
193 { |
316 { |
194 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() begin"); |
317 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() begin"); |
|
318 |
|
319 mActionStartUpdate->setEnabled(false); |
|
320 mActionDisclaimer->setVisible(false); |
|
321 mActionSettings->setVisible(false); |
|
322 mActionCancelUpdate->setVisible(true); |
|
323 disconnect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
|
324 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
|
325 mUpdating = true; |
195 mEngine->StartUpdate(fotaSelected()); |
326 mEngine->StartUpdate(fotaSelected()); |
196 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() end"); |
327 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() end"); |
197 } |
328 } |
198 |
329 |
199 |
330 |
216 HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_ok")); |
349 HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_ok")); |
217 mDialogUtil->showAgreement(primaryAction); |
350 mDialogUtil->showAgreement(primaryAction); |
218 } |
351 } |
219 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() end"); |
352 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() end"); |
220 } |
353 } |
|
354 |
|
355 void IAUpdateMainView::handleCancelRefresh() |
|
356 { |
|
357 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleCancelRefresh() begin"); |
|
358 mEngine->Controller()->HandleUserCancelL(); |
|
359 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleCancelRefresh() end"); |
|
360 } |
|
361 |
|
362 void IAUpdateMainView::handleCancelUpdate() |
|
363 { |
|
364 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleCancelUpdate() begin"); |
|
365 mEngine->Controller()->HandleUserCancelL(); |
|
366 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleCancelUpdate() end"); |
|
367 } |
|
368 |
|
369 |
221 |
370 |
222 void IAUpdateMainView::handleDetails(HbAbstractViewItem * item, const QPointF &) |
371 void IAUpdateMainView::handleDetails(HbAbstractViewItem * item, const QPointF &) |
223 { |
372 { |
224 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDetails() begin"); |
373 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDetails() begin"); |
225 int ind = item->modelIndex().row(); |
374 int ind = item->modelIndex().row(); |
634 |
785 |
635 void IAUpdateMainView::showUpdateCannotOmitDialog() |
786 void IAUpdateMainView::showUpdateCannotOmitDialog() |
636 { |
787 { |
637 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showUpdateCannotOmitDialog() begin"); |
788 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showUpdateCannotOmitDialog() begin"); |
638 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
789 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
639 messageBox->setText(QString("This required update cannot be omitted")); |
790 messageBox->setText(hbTrId("txt_software_info_this_required_update_cannot_be_o")); |
640 int actionCount = messageBox->actions().count(); |
791 int actionCount = messageBox->actions().count(); |
641 for (int i=actionCount-1; i >= 0; i--) |
792 for (int i=actionCount-1; i >= 0; i--) |
642 { |
793 { |
643 messageBox->removeAction(messageBox->actions().at(i)); |
794 messageBox->removeAction(messageBox->actions().at(i)); |
644 } |
795 } |
645 HbAction *okAction = NULL; |
796 HbAction *okAction = NULL; |
646 okAction = new HbAction("Ok"); |
797 okAction = new HbAction(hbTrId("txt_common_button_ok")); |
647 messageBox->addAction(okAction); |
798 messageBox->addAction(okAction); |
648 messageBox->setTimeout(HbPopup::StandardTimeout); |
799 messageBox->setTimeout(HbPopup::StandardTimeout); |
649 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
800 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
650 mDialogState = CannotOmit; |
801 mDialogState = CannotOmit; |
651 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
802 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
740 |
891 |
741 |
892 |
742 void IAUpdateMainView::constructDetailsText(MIAUpdateAnyNode &node, QString &text) |
893 void IAUpdateMainView::constructDetailsText(MIAUpdateAnyNode &node, QString &text) |
743 { |
894 { |
744 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::constructDetailsText() begin"); |
895 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::constructDetailsText() begin"); |
745 text.append(QString("Name:")); |
896 text.append(hbTrId("txt_software_dialog_name")); |
746 text.append(QString("<br />")); |
897 text.append(QString("<br />")); |
747 QString name = XQConversions::s60DescToQString(node.Base().Name()); |
|
748 text.append(name); |
|
749 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
898 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
750 { |
899 { |
751 name.append(QString(" Device software")); |
900 text.append(hbTrId("txt_software_dblist_device_software ")); // TODO: wrong layout |
|
901 } |
|
902 else |
|
903 { |
|
904 QString name = XQConversions::s60DescToQString(node.Base().Name()); |
|
905 text.append(name); |
752 } |
906 } |
753 |
907 |
754 text.append(QString("<br />")); |
908 text.append(QString("<br />")); |
755 text.append(QString("<br />")); |
909 text.append(QString("<br />")); |
756 |
910 |
757 text.append(QString("Description:")); |
911 text.append(hbTrId("txt_software_dialog_description")); |
758 text.append(QString("<br />")); |
912 text.append(QString("<br />")); |
759 QString description; |
913 QString description; |
760 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
914 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
761 { |
915 { |
762 description = QString("This update improves your device performance and brings you latest features."); |
916 description = |
|
917 hbTrId("txt_software_info_this_update_improves_your_device"); |
763 } |
918 } |
764 else |
919 else |
765 { |
920 { |
766 description = XQConversions::s60DescToQString(node.Base().Description()); |
921 description = XQConversions::s60DescToQString(node.Base().Description()); |
767 } |
922 } |
785 } |
940 } |
786 } |
941 } |
787 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
942 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
788 { |
943 { |
789 MIAUpdateFwNode *fwNode = static_cast<MIAUpdateFwNode*> (&node); |
944 MIAUpdateFwNode *fwNode = static_cast<MIAUpdateFwNode*> (&node); |
790 text.append(QString("Version:")); |
945 text.append(hbTrId("txt_software_dialog_version")); |
791 text.append(QString("<br />")); |
946 text.append(QString("<br />")); |
792 QString textVersion = XQConversions::s60DescToQString(fwNode->FwVersion1()); |
947 QString textVersion = XQConversions::s60DescToQString(fwNode->FwVersion1()); |
793 text.append(textVersion); |
948 text.append(textVersion); |
794 text.append(QString("<br />")); |
949 text.append(QString("<br />")); |
795 text.append(QString("<br />")); |
950 text.append(QString("<br />")); |
796 } |
951 } |
797 |
952 |
798 int contentSize = node.Base().ContentSizeL(); |
953 int contentSize = node.Base().ContentSizeL(); |
799 if (contentSize > 0) |
954 if (contentSize > 0) |
800 { |
955 { |
801 text.append(QString("Size:")); |
956 text.append(hbTrId("txt_software_dialog_size")); |
802 text.append(QString("<br />")); |
957 text.append(QString("<br />")); |
803 QString textFileSize; |
958 QString textFileSize; |
804 fileSizeText(contentSize, textFileSize); |
959 fileSizeText(contentSize, textFileSize); |
805 text.append(textFileSize); |
960 text.append(textFileSize); |
806 } |
961 } |
808 } |
963 } |
809 |
964 |
810 void IAUpdateMainView::versionText(const TIAUpdateVersion &version, QString &versionText) |
965 void IAUpdateMainView::versionText(const TIAUpdateVersion &version, QString &versionText) |
811 { |
966 { |
812 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::versionText() begin"); |
967 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::versionText() begin"); |
813 QString stringMajor; |
968 versionText.append |
814 stringMajor.setNum(version.iMajor); |
969 (hbTrId("txt_software_info_version_1l_2l_3l").arg(version.iMajor).arg(version.iMinor).arg(version.iBuild)); |
815 versionText.append(stringMajor); |
|
816 versionText.append(QString(".")); |
|
817 QString stringMinor; |
|
818 stringMinor.setNum(version.iMinor); |
|
819 versionText.append(stringMinor); |
|
820 versionText.append(QString("(")); |
|
821 QString stringBuild; |
|
822 stringBuild.setNum(version.iBuild); |
|
823 versionText.append(stringBuild); |
|
824 versionText.append(QString(")")); |
|
825 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::versionText() end"); |
970 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::versionText() end"); |
826 } |
971 } |
827 |
972 |
828 void IAUpdateMainView::fileSizeText(int fileSize, QString &text) |
973 void IAUpdateMainView::fileSizeText(int fileSize, QString &text) |
829 { |
974 { |
830 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() begin"); |
975 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() begin"); |
831 int size = 0; |
976 int size = 0; |
832 QString stringUnit; |
|
833 |
977 |
834 if (fileSize >= KMaxShownInKiloBytes ) |
978 if (fileSize >= KMaxShownInKiloBytes ) |
835 { |
979 { |
836 stringUnit.append(" MB"); |
|
837 size = fileSize / KMegaByte; |
980 size = fileSize / KMegaByte; |
838 if ( fileSize % KMegaByte != 0 ) |
981 if ( fileSize % KMegaByte != 0 ) |
839 { |
982 { |
840 size++; |
983 size++; |
841 } |
984 } |
|
985 text.append(hbTrId("txt_software_dialog_l_kb").arg(size)); |
842 } |
986 } |
843 else |
987 else |
844 { |
988 { |
845 stringUnit.append(" kB"); |
|
846 size = fileSize / KKiloByte; |
989 size = fileSize / KKiloByte; |
847 if ( fileSize % KKiloByte != 0 ) |
990 if ( fileSize % KKiloByte != 0 ) |
848 { |
991 { |
849 size++; |
992 size++; |
850 } |
993 } |
851 } |
994 text.append(hbTrId("txt_software_dialog_l_mb").arg(size)); |
852 text.setNum(size); |
995 } |
853 text.append(stringUnit); |
996 |
854 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() end"); |
997 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() end"); |
855 } |
998 } |
856 |
999 |
857 void IAUpdateMainView::setImportance(MIAUpdateAnyNode *node, QString &importanceDescription) |
|
858 { |
|
859 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::setImportance() begin"); |
|
860 int sizeInBytes = node->Base().ContentSizeL(); |
|
861 int size = 0; |
|
862 bool shownInMegabytes = false; |
|
863 if (sizeInBytes >= KMaxShownInKiloBytes) |
|
864 { |
|
865 shownInMegabytes = true; |
|
866 size = sizeInBytes / KMegaByte; |
|
867 if (sizeInBytes % KMegaByte != 0) |
|
868 { |
|
869 size++; |
|
870 } |
|
871 } |
|
872 else |
|
873 { |
|
874 size = sizeInBytes / KKiloByte; |
|
875 if (sizeInBytes % KKiloByte != 0) |
|
876 { |
|
877 size++; |
|
878 } |
|
879 } |
|
880 QString sizeString; |
|
881 sizeString.setNum(size); |
|
882 switch(node->Base().Importance()) |
|
883 { |
|
884 case MIAUpdateBaseNode::EMandatory: |
|
885 { |
|
886 importanceDescription = "Required "; |
|
887 importanceDescription.append(sizeString); |
|
888 if (shownInMegabytes) |
|
889 { |
|
890 importanceDescription.append(" MB" ); |
|
891 } |
|
892 else |
|
893 { |
|
894 importanceDescription.append(" kB" ); |
|
895 } |
|
896 break; |
|
897 } |
|
898 |
|
899 case MIAUpdateBaseNode::ECritical: |
|
900 { |
|
901 bool isNSU = false; |
|
902 if(node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
|
903 { |
|
904 MIAUpdateFwNode *fwnode = static_cast<MIAUpdateFwNode*>(node); |
|
905 if (fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) |
|
906 { |
|
907 isNSU = true; |
|
908 } |
|
909 } |
|
910 importanceDescription = "Important "; |
|
911 if (!size || isNSU) |
|
912 { |
|
913 //for firmware when size info is not provided by server |
|
914 } |
|
915 else |
|
916 { |
|
917 importanceDescription.append(sizeString); |
|
918 if (shownInMegabytes) |
|
919 { |
|
920 importanceDescription.append(" MB" ); |
|
921 } |
|
922 else |
|
923 { |
|
924 importanceDescription.append(" kB" ); |
|
925 } |
|
926 } |
|
927 break; |
|
928 } |
|
929 |
|
930 case MIAUpdateBaseNode::ERecommended: |
|
931 { |
|
932 importanceDescription = "Recommended "; |
|
933 importanceDescription.append(sizeString); |
|
934 if (shownInMegabytes) |
|
935 { |
|
936 importanceDescription.append(" MB" ); |
|
937 } |
|
938 else |
|
939 { |
|
940 importanceDescription.append(" kB" ); |
|
941 } |
|
942 break; |
|
943 } |
|
944 |
|
945 case MIAUpdateBaseNode::ENormal: |
|
946 { |
|
947 importanceDescription = "Optional "; |
|
948 importanceDescription.append(sizeString); |
|
949 if (shownInMegabytes) |
|
950 { |
|
951 importanceDescription.append(" MB" ); |
|
952 } |
|
953 else |
|
954 { |
|
955 importanceDescription.append(" kB" ); |
|
956 } |
|
957 break; |
|
958 } |
|
959 |
|
960 default: |
|
961 { |
|
962 break; |
|
963 } |
|
964 } |
|
965 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::setImportance() end"); |
|
966 } |
|
967 |
1000 |
968 void IAUpdateMainView::removeCurrentContentLayout() |
1001 void IAUpdateMainView::removeCurrentContentLayout() |
969 { |
1002 { |
970 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() begin"); |
1003 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() begin"); |
971 int itemCount = mContent->layout()->count(); |
1004 int itemCount = mContent->layout()->count(); |
972 for (int i = 0; i < itemCount; i++) |
1005 for (int i = 0; i < itemCount; i++) |
973 { |
1006 { |
974 mContent->layout()->removeAt(i); |
1007 mContent->layout()->removeAt(i); |
|
1008 } |
|
1009 if (mContentDataForm) |
|
1010 { |
|
1011 mContentDataForm->setVisible(false); |
|
1012 } |
|
1013 if (mLabel) |
|
1014 { |
|
1015 mLabel->setVisible(false); |
|
1016 } |
|
1017 if (mAnimationIconItem) |
|
1018 { |
|
1019 delete mAnimationIconItem; |
|
1020 mAnimationIconItem = NULL; |
975 } |
1021 } |
976 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() end"); |
1022 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() end"); |
977 } |
1023 } |
978 |
1024 |
979 void IAUpdateMainView::refreshFirmwareUpdates(const RPointerArray<MIAUpdateFwNode> &fwNodes) |
1025 void IAUpdateMainView::refreshFirmwareUpdates(const RPointerArray<MIAUpdateFwNode> &fwNodes) |
990 { |
1036 { |
991 refreshFotaUpdate(*fwnode ); |
1037 refreshFotaUpdate(*fwnode ); |
992 } |
1038 } |
993 else if (fwNodes.Count() == 1 && fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) |
1039 else if (fwNodes.Count() == 1 && fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) |
994 { |
1040 { |
995 refreshNsuUpdate(); |
1041 refreshNsuUpdate(*fwnode); |
996 } |
1042 } |
997 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFirmwareUpdates() end"); |
1043 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFirmwareUpdates() end"); |
998 } |
1044 } |
999 } |
1045 } |
1000 |
1046 |
1001 void IAUpdateMainView::refreshFotaUpdate(MIAUpdateFwNode& fwNode) |
1047 void IAUpdateMainView::refreshFotaUpdate(MIAUpdateFwNode& fwNode) |
1002 { |
1048 { |
1003 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() begin"); |
1049 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() begin"); |
1004 if (!mFwListView) |
1050 if (!mFwListView) |
1005 { |
1051 { |
1006 mFwListView = new HbListWidget(mContent); |
1052 mFwListView = new HbListView(mContent); |
1007 mFwListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
1053 mFwListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
1008 connect( mFwListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
1054 connect( mFwListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
1009 this, SLOT( handleFotaDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
1055 this, SLOT( handleFotaDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
|
1056 |
|
1057 IAUpdateAppListModel *model = new IAUpdateAppListModel(); |
|
1058 HbListViewItem *prototype = new IAUpdateAppListItem(mListView); |
|
1059 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
|
1060 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
|
1061 mListView->setModel(model, prototype); |
|
1062 |
1010 mFwListView->listItemPrototype()->setGraphicsSize(HbListViewItem::LargeIcon); |
1063 mFwListView->listItemPrototype()->setGraphicsSize(HbListViewItem::LargeIcon); |
1011 mFwListView->listItemPrototype()->setStretchingStyle(HbListViewItem::NoStretching); |
1064 mFwListView->listItemPrototype()->setStretchingStyle(HbListViewItem::NoStretching); |
1012 connect(mFwListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
1065 connect(mFwListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
1013 this, SLOT(handleFwSelectionChanged(QItemSelection,QItemSelection))); |
1066 this, SLOT(handleFwSelectionChanged(QItemSelection,QItemSelection))); |
1014 } |
1067 } |
1015 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
1068 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
1016 linearLayout->addItem(mFwListView); |
1069 linearLayout->addItem(mFwListView); |
1017 mFwListView->clear(); |
1070 IAUpdateAppListModel *model = (IAUpdateAppListModel*) mListView->model(); |
1018 QItemSelectionModel *selectionModel = mFwListView->selectionModel(); |
1071 QItemSelectionModel *selectionModel = mFwListView->selectionModel(); |
|
1072 mSelectionUpdate = true; |
1019 selectionModel->clear(); |
1073 selectionModel->clear(); |
1020 HbListWidgetItem *fwItem = new HbListWidgetItem(); |
1074 mSelectionUpdate = false; |
1021 QString name(XQConversions::s60DescToQString(fwNode.Base().Name())); |
1075 model->setFwNode(&fwNode); |
1022 name.append(" DEVICE SOFTWARE"); |
1076 |
1023 fwItem->setText(name); |
|
1024 QString importanceDescription; |
|
1025 setImportance(&fwNode, importanceDescription); |
|
1026 fwItem->setSecondaryText(importanceDescription); |
|
1027 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
|
1028 fwItem->setIcon(icon); |
|
1029 if (fwNode.Base().IsSelected()) |
1077 if (fwNode.Base().IsSelected()) |
1030 { |
1078 { |
1031 QModelIndex modelIndex = mFwListView->model()->index(0,0); |
1079 QModelIndex modelIndex = mFwListView->model()->index(0,0); |
1032 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
1080 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
1033 } |
1081 } |
1034 mFwListView->addItem(fwItem); |
1082 model->refresh(); |
1035 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() end"); |
1083 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() end"); |
1036 } |
1084 } |
1037 |
1085 |
1038 void IAUpdateMainView::refreshNsuUpdate() |
1086 void IAUpdateMainView::refreshNsuUpdate(MIAUpdateFwNode& fwNode) |
1039 { |
1087 { |
1040 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() begin"); |
1088 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() begin"); |
1041 if (!mFwNSUGroupBox) |
1089 if (!mFwNSUGroupBox) |
1042 { |
1090 { |
1043 mFwNSUGroupBox = new HbGroupBox(mContent); |
1091 mFwNSUGroupBox = new HbGroupBox(mContent); |
1044 mFwNSUGroupBox->setHeading("Device software available"); |
1092 mFwNSUGroupBox->setHeading(hbTrId("txt_software_subhead_device_software_available")); |
1045 HbDataForm *dataForm = new HbDataForm(mFwNSUGroupBox); |
1093 HbDataForm *dataForm = new HbDataForm(mFwNSUGroupBox); |
1046 mFwNSUGroupBox->setContentWidget(dataForm); |
1094 mFwNSUGroupBox->setContentWidget(dataForm); |
1047 dataForm->setDescription("Use your PC to update the device software ([version %L]) from address www.nokia.com/softwareupdate"); |
1095 QString textVersion = XQConversions::s60DescToQString(fwNode.FwVersion1()); |
|
1096 dataForm->setDescription |
|
1097 (hbTrId("txt_software_info_please_use_your_pc_to_update_the").arg(textVersion)); |
1048 } |
1098 } |
1049 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
1099 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
1050 linearLayout->addItem(mFwNSUGroupBox); |
1100 linearLayout->addItem(mFwNSUGroupBox); |
1051 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() end"); |
1101 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() end"); |
1052 } |
1102 } |
1057 if (nodes.Count() > 0) |
1107 if (nodes.Count() > 0) |
1058 { |
1108 { |
1059 if (!mApplicationUpdatesGroupBox) |
1109 if (!mApplicationUpdatesGroupBox) |
1060 { |
1110 { |
1061 mApplicationUpdatesGroupBox = new HbGroupBox(mContent); |
1111 mApplicationUpdatesGroupBox = new HbGroupBox(mContent); |
1062 mApplicationUpdatesGroupBox->setHeading("Application updates"); |
1112 mApplicationUpdatesGroupBox->setHeading(hbTrId("txt_software_subhead_application_updates")); |
1063 } |
1113 } |
1064 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
1114 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
1065 linearLayout->addItem(mApplicationUpdatesGroupBox); |
1115 linearLayout->addItem(mApplicationUpdatesGroupBox); |
1066 linearLayout->addItem(mListView); |
1116 linearLayout->addItem(mListView); |
1067 } |
1117 } |
1068 mListView->clear(); |
1118 IAUpdateAppListModel *model = (IAUpdateAppListModel*) mListView->model(); |
1069 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
1119 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1120 mSelectionUpdate = true; |
1070 selectionModel->clear(); |
1121 selectionModel->clear(); |
1071 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
1122 mSelectionUpdate = false; |
|
1123 |
|
1124 //HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
1072 mNodes.Reset(); |
1125 mNodes.Reset(); |
|
1126 |
1073 for(int i = 0; i < nodes.Count(); ++i) |
1127 for(int i = 0; i < nodes.Count(); ++i) |
1074 { |
1128 { |
1075 MIAUpdateNode *node = nodes[i]; |
1129 MIAUpdateNode *node = nodes[i]; |
1076 mNodes.Append(node); |
1130 mNodes.Append(node); |
1077 QString importanceDescription; |
1131 } |
1078 MIAUpdateNode::TUIUpdateState uiState = node->UiState(); |
1132 model->setNodeArray(mNodes); |
1079 if (uiState == MIAUpdateNode::ENormal) |
1133 for(int j = 0; j < mNodes.Count(); ++j) |
1080 { |
1134 { |
1081 setImportance(node, importanceDescription); |
1135 if (mNodes[j]->Base().IsSelected()) |
1082 } |
1136 { |
1083 else if (uiState == MIAUpdateNode::EUpdated) |
1137 QModelIndex modelIndex = mListView->model()->index(j,0); |
1084 { |
|
1085 importanceDescription = "Updated"; |
|
1086 } |
|
1087 else if (uiState == MIAUpdateNode::EFailed) |
|
1088 { |
|
1089 importanceDescription = "Failed"; |
|
1090 } |
|
1091 else if (uiState == MIAUpdateNode::EDownloaded) |
|
1092 { |
|
1093 importanceDescription = "Downloaded"; |
|
1094 } |
|
1095 HbListWidgetItem *item = new HbListWidgetItem(); |
|
1096 QString name; |
|
1097 if (uiState == MIAUpdateNode::EDownloading) |
|
1098 { |
|
1099 name = QString("Downloading "); |
|
1100 } |
|
1101 else if (uiState == MIAUpdateNode::EInstalling) |
|
1102 { |
|
1103 name = QString("Installing "); |
|
1104 } |
|
1105 name.append(XQConversions::s60DescToQString(node->Base().Name())); |
|
1106 item->setText(name); |
|
1107 item->setSecondaryText(importanceDescription); |
|
1108 item->setIcon(icon); |
|
1109 mListView->addItem(item); |
|
1110 |
|
1111 if (node->Base().IsSelected()) |
|
1112 { |
|
1113 int count = mListView->count(); |
|
1114 QModelIndex modelIndex = mListView->model()->index(count-1,0); |
|
1115 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
1138 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
1116 } |
1139 } |
1117 } |
1140 } |
1118 if (!mSelectionConnect) |
1141 if (!mSelectionConnect) |
1119 { |
1142 { |
1120 mSelectionConnect = connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
1143 mSelectionConnect = connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
1121 this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); |
1144 this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); |
1122 } |
1145 } |
|
1146 model->refresh(); |
|
1147 |
1123 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshApplicationUpdates() end"); |
1148 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshApplicationUpdates() end"); |
1124 } |
1149 } |
1125 |
1150 |
1126 void IAUpdateMainView::updateSelectionInfoInDock() |
1151 void IAUpdateMainView::updateSelectionInfoInDock() |
1127 { |
1152 { |