photosgallery/viewframework/views/gridview/src/glxgridviewmlobserver.cpp
branchRCL_3
changeset 35 420f6808bf21
parent 32 78ad99c24f08
child 47 f9e827349359
equal deleted inserted replaced
32:78ad99c24f08 35:420f6808bf21
    32 #include <glxuistd.h>
    32 #include <glxuistd.h>
    33 #include <mglxmedialist.h>                              // CGlxMedialist
    33 #include <mglxmedialist.h>                              // CGlxMedialist
    34 #include <glxthumbnailattributeinfo.h>                  // KGlxMediaIdThumbnail
    34 #include <glxthumbnailattributeinfo.h>                  // KGlxMediaIdThumbnail
    35 #include <glxdrmutility.h>                              // DRM utility class to provide DRM-related functionality
    35 #include <glxdrmutility.h>                              // DRM utility class to provide DRM-related functionality
    36 #include <mpxmediadrmdefs.h>                            // KMPXMediaDrmProtected
    36 #include <mpxmediadrmdefs.h>                            // KMPXMediaDrmProtected
    37 #include <glxcollectionplugindownloads.hrh>
       
    38 #include <glxgridviewdata.rsg>                          // Gridview resource
    37 #include <glxgridviewdata.rsg>                          // Gridview resource
    39 #include <glxgeneraluiutilities.h>
    38 #include <glxgeneraluiutilities.h>
    40 
    39 
    41 // Framework
    40 // Framework
    42 #include <data_caging_path_literals.hrh>
    41 #include <data_caging_path_literals.hrh>
   256             bitmap->Duplicate(speedTn->iBitmap->Handle());
   255             bitmap->Duplicate(speedTn->iBitmap->Handle());
   257             iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap));
   256             iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap));
   258             GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL"
   257             GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL"
   259                     " speedTn-Index is %d",aItemIndex);
   258                     " speedTn-Index is %d",aItemIndex);
   260             }
   259             }
   261         else if ( KErrNone != tnError && KErrNotSupported != tnError &&
   260         else if (item.Category() == EMPXVideo && KErrNone != tnError)
   262                             KErrArgument != tnError )
   261             {
   263             {
   262             SetIconL(aItemIndex, EMbmGlxiconsQgn_prop_image_notcreated,
   264             CFbsBitmap* bitmap = NULL;
   263                     EMbmGlxiconsQgn_prop_image_notcreated_mask,
   265             CFbsBitmap* mask = NULL;
   264 					CHgItem::EHgItemFlagsVideo);
   266             AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
   265             }
   267                     bitmap, mask, iIconsFileName,
   266         else if (KErrNone != tnError && KErrNotSupported != tnError
   268                     EMbmGlxiconsQgn_prop_image_corrupted,
   267                 && KErrArgument != tnError)
   269                     EMbmGlxiconsQgn_prop_image_corrupted_mask);
   268             {
   270             __ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
   269             SetIconL(aItemIndex, EMbmGlxiconsQgn_prop_image_corrupted,
   271             __ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer));
   270                     EMbmGlxiconsQgn_prop_image_corrupted_mask,
   272             
   271 					CHgItem::EHgItemFlagsNone);
   273             AknIconUtils::SetSize(bitmap, setSize,
       
   274                     EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   275             AknIconUtils::SetSize(mask, setSize,
       
   276                     EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   277 
       
   278             iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap, mask));
       
   279             CleanupStack::Pop(mask);
       
   280             CleanupStack::Pop(bitmap);
       
   281             }
   272             }
   282         }
   273         }
   283     
   274     
   284     //Now Update the items with the DRM/video icon and  date/time 
   275     //Now Update the items with the DRM/video icon and  date/time 
   285     UpdateItemsL(aItemIndex,aAttributes);
   276     UpdateItemsL(aItemIndex,aAttributes);
   286     
   277     
   287     //Now refresh the screen based on the attributes available index
   278     //Now refresh the screen based on the attributes available index
   288     RefreshScreen(aItemIndex,aAttributes);
   279     RefreshScreenL(aItemIndex,aAttributes);
   289     }
   280     }
   290     
   281     
   291 // ----------------------------------------------------------------------------
   282 // ----------------------------------------------------------------------------
   292 // HandleFocusChangedL
   283 // HandleFocusChangedL
   293 // ----------------------------------------------------------------------------
   284 // ----------------------------------------------------------------------------
   346     TRACER("CGlxGridViewMLObserver::HandleErrorL()");
   337     TRACER("CGlxGridViewMLObserver::HandleErrorL()");
   347 
   338 
   348     TInt bitmapId  = EMbmGlxiconsQgn_prop_image_corrupted;
   339     TInt bitmapId  = EMbmGlxiconsQgn_prop_image_corrupted;
   349     TInt maskId = EMbmGlxiconsQgn_prop_image_corrupted_mask;	
   340     TInt maskId = EMbmGlxiconsQgn_prop_image_corrupted_mask;	
   350     TInt flags     = CHgItem::EHgItemFlagsNone ;
   341     TInt flags     = CHgItem::EHgItemFlagsNone ;
   351     TSize setSize = CHgGrid::PreferredImageSize();
       
   352     
   342     
   353     for ( TInt i = 0; i < iMediaList.Count(); i++ )
   343     for ( TInt i = 0; i < iMediaList.Count(); i++ )
   354         {
   344         {
   355         const TGlxMedia& item = iMediaList.Item( i );
   345         const TGlxMedia& item = iMediaList.Item( i );
   356         TInt thumbnailError = GlxErrorManager::HasAttributeErrorL(
   346         TInt thumbnailError = GlxErrorManager::HasAttributeErrorL(
   373                         {
   363                         {
   374                         DisplayErrorNoteL(KErrDiskFull);
   364                         DisplayErrorNoteL(KErrDiskFull);
   375                         }
   365                         }
   376                     break;
   366                     break;
   377                 default:
   367                 default:
   378                     bitmapId  = EMbmGlxiconsQgn_prop_image_corrupted;
   368                     {
   379 					maskId = EMbmGlxiconsQgn_prop_image_corrupted_mask;
   369                     if (item.Category() == EMPXVideo)
   380                     flags     = CHgItem::EHgItemFlagsNone ;
   370                         {
       
   371                         bitmapId = EMbmGlxiconsQgn_prop_image_notcreated;
       
   372                         maskId = EMbmGlxiconsQgn_prop_image_notcreated_mask;
       
   373 						flags = CHgItem::EHgItemFlagsVideo;
       
   374                         }
       
   375                     else
       
   376                         {
       
   377                         bitmapId = EMbmGlxiconsQgn_prop_image_corrupted;
       
   378                         maskId = EMbmGlxiconsQgn_prop_image_corrupted_mask;
       
   379                     	flags = CHgItem::EHgItemFlagsNone;
       
   380 					    }
       
   381 
       
   382                     }
   381                     break;  
   383                     break;  
   382                 }
   384                 }
   383             
   385             
   384             CFbsBitmap* bitmap = NULL;
   386             SetIconL(i, bitmapId, maskId, flags);
   385             CFbsBitmap* mask = NULL;
       
   386             AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
       
   387                     bitmap, mask, iIconsFileName, bitmapId, maskId);
       
   388             __ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
       
   389             __ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer));
       
   390 
       
   391             AknIconUtils::SetSize(bitmap, setSize,
       
   392                     EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   393             AknIconUtils::SetSize(mask, setSize,
       
   394                     EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   395 
       
   396             iHgGrid->ItemL(i).SetIcon(CGulIcon::NewL(bitmap, mask), flags);
       
   397             CleanupStack::Pop(mask); 
       
   398             CleanupStack::Pop(bitmap); 
       
   399             }
   387             }
   400         }
   388         }
   401     iHgGrid->RefreshScreen(iHgGrid->FirstIndexOnScreen());    
   389     iHgGrid->RefreshScreen(iHgGrid->FirstIndexOnScreen());    
   402     }
   390     }
   403     
   391 
       
   392 // ----------------------------------------------------------------------------
       
   393 // SetIconL
       
   394 // ----------------------------------------------------------------------------
       
   395 //  
       
   396 void CGlxGridViewMLObserver::SetIconL(TInt aItemIndex, TInt aBitmapId,
       
   397         TInt aMaskId, TInt aFlags)
       
   398     {
       
   399     TRACER("CGlxGridViewMLObserver::SetIconL()");
       
   400     CFbsBitmap* bitmap = NULL;
       
   401     CFbsBitmap* mask = NULL;
       
   402     TSize setSize = CHgGrid::PreferredImageSize();
       
   403     AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone, bitmap,
       
   404             mask, iIconsFileName, aBitmapId, aMaskId);
       
   405     __ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
       
   406     __ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer));
       
   407 
       
   408     AknIconUtils::SetSize(bitmap, setSize,
       
   409             EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   410     AknIconUtils::SetSize(mask, setSize,
       
   411             EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   412 
       
   413     iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap, mask), aFlags);
       
   414     CleanupStack::Pop(mask);
       
   415     CleanupStack::Pop(bitmap);
       
   416     }
       
   417 
   404 // ----------------------------------------------------------------------------
   418 // ----------------------------------------------------------------------------
   405 // HandleCommandCompleteL
   419 // HandleCommandCompleteL
   406 // ----------------------------------------------------------------------------
   420 // ----------------------------------------------------------------------------
   407 //  
   421 //  
   408 void CGlxGridViewMLObserver::HandleCommandCompleteL( CMPXCommand* /*aCommandResult*/, 
   422 void CGlxGridViewMLObserver::HandleCommandCompleteL( CMPXCommand* /*aCommandResult*/, 
   500     return EFalse;
   514     return EFalse;
   501     }
   515     }
   502 
   516 
   503 
   517 
   504 // ----------------------------------------------------------------------------
   518 // ----------------------------------------------------------------------------
   505 // RefreshScreen
   519 // RefreshScreenL
   506 // ----------------------------------------------------------------------------
   520 // ----------------------------------------------------------------------------
   507 // 
   521 // 
   508 void CGlxGridViewMLObserver::RefreshScreen(TInt aItemIndex,
   522 void CGlxGridViewMLObserver::RefreshScreenL(TInt aItemIndex,
   509                                       const RArray<TMPXAttribute>& aAttributes)
   523                                       const RArray<TMPXAttribute>& aAttributes)
   510     {
   524     {
   511     TRACER("CGlxGridViewMLObserver::RefreshScreen()");
   525     TRACER("CGlxGridViewMLObserver::RefreshScreenL()");
   512     GLX_DEBUG2("CGlxGridViewMLObserver::RefreshScreen(%d)", aItemIndex);
   526     GLX_DEBUG2("CGlxGridViewMLObserver::RefreshScreenL(%d)", aItemIndex);
   513     TInt mediaCount = iMediaList.Count();
   527     TInt mediaCount = iMediaList.Count();
   514     TInt firstIndex = iHgGrid->FirstIndexOnScreen();
   528     TInt firstIndex = iHgGrid->FirstIndexOnScreen();
   515     firstIndex = (firstIndex<0 ? 0 : firstIndex);
   529     firstIndex = (firstIndex<0 ? 0 : firstIndex);
   516     TInt lastOnScreen = firstIndex + iHgGrid->ItemsOnScreen() - 1;
   530     TInt lastOnScreen = firstIndex + iHgGrid->ItemsOnScreen() - 1;
   517     lastOnScreen = (lastOnScreen >mediaCount-1? mediaCount-1:lastOnScreen);
   531     lastOnScreen = (lastOnScreen >mediaCount-1? mediaCount-1:lastOnScreen);