81 HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2")); |
93 HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2")); |
82 |
94 |
83 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
95 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
84 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
96 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
85 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
97 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
86 |
98 |
|
99 mContent = qobject_cast< HbWidget*>( loader.findWidget("content") ); |
|
100 |
87 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
101 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
88 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
102 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
89 |
103 |
90 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
104 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
91 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
105 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
92 |
106 |
93 HbListViewItem *prototype = mListView->listItemPrototype(); |
107 HbListViewItem *prototype = mListView->listItemPrototype(); |
94 |
108 |
95 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
109 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
96 |
110 |
|
111 HbDockWidget *dock = new HbDockWidget(this); |
|
112 HbWidget *dockContainer = new HbWidget(dock); |
|
113 QGraphicsLinearLayout *dockLayout = new QGraphicsLinearLayout(dockContainer); |
|
114 dockLayout->setOrientation(Qt::Vertical); |
|
115 dockContainer->setLayout(dockLayout); |
|
116 |
|
117 mSelections = new HbGroupBox(dockContainer); |
|
118 mSelections->setHeading("Selected 0/0 (0 kB)"); |
|
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"); |
97 } |
130 } |
98 |
131 |
99 IAUpdateMainView::~IAUpdateMainView() |
132 IAUpdateMainView::~IAUpdateMainView() |
100 { |
133 { |
|
134 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::~IAUpdateMainView() begin"); |
|
135 |
|
136 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::~IAUpdateMainView() end"); |
101 } |
137 } |
102 |
138 |
103 // ----------------------------------------------------------------------------- |
139 // ----------------------------------------------------------------------------- |
104 // IAUpdateMainView::refresh |
140 // IAUpdateMainView::refresh |
105 // Refreshes update list |
141 // Refreshes update list |
106 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
107 // |
143 // |
108 void IAUpdateMainView::refresh( const RPointerArray<MIAUpdateNode> &nodes, |
144 void IAUpdateMainView::refresh(const RPointerArray<MIAUpdateNode> &nodes, |
109 const RPointerArray<MIAUpdateFwNode> &fwNodes, |
145 const RPointerArray<MIAUpdateFwNode> &fwNodes, |
110 int /*error*/ ) |
146 int error) |
111 { |
147 { |
112 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh begin"); |
148 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() begin"); |
113 |
149 removeCurrentContentLayout(); |
114 mAllNodes.Reset(); |
|
115 |
150 |
116 if ( fwNodes.Count() > 0 ) |
151 refreshFirmwareUpdates(fwNodes); |
117 { |
152 |
118 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh hard code importance"); |
153 refreshApplicationUpdates(nodes); |
119 //hardcode the importance of firmware as Critical |
154 |
120 for ( TInt i = 0; i < fwNodes.Count(); i++ ) |
155 if (nodes.Count() == 0 && fwNodes.Count() == 0 && |
121 { |
156 error != KErrCancel && error != KErrAbort) |
122 fwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical ); |
157 { |
123 } |
158 if (!mContentDataForm) |
124 |
159 { |
125 //either NSU or FOTA available |
160 mContentDataForm = new HbDataForm(mContent); |
126 if ( fwNodes.Count() == 1 ) |
161 } |
127 { |
162 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
128 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh either NSU or FOTA available"); |
163 linearLayout->addItem(mContentDataForm); |
129 MIAUpdateAnyNode* node = fwNodes[0]; |
164 QString formText; |
130 mAllNodes.Append( node ); |
|
131 } |
|
132 |
165 |
133 //both NSU and FOTA available, show only FOTA node |
166 if (error == KErrNone) |
134 if ( fwNodes.Count() == 2 ) |
167 { |
135 { |
168 formText = QString("Applications are up to date"); |
136 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh both NSU and FOTA available"); |
169 } |
137 MIAUpdateAnyNode* node1 = fwNodes[0]; |
|
138 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node1 ); |
|
139 if ( fwnode->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
140 { |
|
141 mAllNodes.Append( node1 ); |
|
142 } |
|
143 else |
|
144 { |
|
145 MIAUpdateAnyNode* node2 = fwNodes[1]; |
|
146 mAllNodes.Append( node2 ); |
|
147 } |
|
148 } |
|
149 } |
|
150 |
|
151 |
|
152 for( int i = 0; i < nodes.Count(); ++i ) |
|
153 { |
|
154 MIAUpdateAnyNode* node = nodes[i]; |
|
155 mAllNodes.Append( node ); |
|
156 } |
|
157 |
|
158 mListView->clear(); |
|
159 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
160 selectionModel->clear(); |
|
161 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
|
162 |
|
163 for( int j = 0; j < mAllNodes.Count(); ++j ) |
|
164 { |
|
165 MIAUpdateAnyNode* node = mAllNodes[j]; |
|
166 int sizeInBytes = node->Base().ContentSizeL(); |
|
167 |
|
168 int size = 0; |
|
169 TBool shownInMegabytes = EFalse; |
|
170 if ( sizeInBytes >= KMaxShownInKiloBytes ) |
|
171 { |
|
172 shownInMegabytes = ETrue; |
|
173 size = sizeInBytes / KMegaByte; |
|
174 if ( sizeInBytes % KMegaByte != 0 ) |
|
175 { |
|
176 size++; |
|
177 } |
|
178 } |
|
179 else |
|
180 { |
|
181 size = sizeInBytes / KKiloByte; |
|
182 if ( sizeInBytes % KKiloByte != 0 ) |
|
183 { |
|
184 size++; |
|
185 } |
|
186 } |
|
187 QString sizeString; |
|
188 sizeString.setNum(size); |
|
189 QString importanceDescription; |
|
190 switch( node->Base().Importance() ) |
|
191 { |
|
192 case MIAUpdateBaseNode::EMandatory: |
|
193 { |
|
194 importanceDescription = "Required "; |
|
195 importanceDescription.append(sizeString); |
|
196 if ( shownInMegabytes ) |
|
197 { |
|
198 importanceDescription.append(" MB" ); |
|
199 } |
|
200 else |
|
201 { |
|
202 importanceDescription.append(" kB" ); |
|
203 } |
|
204 break; |
|
205 } |
|
206 |
|
207 |
|
208 case MIAUpdateBaseNode::ECritical: |
|
209 { |
|
210 bool isNSU = false; |
|
211 if( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
212 { |
|
213 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node ); |
|
214 if ( fwnode->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
215 { |
|
216 isNSU = true; |
|
217 } |
|
218 } |
|
219 |
|
220 importanceDescription = "Important "; |
|
221 if ( !size || isNSU ) |
|
222 { |
|
223 //for firmware when size info is not provided by server |
|
224 } |
|
225 else |
|
226 { |
|
227 importanceDescription.append(sizeString); |
|
228 if ( shownInMegabytes ) |
|
229 { |
|
230 importanceDescription.append(" MB" ); |
|
231 } |
|
232 else |
|
233 { |
|
234 importanceDescription.append(" kB" ); |
|
235 } |
|
236 } |
|
237 |
|
238 break; |
|
239 } |
|
240 |
|
241 case MIAUpdateBaseNode::ERecommended: |
|
242 { |
|
243 importanceDescription = "Recommended "; |
|
244 importanceDescription.append(sizeString); |
|
245 if ( shownInMegabytes ) |
|
246 { |
|
247 importanceDescription.append(" MB" ); |
|
248 } |
|
249 else |
|
250 { |
|
251 importanceDescription.append(" kB" ); |
|
252 } |
|
253 break; |
|
254 } |
|
255 |
|
256 case MIAUpdateBaseNode::ENormal: |
|
257 { |
|
258 importanceDescription = "Optional "; |
|
259 importanceDescription.append(sizeString); |
|
260 if ( shownInMegabytes ) |
|
261 { |
|
262 importanceDescription.append(" MB" ); |
|
263 } |
|
264 else |
|
265 { |
|
266 importanceDescription.append(" kB" ); |
|
267 } |
|
268 break; |
|
269 } |
|
270 |
|
271 default: |
|
272 { |
|
273 break; |
|
274 } |
|
275 } |
|
276 |
|
277 //AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
278 |
|
279 HbListWidgetItem *item = new HbListWidgetItem(); |
|
280 QString name = XQConversions::s60DescToQString(node->Base().Name()); |
|
281 if ( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
282 { |
|
283 name.append(" DEVICE SOFTWARE"); |
|
284 } |
|
285 item->setText(name); |
|
286 item->setSecondaryText(importanceDescription); |
|
287 item->setIcon(icon); |
|
288 mListView->addItem(item); |
|
289 |
|
290 if ( node->Base().IsSelected() ) |
|
291 { |
|
292 int count = mListView->count(); |
|
293 QModelIndex modelIndex = mListView->model()->index(count-1,0); |
|
294 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
|
295 } |
|
296 |
|
297 |
|
298 |
|
299 /*if ( nodes.Count() == 0 ) |
|
300 { |
|
301 HBufC* emptyText = NULL; |
|
302 if ( aError ) |
|
303 { |
|
304 if ( aError == KErrCancel || aError == KErrAbort ) |
|
305 { |
|
306 emptyText = KNullDesC().AllocLC(); |
|
307 } |
|
308 else |
|
309 { |
|
310 emptyText = StringLoader::LoadLC( R_IAUPDATE_REFRESH_FAILED ); |
|
311 } |
|
312 } |
|
313 else |
|
314 { |
|
315 emptyText = StringLoader::LoadLC( R_IAUPDATE_TEXT_NO_UPDATES ); |
|
316 } |
|
317 |
|
318 iListBox->View()->SetListEmptyTextL( *emptyText ); |
|
319 CleanupStack::PopAndDestroy( emptyText ); |
|
320 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
321 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
|
322 } |
|
323 else |
170 else |
324 { |
171 { |
325 if ( iListBox->CurrentItemIndex() == KErrNotFound ) |
172 formText = QString("Refreshing failed. Try again later."); |
326 { |
173 } |
327 iListBox->SetCurrentItemIndex( aNodes.Count() - 1 ); |
174 mContentDataForm->setDescription(formText); |
328 } |
175 } |
329 }*/ |
176 updateSelectionInfoInDock(); |
330 |
177 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() end"); |
331 //iListBox->HandleItemAdditionL(); |
178 } |
332 } |
|
333 connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
|
334 this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); |
|
335 |
|
336 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh end"); |
|
337 } |
|
338 |
179 |
339 |
180 |
340 |
181 |
341 |
182 |
342 void IAUpdateMainView::handleStartUpdate() |
183 void IAUpdateMainView::handleStartUpdate() |
343 { |
184 { |
344 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() begin"); |
185 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() begin"); |
345 bool firmwareUpdate = false; |
186 mEngine->StartUpdate(fotaSelected()); |
346 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
347 getSelectedNodes(selectedNodes); |
|
348 if (selectedNodes.Count() > 0) |
|
349 { |
|
350 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
351 { |
|
352 //the marking logic will make sure firmware won't be marked with normal sis updates |
|
353 //at the same time. |
|
354 firmwareUpdate = true; |
|
355 } |
|
356 } |
|
357 selectedNodes.Close(); |
|
358 //mEngine->StartUpdate(firmwareUpdate); |
|
359 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() end"); |
187 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() end"); |
360 } |
188 } |
361 |
189 |
362 |
190 |
363 void IAUpdateMainView::handleSettings() |
191 void IAUpdateMainView::handleSettings() |
364 { |
192 { |
|
193 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSettings() begin"); |
365 emit toSettingView(); |
194 emit toSettingView(); |
|
195 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSettings() end"); |
366 } |
196 } |
367 |
197 |
368 void IAUpdateMainView::handleDisclaimer() |
198 void IAUpdateMainView::handleDisclaimer() |
369 { |
199 { |
|
200 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() begin"); |
370 if (!mDialogUtil) |
201 if (!mDialogUtil) |
371 { |
202 { |
372 mDialogUtil = new IAUpdateDialogUtil(this); |
203 mDialogUtil = new IAUpdateDialogUtil(this); |
373 } |
204 } |
374 if (mDialogUtil) |
205 if (mDialogUtil) |
375 { |
206 { |
376 HbAction *primaryAction = new HbAction("OK"); |
207 HbAction *primaryAction = new HbAction("OK"); |
377 mDialogUtil->showAgreement(primaryAction); |
208 mDialogUtil->showAgreement(primaryAction); |
378 } |
209 } |
379 } |
210 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() end"); |
380 |
211 } |
381 void IAUpdateMainView::handleDetails( HbAbstractViewItem * item, const QPointF & ) |
212 |
382 { |
213 void IAUpdateMainView::handleDetails(HbAbstractViewItem * item, const QPointF &) |
383 |
214 { |
384 |
215 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDetails() begin"); |
385 int ind = item->modelIndex().row(); |
216 int ind = item->modelIndex().row(); |
386 if (getNode(ind) != NULL) |
217 if (getApplicationNode(ind) != NULL) |
387 { |
218 { |
388 showDetails(*getNode(ind)); |
219 showDetails(*getApplicationNode(ind)); |
389 } |
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"); |
390 } |
236 } |
391 |
237 |
392 |
238 |
393 void IAUpdateMainView::handleSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
239 void IAUpdateMainView::handleSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
394 { |
240 { |
|
241 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSelectionChanged begin"); |
395 if (!mSelectionUpdate) |
242 if (!mSelectionUpdate) |
396 { |
243 { |
397 bool changedItemFound = false; |
244 bool changedItemFound = false; |
398 QModelIndexList indexList = selected.indexes(); |
245 QModelIndexList indexList = selected.indexes(); |
399 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
246 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
425 if (action == mPrimaryAction) |
299 if (action == mPrimaryAction) |
426 { |
300 { |
427 updateSelectionsToNodeArray(*mNode,mMark); |
301 updateSelectionsToNodeArray(*mNode,mMark); |
428 } |
302 } |
429 updateSelectionsToList(); |
303 updateSelectionsToList(); |
|
304 updateSelectionInfoInDock(); |
430 break; |
305 break; |
431 case CannotOmit: |
306 case CannotOmit: |
432 break; |
307 break; |
433 case Details: |
308 case Details: |
434 break; |
309 break; |
435 default: |
310 default: |
436 break; |
311 break; |
437 } |
312 } |
438 } |
313 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::dialogFinished end"); |
439 |
314 } |
440 |
315 |
441 void IAUpdateMainView::getSelectedNodes(RPointerArray<MIAUpdateAnyNode> &selectedNodes) const |
316 bool IAUpdateMainView::fotaSelected() const |
442 { |
317 { |
443 for (int i = 0; i < mAllNodes.Count(); ++i) |
318 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fotaSelected() begin"); |
444 { |
319 bool selected = false; |
445 if (mAllNodes[i]->Base().IsSelected()) |
320 for (int i = 0; i < mFwNodes.Count() && !selected; ++i) |
446 { |
321 { |
447 selectedNodes.Append(mAllNodes[i]); |
322 if ( mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2 && mFwNodes[i]->Base().IsSelected() ) |
448 } |
323 { |
449 } |
324 selected = true; |
450 } |
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 |
451 |
336 |
452 void IAUpdateMainView::markListItem(bool mark, int index) |
337 void IAUpdateMainView::markListItem(bool mark, int index) |
453 { |
338 { |
|
339 IAUPDATE_TRACE_2("[IAUPDATE] IAUpdateMainView::markListItem() begin mark: %d index %d", mark, index); |
454 if (mark) |
340 if (mark) |
455 { |
341 { |
456 //It's Mark Command |
342 //It's Mark Command |
457 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
343 if (fotaSelected()) |
458 getSelectedNodes(selectedNodes); |
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 } |
|
350 |
|
351 bool accepted = false; |
459 |
352 |
460 //There are selected items already and type are different with the current one |
353 if(index > -1) |
461 if (selectedNodes.Count() > 0 && (mAllNodes[index]->NodeType() != selectedNodes[0]->NodeType())) |
354 { |
462 { |
355 accepted = true; |
463 // firmware item and normal sis items can't be selected at the same time |
356 MIAUpdateNode* node = mNodes[index]; |
464 // unmark the selected nodes. |
357 RPointerArray<MIAUpdateNode> mands; |
465 for (int i = 0; i < selectedNodes.Count(); i++) |
358 RPointerArray<MIAUpdateNode> deps; |
466 { |
|
467 int index = mAllNodes.Find(selectedNodes[i]); |
|
468 mAllNodes[index]->Base().SetSelected(false); |
|
469 } |
|
470 } |
|
471 selectedNodes.Close(); |
|
472 } |
|
473 |
|
474 //there is no selected items or the type is the same with the current one |
|
475 |
|
476 if (mAllNodes[index]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
477 { |
|
478 mAllNodes[index]->Base().SetSelected(mark); |
|
479 updateSelectionsToList(); |
|
480 return; |
|
481 } |
|
482 |
|
483 if (mAllNodes[index]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal ) |
|
484 { |
|
485 bool accepted = false; |
|
486 |
|
487 if(index > -1) |
|
488 { |
|
489 accepted = true; |
|
490 |
|
491 MIAUpdateNode* node = static_cast<MIAUpdateNode*>(mAllNodes[index]); |
|
492 RPointerArray<MIAUpdateAnyNode> mands; |
|
493 RPointerArray<MIAUpdateNode> deps; |
|
494 |
359 |
|
360 if (mark) |
|
361 { |
|
362 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*node, mNodes, deps)); |
|
363 if (err != KErrNone) |
|
364 { |
|
365 deps.Close(); |
|
366 updateSelectionsToList(); |
|
367 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
368 return; |
|
369 } |
|
370 if (!getMandatoryNodes(mands)) |
|
371 { |
|
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 |
495 if (mark) |
437 if (mark) |
496 { |
438 { |
497 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*node, mAllNodes, deps)); |
439 if (depCount > 1) |
498 if (err != KErrNone) |
|
499 { |
440 { |
500 deps.Close(); |
441 text.append("This update needs also updates "); |
501 updateSelectionsToList(); |
442 text.append(names); |
502 return; |
443 text.append(" for working"); |
503 } |
444 } |
504 if (!getMandatoryNodes(mands)) |
445 else |
505 { |
446 { |
506 // error when creating mandatory node list |
447 text.append("This update needs also \""); |
507 mands.Close(); |
448 text.append(names); |
508 updateSelectionsToList(); |
449 text.append("\" for working"); |
509 return; |
|
510 } |
|
511 } |
|
512 else |
|
513 { |
|
514 //mandatory item is not allowed to be unmarked |
|
515 if (mAllNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
516 { |
|
517 //show dialog |
|
518 showUpdateCannotOmitDialog(); |
|
519 updateSelectionsToList(); |
|
520 return; |
|
521 } |
|
522 |
|
523 //CleanupClosePushL( deps ); |
|
524 TRAPD(err,IAUpdateDepUtils::GetDependantsL(*node, mAllNodes, deps)); |
|
525 if (err != KErrNone) |
|
526 { |
|
527 deps.Close(); |
|
528 updateSelectionsToList(); |
|
529 return; |
|
530 } |
|
531 // item is not allowed to be unmarked if its dependant is mandatory |
|
532 bool mandatoryDependantFound = false; |
|
533 for(int i = 0; i < deps.Count() && !mandatoryDependantFound; i++) |
|
534 { |
|
535 if (deps[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
536 { |
|
537 mandatoryDependantFound = true; |
|
538 } |
450 } |
539 } |
451 } |
540 if (mandatoryDependantFound) |
452 else |
|
453 { |
|
454 if (depCount > 1) |
541 { |
455 { |
542 showUpdateCannotOmitDialog(); |
456 text.append("Updates "); |
543 deps.Close(); |
457 text.append(names); |
544 updateSelectionsToList(); |
458 text.append(" need this update for working"); |
545 return; |
459 } |
546 } |
|
547 } |
|
548 |
|
549 int depCount = deps.Count(); |
|
550 |
|
551 if (depCount > 0) |
|
552 { |
|
553 QString text; |
|
554 QString names; |
|
555 MIAUpdateNode* depNode = NULL; |
|
556 QString separator(","); |
|
557 |
|
558 for(int i = 0; i < depCount; i++) |
|
559 { |
|
560 depNode = deps[i]; |
|
561 if (i > 0) |
|
562 { |
|
563 names.append(separator); |
|
564 names.append(QString(" ")); |
|
565 } |
|
566 names.append(XQConversions::s60DescToQString(depNode->Base().Name())); |
|
567 } |
|
568 |
|
569 |
|
570 if (mark) |
|
571 { |
|
572 if (depCount > 1) |
|
573 { |
|
574 text.append("This update needs also updates "); |
|
575 text.append(names); |
|
576 text.append(" for working"); |
|
577 //resourceId = R_IAUPDATE_DEPENDENCY_MARK_MANY; |
|
578 } |
|
579 else |
|
580 { |
|
581 text.append("This update needs also \""); |
|
582 text.append(names); |
|
583 text.append("\" for working"); |
|
584 //resourceId = R_IAUPDATE_DEPENDENCY_MARK_ONE; |
|
585 } |
|
586 } |
|
587 else |
460 else |
588 { |
461 { |
589 if (depCount > 1) |
462 text.append("Update \""); |
590 { |
463 text.append(names); |
591 text.append("Updates "); |
464 text.append("\" needs this update for working"); |
592 text.append(names); |
465 } |
593 text.append(" need this update for working"); |
466 } |
594 //resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_MANY; |
|
595 } |
|
596 else |
|
597 { |
|
598 text.append("Update \""); |
|
599 text.append(names); |
|
600 text.append("\" needs this update for working"); |
|
601 //resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_ONE; |
|
602 } |
|
603 } |
|
604 |
467 |
605 if (mark && mAllNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
468 if (mark && mNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
606 { |
469 { |
607 // depencencies of mandatory update are also selected without showing dialog |
470 // depencencies of mandatory update are also selected without showing dialog |
608 accepted = true; |
471 accepted = true; |
609 } |
472 } |
610 else |
473 else |
611 { |
474 { |
612 mNode = node; |
475 mNode = node; |
613 mMark = mark; |
476 mMark = mark; |
614 showDependenciesFoundDialog(text); |
477 accepted = false; |
615 return; |
478 showDependenciesFoundDialog(text); |
616 } |
479 } |
617 } |
480 } |
618 if (accepted) |
481 if (accepted) |
619 { |
482 { |
620 updateSelectionsToNodeArray(*node, mark); |
483 updateSelectionsToNodeArray(*node, mark); |
621 } |
484 } |
622 } |
485 } |
623 |
486 if (accepted) |
624 } |
487 { |
625 updateSelectionsToList(); |
488 updateSelectionsToList(); |
|
489 updateSelectionInfoInDock(); |
|
490 } |
|
491 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() end"); |
626 } |
492 } |
627 |
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 |
628 void IAUpdateMainView::updateSelectionsToNodeArray(MIAUpdateNode &node, bool mark) |
541 void IAUpdateMainView::updateSelectionsToNodeArray(MIAUpdateNode &node, bool mark) |
629 { |
542 { |
|
543 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToNodeArray() begin"); |
630 RPointerArray<MIAUpdateNode> deps; |
544 RPointerArray<MIAUpdateNode> deps; |
631 TInt err = KErrNone; |
545 TInt err = KErrNone; |
632 if (mark) |
546 if (mark) |
633 { |
547 { |
634 TRAP(err,IAUpdateDepUtils::GetDependenciesL(node, mAllNodes, deps)); |
548 TRAP(err,IAUpdateDepUtils::GetDependenciesL(node, mNodes, deps)); |
635 } |
549 } |
636 else |
550 else |
637 { |
551 { |
638 TRAP(err,IAUpdateDepUtils::GetDependantsL(node, mAllNodes, deps)); |
552 TRAP(err,IAUpdateDepUtils::GetDependantsL(node, mNodes, deps)); |
639 } |
553 } |
640 if (err == KErrNone ) |
554 if (err == KErrNone ) |
641 { |
555 { |
642 int depCount = deps.Count(); |
556 int depCount = deps.Count(); |
643 for(int i = 0; i < depCount; i++) |
557 for(int i = 0; i < depCount; i++) |
644 { |
558 { |
645 int depNodeInd = mAllNodes.Find(deps[i]); |
559 int depNodeInd = mNodes.Find(deps[i]); |
646 mAllNodes[depNodeInd]->Base().SetSelected(mark); |
560 mNodes[depNodeInd]->Base().SetSelected(mark); |
647 } |
561 } |
648 deps.Close(); |
562 deps.Close(); |
649 int nodeInd = mAllNodes.Find(&node); |
563 int nodeInd = mNodes.Find(&node); |
650 mAllNodes[nodeInd]->Base().SetSelected(mark); |
564 mNodes[nodeInd]->Base().SetSelected(mark); |
651 } |
565 } |
652 |
566 |
653 //mark all of the mandatory items |
567 //mark all of the mandatory items |
654 if ( mark ) |
568 if ( mark ) |
655 { |
569 { |
656 RPointerArray<MIAUpdateAnyNode> mands; |
570 RPointerArray<MIAUpdateNode> mands; |
657 if (getMandatoryNodes(mands)) |
571 if (getMandatoryNodes(mands)) |
658 { |
572 { |
659 int mandCount = mands.Count(); |
573 int mandCount = mands.Count(); |
660 if (mandCount > 0) |
574 if (mandCount > 0) |
661 { |
575 { |
662 for(int i = 0; i < mandCount; i++) |
576 for(int i = 0; i < mandCount; i++) |
663 { |
577 { |
664 int mandNodeInd = mAllNodes.Find(mands[i]); |
578 int mandNodeInd = mNodes.Find(mands[i]); |
665 mAllNodes[mandNodeInd]->Base().SetSelected(mark); |
579 mNodes[mandNodeInd]->Base().SetSelected(mark); |
666 if (mAllNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
580 if (mNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
667 { |
581 { |
668 // mark also all dependencies of a mandatory item |
582 // mark also all dependencies of a mandatory item |
669 MIAUpdateNode* dependencyNode = static_cast<MIAUpdateNode*>(mAllNodes[mandNodeInd]); |
583 MIAUpdateNode* dependencyNode = mNodes[mandNodeInd]; |
670 RPointerArray<MIAUpdateNode> dependencies; |
584 RPointerArray<MIAUpdateNode> dependencies; |
671 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*dependencyNode, mAllNodes, dependencies)); |
585 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*dependencyNode, mNodes, dependencies)); |
672 if (err) |
586 if (err) |
673 { |
587 { |
674 dependencies.Close(); |
588 dependencies.Close(); |
675 mands.Close(); |
589 mands.Close(); |
676 return; |
590 return; |
677 } |
591 } |
678 for(int j = 0; j < dependencies.Count(); j++) |
592 for(int j = 0; j < dependencies.Count(); j++) |
679 { |
593 { |
680 int depNodeInd = mAllNodes.Find(dependencies[j]); |
594 int depNodeInd = mNodes.Find(dependencies[j]); |
681 mAllNodes[depNodeInd]->Base().SetSelected(true); |
595 mNodes[depNodeInd]->Base().SetSelected(true); |
682 } |
596 } |
683 dependencies.Close(); |
597 dependencies.Close(); |
684 } |
598 } |
685 } |
599 } |
686 } |
600 } |
687 } |
601 } |
688 mands.Close(); |
602 mands.Close(); |
689 } |
603 } |
690 } |
604 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToNodeArray() end"); |
691 |
605 } |
692 |
606 |
693 bool IAUpdateMainView::getMandatoryNodes(RPointerArray<MIAUpdateAnyNode> &mandNodes) const |
607 |
694 { |
608 bool IAUpdateMainView::getMandatoryNodes(RPointerArray<MIAUpdateNode> &mandNodes) const |
|
609 { |
|
610 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getMandatoryNodes() begin"); |
695 bool ret = true; |
611 bool ret = true; |
696 for(int i = 0; i < mAllNodes.Count(); ++i) |
612 for(int i = 0; i < mNodes.Count(); ++i) |
697 { |
613 { |
698 if (mAllNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
614 if (mNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
699 { |
615 { |
700 if (mandNodes.Append(mAllNodes[i]) != KErrNone) |
616 if (mandNodes.Append(mNodes[i]) != KErrNone) |
701 { |
617 { |
702 ret = false; |
618 ret = false; |
703 } |
619 } |
704 } |
620 } |
705 } |
621 } |
|
622 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getMandatoryNodes() end"); |
706 return ret; |
623 return ret; |
707 } |
624 } |
708 |
625 |
709 void IAUpdateMainView::showUpdateCannotOmitDialog() |
626 void IAUpdateMainView::showUpdateCannotOmitDialog() |
710 { |
627 { |
|
628 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showUpdateCannotOmitDialog() begin"); |
711 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
629 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
712 messageBox->setText(QString("This required update cannot be omitted")); |
630 messageBox->setText(QString("This required update cannot be omitted")); |
713 int actionCount = messageBox->actions().count(); |
631 int actionCount = messageBox->actions().count(); |
714 for (int i=actionCount-1; i >= 0; i--) |
632 for (int i=actionCount-1; i >= 0; i--) |
715 { |
633 { |
763 } |
690 } |
764 mListView->selectionModel()->select(mListView->model()->index(i,0),selectionFlag); |
691 mListView->selectionModel()->select(mListView->model()->index(i,0),selectionFlag); |
765 } |
692 } |
766 } |
693 } |
767 mSelectionUpdate = false; |
694 mSelectionUpdate = false; |
768 } |
695 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToList() end"); |
769 |
696 } |
770 |
697 |
771 MIAUpdateAnyNode* IAUpdateMainView::getNode(int index) const |
698 |
772 { |
699 MIAUpdateNode* IAUpdateMainView::getApplicationNode(int index) const |
773 MIAUpdateAnyNode *currentNode = NULL; |
700 { |
|
701 IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateMainView::getApplicationNode() begin index: %d", index); |
|
702 MIAUpdateNode *currentNode = NULL; |
774 |
703 |
775 if (index >= 0 && index < mAllNodes.Count()) |
704 if (index >= 0 && index < mNodes.Count()) |
776 { |
705 { |
777 currentNode = mAllNodes[index]; |
706 currentNode = mNodes[index]; |
778 } |
707 } |
|
708 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getApplicationNode() end"); |
779 return currentNode; |
709 return currentNode; |
780 } |
710 } |
781 |
711 |
782 void IAUpdateMainView::showDetails(MIAUpdateAnyNode& node) |
712 void IAUpdateMainView::showDetails(MIAUpdateAnyNode& node) |
783 { |
713 { |
|
714 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDetails() begin"); |
784 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
715 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
716 HbLabel *label = new HbLabel(messageBox); |
|
717 label->setHtml(QString("Details")); |
|
718 messageBox->setHeadingWidget(label); |
|
719 |
785 messageBox->setIconVisible(false); |
720 messageBox->setIconVisible(false); |
786 |
721 |
787 QString text; |
722 QString text; |
788 constructDetailsText(node,text); |
723 constructDetailsText(node,text); |
789 messageBox->setText(text); |
724 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); |
725 messageBox->setTimeout(HbPopup::NoTimeout); |
800 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
726 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
801 mDialogState = Details; |
727 mDialogState = Details; |
802 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
728 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
|
729 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDetails() end"); |
803 } |
730 } |
804 |
731 |
805 |
732 |
806 void IAUpdateMainView::constructDetailsText(MIAUpdateAnyNode &node, QString &text) |
733 void IAUpdateMainView::constructDetailsText(MIAUpdateAnyNode &node, QString &text) |
807 { |
734 { |
808 |
735 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::constructDetailsText() begin"); |
809 text.append(QString("Name:")); |
736 text.append(QString("Name:")); |
810 text.append(QString("<br />")); |
737 text.append(QString("<br />")); |
811 QString name = XQConversions::s60DescToQString(node.Base().Name()); |
738 QString name = XQConversions::s60DescToQString(node.Base().Name()); |
812 text.append(name); |
739 text.append(name); |
813 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
740 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
909 size++; |
840 size++; |
910 } |
841 } |
911 } |
842 } |
912 text.setNum(size); |
843 text.setNum(size); |
913 text.append(stringUnit); |
844 text.append(stringUnit); |
914 } |
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 } |
|
1059 mListView->clear(); |
|
1060 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1061 selectionModel->clear(); |
|
1062 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
|
1063 mNodes.Reset(); |
|
1064 for(int i = 0; i < nodes.Count(); ++i) |
|
1065 { |
|
1066 MIAUpdateNode *node = nodes[i]; |
|
1067 mNodes.Append(node); |
|
1068 QString importanceDescription; |
|
1069 MIAUpdateNode::TUIUpdateState uiState = node->UiState(); |
|
1070 if (uiState == MIAUpdateNode::ENormal) |
|
1071 { |
|
1072 setImportance(node, importanceDescription); |
|
1073 } |
|
1074 else if (uiState == MIAUpdateNode::EUpdated) |
|
1075 { |
|
1076 importanceDescription = "Updated"; |
|
1077 } |
|
1078 else if (uiState == MIAUpdateNode::EFailed) |
|
1079 { |
|
1080 importanceDescription = "Failed"; |
|
1081 } |
|
1082 else if (uiState == MIAUpdateNode::EDownloaded) |
|
1083 { |
|
1084 importanceDescription = "Downloaded"; |
|
1085 } |
|
1086 HbListWidgetItem *item = new HbListWidgetItem(); |
|
1087 QString name; |
|
1088 if (uiState == MIAUpdateNode::EDownloading) |
|
1089 { |
|
1090 name = QString("Downloading "); |
|
1091 } |
|
1092 else if (uiState == MIAUpdateNode::EInstalling) |
|
1093 { |
|
1094 name = QString("Installing "); |
|
1095 } |
|
1096 name.append(XQConversions::s60DescToQString(node->Base().Name())); |
|
1097 item->setText(name); |
|
1098 item->setSecondaryText(importanceDescription); |
|
1099 item->setIcon(icon); |
|
1100 mListView->addItem(item); |
|
1101 |
|
1102 if (node->Base().IsSelected()) |
|
1103 { |
|
1104 int count = mListView->count(); |
|
1105 QModelIndex modelIndex = mListView->model()->index(count-1,0); |
|
1106 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
|
1107 } |
|
1108 } |
|
1109 if (!mSelectionConnect) |
|
1110 { |
|
1111 mSelectionConnect = connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
|
1112 this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); |
|
1113 } |
|
1114 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshApplicationUpdates() end"); |
|
1115 } |
|
1116 |
|
1117 void IAUpdateMainView::updateSelectionInfoInDock() |
|
1118 { |
|
1119 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionInfoInDock() begin"); |
|
1120 int countOfSelectedItems = 0; |
|
1121 int countOfAllItems = 0; |
|
1122 int selectedSizeInBytes = 0; |
|
1123 for (int i = 0; i < mFwNodes.Count(); ++i) |
|
1124 { |
|
1125 if (mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2) |
|
1126 { |
|
1127 countOfAllItems++; |
|
1128 if (mFwNodes[i]->Base().IsSelected()) |
|
1129 { |
|
1130 countOfSelectedItems++; |
|
1131 selectedSizeInBytes += mFwNodes[i]->Base().ContentSizeL(); |
|
1132 } |
|
1133 } |
|
1134 } |
|
1135 countOfAllItems += mNodes.Count(); |
|
1136 for (int j = 0; j < mNodes.Count(); ++j) |
|
1137 { |
|
1138 if (mNodes[j]->Base().IsSelected()) |
|
1139 { |
|
1140 countOfSelectedItems++; |
|
1141 selectedSizeInBytes += mNodes[j]->Base().ContentSizeL(); |
|
1142 } |
|
1143 } |
|
1144 |
|
1145 int selectedSize = 0; |
|
1146 QString unit; |
|
1147 if (selectedSizeInBytes >= KMaxShownInKiloBytes) |
|
1148 { |
|
1149 unit = "MB"; |
|
1150 selectedSize = selectedSizeInBytes / KMegaByte; |
|
1151 if (selectedSizeInBytes % KMegaByte != 0) |
|
1152 { |
|
1153 selectedSize++; |
|
1154 } |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 unit = "kB"; |
|
1159 selectedSize = selectedSizeInBytes / KKiloByte; |
|
1160 if (selectedSizeInBytes % KKiloByte != 0) |
|
1161 { |
|
1162 selectedSize++; |
|
1163 } |
|
1164 } |
|
1165 QString selectionString; |
|
1166 selectionString.append("Selected "); |
|
1167 QString numText; |
|
1168 numText.setNum(countOfSelectedItems); |
|
1169 selectionString.append(numText); |
|
1170 selectionString.append("/"); |
|
1171 numText.setNum(countOfAllItems); |
|
1172 selectionString.append(numText); |
|
1173 if (selectedSize > 0) |
|
1174 { |
|
1175 selectionString.append(" ("); |
|
1176 numText.setNum(selectedSize); |
|
1177 selectionString.append(numText); |
|
1178 selectionString.append(" "); |
|
1179 selectionString.append(unit); |
|
1180 selectionString.append(")"); |
|
1181 } |
|
1182 mSelections->setHeading(selectionString); |
|
1183 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionInfoInDock() end"); |
|
1184 } |