9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: This module contains the implementation of IAUpdateMainView |
14 * Description: This module contains the implementation of CIAUpdateMainView class |
15 * class member functions. |
15 * member functions. |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 #include <hbaction.h> |
19 |
20 #include <QGraphicsWidget> |
20 |
21 #include <QGraphicsLayout> |
21 #include <eikmenup.h> |
22 #include <QGraphicsLayoutItem> |
22 #include <aknViewAppUi.h> |
23 #include <QGraphicsLinearLayout> |
23 #include <akntitle.h> |
24 |
24 #include <aknnavi.h> // CAknNavigationControlContainer |
25 #include <hbdockwidget.h> |
25 #include <aknnavide.h> // CAknNavigationDecorator |
26 #include <hblistwidget.h> |
26 #include <AknUtils.h> |
27 #include <hblistviewitem.h> |
27 #include <aknmessagequerydialog.h> // CAknMessageQueryDialog |
28 #include <hblistwidgetitem.h> |
28 #include <akntoolbar.h> |
29 #include <hbtoolbar.h> |
29 #include <StringLoader.h> |
30 #include <hbmenu.h> |
30 #include <featmgr.h> |
31 #include <hbdocumentloader.h> |
31 #include <iaupdate.rsg> |
32 #include <xqconversions.h> |
32 |
33 #include <hbmessagebox.h> |
33 #include "iaupdate.hrh" |
34 #include <hblabel.h> |
|
35 #include <hbgroupbox.h> |
|
36 #include <hbdataform.h> |
|
37 #include <hbtranslator.h> |
|
38 |
|
39 #include "iaupdatemainview.h" |
34 #include "iaupdatemainview.h" |
40 #include "iaupdateengine.h" |
35 #include "iaupdatemaincontainer.h" |
41 #include "iaupdateagreement.h" |
36 #include "iaupdatenode.h" |
|
37 #include "iaupdatefwnode.h" |
|
38 #include "iaupdatebasenode.h" |
|
39 #include "iaupdatedialogutil.h" |
|
40 #include "iaupdatestatusdialog.h" |
|
41 #include "iaupdateappui.h" |
|
42 #include "iaupdateuicontroller.h" |
42 #include "iaupdatedeputils.h" |
43 #include "iaupdatedeputils.h" |
43 #include "iaupdatedialogutil.h" |
|
44 #include "iaupdateversion.h" |
|
45 |
|
46 #include "iaupdatedebug.h" |
44 #include "iaupdatedebug.h" |
47 |
45 #include "iaupdatefwupdatehandler.h" |
48 |
46 |
49 |
47 //CONSTANTS |
50 const int KKiloByte = 1024; |
48 const TInt KKiloByte = 1024; |
51 const int KMegaByte = 1024 * 1024; |
49 const TInt KMegaByte = 1024 * 1024; |
52 const int KMaxShownInKiloBytes = 10 * KMegaByte; |
50 const TInt KMaxShownInKiloBytes = 10 * KMegaByte; |
53 const QString KTranslationsPath = "/resource/qt/translations/"; |
51 const TInt KSelInfoArrayGranularity = 3; |
54 const QString KTranslationsFile = "swupdate"; |
52 |
55 |
53 //MACROS |
56 |
54 _LIT( KSpace, " " ); |
57 IAUpdateMainView::IAUpdateMainView(IAUpdateEngine *engine): |
55 |
58 mEngine(engine) |
56 // ============================ MEMBER FUNCTIONS =============================== |
59 { |
57 |
60 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::IAUpdateMainView() begin"); |
58 |
61 mFwListView = NULL; |
59 |
62 mApplicationUpdatesGroupBox = NULL;; |
60 // ----------------------------------------------------------------------------- |
63 mFwNSUGroupBox = NULL; |
61 // CIAUpdateMainView::NewL |
64 mContentDataForm = NULL; |
62 // Two-phased constructor. |
65 mDialogUtil = NULL; |
63 // ----------------------------------------------------------------------------- |
66 mDialogState = NoDialog; |
64 // |
67 mPrimaryAction = NULL; |
65 CIAUpdateMainView* CIAUpdateMainView::NewL( const TRect& aRect ) |
68 mNode = NULL; |
66 { |
69 mSelectionUpdate = false; |
67 CIAUpdateMainView* self = CIAUpdateMainView::NewLC( aRect ); |
70 mSelectionConnect = false; |
68 CleanupStack::Pop(self); |
71 mTranslator = NULL; |
69 return self; |
72 |
70 } |
73 //mTranslator = new HbTranslator(KTranslationsPath, KTranslationsFile); |
71 |
74 |
72 // ----------------------------------------------------------------------------- |
75 HbDocumentLoader loader; |
73 // CIAUpdateMainView::NewLC |
76 bool ok = false; |
74 // |
77 loader.load(":/xml/iaupdate_mainview.docml", &ok); |
75 // ----------------------------------------------------------------------------- |
78 |
76 // |
79 // Exit if the file format is invalid |
77 CIAUpdateMainView* CIAUpdateMainView::NewLC( const TRect& aRect ) |
80 Q_ASSERT_X(ok, "Software update", "Invalid docml file"); |
78 { |
81 // Create the view from DocML |
79 CIAUpdateMainView* self = new (ELeave) CIAUpdateMainView(); |
82 |
80 CleanupStack::PushL( self ); |
83 HbView* loadedWidget = qobject_cast<HbView*>(loader.findWidget("view")); |
81 self->ConstructL( aRect ); |
84 Q_ASSERT_X(loadedWidget != 0, "Software update", "View not found"); |
82 return self; |
85 QString viewTitle(loadedWidget->title()); |
83 } |
86 // Set the IAUpdateMainView view to be the widget that was loaded from the xml |
84 |
87 setWidget(loadedWidget); |
85 // ----------------------------------------------------------------------------- |
88 setTitle(viewTitle); |
86 // CIAUpdateMainView::CIAUpdateMainView |
89 |
87 // C++ default constructor can NOT contain any code, that |
90 HbToolBar *toolBar = qobject_cast< HbToolBar*>( loader.findWidget("viewToolbar") ); |
88 // might leave. |
91 //setToolBar(toolBar); |
89 // ----------------------------------------------------------------------------- |
92 |
90 // |
93 HbMenu *menu = qobject_cast< HbMenu*>( loader.findWidget("viewMenu") ); |
91 CIAUpdateMainView::CIAUpdateMainView() |
94 setMenu(menu); |
92 { |
95 |
93 } |
96 //Get the Action objects from the docml file |
94 |
97 HbAction *action = qobject_cast<HbAction*>(loader.findObject("action")); |
95 // ----------------------------------------------------------------------------- |
98 HbAction *action_1 = qobject_cast<HbAction*>(loader.findObject("action_1")); |
96 // CIAUpdateMainView::~CIAUpdateMainView |
99 HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2")); |
97 // Destructor |
100 |
98 // ----------------------------------------------------------------------------- |
101 connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate())); |
99 // |
102 connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings())); |
100 CIAUpdateMainView::~CIAUpdateMainView() |
103 connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer())); |
101 { |
104 |
102 delete iDecorator; |
105 mContent = qobject_cast< HbWidget*>( loader.findWidget("content") ); |
103 iAllNodes.Close(); |
|
104 if ( iContainer ) |
|
105 { |
|
106 AppUi()->RemoveFromStack( iContainer ); |
|
107 delete iContainer; |
|
108 } |
|
109 delete iFwUpdateHandler; |
|
110 } |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CIAUpdateMainView::ConstructL |
|
113 // Symbian 2nd phase constructor can leave. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CIAUpdateMainView::ConstructL( const TRect& /*aRect*/ ) |
|
117 { |
|
118 BaseConstructL( R_IAUPDATE_MAIN_VIEW ); |
|
119 Toolbar()->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue, ETrue ); |
|
120 Toolbar()->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, ETrue, ETrue ); |
|
121 Toolbar()->SetItemDimmed( EIAUpdateCmdUpdateHistory, ETrue, ETrue ); |
|
122 Toolbar()->SetToolbarObserver( this ); |
|
123 iFwUpdateHandler = CIAUpdateFWUpdateHandler::NewL(); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CIAUpdateMainView::RefreshL |
|
128 // Refreshes update list |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CIAUpdateMainView::RefreshL( const RPointerArray<MIAUpdateNode>& aNodes, |
|
132 const RPointerArray<MIAUpdateFwNode>& aFwNodes, |
|
133 TInt aError ) |
|
134 { |
|
135 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL begin"); |
|
136 iRefreshError = aError; |
|
137 iAllNodes.Reset(); |
|
138 |
|
139 if ( aFwNodes.Count() > 0 ) |
|
140 { |
|
141 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL hard code importance"); |
|
142 //hardcode the importance of firmware as Critical |
|
143 for ( TInt i = 0; i < aFwNodes.Count(); i++ ) |
|
144 { |
|
145 aFwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical ); |
|
146 } |
|
147 |
|
148 //either NSU or FOTA available |
|
149 if ( aFwNodes.Count() == 1 ) |
|
150 { |
|
151 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL either NSU or FOTA available"); |
|
152 MIAUpdateAnyNode* node = aFwNodes[0]; |
|
153 User::LeaveIfError( iAllNodes.Append( node ) ); |
|
154 } |
|
155 |
|
156 //both NSU and FOTA available, show only FOTA node |
|
157 if ( aFwNodes.Count() == 2 ) |
|
158 { |
|
159 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL both NSU and FOTA available"); |
|
160 MIAUpdateAnyNode* node1 = aFwNodes[0]; |
|
161 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node1 ); |
|
162 if ( fwnode->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
163 { |
|
164 User::LeaveIfError( iAllNodes.Append( node1 ) ); |
|
165 } |
|
166 else |
|
167 { |
|
168 MIAUpdateAnyNode* node2 = aFwNodes[1]; |
|
169 User::LeaveIfError( iAllNodes.Append( node2 ) ); |
|
170 } |
|
171 } |
|
172 } |
|
173 |
|
174 |
|
175 for( TInt i = 0; i < aNodes.Count(); ++i ) |
|
176 { |
|
177 MIAUpdateAnyNode* node = aNodes[i]; |
|
178 User::LeaveIfError( iAllNodes.Append( node ) ); |
|
179 } |
|
180 |
|
181 if( iContainer ) |
|
182 { |
|
183 iContainer->RefreshL( iAllNodes, iRefreshError ); |
|
184 SetSelectedIndicesL(); |
|
185 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
186 } |
|
187 Toolbar()->SetItemDimmed( EIAUpdateCmdUpdateHistory, EFalse, ETrue ); |
|
188 } |
|
189 |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CIAUpdateMainView::GetCurrentNode |
|
193 // |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 MIAUpdateAnyNode* CIAUpdateMainView::GetCurrentNode() |
|
197 { |
|
198 if ( iContainer ) |
|
199 { |
|
200 return iContainer->GetCurrentNode( iAllNodes ); |
|
201 } |
|
202 return NULL; |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CIAUpdateMainView::GetSelectedNode |
|
207 // |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 MIAUpdateAnyNode* CIAUpdateMainView::GetSelectedNode() |
|
211 { |
|
212 MIAUpdateAnyNode* selectedNode = NULL; |
|
213 for( TInt i = 0; i < iAllNodes.Count() && !selectedNode ; ++i ) |
|
214 { |
|
215 if ( iAllNodes[i]->Base().IsSelected() ) |
|
216 { |
|
217 selectedNode = iAllNodes[i]; |
|
218 } |
|
219 } |
|
220 return selectedNode; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CIAUpdateMainView::Id |
|
225 // Get Uid of this view |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 TUid CIAUpdateMainView::Id() const |
|
229 { |
|
230 return TUid::Uid( EIAUpdateMainViewId ); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CIAUpdateMainView::HandleCommandL |
|
235 // |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CIAUpdateMainView::HandleCommandL( TInt aCommand ) |
|
239 { |
|
240 switch( aCommand ) |
|
241 { |
|
242 case EIAUpdateCmdStartUpdate: |
|
243 { |
|
244 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
245 CleanupClosePushL( selectedNodes ); |
|
246 GetSelectedNodesL( selectedNodes ); |
|
247 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
248 { |
|
249 //the marking logic will make sure firmware won't be marked with normal sis updates |
|
250 //at the same time. |
|
251 iFwUpdateHandler->FirmWareUpdatewithFOTA(); |
|
252 } |
|
253 else |
|
254 { |
|
255 AppUi()->HandleCommandL( aCommand ); |
|
256 } |
|
257 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
258 break; |
|
259 } |
|
260 case EIAUpdateCmdUpdateWithPC: |
|
261 { |
|
262 iFwUpdateHandler->FirmWareUpdatewithNSU(); |
|
263 break; |
|
264 } |
|
265 case EIAUpdateCmdSettings: |
|
266 { |
|
267 Toolbar()->SetToolbarVisibility( EFalse ); |
|
268 AppUi()->HandleCommandL( aCommand ); |
|
269 Toolbar()->SetToolbarVisibility( ETrue ); |
|
270 break; |
|
271 } |
|
272 case EAknSoftkeyMark: |
|
273 { |
|
274 iContainer->HandleMarkCommandL( EAknCmdMark ); |
|
275 break; |
|
276 } |
|
277 case EAknSoftkeyUnmark: |
|
278 { |
|
279 iContainer->HandleMarkCommandL( EAknCmdUnmark ); |
|
280 break; |
|
281 } |
|
282 case EAknCmdMark: |
|
283 case EAknCmdUnmark: |
|
284 { |
|
285 iContainer->HandleMarkCommandL( aCommand ); |
|
286 break; |
|
287 } |
|
288 default: |
|
289 { |
|
290 AppUi()->HandleCommandL( aCommand ); |
|
291 break; |
|
292 } |
|
293 } |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CIAUpdateMainView::DynInitMenuPaneL |
|
298 // Dim options which are not availble in empty list. |
|
299 // Set Mark/Unmark option |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 void CIAUpdateMainView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
303 { |
|
304 if( aResourceId == R_IAUPDATE_MAIN_MENU ) |
|
305 { |
|
306 if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
307 { |
|
308 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
309 } |
|
310 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
311 CleanupClosePushL( selectedNodes ); |
|
312 GetSelectedNodesL( selectedNodes ); |
|
313 |
|
314 if ( selectedNodes.Count() ) |
|
315 { |
|
316 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
317 { |
|
318 //firmware is selected |
|
319 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( selectedNodes[0] ); |
|
320 |
|
321 if ( node->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
322 { |
|
323 aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue ); |
|
324 } |
|
325 |
|
326 if ( node->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
327 { |
|
328 aMenuPane->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue ); |
|
329 } |
|
330 } |
|
331 else |
|
332 { |
|
333 //firmware is not selected, only sis |
|
334 aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue ); |
|
335 } |
|
336 } |
|
337 else |
|
338 { |
|
339 aMenuPane->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue ); |
|
340 aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue ); |
|
341 } |
|
342 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
343 } |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CIAUpdateMainView::DoActivateL |
|
348 // Activate view |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 void CIAUpdateMainView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
352 TUid /*aCustomMessageId*/, |
|
353 const TDesC8& /*aCustomMessage*/ ) |
|
354 { |
|
355 UpdateStatusPaneL(); |
|
356 Toolbar()->SetToolbarVisibility( ETrue ); |
|
357 if( !iContainer ) |
|
358 { |
|
359 iContainer = CIAUpdateMainContainer::NewL( ClientRect(), *this ); |
|
360 |
|
361 if( iAllNodes.Count() > 0 ) |
|
362 { |
|
363 iContainer->RefreshL( iAllNodes, iRefreshError ); |
|
364 } |
|
365 |
|
366 SetSelectedIndicesL(); |
|
367 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
368 AppUi()->AddToStackL( iContainer ); |
|
369 } |
|
370 else |
|
371 { |
|
372 UpdateSelectionInfoInNaviPaneL(); |
|
373 } |
|
374 } |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // CIAUpdateMainView::DoDeactivate() |
|
378 // Container is deleted in deactivation |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 void CIAUpdateMainView::DoDeactivate() |
|
382 { |
|
383 RemoveSelectionInfoInNaviPane(); |
|
384 Toolbar()->SetToolbarVisibility( EFalse ); |
|
385 } |
|
386 |
|
387 // ----------------------------------------------------------------------------- |
|
388 // CIAUpdateMainView::DynInitToolbarL() |
|
389 // |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 void CIAUpdateMainView::DynInitToolbarL( TInt aResourceId, CAknToolbar* aToolbar ) |
|
393 { |
|
394 if ( aResourceId == R_IAUPDATE_MAIN_TOOLBAR ) |
|
395 { |
|
396 if ( iContainer ) |
|
397 { |
|
398 if ( CountOfSelectedItems() > 0 ) |
|
399 { |
|
400 aToolbar->SetItemDimmed( EIAUpdateCmdStartUpdate, EFalse, ETrue ); |
|
401 } |
|
402 else |
|
403 { |
|
404 aToolbar->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue, ETrue ); |
|
405 } |
|
406 if ( CountOfSelectedItems() == 1 ) |
|
407 { |
|
408 aToolbar->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, EFalse, ETrue ); |
|
409 } |
|
410 else |
|
411 { |
|
412 aToolbar->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, ETrue, ETrue ); |
|
413 } |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 // ----------------------------------------------------------------------------- |
|
419 // CIAUpdateMainView::OfferToolbarEventL() |
|
420 // |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 void CIAUpdateMainView::OfferToolbarEventL( TInt aCommand ) |
|
424 { |
|
425 if ( aCommand == EIAUpdateCmdStartUpdate ) |
|
426 { |
|
427 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
428 CleanupClosePushL( selectedNodes ); |
|
429 GetSelectedNodesL( selectedNodes ); |
|
430 |
|
431 if ( selectedNodes.Count() ) |
|
432 { |
|
433 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
434 { |
|
435 //firmware is selected |
|
436 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( selectedNodes[0] ); |
|
437 |
|
438 if ( node->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
439 { |
|
440 aCommand = EIAUpdateCmdStartUpdate; |
|
441 } |
|
442 |
|
443 if ( node->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
444 { |
|
445 aCommand = EIAUpdateCmdUpdateWithPC; |
|
446 } |
|
447 } |
|
448 else |
|
449 { |
|
450 //firmware is not selected, only sis |
|
451 aCommand = EIAUpdateCmdStartUpdate; |
|
452 } |
|
453 } |
|
454 else |
|
455 { |
|
456 MIAUpdateAnyNode* currentNode = GetCurrentNode(); |
|
457 if ( currentNode->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
458 { |
|
459 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( currentNode ); |
|
460 if ( node->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
461 { |
|
462 aCommand = EIAUpdateCmdUpdateWithPC; |
|
463 } |
|
464 } |
|
465 } |
|
466 |
|
467 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
468 } |
|
469 HandleCommandL( aCommand ); |
|
470 } |
|
471 |
|
472 |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CIAUpdateMainView::MarkListItemL |
|
476 // Mark list item |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 TBool CIAUpdateMainView::MarkListItemL( TBool aMark, TInt aIndex ) |
|
480 { |
|
481 if ( aMark ) |
|
482 { |
|
483 //It's Mark Command |
|
484 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
485 CleanupClosePushL( selectedNodes ); |
|
486 GetSelectedNodesL( selectedNodes ); |
|
487 |
|
488 //There are selected items already and type are different with the current one |
|
489 if ( selectedNodes.Count() > 0 && (iAllNodes[aIndex]->NodeType() != selectedNodes[0]->NodeType() ) ) |
|
490 { |
|
491 /*HBufC* msgText = StringLoader::LoadLC(R_IAUPDATE_FIRMWARE_WITH_OTHERS); |
|
492 |
|
493 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
494 |
|
495 dlg->ExecuteLD( R_IAUPDATE_INFORMATION_QUERY, *msgText ); |
|
496 |
|
497 CleanupStack::PopAndDestroy( msgText );*/ |
|
498 |
|
499 //clean all of the current selection(s) |
|
500 iContainer->CleanAllSelection(); |
|
501 |
|
502 // firmware item and normal sis items can't be selected at the same time |
|
503 // unmark the selected nodes. |
|
504 for ( TInt i = 0; i < selectedNodes.Count(); i++ ) |
|
505 { |
|
506 TInt index = iAllNodes.Find( selectedNodes[i]); |
|
507 iAllNodes[index]->Base().SetSelected( EFalse ); |
|
508 } |
|
509 } |
|
510 |
|
511 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
512 } |
|
513 |
|
514 //there is no selected items or the type is the same with the current one |
|
515 |
|
516 if ( iAllNodes[aIndex]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
517 { |
|
518 iAllNodes[aIndex]->Base().SetSelected( aMark ); |
|
519 |
|
520 if ( aMark ) |
|
521 { |
|
522 SetMiddleSKTextL( ETrue, ETrue ); |
|
523 } |
|
524 else |
|
525 { |
|
526 SetMiddleSKTextL( ETrue, EFalse ); |
|
527 } |
|
528 UpdateSelectionInfoInNaviPaneL(); |
|
529 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
530 return ETrue; |
|
531 } |
|
532 |
|
533 if ( iAllNodes[aIndex]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal ) |
|
534 { |
|
535 TBool accepted = EFalse; |
|
536 |
|
537 if( aIndex > -1 ) |
|
538 { |
|
539 accepted = ETrue; |
|
540 |
|
541 MIAUpdateNode* node = static_cast<MIAUpdateNode*>( iAllNodes[aIndex] ); |
|
542 RPointerArray<MIAUpdateAnyNode> mands; |
|
543 RPointerArray<MIAUpdateNode> deps; |
106 |
544 |
107 mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") ); |
545 if ( aMark ) |
108 mListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
546 { |
109 |
547 CleanupClosePushL( mands ); |
110 connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
548 CleanupClosePushL( deps ); |
111 this, SLOT( handleDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
549 IAUpdateDepUtils::GetDependenciesL( *node, iAllNodes, deps ); |
112 |
550 GetMandatoryNodesL( mands ); |
113 HbListViewItem *prototype = mListView->listItemPrototype(); |
551 } |
114 |
552 else |
115 prototype->setGraphicsSize(HbListViewItem::LargeIcon); |
553 { |
116 |
554 //mandatory item is not allowed to be unmarked |
117 HbDockWidget *dock = new HbDockWidget(this); |
555 if ( iAllNodes[aIndex]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
118 HbWidget *dockContainer = new HbWidget(dock); |
556 { |
119 QGraphicsLinearLayout *dockLayout = new QGraphicsLinearLayout(dockContainer); |
557 //show dialog |
120 dockLayout->setOrientation(Qt::Vertical); |
558 ShowUpdateCannotOmitDialogL(); |
121 dockContainer->setLayout(dockLayout); |
559 return EFalse; |
122 |
560 } |
123 mSelections = new HbGroupBox(dockContainer); |
561 |
124 mSelections->setHeading("Selected 0/0 (0 kB)"); |
562 CleanupClosePushL( deps ); |
125 //QString selectedString = QString(hbTrId("txt_software_subhead_selected_1l_2l_3l_kb")).arg(0).arg(0).arg(0); |
563 IAUpdateDepUtils::GetDependantsL( *node, iAllNodes, deps ); |
126 //mSelections->setHeading(selectedString); |
564 // item is not allowed to be unmarked if its dependant is mandatory |
127 |
565 TBool mandatoryDependantFound = EFalse; |
128 dockLayout->addItem( mSelections); |
566 for( TInt i = 0; i < deps.Count() && !mandatoryDependantFound; i++ ) |
129 |
567 { |
130 dockLayout->addItem(toolBar); |
568 if ( deps[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
131 |
569 { |
132 dock->setWidget(dockContainer); |
570 mandatoryDependantFound = ETrue; |
133 |
571 } |
134 setDockWidget(dock); |
572 } |
135 |
573 if ( mandatoryDependantFound ) |
136 |
574 { |
137 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::IAUpdateMainView() end"); |
575 ShowUpdateCannotOmitDialogL(); |
138 } |
576 CleanupStack::PopAndDestroy( &deps ); |
139 |
577 return EFalse; |
140 IAUpdateMainView::~IAUpdateMainView() |
578 } |
141 { |
579 } |
142 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::~IAUpdateMainView() begin"); |
580 |
143 //delete mTranslator; |
581 TInt depCount = deps.Count(); |
144 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::~IAUpdateMainView() end"); |
582 |
145 } |
583 if ( depCount > 0 ) |
146 |
584 { |
147 // ----------------------------------------------------------------------------- |
585 HBufC* text = NULL; |
148 // IAUpdateMainView::refresh |
586 HBufC* names = NULL; |
149 // Refreshes update list |
587 MIAUpdateNode* depNode = NULL; |
|
588 HBufC* separator = NULL; |
|
589 |
|
590 if ( depCount > 1 ) |
|
591 { |
|
592 separator = StringLoader::LoadLC( R_IAUPDATE_SEPARATOR ); |
|
593 } |
|
594 |
|
595 names = HBufC::NewLC( 0 ); |
|
596 |
|
597 for( TInt i = 0; i < depCount; i++ ) |
|
598 { |
|
599 depNode = deps[i]; |
|
600 HBufC* temp = NULL; |
|
601 if ( separator ) |
|
602 { |
|
603 temp = names->ReAllocL( names->Length() + |
|
604 depNode->Base().Name().Length() + |
|
605 separator->Length() + |
|
606 KSpace.iTypeLength ); |
|
607 } |
|
608 else |
|
609 { |
|
610 temp = names->ReAllocL( names->Length() + |
|
611 depNode->Base().Name().Length() + |
|
612 KSpace.iTypeLength ); |
|
613 } |
|
614 |
|
615 CleanupStack::Pop( names ); |
|
616 names = temp; |
|
617 CleanupStack::PushL( names ); |
|
618 |
|
619 if ( i > 0 ) |
|
620 { |
|
621 names->Des() += *separator; |
|
622 names->Des() += KSpace; |
|
623 } |
|
624 names->Des() += depNode->Base().Name(); |
|
625 } |
|
626 |
|
627 TInt resourceId = 0; |
|
628 if ( aMark ) |
|
629 { |
|
630 if ( depCount > 1 ) |
|
631 { |
|
632 resourceId = R_IAUPDATE_DEPENDENCY_MARK_MANY; |
|
633 } |
|
634 else |
|
635 { |
|
636 resourceId = R_IAUPDATE_DEPENDENCY_MARK_ONE; |
|
637 } |
|
638 } |
|
639 else |
|
640 { |
|
641 if ( depCount > 1 ) |
|
642 { |
|
643 resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_MANY; |
|
644 } |
|
645 else |
|
646 { |
|
647 resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_ONE; |
|
648 } |
|
649 } |
|
650 text = StringLoader::LoadLC( resourceId, *names ); |
|
651 |
|
652 if ( aMark && iAllNodes[aIndex]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
|
653 { |
|
654 // depencencies of mandatory update are also selected without showing dialog |
|
655 accepted = ETrue; |
|
656 } |
|
657 else |
|
658 { |
|
659 accepted = ShowDependenciesFoundDialogL( *text ); |
|
660 } |
|
661 CleanupStack::PopAndDestroy( text ); |
|
662 CleanupStack::PopAndDestroy( names ); |
|
663 |
|
664 if ( separator ) |
|
665 { |
|
666 CleanupStack::PopAndDestroy( separator ); |
|
667 } |
|
668 } |
|
669 |
|
670 if ( accepted ) |
|
671 { |
|
672 for( TInt j = 0; j < depCount; j++ ) |
|
673 { |
|
674 TInt depNodeInd = iAllNodes.Find( deps[j] ); |
|
675 iAllNodes[depNodeInd]->Base().SetSelected( aMark ); |
|
676 } |
|
677 CleanupStack::PopAndDestroy( &deps ); |
|
678 |
|
679 TInt nodeInd = iAllNodes.Find( node ); |
|
680 iAllNodes[nodeInd]->Base().SetSelected( aMark ); |
|
681 } |
|
682 else |
|
683 { |
|
684 //user rejects the dependency dialog |
|
685 CleanupStack::PopAndDestroy( &deps ); |
|
686 if ( aMark ) |
|
687 { |
|
688 CleanupStack::PopAndDestroy( &mands ); |
|
689 } |
|
690 return EFalse; |
|
691 } |
|
692 |
|
693 //mark all of the mandatory items |
|
694 TInt mandCount = mands.Count(); |
|
695 if ( mandCount > 0 && aMark ) |
|
696 { |
|
697 for( TInt j = 0; j < mandCount; j++ ) |
|
698 { |
|
699 TInt mandNodeInd = iAllNodes.Find( mands[j] ); |
|
700 iAllNodes[mandNodeInd]->Base().SetSelected( aMark ); |
|
701 if ( iAllNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal ) |
|
702 { |
|
703 // mark also all dependencies of a mandatory item |
|
704 MIAUpdateNode* dependencyNode = static_cast<MIAUpdateNode*>( iAllNodes[mandNodeInd] ); |
|
705 RPointerArray<MIAUpdateNode> dependencies; |
|
706 CleanupClosePushL( dependencies ); |
|
707 IAUpdateDepUtils::GetDependenciesL( *dependencyNode, iAllNodes, dependencies ); |
|
708 for( TInt k = 0; k < dependencies.Count(); k++ ) |
|
709 { |
|
710 TInt depNodeInd = iAllNodes.Find( dependencies[k] ); |
|
711 iAllNodes[depNodeInd]->Base().SetSelected( ETrue ); |
|
712 } |
|
713 CleanupStack::PopAndDestroy( &dependencies ); |
|
714 } |
|
715 } |
|
716 } |
|
717 if ( aMark ) |
|
718 { |
|
719 CleanupStack::PopAndDestroy( &mands ); |
|
720 } |
|
721 |
|
722 if ( depCount > 0 || mandCount > 0 ) |
|
723 { |
|
724 SetSelectedIndicesL(); |
|
725 } |
|
726 else |
|
727 { |
|
728 UpdateSelectionInfoInNaviPaneL(); |
|
729 } |
|
730 |
|
731 if ( aMark ) |
|
732 { |
|
733 SetMiddleSKTextL( ETrue, ETrue ); |
|
734 } |
|
735 else |
|
736 { |
|
737 SetMiddleSKTextL( ETrue, EFalse ); |
|
738 } |
|
739 } |
|
740 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
741 return ETrue; |
|
742 } |
|
743 return EFalse; |
|
744 } |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 // ----------------------------------------------------------------------------- |
|
750 // CIAUpdateMainView::SetMiddleSKTextL |
|
751 // Middle soft key label to be set |
150 // ----------------------------------------------------------------------------- |
752 // ----------------------------------------------------------------------------- |
151 // |
753 // |
152 void IAUpdateMainView::refresh(const RPointerArray<MIAUpdateNode> &nodes, |
754 void CIAUpdateMainView::SetMiddleSKTextL( TBool aVisible, TBool aSelected ) |
153 const RPointerArray<MIAUpdateFwNode> &fwNodes, |
755 { |
154 int error) |
756 CEikButtonGroupContainer* cbaGroup = Cba(); |
155 { |
757 if ( cbaGroup ) |
156 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() begin"); |
758 { |
157 removeCurrentContentLayout(); |
759 cbaGroup->RemoveCommandFromStack( CEikButtonGroupContainer::EMiddleSoftkeyPosition, iLastCommandId ); |
158 |
760 if ( aVisible ) |
159 refreshFirmwareUpdates(fwNodes); |
761 { |
160 |
762 HBufC* middleSKText = NULL; |
161 refreshApplicationUpdates(nodes); |
763 if ( aSelected ) |
162 |
764 { |
163 if (nodes.Count() == 0 && fwNodes.Count() == 0 && |
765 middleSKText = StringLoader::LoadLC( R_IAUPDATE_MSK_UNMARK ); |
164 error != KErrCancel && error != KErrAbort) |
766 TPtr mskPtr = middleSKText->Des(); |
165 { |
767 cbaGroup->AddCommandToStackL( |
166 if (!mContentDataForm) |
768 CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
167 { |
769 EAknSoftkeyUnmark, |
168 mContentDataForm = new HbDataForm(mContent); |
770 mskPtr ); |
169 } |
771 iLastCommandId = EAknSoftkeyUnmark; |
170 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
772 } |
171 linearLayout->addItem(mContentDataForm); |
773 else |
172 QString formText; |
774 { |
173 |
775 middleSKText = StringLoader::LoadLC( R_IAUPDATE_MSK_MARK ); |
174 if (error == KErrNone) |
776 TPtr mskPtr = middleSKText->Des(); |
175 { |
777 cbaGroup->AddCommandToStackL( |
176 formText = QString("Applications are up to date"); |
778 CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
177 //formText = hbTrId("txt_software_formlabel_applications_are_up_to_date"); |
779 EAknSoftkeyMark, |
178 } |
780 mskPtr ); |
179 else |
781 iLastCommandId = EAknSoftkeyMark; |
180 { |
782 } |
181 formText = QString("Refreshing failed. Try again later."); |
783 CleanupStack::PopAndDestroy( middleSKText ); |
182 } |
784 } |
183 mContentDataForm->setDescription(formText); |
785 } |
184 } |
786 } |
185 updateSelectionInfoInDock(); |
787 |
186 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh() end"); |
788 // ----------------------------------------------------------------------------- |
187 } |
789 // CIAUpdateMainView::GetSelectedNodesL |
188 |
790 // Get selected (marked) nodes |
189 |
791 // ----------------------------------------------------------------------------- |
190 |
792 // |
191 |
793 void CIAUpdateMainView::GetSelectedNodesL( RPointerArray<MIAUpdateAnyNode>& aSelectedNodes ) const |
192 void IAUpdateMainView::handleStartUpdate() |
794 { |
193 { |
795 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
194 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() begin"); |
796 { |
195 mEngine->StartUpdate(fotaSelected()); |
797 if ( iAllNodes[i]->Base().IsSelected() ) |
196 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleStartUpdate() end"); |
798 { |
197 } |
799 User::LeaveIfError( aSelectedNodes.Append( iAllNodes[i] ) ); |
198 |
800 } |
199 |
801 } |
200 void IAUpdateMainView::handleSettings() |
802 } |
201 { |
803 |
202 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSettings() begin"); |
804 // ----------------------------------------------------------------------------- |
203 emit toSettingView(); |
805 // CIAUpdateMainView::GetMandatoryItemsL |
204 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSettings() end"); |
806 // Get selected (marked) nodes |
205 } |
807 // ----------------------------------------------------------------------------- |
206 |
808 // |
207 void IAUpdateMainView::handleDisclaimer() |
809 void CIAUpdateMainView::GetMandatoryNodesL( RPointerArray<MIAUpdateAnyNode>& aMandNodes ) const |
208 { |
810 { |
209 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() begin"); |
811 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
210 if (!mDialogUtil) |
812 { |
211 { |
813 if ( iAllNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
212 mDialogUtil = new IAUpdateDialogUtil(this); |
814 { |
213 } |
815 User::LeaveIfError( aMandNodes.Append( iAllNodes[i] ) ); |
214 if (mDialogUtil) |
816 } |
215 { |
817 } |
216 HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_ok")); |
818 } |
217 mDialogUtil->showAgreement(primaryAction); |
819 |
218 } |
820 |
219 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDisclaimer() end"); |
821 |
220 } |
822 // ----------------------------------------------------------------------------- |
221 |
823 // CIAUpdateMainView::SetSelectedIndicesL |
222 void IAUpdateMainView::handleDetails(HbAbstractViewItem * item, const QPointF &) |
824 // Indices of selected items are passed to container |
223 { |
825 // ----------------------------------------------------------------------------- |
224 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDetails() begin"); |
826 // |
225 int ind = item->modelIndex().row(); |
827 void CIAUpdateMainView::SetSelectedIndicesL() |
226 if (getApplicationNode(ind) != NULL) |
828 { |
227 { |
829 RArray<TInt> indices; |
228 showDetails(*getApplicationNode(ind)); |
830 |
229 } |
831 CleanupClosePushL( indices ); |
230 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleDetails() end"); |
832 |
231 } |
833 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
232 |
834 { |
233 void IAUpdateMainView::handleFotaDetails(HbAbstractViewItem *, const QPointF &) |
835 if ( iAllNodes[i]->Base().IsSelected() ) |
234 { |
836 { |
235 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFotaDetails begin"); |
837 User::LeaveIfError( indices.Append( i ) ); |
236 //only one FOTA item in a list, just use it |
838 } |
237 for (int i = 0; i < mFwNodes.Count(); i++) |
839 } |
238 { |
840 |
239 if (mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2) |
841 iContainer->SetSelectedIndicesL( indices ); |
240 { |
842 UpdateSelectionInfoInNaviPaneL(); |
241 showDetails(*mFwNodes[i]); |
843 |
242 } |
844 CleanupStack::PopAndDestroy( &indices ); |
243 } |
845 } |
244 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFotaDetails end"); |
846 |
245 } |
847 // ----------------------------------------------------------------------------- |
246 |
848 // CIAUpdateMainView::NodeIndex |
247 |
849 // Get index of node |
248 void IAUpdateMainView::handleSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
850 // ----------------------------------------------------------------------------- |
249 { |
851 // |
250 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSelectionChanged begin"); |
852 TInt CIAUpdateMainView::NodeIndex( const MIAUpdateAnyNode& aNode ) const |
251 if (!mSelectionUpdate) |
853 { |
252 { |
854 TInt result = -1; |
253 bool changedItemFound = false; |
855 |
254 QModelIndexList indexList = selected.indexes(); |
856 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
255 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
857 { |
256 { |
858 if( &aNode == iAllNodes[i] ) |
257 changedItemFound = true; |
859 { |
258 markListItem(true, indexList.at(i).row()); |
860 result = i; |
259 } |
|
260 if (!changedItemFound) |
|
261 { |
|
262 indexList = deselected.indexes(); |
|
263 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
264 { |
|
265 changedItemFound = true; |
|
266 markListItem(false, indexList.at(i).row()); |
|
267 } |
|
268 } |
|
269 } |
|
270 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleSelectionChanged end"); |
|
271 } |
|
272 |
|
273 void IAUpdateMainView::handleFwSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
|
274 { |
|
275 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFwSelectionChanged begin"); |
|
276 if (!mSelectionUpdate) |
|
277 { |
|
278 bool changedItemFound = false; |
|
279 QModelIndexList indexList = selected.indexes(); |
|
280 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
281 { |
|
282 changedItemFound = true; |
|
283 markFotaItem(true); |
|
284 } |
|
285 if (!changedItemFound) |
|
286 { |
|
287 indexList = deselected.indexes(); |
|
288 for (int i = 0; !changedItemFound && i < indexList.count(); ++i) |
|
289 { |
|
290 changedItemFound = true; |
|
291 markFotaItem(false); |
|
292 } |
|
293 } |
|
294 } |
|
295 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::handleFwSelectionChanged end"); |
|
296 } |
|
297 |
|
298 |
|
299 void IAUpdateMainView::dialogFinished(HbAction *action) |
|
300 { |
|
301 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::dialogFinished begin"); |
|
302 DialogState dialogState = mDialogState; |
|
303 mDialogState = NoDialog; |
|
304 |
|
305 switch ( dialogState ) |
|
306 { |
|
307 case Dependencies: |
|
308 if (action == mPrimaryAction) |
|
309 { |
|
310 updateSelectionsToNodeArray(*mNode,mMark); |
|
311 } |
|
312 updateSelectionsToList(); |
|
313 updateSelectionInfoInDock(); |
|
314 break; |
861 break; |
315 case CannotOmit: |
862 } |
316 break; |
863 } |
317 case Details: |
864 return result; |
318 break; |
865 } |
319 default: |
866 |
320 break; |
867 // ----------------------------------------------------------------------------- |
321 } |
868 // CIAUpdateMainView::UpdateStatusPaneL |
322 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::dialogFinished end"); |
869 // Update title in status pane |
323 } |
870 // ----------------------------------------------------------------------------- |
324 |
871 // |
325 bool IAUpdateMainView::fotaSelected() const |
872 |
326 { |
873 void CIAUpdateMainView::UpdateStatusPaneL() |
327 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fotaSelected() begin"); |
874 { |
328 bool selected = false; |
875 CAknTitlePane* titlePane = |
329 for (int i = 0; i < mFwNodes.Count() && !selected; ++i) |
876 static_cast< CAknTitlePane* >( StatusPane()->ControlL( |
330 { |
877 TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
331 if ( mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2 && mFwNodes[i]->Base().IsSelected() ) |
878 HBufC* text = StringLoader::LoadLC( R_IAUPDATE_TEXT_TITLE_MAIN_VIEW ); |
332 { |
879 titlePane->SetTextL( *text ); |
333 selected = true; |
880 CleanupStack::PopAndDestroy( text ); |
334 } |
881 } |
335 } |
882 |
336 if (selected) |
883 |
337 { |
884 // ----------------------------------------------------------------------------- |
338 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fotaSelected() Fota item is selected"); |
885 // CIAUpdateMainView::UpdateSelectionInfoInNaviPaneL |
339 } |
886 // Update selection information in status pane |
340 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fotaSelected() end"); |
887 // ----------------------------------------------------------------------------- |
341 return selected; |
888 // |
342 } |
889 // |
343 |
890 void CIAUpdateMainView::UpdateSelectionInfoInNaviPaneL() |
344 |
891 { |
345 |
892 RemoveSelectionInfoInNaviPane(); |
346 void IAUpdateMainView::markListItem(bool mark, int index) |
893 |
347 { |
894 if ( iAllNodes.Count() > 0 ) |
348 IAUPDATE_TRACE_2("[IAUPDATE] IAUpdateMainView::markListItem() begin mark: %d index %d", mark, index); |
895 { |
349 if (mark) |
896 //show empty navi pane when firmware is selected but no size info or it is NSU |
350 { |
897 if ( (iAllNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw) && iAllNodes[0]->Base().IsSelected() ) |
351 //It's Mark Command |
898 { |
352 if (fotaSelected()) |
899 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( iAllNodes[0] ); |
353 { |
900 if ( (iAllNodes[0]->Base().ContentSizeL() == 0) || (fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) ) |
354 //FOTA item is selected, unmark FOTA item |
901 { |
355 //FOTA item and application update items can't be selected at the same time |
|
356 markFotaItem(false); |
|
357 } |
|
358 } |
|
359 |
|
360 bool accepted = false; |
|
361 |
|
362 if(index > -1) |
|
363 { |
|
364 accepted = true; |
|
365 MIAUpdateNode* node = mNodes[index]; |
|
366 RPointerArray<MIAUpdateNode> mands; |
|
367 RPointerArray<MIAUpdateNode> deps; |
|
368 |
|
369 if (mark) |
|
370 { |
|
371 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*node, mNodes, deps)); |
|
372 if (err != KErrNone) |
|
373 { |
|
374 deps.Close(); |
|
375 updateSelectionsToList(); |
|
376 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
377 return; |
902 return; |
378 } |
903 } |
379 if (!getMandatoryNodes(mands)) |
904 } |
380 { |
905 |
381 // error when creating mandatory node list |
906 if ( !iNaviPane ) |
382 mands.Close(); |
907 { |
383 updateSelectionsToList(); |
908 iNaviPane = static_cast<CAknNavigationControlContainer*> |
384 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
909 ( StatusPane()->ControlL( TUid::Uid(EEikStatusPaneUidNavi ) ) ); |
385 return; |
910 } |
386 } |
911 TInt selectedSizeInBytes = 0; |
387 } |
912 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
388 else |
913 { |
389 { |
914 if ( iAllNodes[i]->Base().IsSelected() ) |
390 //mandatory item is not allowed to be unmarked |
915 { |
391 if (mNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
916 selectedSizeInBytes += iAllNodes[i]->Base().ContentSizeL(); |
392 { |
917 } |
393 //show dialog |
|
394 showUpdateCannotOmitDialog(); |
|
395 updateSelectionsToList(); |
|
396 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
397 return; |
|
398 } |
|
399 TRAPD(err,IAUpdateDepUtils::GetDependantsL(*node, mNodes, deps)); |
|
400 if (err != KErrNone) |
|
401 { |
|
402 deps.Close(); |
|
403 updateSelectionsToList(); |
|
404 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
405 return; |
|
406 } |
|
407 // item is not allowed to be unmarked if its dependant is mandatory |
|
408 bool mandatoryDependantFound = false; |
|
409 for(int i = 0; i < deps.Count() && !mandatoryDependantFound; i++) |
|
410 { |
|
411 if (deps[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
412 { |
|
413 mandatoryDependantFound = true; |
|
414 } |
|
415 } |
|
416 if (mandatoryDependantFound) |
|
417 { |
|
418 showUpdateCannotOmitDialog(); |
|
419 deps.Close(); |
|
420 updateSelectionsToList(); |
|
421 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() return end"); |
|
422 return; |
|
423 } |
|
424 } |
|
425 |
|
426 int depCount = deps.Count(); |
|
427 |
|
428 if (depCount > 0) |
|
429 { |
|
430 QString text; |
|
431 QString names; |
|
432 MIAUpdateNode* depNode = NULL; |
|
433 QString separator(","); |
|
434 |
|
435 for(int i = 0; i < depCount; i++) |
|
436 { |
|
437 depNode = deps[i]; |
|
438 if (i > 0) |
|
439 { |
|
440 names.append(separator); |
|
441 names.append(QString(" ")); |
|
442 } |
|
443 names.append(XQConversions::s60DescToQString(depNode->Base().Name())); |
|
444 } |
|
445 |
|
446 if (mark) |
|
447 { |
|
448 if (depCount > 1) |
|
449 { |
|
450 text.append("This update needs also updates "); |
|
451 text.append(names); |
|
452 text.append(" for working"); |
|
453 } |
|
454 else |
|
455 { |
|
456 text.append("This update needs also \""); |
|
457 text.append(names); |
|
458 text.append("\" for working"); |
|
459 } |
|
460 } |
|
461 else |
|
462 { |
|
463 if (depCount > 1) |
|
464 { |
|
465 text.append("Updates "); |
|
466 text.append(names); |
|
467 text.append(" need this update for working"); |
|
468 } |
|
469 else |
|
470 { |
|
471 text.append("Update \""); |
|
472 text.append(names); |
|
473 text.append("\" needs this update for working"); |
|
474 } |
|
475 } |
918 } |
476 |
919 |
477 if (mark && mNodes[index]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
920 |
478 { |
921 TInt resourceId = 0; |
479 // depencencies of mandatory update are also selected without showing dialog |
922 TInt selectedSize; |
480 accepted = true; |
923 if ( selectedSizeInBytes >= KMaxShownInKiloBytes ) |
481 } |
924 { |
482 else |
925 resourceId = R_IAUPDATE_NAVIPANE_MEGABYTE; |
483 { |
926 selectedSize = selectedSizeInBytes / KMegaByte; |
484 mNode = node; |
927 if ( selectedSizeInBytes % KMegaByte != 0 ) |
485 mMark = mark; |
928 { |
486 accepted = false; |
929 selectedSize++; |
487 showDependenciesFoundDialog(text); |
930 } |
488 } |
931 } |
489 } |
932 else |
490 if (accepted) |
933 { |
491 { |
934 resourceId = R_IAUPDATE_NAVIPANE_KILOBYTE; |
492 updateSelectionsToNodeArray(*node, mark); |
935 selectedSize = selectedSizeInBytes / KKiloByte; |
493 } |
936 if ( selectedSizeInBytes % KKiloByte != 0 ) |
494 } |
937 { |
495 if (accepted) |
938 selectedSize++; |
496 { |
939 } |
497 updateSelectionsToList(); |
940 } |
498 updateSelectionInfoInDock(); |
|
499 } |
|
500 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markListItem() end"); |
|
501 } |
|
502 |
|
503 |
|
504 void IAUpdateMainView::markFotaItem(bool mark) |
|
505 { |
|
506 IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateMainView::markFotaItem() begin mark: %d", mark); |
|
507 if (mark) |
|
508 { |
|
509 //It's Mark Command |
|
510 |
|
511 //if some of application update item(s) are selected, unmark them |
|
512 //FOTA item and application update items can't be selected at the same time |
|
513 bool deselected = false; |
|
514 for (int i = 0; i < mNodes.Count(); ++i) |
|
515 { |
|
516 if (mNodes[i]->Base().IsSelected()) |
|
517 { |
|
518 mNodes[i]->Base().SetSelected(false); |
|
519 } |
|
520 } |
|
521 if (deselected) |
|
522 { |
|
523 // umnmarked items to be updated also to UI |
|
524 updateSelectionsToList(); |
|
525 } |
|
526 } |
|
527 for (int j = 0; j < mFwNodes.Count(); ++j) |
|
528 { |
|
529 if (mFwNodes[j]->FwType() == MIAUpdateFwNode::EFotaDp2) |
|
530 { |
|
531 mFwNodes[j]->Base().SetSelected(mark); |
|
532 if (mark) |
|
533 { |
|
534 mFwListView->selectionModel()->select(mFwListView->model()->index(0,0),QItemSelectionModel::Select); |
|
535 } |
|
536 else |
|
537 { |
|
538 mFwListView->selectionModel()->select(mFwListView->model()->index(0,0),QItemSelectionModel::Deselect); |
|
539 } |
|
540 } |
|
541 } |
|
542 updateSelectionInfoInDock(); |
|
543 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::markFotaItem() end"); |
|
544 } |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 void IAUpdateMainView::updateSelectionsToNodeArray(MIAUpdateNode &node, bool mark) |
|
551 { |
|
552 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToNodeArray() begin"); |
|
553 RPointerArray<MIAUpdateNode> deps; |
|
554 TInt err = KErrNone; |
|
555 if (mark) |
|
556 { |
|
557 TRAP(err,IAUpdateDepUtils::GetDependenciesL(node, mNodes, deps)); |
|
558 } |
|
559 else |
|
560 { |
|
561 TRAP(err,IAUpdateDepUtils::GetDependantsL(node, mNodes, deps)); |
|
562 } |
|
563 if (err == KErrNone ) |
|
564 { |
|
565 int depCount = deps.Count(); |
|
566 for(int i = 0; i < depCount; i++) |
|
567 { |
|
568 int depNodeInd = mNodes.Find(deps[i]); |
|
569 mNodes[depNodeInd]->Base().SetSelected(mark); |
|
570 } |
|
571 deps.Close(); |
|
572 int nodeInd = mNodes.Find(&node); |
|
573 mNodes[nodeInd]->Base().SetSelected(mark); |
|
574 } |
|
575 |
|
576 //mark all of the mandatory items |
|
577 if ( mark ) |
|
578 { |
|
579 RPointerArray<MIAUpdateNode> mands; |
|
580 if (getMandatoryNodes(mands)) |
|
581 { |
|
582 int mandCount = mands.Count(); |
|
583 if (mandCount > 0) |
|
584 { |
|
585 for(int i = 0; i < mandCount; i++) |
|
586 { |
|
587 int mandNodeInd = mNodes.Find(mands[i]); |
|
588 mNodes[mandNodeInd]->Base().SetSelected(mark); |
|
589 if (mNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
|
590 { |
|
591 // mark also all dependencies of a mandatory item |
|
592 MIAUpdateNode* dependencyNode = mNodes[mandNodeInd]; |
|
593 RPointerArray<MIAUpdateNode> dependencies; |
|
594 TRAPD(err,IAUpdateDepUtils::GetDependenciesL(*dependencyNode, mNodes, dependencies)); |
|
595 if (err) |
|
596 { |
|
597 dependencies.Close(); |
|
598 mands.Close(); |
|
599 return; |
|
600 } |
|
601 for(int j = 0; j < dependencies.Count(); j++) |
|
602 { |
|
603 int depNodeInd = mNodes.Find(dependencies[j]); |
|
604 mNodes[depNodeInd]->Base().SetSelected(true); |
|
605 } |
|
606 dependencies.Close(); |
|
607 } |
|
608 } |
|
609 } |
|
610 } |
|
611 mands.Close(); |
|
612 } |
|
613 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToNodeArray() end"); |
|
614 } |
|
615 |
|
616 |
|
617 bool IAUpdateMainView::getMandatoryNodes(RPointerArray<MIAUpdateNode> &mandNodes) const |
|
618 { |
|
619 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getMandatoryNodes() begin"); |
|
620 bool ret = true; |
|
621 for(int i = 0; i < mNodes.Count(); ++i) |
|
622 { |
|
623 if (mNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory) |
|
624 { |
|
625 if (mandNodes.Append(mNodes[i]) != KErrNone) |
|
626 { |
|
627 ret = false; |
|
628 } |
|
629 } |
|
630 } |
|
631 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getMandatoryNodes() end"); |
|
632 return ret; |
|
633 } |
|
634 |
|
635 void IAUpdateMainView::showUpdateCannotOmitDialog() |
|
636 { |
|
637 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showUpdateCannotOmitDialog() begin"); |
|
638 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
639 messageBox->setText(QString("This required update cannot be omitted")); |
|
640 int actionCount = messageBox->actions().count(); |
|
641 for (int i=actionCount-1; i >= 0; i--) |
|
642 { |
|
643 messageBox->removeAction(messageBox->actions().at(i)); |
|
644 } |
|
645 HbAction *okAction = NULL; |
|
646 okAction = new HbAction("Ok"); |
|
647 messageBox->addAction(okAction); |
|
648 messageBox->setTimeout(HbPopup::StandardTimeout); |
|
649 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
650 mDialogState = CannotOmit; |
|
651 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
|
652 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showUpdateCannotOmitDialog() end"); |
|
653 } |
|
654 |
|
655 void IAUpdateMainView::showDependenciesFoundDialog(QString &text) |
|
656 { |
|
657 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDependenciesFoundDialog() begin"); |
|
658 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
659 HbLabel *label = new HbLabel(messageBox); |
|
660 label->setHtml(QString("Depencencies")); |
|
661 messageBox->setHeadingWidget(label); |
|
662 //messageBox->setIconVisible(false); |
|
663 |
|
664 messageBox->setText(text); |
|
665 int actionCount = messageBox->actions().count(); |
|
666 for (int i=actionCount-1; i >= 0; i--) |
|
667 { |
|
668 messageBox->removeAction(messageBox->actions().at(i)); |
|
669 } |
|
670 mPrimaryAction = NULL; |
|
671 mPrimaryAction = new HbAction("Continue"); |
|
672 HbAction *secondaryAction = NULL; |
|
673 secondaryAction = new HbAction("Cancel"); |
|
674 messageBox->addAction(mPrimaryAction); |
|
675 messageBox->addAction(secondaryAction); |
|
676 messageBox->setTimeout(HbPopup::NoTimeout); |
|
677 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
678 mDialogState = Dependencies; |
|
679 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
|
680 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDependenciesFoundDialog() end"); |
|
681 } |
|
682 |
|
683 void IAUpdateMainView::updateSelectionsToList() |
|
684 { |
|
685 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToList() begin"); |
|
686 mSelectionUpdate = true; |
|
687 for(int i = 0; i < mNodes.Count(); ++i) |
|
688 { |
|
689 if ( mNodes[i]->Base().IsSelected() != mListView->selectionModel()->isSelected(mListView->model()->index(i,0))) |
|
690 { |
|
691 QItemSelectionModel::SelectionFlag selectionFlag; |
|
692 if ( mNodes[i]->Base().IsSelected()) |
|
693 { |
|
694 selectionFlag = QItemSelectionModel::Select; |
|
695 } |
|
696 else |
|
697 { |
|
698 selectionFlag = QItemSelectionModel::Deselect; |
|
699 } |
|
700 mListView->selectionModel()->select(mListView->model()->index(i,0),selectionFlag); |
|
701 } |
|
702 } |
|
703 mSelectionUpdate = false; |
|
704 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionsToList() end"); |
|
705 } |
|
706 |
|
707 |
|
708 MIAUpdateNode* IAUpdateMainView::getApplicationNode(int index) const |
|
709 { |
|
710 IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateMainView::getApplicationNode() begin index: %d", index); |
|
711 MIAUpdateNode *currentNode = NULL; |
|
712 |
941 |
713 if (index >= 0 && index < mNodes.Count()) |
942 CArrayFix<TInt>* numberArray = |
714 { |
943 new ( ELeave ) CArrayFixFlat<TInt>( KSelInfoArrayGranularity ); |
715 currentNode = mNodes[index]; |
944 CleanupStack::PushL( numberArray ); |
716 } |
945 numberArray->AppendL( CountOfSelectedItems() ); |
717 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::getApplicationNode() end"); |
946 numberArray->AppendL( iAllNodes.Count() ); |
718 return currentNode; |
947 numberArray->AppendL( selectedSize ); |
719 } |
948 |
720 |
949 HBufC* selectionInfo = StringLoader::LoadLC( resourceId, |
721 void IAUpdateMainView::showDetails(MIAUpdateAnyNode& node) |
950 *numberArray ); |
722 { |
951 TPtr ptr = selectionInfo->Des(); |
723 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDetails() begin"); |
952 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
724 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
725 HbLabel *label = new HbLabel(messageBox); |
|
726 label->setHtml(QString("Details")); |
|
727 messageBox->setHeadingWidget(label); |
|
728 |
|
729 messageBox->setIconVisible(false); |
|
730 |
953 |
731 QString text; |
954 iDecorator = iNaviPane->CreateNavigationLabelL( *selectionInfo ); |
732 constructDetailsText(node,text); |
955 |
733 messageBox->setText(text); |
956 iNaviPane->PushL( *iDecorator ); |
734 messageBox->setTimeout(HbPopup::NoTimeout); |
957 |
735 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
958 CleanupStack::PopAndDestroy( selectionInfo ); |
736 mDialogState = Details; |
959 CleanupStack::PopAndDestroy( numberArray ); |
737 messageBox->open(this, SLOT(dialogFinished(HbAction*))); |
960 } |
738 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::showDetails() end"); |
961 } |
739 } |
962 |
740 |
963 // ----------------------------------------------------------------------------- |
741 |
964 // CIAUpdateMainView::RemoveSelectionInfoInNaviPane |
742 void IAUpdateMainView::constructDetailsText(MIAUpdateAnyNode &node, QString &text) |
965 // Remove existing selection info (created by main view) from navi pane |
743 { |
966 // ----------------------------------------------------------------------------- |
744 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::constructDetailsText() begin"); |
967 // |
745 text.append(QString("Name:")); |
968 |
746 text.append(QString("<br />")); |
969 void CIAUpdateMainView::RemoveSelectionInfoInNaviPane() |
747 QString name = XQConversions::s60DescToQString(node.Base().Name()); |
970 { |
748 text.append(name); |
971 if ( iNaviPane && iDecorator ) |
749 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
972 { |
750 { |
973 iNaviPane->Pop( iDecorator ); |
751 name.append(QString(" Device software")); |
974 delete iDecorator; |
752 } |
975 iDecorator = NULL; |
753 |
976 } |
754 text.append(QString("<br />")); |
977 } |
755 text.append(QString("<br />")); |
978 |
756 |
979 // ----------------------------------------------------------------------------- |
757 text.append(QString("Description:")); |
980 // CIAUpdateMainView::ShowDependenciesFoundDialogL |
758 text.append(QString("<br />")); |
981 // |
759 QString description; |
982 // ----------------------------------------------------------------------------- |
760 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
983 // |
761 { |
984 TBool CIAUpdateMainView::ShowDependenciesFoundDialogL( TDesC& aText ) const |
762 description = QString("This update improves your device performance and brings you latest features."); |
985 { |
763 } |
986 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( aText ); |
764 else |
987 dlg->PrepareLC( R_IAUPDATE_MESSAGE_QUERY ); |
765 { |
988 CAknPopupHeadingPane* headingPane = dlg->Heading(); |
766 description = XQConversions::s60DescToQString(node.Base().Description()); |
989 HBufC* title = StringLoader::LoadLC( R_IAUPDATE_DEPENDENCY_TITLE ); |
767 } |
990 headingPane->SetTextL( *title ); |
768 text.append(description); |
991 CleanupStack::PopAndDestroy( title ); |
769 text.append(QString("<br />")); |
992 |
770 text.append(QString("<br />")); |
993 dlg->ButtonGroupContainer().SetCommandSetL( |
771 |
994 R_IAUPDATE_SOFTKEYS_CONTINUE_CANCEL__CONTINUE ); |
772 |
995 |
773 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeNormal) |
996 return( dlg->RunLD() == EAknSoftkeyOk ); |
774 { |
997 } |
775 MIAUpdateNode *iaupdateNode = static_cast<MIAUpdateNode*> (&node); |
998 |
776 if (iaupdateNode->Type()!= MIAUpdateNode::EPackageTypeServicePack) |
999 // --------------------------------------------------------------------------- |
777 { |
1000 // CIAUpdateMainView::CountOfSelectedItems |
778 text.append(QString("Version:")); |
1001 // |
779 text.append(QString("<br />")); |
1002 // --------------------------------------------------------------------------- |
780 QString textVersion; |
1003 // |
781 versionText(node.Base().Version(), textVersion); |
1004 TInt CIAUpdateMainView::CountOfSelectedItems() const |
782 text.append(textVersion); |
1005 { |
783 text.append(QString("<br />")); |
1006 TInt countOfSelectedItems = 0; |
784 text.append(QString("<br />")); |
1007 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
785 } |
1008 { |
786 } |
1009 if ( iAllNodes[i]->Base().IsSelected() ) |
787 if (node.NodeType() == MIAUpdateAnyNode::ENodeTypeFw) |
1010 { |
788 { |
1011 countOfSelectedItems++; |
789 MIAUpdateFwNode *fwNode = static_cast<MIAUpdateFwNode*> (&node); |
1012 } |
790 text.append(QString("Version:")); |
1013 } |
791 text.append(QString("<br />")); |
1014 return countOfSelectedItems; |
792 QString textVersion = XQConversions::s60DescToQString(fwNode->FwVersion1()); |
1015 } |
793 text.append(textVersion); |
1016 |
794 text.append(QString("<br />")); |
1017 // --------------------------------------------------------------------------- |
795 text.append(QString("<br />")); |
1018 // CIAUpdateMainView::ShowUpdateCannotOmitDialogL |
796 } |
1019 // |
797 |
1020 // --------------------------------------------------------------------------- |
798 int contentSize = node.Base().ContentSizeL(); |
1021 // |
799 if (contentSize > 0) |
1022 void CIAUpdateMainView::ShowUpdateCannotOmitDialogL() const |
800 { |
1023 { |
801 text.append(QString("Size:")); |
1024 HBufC* msgText = StringLoader::LoadLC( R_IAUPDATE_CANNOT_OMIT ); |
802 text.append(QString("<br />")); |
1025 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
803 QString textFileSize; |
1026 dlg->ExecuteLD( R_IAUPDATE_INFORMATION_QUERY, *msgText ); |
804 fileSizeText(contentSize, textFileSize); |
1027 CleanupStack::PopAndDestroy( msgText ); |
805 text.append(textFileSize); |
1028 } |
806 } |
1029 |
807 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::constructDetailsText() end"); |
1030 // End of File |
808 } |
1031 |
809 |
|
810 void IAUpdateMainView::versionText(const TIAUpdateVersion &version, QString &versionText) |
|
811 { |
|
812 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::versionText() begin"); |
|
813 QString stringMajor; |
|
814 stringMajor.setNum(version.iMajor); |
|
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"); |
|
826 } |
|
827 |
|
828 void IAUpdateMainView::fileSizeText(int fileSize, QString &text) |
|
829 { |
|
830 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() begin"); |
|
831 int size = 0; |
|
832 QString stringUnit; |
|
833 |
|
834 if (fileSize >= KMaxShownInKiloBytes ) |
|
835 { |
|
836 stringUnit.append(" MB"); |
|
837 size = fileSize / KMegaByte; |
|
838 if ( fileSize % KMegaByte != 0 ) |
|
839 { |
|
840 size++; |
|
841 } |
|
842 } |
|
843 else |
|
844 { |
|
845 stringUnit.append(" kB"); |
|
846 size = fileSize / KKiloByte; |
|
847 if ( fileSize % KKiloByte != 0 ) |
|
848 { |
|
849 size++; |
|
850 } |
|
851 } |
|
852 text.setNum(size); |
|
853 text.append(stringUnit); |
|
854 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::fileSizeText() end"); |
|
855 } |
|
856 |
|
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 |
|
968 void IAUpdateMainView::removeCurrentContentLayout() |
|
969 { |
|
970 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() begin"); |
|
971 int itemCount = mContent->layout()->count(); |
|
972 for (int i = 0; i < itemCount; i++) |
|
973 { |
|
974 mContent->layout()->removeAt(i); |
|
975 } |
|
976 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::removeCurrentContentLayout() end"); |
|
977 } |
|
978 |
|
979 void IAUpdateMainView::refreshFirmwareUpdates(const RPointerArray<MIAUpdateFwNode> &fwNodes) |
|
980 { |
|
981 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFirmwareUpdates() begin"); |
|
982 mFwNodes.Reset(); |
|
983 |
|
984 for (int i = 0; i < fwNodes.Count(); i++) |
|
985 { |
|
986 MIAUpdateFwNode *fwnode = (fwNodes[i]); |
|
987 mFwNodes.Append(fwnode); |
|
988 fwnode->Base().SetImportance(MIAUpdateBaseNode::ECritical); |
|
989 if (fwnode->FwType() == MIAUpdateFwNode::EFotaDp2) |
|
990 { |
|
991 refreshFotaUpdate(*fwnode ); |
|
992 } |
|
993 else if (fwNodes.Count() == 1 && fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) |
|
994 { |
|
995 refreshNsuUpdate(); |
|
996 } |
|
997 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFirmwareUpdates() end"); |
|
998 } |
|
999 } |
|
1000 |
|
1001 void IAUpdateMainView::refreshFotaUpdate(MIAUpdateFwNode& fwNode) |
|
1002 { |
|
1003 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() begin"); |
|
1004 if (!mFwListView) |
|
1005 { |
|
1006 mFwListView = new HbListWidget(mContent); |
|
1007 mFwListView->setSelectionMode( HbAbstractItemView::MultiSelection ); |
|
1008 connect( mFwListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ), |
|
1009 this, SLOT( handleFotaDetails( HbAbstractViewItem *, const QPointF & ) ) ); |
|
1010 mFwListView->listItemPrototype()->setGraphicsSize(HbListViewItem::LargeIcon); |
|
1011 mFwListView->listItemPrototype()->setStretchingStyle(HbListViewItem::NoStretching); |
|
1012 connect(mFwListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
|
1013 this, SLOT(handleFwSelectionChanged(QItemSelection,QItemSelection))); |
|
1014 } |
|
1015 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
1016 linearLayout->addItem(mFwListView); |
|
1017 mFwListView->clear(); |
|
1018 QItemSelectionModel *selectionModel = mFwListView->selectionModel(); |
|
1019 selectionModel->clear(); |
|
1020 HbListWidgetItem *fwItem = new HbListWidgetItem(); |
|
1021 QString name(XQConversions::s60DescToQString(fwNode.Base().Name())); |
|
1022 name.append(" DEVICE SOFTWARE"); |
|
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()) |
|
1030 { |
|
1031 QModelIndex modelIndex = mFwListView->model()->index(0,0); |
|
1032 selectionModel->select(modelIndex, QItemSelectionModel::Select); |
|
1033 } |
|
1034 mFwListView->addItem(fwItem); |
|
1035 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshFotaUpdate() end"); |
|
1036 } |
|
1037 |
|
1038 void IAUpdateMainView::refreshNsuUpdate() |
|
1039 { |
|
1040 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() begin"); |
|
1041 if (!mFwNSUGroupBox) |
|
1042 { |
|
1043 mFwNSUGroupBox = new HbGroupBox(mContent); |
|
1044 mFwNSUGroupBox->setHeading("Device software available"); |
|
1045 HbDataForm *dataForm = new HbDataForm(mFwNSUGroupBox); |
|
1046 mFwNSUGroupBox->setContentWidget(dataForm); |
|
1047 dataForm->setDescription("Use your PC to update the device software ([version %L]) from address www.nokia.com/softwareupdate"); |
|
1048 } |
|
1049 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
1050 linearLayout->addItem(mFwNSUGroupBox); |
|
1051 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshNsuUpdate() end"); |
|
1052 } |
|
1053 |
|
1054 void IAUpdateMainView::refreshApplicationUpdates(const RPointerArray<MIAUpdateNode> &nodes) |
|
1055 { |
|
1056 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshApplicationUpdates() begin"); |
|
1057 if (nodes.Count() > 0) |
|
1058 { |
|
1059 if (!mApplicationUpdatesGroupBox) |
|
1060 { |
|
1061 mApplicationUpdatesGroupBox = new HbGroupBox(mContent); |
|
1062 mApplicationUpdatesGroupBox->setHeading("Application updates"); |
|
1063 } |
|
1064 QGraphicsLinearLayout *linearLayout = (QGraphicsLinearLayout*) mContent->layout(); |
|
1065 linearLayout->addItem(mApplicationUpdatesGroupBox); |
|
1066 linearLayout->addItem(mListView); |
|
1067 } |
|
1068 mListView->clear(); |
|
1069 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
|
1070 selectionModel->clear(); |
|
1071 HbIcon icon(QString(":/icons/qgn_menu_swupdate")); |
|
1072 mNodes.Reset(); |
|
1073 for(int i = 0; i < nodes.Count(); ++i) |
|
1074 { |
|
1075 MIAUpdateNode *node = nodes[i]; |
|
1076 mNodes.Append(node); |
|
1077 QString importanceDescription; |
|
1078 MIAUpdateNode::TUIUpdateState uiState = node->UiState(); |
|
1079 if (uiState == MIAUpdateNode::ENormal) |
|
1080 { |
|
1081 setImportance(node, importanceDescription); |
|
1082 } |
|
1083 else if (uiState == MIAUpdateNode::EUpdated) |
|
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); |
|
1116 } |
|
1117 } |
|
1118 if (!mSelectionConnect) |
|
1119 { |
|
1120 mSelectionConnect = connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
|
1121 this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); |
|
1122 } |
|
1123 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refreshApplicationUpdates() end"); |
|
1124 } |
|
1125 |
|
1126 void IAUpdateMainView::updateSelectionInfoInDock() |
|
1127 { |
|
1128 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionInfoInDock() begin"); |
|
1129 int countOfSelectedItems = 0; |
|
1130 int countOfAllItems = 0; |
|
1131 int selectedSizeInBytes = 0; |
|
1132 for (int i = 0; i < mFwNodes.Count(); ++i) |
|
1133 { |
|
1134 if (mFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2) |
|
1135 { |
|
1136 countOfAllItems++; |
|
1137 if (mFwNodes[i]->Base().IsSelected()) |
|
1138 { |
|
1139 countOfSelectedItems++; |
|
1140 selectedSizeInBytes += mFwNodes[i]->Base().ContentSizeL(); |
|
1141 } |
|
1142 } |
|
1143 } |
|
1144 countOfAllItems += mNodes.Count(); |
|
1145 for (int j = 0; j < mNodes.Count(); ++j) |
|
1146 { |
|
1147 if (mNodes[j]->Base().IsSelected()) |
|
1148 { |
|
1149 countOfSelectedItems++; |
|
1150 selectedSizeInBytes += mNodes[j]->Base().ContentSizeL(); |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 int selectedSize = 0; |
|
1155 QString unit; |
|
1156 if (selectedSizeInBytes >= KMaxShownInKiloBytes) |
|
1157 { |
|
1158 unit = "MB"; |
|
1159 selectedSize = selectedSizeInBytes / KMegaByte; |
|
1160 if (selectedSizeInBytes % KMegaByte != 0) |
|
1161 { |
|
1162 selectedSize++; |
|
1163 } |
|
1164 } |
|
1165 else |
|
1166 { |
|
1167 unit = "kB"; |
|
1168 selectedSize = selectedSizeInBytes / KKiloByte; |
|
1169 if (selectedSizeInBytes % KKiloByte != 0) |
|
1170 { |
|
1171 selectedSize++; |
|
1172 } |
|
1173 } |
|
1174 QString selectionString; |
|
1175 selectionString.append("Selected "); |
|
1176 QString numText; |
|
1177 numText.setNum(countOfSelectedItems); |
|
1178 selectionString.append(numText); |
|
1179 selectionString.append("/"); |
|
1180 numText.setNum(countOfAllItems); |
|
1181 selectionString.append(numText); |
|
1182 if (selectedSize > 0) |
|
1183 { |
|
1184 selectionString.append(" ("); |
|
1185 numText.setNum(selectedSize); |
|
1186 selectionString.append(numText); |
|
1187 selectionString.append(" "); |
|
1188 selectionString.append(unit); |
|
1189 selectionString.append(")"); |
|
1190 } |
|
1191 mSelections->setHeading(selectionString); |
|
1192 IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::updateSelectionInfoInDock() end"); |
|
1193 } |
|