|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of Grid view control |
|
15 * |
|
16 */ |
|
17 #include <AknUtils.h> // For AknLayoutUtils to calculate rect |
|
18 #include <glxtracer.h> |
|
19 #include <StringLoader.h> |
|
20 #include <AknsBasicBackgroundControlContext.h> |
|
21 #include <caf/caferr.h> |
|
22 #include <eikcolib.h> |
|
23 // Ganes Headers |
|
24 #include <gulicon.h> // Gul Icons |
|
25 #include <ganes/HgItem.h> // HG Items |
|
26 #include <ganes/HgGrid.h> // Hg Grid Widget |
|
27 |
|
28 // Framework |
|
29 #include <data_caging_path_literals.hrh> |
|
30 #include <glxcommandhandlers.hrh> // For EGlxCmdFullScreenBack |
|
31 #include <glxcollectionpluginall.hrh> // All item collection plugin id |
|
32 |
|
33 |
|
34 #include <glxnavigationalstate.h> // For Navigational State |
|
35 #include <mglxmedialist.h> // MGlxMediaList, CMPXCollectionPath |
|
36 #include <glxuiutility.h> // For UiUtility instance |
|
37 #include <glxdrmutility.h> // DRM utility class to provide DRM-related functionality |
|
38 #include <glxerrormanager.h> // For CGlxErrormanager |
|
39 #include <glxthumbnailattributeinfo.h> // KGlxMediaIdThumbnail |
|
40 #include <glxgridviewdata.rsg> // Gridview resource |
|
41 #include <glxicons.mbg> // For Corrupted and not created icons |
|
42 |
|
43 #include "glxgridviewcontainer.h" |
|
44 #include "glxgridviewimp.h" |
|
45 #include "glxgridviewmlobserver.h" // medialist observer for Hg Grid |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // Two-phased constructor. |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CGlxGridViewContainer* CGlxGridViewContainer::NewL(MGlxMediaList *aMediaList, |
|
54 CGlxUiUtility* aUiUtility, MGlxGridEventObserver& aObserver, |
|
55 CAknToolbar* aToolbar) |
|
56 { |
|
57 TRACER("CGlxGridViewContainer::NewL"); |
|
58 CGlxGridViewContainer* self = CGlxGridViewContainer::NewLC(aMediaList, |
|
59 aUiUtility, aObserver, aToolbar); |
|
60 CleanupStack::Pop(self); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // Two-phased constructor. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CGlxGridViewContainer* CGlxGridViewContainer::NewLC( |
|
69 MGlxMediaList *aMediaList, CGlxUiUtility* aUiUtility, |
|
70 MGlxGridEventObserver& aObserver, CAknToolbar* aToolbar) |
|
71 { |
|
72 TRACER("CGlxGridViewContainer::NewLC"); |
|
73 CGlxGridViewContainer* self = new (ELeave) CGlxGridViewContainer( |
|
74 aMediaList, aUiUtility, aObserver, aToolbar); |
|
75 CleanupStack::PushL(self); |
|
76 self->ConstructL(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // Destructor |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CGlxGridViewContainer::~CGlxGridViewContainer() |
|
85 { |
|
86 TRACER("CGlxGridViewContainer::~CGlxGridViewContainer"); |
|
87 delete iMMCNotifier; |
|
88 iMMCNotifier = NULL; |
|
89 |
|
90 if(iBgContext) |
|
91 { |
|
92 delete iBgContext; |
|
93 } |
|
94 if(iDRMUtility) |
|
95 { |
|
96 iDRMUtility->Close(); |
|
97 } |
|
98 if (iGlxGridMLObserver) |
|
99 { |
|
100 delete iGlxGridMLObserver; |
|
101 iGlxGridMLObserver = NULL; |
|
102 } |
|
103 if (iMediaList) |
|
104 { |
|
105 iMediaList->RemoveContext(iThumbnailContext); |
|
106 delete iThumbnailContext; |
|
107 } |
|
108 if(iNavigationalstate) |
|
109 { |
|
110 iNavigationalstate->Close(); |
|
111 } |
|
112 if (iHgGrid) |
|
113 { |
|
114 delete iHgGrid; |
|
115 iHgGrid = NULL; |
|
116 } |
|
117 //reset the flag |
|
118 iBackwardActivation = EFalse; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // C++ default constructor can NOT contain any code, that |
|
123 // might leave. |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CGlxGridViewContainer::CGlxGridViewContainer(MGlxMediaList *aMediaList, |
|
127 CGlxUiUtility* aUiUtility, MGlxGridEventObserver& aObserver, |
|
128 CAknToolbar* aToolbar) : |
|
129 iMediaList(aMediaList), iUiUtility(aUiUtility), iGlxGridViewObserver( |
|
130 aObserver), iToolbar(aToolbar) |
|
131 { |
|
132 TRACER("CGlxGridViewContainer::CGlxGridViewContainer"); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Symbian 2nd phase constructor can leave. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CGlxGridViewContainer::ConstructL() |
|
140 { |
|
141 TRACER("CGlxGridViewContainer::ConstructL()"); |
|
142 //create the container window. |
|
143 CreateWindowL(); |
|
144 |
|
145 // Making the default FSActivation as false |
|
146 iFullscreenViewActivated = EFalse; |
|
147 |
|
148 iNavigationalstate = CGlxNavigationalState::InstanceL(); |
|
149 |
|
150 //check the navigational direction |
|
151 if (iUiUtility->ViewNavigationDirection ()== EGlxNavigationBackwards) |
|
152 { |
|
153 iBackwardActivation = ETrue; |
|
154 } |
|
155 |
|
156 // making the default mode of marking as false |
|
157 iMultipleMarkingActive = EFalse; |
|
158 |
|
159 iGridIconSize = iUiUtility->GetGridIconSize(); |
|
160 |
|
161 iItemsPerPage = iUiUtility->VisibleItemsInPageGranularityL(); |
|
162 |
|
163 // For DRM Utility |
|
164 iDRMUtility = CGlxDRMUtility::InstanceL(); |
|
165 |
|
166 //Clear the last uri for which DRM Rights were consumed |
|
167 //since the GridView::Activate() and FullScreen::DeActivate() |
|
168 //can be called in any order, this call is being made to be on safer side |
|
169 iDRMUtility->ClearLastConsumedItemUriL(); |
|
170 |
|
171 // background Skin Context for the skin support |
|
172 TRect apRect = iEikonEnv->EikAppUi()->ApplicationRect(); |
|
173 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
|
174 KAknsIIDQsnBgScreen,apRect,ETrue); |
|
175 |
|
176 iQualityTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
|
177 GlxFullThumbnailAttributeId( ETrue, iGridIconSize.iWidth, |
|
178 iGridIconSize.iHeight ) ); |
|
179 |
|
180 iSpeedTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
|
181 GlxFullThumbnailAttributeId( EFalse, iGridIconSize.iWidth, |
|
182 iGridIconSize.iHeight ) ); |
|
183 CreateGridL(); |
|
184 |
|
185 iIsDialogLaunched = EFalse; |
|
186 iIsMMCRemoved = EFalse; |
|
187 |
|
188 iMMCNotifier = CGlxMMCNotifier::NewL(*this); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // From OfferKeyEventL |
|
193 // Default implementation, |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 TKeyResponse CGlxGridViewContainer::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType) |
|
197 { |
|
198 TRACER("CGlxGridViewContainer::OfferKeyEventL()"); |
|
199 TKeyResponse response = EKeyWasNotConsumed; |
|
200 CCoeControl::OfferKeyEventL(aKeyEvent,aType); |
|
201 if(aType == EEventKey) |
|
202 { |
|
203 switch(aKeyEvent.iCode) |
|
204 { |
|
205 case EKeyBackspace: |
|
206 { |
|
207 iGlxGridViewObserver.HandleGridEventsL(EGlxCmdDelete); |
|
208 response = EKeyWasConsumed; |
|
209 break; |
|
210 } |
|
211 default: |
|
212 response = EKeyWasNotConsumed; |
|
213 break; |
|
214 } |
|
215 } |
|
216 |
|
217 //send the unconsumed events from grid container to hg-grid to handle related key events |
|
218 if(response == EKeyWasNotConsumed) |
|
219 { |
|
220 response = iHgGrid->OfferKeyEventL(aKeyEvent,aType); |
|
221 } |
|
222 return response ; |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // Release |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void CGlxGridViewContainer::Release(TInt /*aBufferStart*/, TInt/* aBufferEnd*/) |
|
230 { |
|
231 TRACER("CGlxGridViewContainer::Release()"); |
|
232 // This has to do nothing on default |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // Request |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CGlxGridViewContainer::Request(TInt aRequestStart, TInt aRequestEnd, |
|
240 THgScrollDirection /*aDirection*/) |
|
241 { |
|
242 TRACER("CGlxGridViewContainer::Request()"); |
|
243 RequestL(aRequestStart, aRequestEnd); |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // RequestL |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 void CGlxGridViewContainer::RequestL(TInt aRequestStart, TInt aRequestEnd) |
|
251 { |
|
252 TRACER("CGlxGridViewContainer::RequestL()"); |
|
253 TInt visIndex = 0; |
|
254 TInt mediaCount = iMediaList->Count(); |
|
255 aRequestStart = (aRequestStart<0 ? 0 : aRequestStart) ; |
|
256 aRequestEnd = (aRequestEnd>=mediaCount? (mediaCount-1) : aRequestEnd); |
|
257 |
|
258 GLX_LOG_INFO3("CGlxGridViewContainer::RequestL - aRequestStart(%d), " |
|
259 "aRequestEnd(%d), FirstIndexOnScreen(%d)", aRequestStart, |
|
260 aRequestEnd, iHgGrid->FirstIndexOnScreen()); |
|
261 GLX_LOG_INFO1("CGlxGridViewContainer::Request - mediaCount(%d)",mediaCount); |
|
262 |
|
263 visIndex = iHgGrid->FirstIndexOnScreen(); |
|
264 |
|
265 if(visIndex >= mediaCount ) |
|
266 { |
|
267 visIndex = mediaCount-1; |
|
268 } |
|
269 if(visIndex<0 || mediaCount<=0) |
|
270 { |
|
271 visIndex = 0; |
|
272 } |
|
273 GLX_LOG_INFO1("CGlxGridViewContainer::Request - SetVisibleWindowIndex" |
|
274 " visIndex(%d)", visIndex); |
|
275 iMediaList->SetVisibleWindowIndexL(visIndex); |
|
276 |
|
277 if(mediaCount>0) |
|
278 { |
|
279 //Set the icons and refresh the screen only when the items are present |
|
280 for (TInt i=aRequestStart; i<= aRequestEnd; i++) |
|
281 { |
|
282 SetIconsL(i); |
|
283 TInt firstIndex = iHgGrid->FirstIndexOnScreen(); |
|
284 firstIndex = (firstIndex<0 ? 0 : firstIndex); |
|
285 TInt lastOnScreen = firstIndex + iHgGrid->ItemsOnScreen() - 1; |
|
286 lastOnScreen = (lastOnScreen >mediaCount-1? mediaCount-1:lastOnScreen); |
|
287 if (i == lastOnScreen || (i == aRequestEnd && i < lastOnScreen)) |
|
288 { |
|
289 if (HasRelevantThumbnail(i)) |
|
290 { |
|
291 GLX_LOG_INFO1("CGlxGridViewContainer::Request - RefreshScreen" |
|
292 " lastOnScreen / aRequestEnd i(%d)", i); |
|
293 iHgGrid->RefreshScreen(i); |
|
294 } |
|
295 } |
|
296 } |
|
297 } |
|
298 } |
|
299 |
|
300 // ---------------------------------------------------------------------------- |
|
301 // HasRelevantThumbnail |
|
302 // ---------------------------------------------------------------------------- |
|
303 // |
|
304 TBool CGlxGridViewContainer::HasRelevantThumbnail(TInt aIndex) |
|
305 { |
|
306 TRACER("CGlxGridViewContainer::HasRelevantThumbnail()"); |
|
307 const TGlxMedia& item = iMediaList->Item( aIndex ); |
|
308 const CGlxThumbnailAttribute* qualityTn = item.ThumbnailAttribute( |
|
309 iQualityTnAttrib ); |
|
310 const CGlxThumbnailAttribute* speedTn = item.ThumbnailAttribute( |
|
311 iSpeedTnAttrib ); |
|
312 if ( qualityTn || speedTn ) |
|
313 { |
|
314 GLX_LOG_INFO("CGlxGridViewContainer::HasRelevantThumbnail() - TN avail"); |
|
315 return ETrue; |
|
316 } |
|
317 return EFalse; |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // HandleSelectL |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CGlxGridViewContainer::HandleSelectL( TInt aIndex ) |
|
325 { |
|
326 TRACER("CGlxGridViewContainer::HandleSelectL()"); |
|
327 // Map the index of HG Grid and Medialist |
|
328 // Make sure that the Selection Index is inside medialist count |
|
329 if (aIndex <iMediaList->Count() && aIndex >=0) |
|
330 { |
|
331 iMediaList->SetFocusL(NGlxListDefs::EAbsolute, aIndex); |
|
332 } |
|
333 } |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // HandleOpenL |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 void CGlxGridViewContainer::HandleOpenL( TInt aIndex ) |
|
340 { |
|
341 TRACER("CGlxGridViewContainer::HandleOpenL()"); |
|
342 // Make sure that the Selection Index is inside medialist count |
|
343 if (!iIsDialogLaunched && aIndex <iMediaList->Count() && aIndex >=0) |
|
344 { |
|
345 if (!(iHgGrid->Flags() && CHgScroller::EHgScrollerSelectionMode)) |
|
346 { |
|
347 // If not in marking mode, then open FS view |
|
348 iUiUtility->SetViewNavigationDirection(EGlxNavigationForwards); |
|
349 //Navigate to the next view |
|
350 //Item is selected, go to next view |
|
351 HandleEnterKeyEventL((TInt)EAknCmdOpen); |
|
352 } |
|
353 } |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // HandleEnterKeyEventL |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CGlxGridViewContainer::HandleEnterKeyEventL(TInt aCommand) |
|
361 { |
|
362 TRACER("CGlxGridViewContainer::HandleEnterKeyEventL()"); |
|
363 HandleViewCommandL(aCommand); |
|
364 } |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // HandleMarkingL |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 void CGlxGridViewContainer::HandleMarkingL( TInt aIndex, TBool aMarked ) |
|
371 { |
|
372 TRACER("CGlxGridViewContainer::HandleMarkingL()"); |
|
373 HandleMultipleMarkingL(aIndex,aMarked); |
|
374 } |
|
375 |
|
376 // --------------------------------------------------------------------------- |
|
377 // CreateHgGridWidgetL |
|
378 // --------------------------------------------------------------------------- |
|
379 // |
|
380 void CGlxGridViewContainer::CreateHgGridWidgetL() |
|
381 { |
|
382 TRACER("CGlxGridViewContainer::CreateHgGridWidgetL()"); |
|
383 TInt mediaCount = iMediaList->Count(); |
|
384 GLX_DEBUG2("GlxGrid: CHgGrid::CreateHgGridWidgetL() " |
|
385 "mediaCount(%d)", mediaCount); |
|
386 if (!iHgGrid) |
|
387 { |
|
388 iHgGridImageSize = CHgGrid::PreferredImageSize(); |
|
389 GLX_DEBUG3("GlxGrid: CHgGrid::PreferredImageSize() w(%d) h(%d)", |
|
390 iHgGridImageSize.iWidth, iHgGridImageSize.iHeight); |
|
391 iIconsFileName.Append(KDC_APP_BITMAP_DIR); |
|
392 iIconsFileName.Append(KGlxIconsFilename); |
|
393 |
|
394 // Create Hg grid object |
|
395 if (mediaCount) |
|
396 { |
|
397 CFbsBitmap* bitmap = NULL; |
|
398 CFbsBitmap* mask = NULL; |
|
399 AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone, |
|
400 bitmap, mask, iIconsFileName, |
|
401 EMbmGlxiconsQgn_prop_image_notcreated, |
|
402 EMbmGlxiconsQgn_prop_image_notcreated_mask); |
|
403 __ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer)); |
|
404 __ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer)); |
|
405 |
|
406 AknIconUtils::SetSize(bitmap, CHgGrid::PreferredImageSize(), |
|
407 EAspectRatioPreservedAndUnusedSpaceRemoved); |
|
408 AknIconUtils::SetSize(mask, CHgGrid::PreferredImageSize(), |
|
409 EAspectRatioPreservedAndUnusedSpaceRemoved); |
|
410 |
|
411 iHgGrid = CHgGrid::NewL(GetHgGridRect(), mediaCount, |
|
412 CGulIcon::NewL(bitmap, mask)); |
|
413 CleanupStack::Pop(mask); |
|
414 CleanupStack::Pop(bitmap); |
|
415 |
|
416 for (TInt index=0; index<mediaCount; index++) |
|
417 { |
|
418 SetIconsL(index); |
|
419 } |
|
420 } |
|
421 else |
|
422 { |
|
423 iHgGrid = CHgGrid::NewL(GetHgGridRect(), mediaCount); |
|
424 } |
|
425 } |
|
426 |
|
427 // Setting to MopParent to update background skin |
|
428 iHgGrid->SetMopParent(this); |
|
429 // Setting Selction observer for getting callback on key event change |
|
430 iHgGrid->SetSelectionObserver(*this); |
|
431 |
|
432 // This Displays the scrollbar at the opening of the Grid view |
|
433 iHgGrid->SetScrollBarTypeL(CHgScroller::EHgScrollerTimeStrip ); |
|
434 |
|
435 // Enable Buffer support |
|
436 iHgGrid->EnableScrollBufferL(*this, (KNoOfPages * iItemsPerPage), |
|
437 KBufferTresholdSize); |
|
438 |
|
439 // Enable Marking support |
|
440 iHgGrid->SetMarkingObserver(*this); |
|
441 iHgGrid->SetFocus(ETrue); |
|
442 /* |
|
443 * note: don't push hggrid to the control stack |
|
444 */ |
|
445 } |
|
446 // --------------------------------------------------------------------------- |
|
447 // GetHgGridRect |
|
448 // --------------------------------------------------------------------------- |
|
449 // |
|
450 TRect CGlxGridViewContainer::GetHgGridRect() |
|
451 { |
|
452 TRACER("CGlxGridViewContainer::GetHgGridRect()"); |
|
453 TRect clientrect = iEikonEnv->EikAppUi()->ClientRect(); |
|
454 TRect apprect = iEikonEnv->EikAppUi()->ApplicationRect(); |
|
455 if (apprect.Height() > apprect.Width()) |
|
456 { |
|
457 //portrait: |
|
458 //height : apprect height - (status pane height + toolbar height + cba height) |
|
459 //width remains 360. |
|
460 clientrect.SetHeight(apprect.Height() - ((clientrect.iTl.iY) |
|
461 + (iToolbar->Size().iHeight) |
|
462 + (iEikonEnv->AppUiFactory()->Cba()->Rect().Height()))); |
|
463 } |
|
464 else |
|
465 { |
|
466 //Landscape: |
|
467 //height : apprect - (status pane height + cba height) |
|
468 //width : apprect width - toolbarwidth. |
|
469 clientrect.SetHeight(apprect.Height() - ((clientrect.iTl.iY) |
|
470 + (iEikonEnv->AppUiFactory()->Cba()->Rect().Height()))); |
|
471 clientrect.SetWidth(apprect.Width() - iToolbar->Size().iWidth); |
|
472 } |
|
473 return clientrect; |
|
474 } |
|
475 // --------------------------------------------------------------------------- |
|
476 // CreateGridL |
|
477 // --------------------------------------------------------------------------- |
|
478 // |
|
479 void CGlxGridViewContainer::CreateGridL() |
|
480 { |
|
481 TRACER("CGlxGridViewContainer::CreateGridL()"); |
|
482 #ifdef _DEBUG |
|
483 TTime startTime; |
|
484 GLX_LOG_INFO("CGlxGridViewContainer::CreateGridL(+)"); |
|
485 startTime.HomeTime(); |
|
486 #endif |
|
487 // Set the Grid thumbnail context and iterator |
|
488 SetGridThumbnailContextL(); |
|
489 // Create HG Grid widget |
|
490 CreateHgGridWidgetL(); |
|
491 // Create an observer and pass MediaList and HGGrid objects |
|
492 CreateGridMediaListObserverL(); |
|
493 // Create Grid once again after returning from FS as No calls for handleItem added. |
|
494 CreateGridAfterFSDeactivatedL(); |
|
495 #ifdef _DEBUG |
|
496 TTime stopTime; |
|
497 stopTime.HomeTime(); |
|
498 GLX_DEBUG2("CGlxGridViewContainer::CreateGridL(-) took <%d> us", |
|
499 (TInt)stopTime.MicroSecondsFrom(startTime).Int64()); |
|
500 #endif |
|
501 } |
|
502 |
|
503 // --------------------------------------------------------------------------- |
|
504 // SetGridThumbnailContextL |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 void CGlxGridViewContainer::SetGridThumbnailContextL() |
|
508 { |
|
509 TRACER("CGlxGridViewContainer::SetGridThumbnailContextL()"); |
|
510 // show static items again |
|
511 iMediaList->SetStaticItemsEnabled(ETrue); |
|
512 |
|
513 iThumbnailContext = CGlxThumbnailContext::NewL( &iBlockyIterator ); // set the thumbnail context |
|
514 iThumbnailContext->SetDefaultSpec( iGridIconSize.iWidth,iGridIconSize.iHeight ); |
|
515 iMediaList->AddContextL(iThumbnailContext, KGlxFetchContextPriorityNormal ); |
|
516 } |
|
517 |
|
518 // --------------------------------------------------------------------------- |
|
519 // CreateGridMediaListObserverL |
|
520 // --------------------------------------------------------------------------- |
|
521 // |
|
522 void CGlxGridViewContainer::CreateGridMediaListObserverL() |
|
523 { |
|
524 TRACER("CGlxGridViewContainer::CreateGridMediaListObserverL()"); |
|
525 // Creating the Medialist observer for HG Grid |
|
526 iGlxGridMLObserver = CGlxGridViewMLObserver::NewL(*this, *iMediaList, |
|
527 iHgGrid); |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------------------------- |
|
531 // CreateGridAfterFSDeactivatedL |
|
532 // On Returning from the FS View, There is no calls to the handle attribut available, |
|
533 // So repeating the code to view Grid on FS return |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 void CGlxGridViewContainer::CreateGridAfterFSDeactivatedL() |
|
537 { |
|
538 TRACER("CGlxGridViewContainer::CreateGridAfterFSDeactivatedL()"); |
|
539 TInt focusIndex = iMediaList->FocusIndex(); |
|
540 GLX_LOG_INFO1("CreateGridAfterFSDeactivatedL() focusIndex=%d", focusIndex); |
|
541 |
|
542 if (iBackwardActivation) |
|
543 { |
|
544 TInt mlCount = iMediaList->Count(); |
|
545 GLX_LOG_INFO1("CreateGridAfterFSDeactivatedL() mlCount=%d", mlCount); |
|
546 |
|
547 // Setting the Empty Text |
|
548 HBufC* emptyText = |
|
549 StringLoader::LoadLC(R_GRID_EMPTY_VIEW_TEXT); |
|
550 iHgGrid->SetEmptyTextL(*emptyText); |
|
551 CleanupStack::PopAndDestroy(emptyText); |
|
552 |
|
553 if (mlCount <= 0) |
|
554 { |
|
555 GLX_LOG_INFO("CreateGridAfterFSDeactivatedL() - SetEmptyTextL()"); |
|
556 iHgGrid->DrawNow(); |
|
557 } |
|
558 } |
|
559 |
|
560 if (focusIndex != KErrNotFound) |
|
561 { |
|
562 iHgGrid->SetSelectedIndex(focusIndex); |
|
563 iHgGrid->RefreshScreen(focusIndex); |
|
564 } |
|
565 iBackwardActivation = EFalse; |
|
566 } |
|
567 |
|
568 // --------------------------------------------------------------------------- |
|
569 // SetIconsL |
|
570 // --------------------------------------------------------------------------- |
|
571 // |
|
572 void CGlxGridViewContainer::SetIconsL(TInt index) |
|
573 { |
|
574 TRACER("CGlxGridViewContainer::SetIconsL()"); |
|
575 const TGlxMedia& item = iMediaList->Item(index); |
|
576 TInt tnError = GlxErrorManager::HasAttributeErrorL( |
|
577 item.Properties(), KGlxMediaIdThumbnail ); |
|
578 |
|
579 const CGlxThumbnailAttribute* qualityTn = item.ThumbnailAttribute( iQualityTnAttrib ); |
|
580 const CGlxThumbnailAttribute* speedTn = item.ThumbnailAttribute( iSpeedTnAttrib ); |
|
581 |
|
582 if (qualityTn) |
|
583 { |
|
584 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
585 bitmap->Duplicate( qualityTn->iBitmap->Handle()); |
|
586 iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap)); |
|
587 GLX_LOG_INFO1("### CGlxGridViewContainer::SetIconsL qualityTn-Index is %d",index); |
|
588 } |
|
589 else if (speedTn) |
|
590 { |
|
591 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
592 bitmap->Duplicate( speedTn->iBitmap->Handle()); |
|
593 iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap)); |
|
594 GLX_LOG_INFO1("### CGlxGridViewContainer::SetIconsL speedTn-Index is %d",index); |
|
595 } |
|
596 else if ((KErrCANoRights ==tnError) || (KErrDiskFull ==tnError) |
|
597 || (item.Category() == EMPXVideo && KErrNone != tnError)) |
|
598 { |
|
599 /* |
|
600 * this is a safe code added to show default |
|
601 * TNM returns -17452 in case SD DRM files |
|
602 * this code is added as coming from other view to |
|
603 * gridview,it draws broken TN then the callback goes to |
|
604 * glxgridviewobserver and redraws a not-created TN. |
|
605 * with this part of code that TN swich will not be visible |
|
606 * |
|
607 * The same thing is needs to be done for the case when there is no |
|
608 * disk space for the thumbnails to be created. |
|
609 * In such a case we need to show default thumbnails instead of corrupted. |
|
610 * |
|
611 */ |
|
612 GLX_LOG_INFO2( |
|
613 "CGlxGridViewContainer::SetIconsL - image_defaultthumbnail tnError(%d), i(%d)", |
|
614 tnError, index); |
|
615 SetIconL(index, EMbmGlxiconsQgn_prop_image_notcreated, |
|
616 EMbmGlxiconsQgn_prop_image_notcreated_mask); |
|
617 } |
|
618 else if(KErrNone != tnError) |
|
619 { |
|
620 GLX_LOG_INFO2( |
|
621 "CGlxGridViewContainer::SetIconsL - image_corrupted tnError(%d), i(%d)", |
|
622 tnError, index); |
|
623 SetIconL(index, EMbmGlxiconsQgn_prop_image_corrupted, |
|
624 EMbmGlxiconsQgn_prop_image_corrupted_mask); |
|
625 } |
|
626 |
|
627 if (item.IsDrmProtected()) |
|
628 { |
|
629 const TDesC& uri = item.Uri(); |
|
630 if( uri.Length() > 0) |
|
631 { |
|
632 if(iDRMUtility->IsForwardLockedL(uri)) |
|
633 { |
|
634 /* |
|
635 * fix for EABI-7RKHDG |
|
636 * to show the invalid DRM icon |
|
637 */ |
|
638 TMPXGeneralCategory cat = item.Category(); |
|
639 TBool checkViewRights = (cat==EMPXImage); |
|
640 |
|
641 if(iDRMUtility->ItemRightsValidityCheckL(uri, checkViewRights)) |
|
642 { |
|
643 iHgGrid->ItemL(index).SetFlags(CHgItem::EHgItemFlagsDrmRightsValid); |
|
644 } |
|
645 else |
|
646 { |
|
647 iHgGrid->ItemL(index).SetFlags(CHgItem::EHgItemFlagsDrmRightsExpired); |
|
648 } |
|
649 } |
|
650 else |
|
651 { |
|
652 TMPXGeneralCategory cat = item.Category(); |
|
653 TBool checkViewRights = (cat==EMPXImage); |
|
654 |
|
655 if(iDRMUtility->ItemRightsValidityCheckL(uri, checkViewRights)) |
|
656 { |
|
657 iHgGrid->ItemL(index).SetFlags(CHgItem::EHgItemFlagsDrmRightsValid); |
|
658 } |
|
659 else |
|
660 { |
|
661 iHgGrid->ItemL(index).SetFlags(CHgItem::EHgItemFlagsDrmRightsExpired); |
|
662 } |
|
663 } |
|
664 } |
|
665 } |
|
666 TTime time(0); |
|
667 if (item.GetDate(time)) |
|
668 { |
|
669 iHgGrid->ItemL(index).SetTime(time); |
|
670 } |
|
671 |
|
672 if (item.Category() == EMPXVideo) |
|
673 { |
|
674 iHgGrid->ItemL(index).SetFlags(CHgItem::EHgItemFlagsVideo); |
|
675 } |
|
676 } |
|
677 |
|
678 // ---------------------------------------------------------------------------- |
|
679 // SetIconL |
|
680 // ---------------------------------------------------------------------------- |
|
681 // |
|
682 void CGlxGridViewContainer::SetIconL(TInt aItemIndex, TInt aBitmapId, |
|
683 TInt aMaskId) |
|
684 { |
|
685 TRACER("CGlxGridViewContainer::SetIconL()"); |
|
686 CFbsBitmap* bitmap = NULL; |
|
687 CFbsBitmap* mask = NULL; |
|
688 TSize setSize = CHgGrid::PreferredImageSize(); |
|
689 AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone, bitmap, |
|
690 mask, iIconsFileName, aBitmapId, aMaskId); |
|
691 __ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer)); |
|
692 __ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer)); |
|
693 |
|
694 AknIconUtils::SetSize(bitmap, setSize, |
|
695 EAspectRatioPreservedAndUnusedSpaceRemoved); |
|
696 AknIconUtils::SetSize(mask, setSize, |
|
697 EAspectRatioPreservedAndUnusedSpaceRemoved); |
|
698 |
|
699 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap, mask)); |
|
700 CleanupStack::Pop(mask); |
|
701 CleanupStack::Pop(bitmap); |
|
702 } |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // MopSupplyObject |
|
706 // To handle Skin support |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 TTypeUid::Ptr CGlxGridViewContainer::MopSupplyObject(TTypeUid aId) |
|
710 { |
|
711 TRACER("CGlxGridViewContainer::MopSupplyObject()"); |
|
712 if (iBgContext) |
|
713 { |
|
714 return MAknsControlContext::SupplyMopObject(aId, iBgContext ); |
|
715 } |
|
716 return CCoeControl::MopSupplyObject( aId ); |
|
717 } |
|
718 |
|
719 // --------------------------------------------------------------------------- |
|
720 // HandleMultipleMarkingL |
|
721 // --------------------------------------------------------------------------- |
|
722 // |
|
723 void CGlxGridViewContainer::HandleMultipleMarkingL(TInt aIndex , TBool aMarked ) |
|
724 { |
|
725 TRACER("CGlxGridViewContainer::HandleMultipleMarkingL()"); |
|
726 //@ fix for EIZU-7RE43S |
|
727 if(!iMediaList->Item(aIndex).IsStatic() && iHgGrid) |
|
728 { |
|
729 if(aMarked) |
|
730 { |
|
731 iGlxGridViewObserver.HandleGridEventsL(EAknCmdMark) ; |
|
732 |
|
733 } |
|
734 else |
|
735 { |
|
736 iGlxGridViewObserver.HandleGridEventsL(EAknCmdUnmark) ; |
|
737 |
|
738 } |
|
739 } |
|
740 |
|
741 // This check is only implicated when multiple marking mode and we mark static items |
|
742 // As Hg Grid marks the items on the screen, we have to unmark the same. |
|
743 if (iMediaList->Item(aIndex).IsStatic()) |
|
744 { |
|
745 iHgGrid->UnMark(aIndex); |
|
746 } |
|
747 } |
|
748 |
|
749 // --------------------------------------------------------------------------- |
|
750 // HandleViewCommandL |
|
751 // Command handling function. |
|
752 // --------------------------------------------------------------------------- |
|
753 TBool CGlxGridViewContainer::HandleViewCommandL(TInt aCommand) |
|
754 { |
|
755 TRACER("CGlxGridViewContainer::HandleViewCommandL()"); |
|
756 GLX_LOG_INFO1( "CGlxGridViewContainer::HandleViewCommandL(%x) entering", aCommand ); |
|
757 |
|
758 TBool retVal = EFalse; |
|
759 TInt focusIndex = iMediaList->FocusIndex(); |
|
760 switch (aCommand) |
|
761 { |
|
762 case EAknCmdOpen: |
|
763 { |
|
764 GLX_LOG_INFO( "EAknCmdOpen" ); |
|
765 // Activate Fullscreen |
|
766 GLX_LOG_INFO("CGlxGridViewContainer::HandleViewCommandL - EAKnCmdOpen received"); |
|
767 if ( !iFullscreenViewActivated && !iMultipleMarkingActive && |
|
768 focusIndex != KErrNotFound) |
|
769 { |
|
770 const TGlxMedia& item = iMediaList->Item(focusIndex); |
|
771 const TDesC& uri = item.Uri(); |
|
772 |
|
773 if ( item.IsStatic() ) |
|
774 { |
|
775 TInt cmd = 0; |
|
776 if( item.GetStaticItemCommand(cmd) ) |
|
777 { |
|
778 iGlxGridViewObserver.HandleGridEventsL(cmd) ; |
|
779 } |
|
780 } |
|
781 else if(item.Category() == EMPXVideo) |
|
782 { |
|
783 //Fix for ESLM-7U58CG - here since we get |
|
784 //multiple HandleOpen( ) event on multiple tap |
|
785 //we need to guard the event by a flag. |
|
786 if(!iIsFSVideoViewActivating) |
|
787 { |
|
788 iIsFSVideoViewActivating = ETrue; |
|
789 iFullscreenViewActivated = ETrue; |
|
790 iGlxGridViewObserver.HandleGridEventsL(EGlxCmdPlay) ; |
|
791 iIsFSVideoViewActivating = EFalse; |
|
792 } |
|
793 } |
|
794 else |
|
795 { |
|
796 iFullscreenViewActivated = ETrue; |
|
797 iNavigationalstate->SetToViewMode(); |
|
798 } |
|
799 } |
|
800 |
|
801 //@ fix for EIZU-7RE43S |
|
802 if(iMultipleMarkingActive) |
|
803 { |
|
804 //If in marking mode Mark/Unmark the item |
|
805 //appropriately. |
|
806 if(iMediaList->IsSelected(focusIndex)) |
|
807 { |
|
808 iGlxGridViewObserver.HandleGridEventsL(EAknCmdUnmark) ; |
|
809 } |
|
810 else |
|
811 { |
|
812 iGlxGridViewObserver.HandleGridEventsL(EAknCmdMark) ; |
|
813 } |
|
814 } |
|
815 retVal = ETrue; |
|
816 break; |
|
817 } |
|
818 |
|
819 case EAknCmdMark: |
|
820 { |
|
821 iHgGrid->SetFlags( CHgScroller::EHgScrollerSelectionMode ); |
|
822 //Start Marking mode on grid. |
|
823 iMultipleMarkingActive = ETrue; |
|
824 //@ fix for EIZU-7RE43S |
|
825 iHgGrid->Mark(focusIndex); |
|
826 iHgGrid->RefreshScreen(focusIndex); |
|
827 retVal = ETrue; |
|
828 break; |
|
829 } |
|
830 |
|
831 case EAknCmdUnmark: |
|
832 { |
|
833 //@ fix for EIZU-7RE43S |
|
834 iHgGrid->UnMark(focusIndex); |
|
835 iHgGrid->RefreshScreen(focusIndex); |
|
836 retVal = ETrue; |
|
837 break; |
|
838 } |
|
839 |
|
840 case EAknMarkAll: |
|
841 { |
|
842 //Start Marking mode on grid. |
|
843 iMultipleMarkingActive = ETrue; |
|
844 iHgGrid->SetFlags( CHgScroller::EHgScrollerSelectionMode ); |
|
845 iHgGrid->MarkAll(); |
|
846 |
|
847 // If the 0th item is static, then it must be downloads, |
|
848 // so unmark 0th and 1st item |
|
849 // corresponding to image and vieo icons |
|
850 const TGlxMedia& item = iMediaList->Item(0); |
|
851 if (item.IsStatic()) |
|
852 { |
|
853 // Assuming that the first two items are static |
|
854 iHgGrid->UnMark(0); |
|
855 iHgGrid->UnMark(1); |
|
856 } |
|
857 // When mark all after some item is marked using toolbar |
|
858 // it directly goes to commandhandler, so it returns not |
|
859 // consumed after marking medialist |
|
860 // and view marks on the display |
|
861 // The Check prevents looping from view to mark and vice versa |
|
862 // @ fix for ESLM-7TQGMP |
|
863 if (iMediaList->SelectionCount() < 1) |
|
864 { |
|
865 iGlxGridViewObserver.HandleGridEventsL(aCommand) ; |
|
866 } |
|
867 retVal = ETrue; |
|
868 break; |
|
869 } |
|
870 |
|
871 case EAknUnmarkAll: |
|
872 { |
|
873 if(iHgGrid) |
|
874 { |
|
875 iHgGrid->UnMarkAll(); |
|
876 iHgGrid->RefreshScreen(iMediaList->Count()-1); |
|
877 if (!iMultipleMarkingActive) |
|
878 { |
|
879 iHgGrid->ClearFlags( CHgScroller::EHgScrollerSelectionMode ); |
|
880 } |
|
881 iGlxGridViewObserver.HandleLatchToolbar(); |
|
882 iGlxGridViewObserver.HandleGridEventsL(EGlxCmdEndMultipleMarking); |
|
883 } |
|
884 break; |
|
885 } |
|
886 |
|
887 case EGlxCmdEndMultipleMarking: |
|
888 { |
|
889 iMultipleMarkingActive = EFalse; |
|
890 iHgGrid->ClearFlags( CHgScroller::EHgScrollerSelectionMode ); |
|
891 // Turn off the marking mode only if the event is from toolbar marking button. |
|
892 //Unlatch the mark toolbar button upon exiting the marking mode |
|
893 if(iEikonEnv->AppUiFactory()->ToolBar()) |
|
894 { |
|
895 // This will unmark the items after adding an album/tag |
|
896 // Have to find a better solution and unmark only the items |
|
897 // marked and not all, might be a perf hit |
|
898 if(iHgGrid) |
|
899 { |
|
900 iHgGrid->UnMarkAll(); |
|
901 } |
|
902 iGlxGridViewObserver.HandleLatchToolbar(); |
|
903 } |
|
904 retVal = ETrue; |
|
905 break; |
|
906 } |
|
907 |
|
908 case EGlxCmdStartMultipleMarking: |
|
909 { |
|
910 if( iHgGrid->Flags() & CHgScroller::EHgScrollerSelectionMode ) |
|
911 { |
|
912 iHgGrid->ClearFlags( CHgScroller::EHgScrollerSelectionMode ); |
|
913 // Refreshing the items selected after unmark |
|
914 for (TInt i= 0;i<iMediaList->SelectionCount();i++) |
|
915 { |
|
916 TInt selectedItemIndex = iMediaList->SelectedItemIndex(i); |
|
917 iHgGrid->UnMark(selectedItemIndex); |
|
918 iHgGrid->RefreshScreen(selectedItemIndex); |
|
919 } |
|
920 iGlxGridViewObserver.HandleGridEventsL(EGlxCmdEndMultipleMarking) ; |
|
921 } |
|
922 else |
|
923 { |
|
924 //Start Marking mode on grid. |
|
925 iMultipleMarkingActive = ETrue; |
|
926 iHgGrid->SetFlags(CHgScroller::EHgScrollerSelectionMode); |
|
927 } |
|
928 retVal = ETrue; |
|
929 break; |
|
930 } |
|
931 |
|
932 case EAknSoftkeyCancel: |
|
933 { |
|
934 //@ fix for EIZU-7RE43S |
|
935 if( iHgGrid->Flags() & CHgScroller::EHgScrollerSelectionMode ) |
|
936 { |
|
937 iGlxGridViewObserver.HandleGridEventsL(EGlxCmdEndMultipleMarking) ; |
|
938 } |
|
939 retVal = ETrue; |
|
940 break; |
|
941 |
|
942 } |
|
943 case EGlxCmdResetView: |
|
944 { |
|
945 //@ fix for ESLM-7VRGKH |
|
946 if(iHgGrid) |
|
947 { |
|
948 iHgGrid->InitScreenL(GetHgGridRect()); |
|
949 } |
|
950 if (iIsDialogLaunched && iIsMMCRemoved) |
|
951 { |
|
952 iGlxGridViewObserver.HandleGridEventsL(EAknSoftkeyExit); |
|
953 } |
|
954 retVal = ETrue; |
|
955 iIsDialogLaunched = EFalse; |
|
956 break; |
|
957 } |
|
958 case EGlxCmdDialogLaunched: |
|
959 { |
|
960 iIsDialogLaunched = ETrue; |
|
961 break; |
|
962 } |
|
963 case EGlxCmdDialogDismissed: |
|
964 { |
|
965 if (iIsDialogLaunched && iIsMMCRemoved) |
|
966 { |
|
967 iGlxGridViewObserver.HandleGridEventsL(EAknSoftkeyExit); |
|
968 } |
|
969 |
|
970 iIsDialogLaunched = EFalse; |
|
971 retVal = ETrue; |
|
972 break; |
|
973 } |
|
974 default: |
|
975 break; |
|
976 } |
|
977 GLX_LOG_INFO("CGlxGridViewContainer::HandleViewCommandL() exiting"); |
|
978 return retVal; |
|
979 } |
|
980 |
|
981 // --------------------------------------------------------------------------- |
|
982 // HandleResourceChange |
|
983 // Handle BG screen context && Hg grid orientaion |
|
984 // --------------------------------------------------------------------------- |
|
985 // |
|
986 void CGlxGridViewContainer::HandleResourceChange(TInt aId) |
|
987 { |
|
988 TRACER("CGlxGridViewContainer::HandleResourceChange()"); |
|
989 CCoeControl::HandleResourceChange(aId); |
|
990 switch (aId) |
|
991 { |
|
992 case KEikDynamicLayoutVariantSwitch: |
|
993 { |
|
994 if ( iBgContext ) |
|
995 { |
|
996 TRect apRect = iEikonEnv->EikAppUi()->ApplicationRect(); |
|
997 iBgContext->SetRect( apRect ); |
|
998 } |
|
999 if(iHgGrid) |
|
1000 { |
|
1001 TRAP_IGNORE (iHgGrid->InitScreenL(GetHgGridRect());) |
|
1002 } |
|
1003 break; |
|
1004 } |
|
1005 default: |
|
1006 break; |
|
1007 } |
|
1008 } |
|
1009 |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // HandleMMCInsertionL |
|
1012 // |
|
1013 // --------------------------------------------------------------------------- |
|
1014 void CGlxGridViewContainer::HandleMMCInsertionL() |
|
1015 { |
|
1016 TRACER("CGlxGridViewContainer::HandleMMCInsertionL()"); |
|
1017 iGlxGridViewObserver.HandleGridEventsL(EAknSoftkeyClose); |
|
1018 } |
|
1019 |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // HandleMMCRemovalL |
|
1022 // |
|
1023 // --------------------------------------------------------------------------- |
|
1024 void CGlxGridViewContainer::HandleMMCRemovalL() |
|
1025 { |
|
1026 TRACER("CGlxGridViewContainer::HandleMMCRemovalL()"); |
|
1027 iIsMMCRemoved = ETrue; |
|
1028 if(!iIsDialogLaunched) |
|
1029 { |
|
1030 iGlxGridViewObserver.HandleGridEventsL(EAknSoftkeyExit); |
|
1031 } |
|
1032 } |
|
1033 //end of file |