photosgallery/viewframework/views/gridview/src/glxgridviewcontainer.cpp
branchRCL_3
changeset 9 6b87b143d312
parent 3 9a9c174934f5
child 14 ce1c7ad1f18b
equal deleted inserted replaced
5:f7f0874bfe7d 9:6b87b143d312
    17 #include <AknUtils.h>                               	// For AknLayoutUtils to calculate rect
    17 #include <AknUtils.h>                               	// For AknLayoutUtils to calculate rect
    18 #include <glxtracer.h>
    18 #include <glxtracer.h>
    19 #include <StringLoader.h>
    19 #include <StringLoader.h>
    20 #include <AknsBasicBackgroundControlContext.h>
    20 #include <AknsBasicBackgroundControlContext.h>
    21 #include <caf/caferr.h>
    21 #include <caf/caferr.h>
    22 
    22 #include <eikcolib.h> 
    23 // Ganes Headers
    23 // Ganes Headers
    24 #include <gulicon.h>                                    // Gul Icons
    24 #include <gulicon.h>                                    // Gul Icons
    25 #include <ganes/HgItem.h>                               // HG Items
    25 #include <ganes/HgItem.h>                               // HG Items
    26 #include <ganes/HgGrid.h>                               // Hg Grid Widget
    26 #include <ganes/HgGrid.h>                               // Hg Grid Widget
    27 
    27 
    53 // Two-phased constructor.
    53 // Two-phased constructor.
    54 // ---------------------------------------------------------------------------
    54 // ---------------------------------------------------------------------------
    55 //
    55 //
    56 CGlxGridViewContainer* CGlxGridViewContainer::NewL(MGlxMediaList *aMediaList,
    56 CGlxGridViewContainer* CGlxGridViewContainer::NewL(MGlxMediaList *aMediaList,
    57 														CGlxUiUtility* aUiUtility,
    57 														CGlxUiUtility* aUiUtility,
    58 																	MGlxGridEventObserver& aObserver)
    58 																	MGlxGridEventObserver& aObserver,CAknToolbar* aToolbar)
    59 	{
    59 	{
    60 	TRACER("CGlxGridViewContainer::NewL");
    60 	TRACER("CGlxGridViewContainer::NewL");
    61 	CGlxGridViewContainer* self = CGlxGridViewContainer::NewLC(aMediaList,aUiUtility,aObserver) ;
    61 	CGlxGridViewContainer* self = CGlxGridViewContainer::NewLC(aMediaList,aUiUtility,aObserver,aToolbar) ;
    62 	CleanupStack::Pop(self) ;
    62 	CleanupStack::Pop(self) ;
    63 	return self ;
    63 	return self ;
    64 	}
    64 	}
    65 	
    65 	
    66 // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
    67 // Two-phased constructor.
    67 // Two-phased constructor.
    68 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    69 //
    69 //
    70 CGlxGridViewContainer* CGlxGridViewContainer::NewLC(MGlxMediaList *aMediaList,
    70 CGlxGridViewContainer* CGlxGridViewContainer::NewLC(MGlxMediaList *aMediaList,
    71 														CGlxUiUtility* aUiUtility,
    71 														CGlxUiUtility* aUiUtility,
    72 																	MGlxGridEventObserver& aObserver)
    72 																	MGlxGridEventObserver& aObserver,CAknToolbar* aToolbar)
    73 	{
    73 	{
    74 	TRACER("CGlxGridViewContainer::NewLC");
    74 	TRACER("CGlxGridViewContainer::NewLC");
    75 	CGlxGridViewContainer* self = new(ELeave) CGlxGridViewContainer(aMediaList,aUiUtility,aObserver);
    75 	CGlxGridViewContainer* self = new(ELeave) CGlxGridViewContainer(aMediaList,aUiUtility,aObserver,aToolbar);
    76 	CleanupStack::PushL(self ) ;
    76 	CleanupStack::PushL(self ) ;
    77 	self->ConstructL() ;
    77 	self->ConstructL() ;
    78 	return self ;
    78 	return self ;
    79 	}
    79 	}
    80 	
    80 	
   120 // C++ default constructor can NOT contain any code, that
   120 // C++ default constructor can NOT contain any code, that
   121 // might leave.
   121 // might leave.
   122 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   123 //
   123 //
   124 CGlxGridViewContainer::CGlxGridViewContainer(MGlxMediaList *aMediaList,CGlxUiUtility* aUiUtility,
   124 CGlxGridViewContainer::CGlxGridViewContainer(MGlxMediaList *aMediaList,CGlxUiUtility* aUiUtility,
   125 																MGlxGridEventObserver& aObserver)
   125 																MGlxGridEventObserver& aObserver,CAknToolbar* aToolbar)
   126 					: iMediaList(aMediaList),iUiUtility(aUiUtility),iGlxGridViewObserver(aObserver)
   126 					: iMediaList(aMediaList),iUiUtility(aUiUtility),iGlxGridViewObserver(aObserver),iToolbar(aToolbar)
   127 		{
   127 		{
   128 		TRACER("CGlxGridViewContainer::CGlxGridViewContainer");
   128 		TRACER("CGlxGridViewContainer::CGlxGridViewContainer");
   129 		}
   129 		}
   130 	
   130 	
   131 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   378 		TFileName resFile(KDC_APP_BITMAP_DIR);
   378 		TFileName resFile(KDC_APP_BITMAP_DIR);
   379 		resFile.Append(KGlxIconsFilename);
   379 		resFile.Append(KGlxIconsFilename);
   380 		CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile,
   380 		CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile,
   381 				EMbmGlxiconsQgn_prop_image_notcreated);
   381 				EMbmGlxiconsQgn_prop_image_notcreated);
   382         AknIconUtils::SetSize(bitmap, tnSize);
   382         AknIconUtils::SetSize(bitmap, tnSize);
   383 		TRect rect = iEikonEnv->EikAppUi()->ClientRect();
       
   384 		// Create Hg grid object
   383 		// Create Hg grid object
   385 		iHgGrid = CHgGrid::NewL (rect,mediaCount,CGulIcon::NewL(bitmap));
   384 		iHgGrid = CHgGrid::NewL (GetHgGridRect(),mediaCount,CGulIcon::NewL(bitmap));
   386 		}
   385 		}
   387 
   386 
   388 	// Setting to MopParent to update background skin
   387 	// Setting to MopParent to update background skin
   389 	iHgGrid->SetMopParent(this);
   388 	iHgGrid->SetMopParent(this);
   390 	// Setting Selction observer for getting callback on key event change
   389 	// Setting Selction observer for getting callback on key event change
   402 	iHgGrid->SetFocus(ETrue);
   401 	iHgGrid->SetFocus(ETrue);
   403 	/*
   402 	/*
   404 	 * note: don't push hggrid to the control stack
   403 	 * note: don't push hggrid to the control stack
   405 	 */
   404 	 */
   406 	}
   405 	}
   407 
   406 // ---------------------------------------------------------------------------
       
   407 // GetHgGridRect
       
   408 // ---------------------------------------------------------------------------
       
   409 //
       
   410 TRect CGlxGridViewContainer::GetHgGridRect()
       
   411     {
       
   412     TRACER("CGlxGridViewContainer::GetHgGridRect()");
       
   413     
       
   414     TRect clientrect = iEikonEnv->EikAppUi()->ClientRect();
       
   415     TRect apprect = iEikonEnv->EikAppUi()->ApplicationRect();	
       
   416     if(apprect.Height()>apprect.Width())
       
   417         {
       
   418         //portrait:
       
   419         //height : apprect height - (status pane height + toolbar height + cba height)
       
   420         //width remains 360.
       
   421         clientrect.SetHeight(apprect.Height() - ((clientrect.iTl.iY) + (iToolbar->Size().iHeight) + (iEikonEnv->AppUiFactory()->Cba()->Rect().Height())));
       
   422         }
       
   423     else
       
   424         {
       
   425         //Landscape:
       
   426         //height : apprect - (status pane height + cba height)
       
   427         //width  : apprect width - toolbarwidth.
       
   428         clientrect.SetHeight(apprect.Height() - ((clientrect.iTl.iY) + (iEikonEnv->AppUiFactory()->Cba()->Rect().Height())));
       
   429         clientrect.SetWidth(apprect.Width() - iToolbar->Size().iWidth);
       
   430         }        
       
   431     return clientrect;
       
   432     }
   408 // ---------------------------------------------------------------------------
   433 // ---------------------------------------------------------------------------
   409 // CreateGridL
   434 // CreateGridL
   410 // ---------------------------------------------------------------------------
   435 // ---------------------------------------------------------------------------
   411 //
   436 //
   412 void CGlxGridViewContainer::CreateGridL()
   437 void CGlxGridViewContainer::CreateGridL()
   520 		CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   545 		CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   521 		bitmap->Duplicate( speedTn->iBitmap->Handle());
   546 		bitmap->Duplicate( speedTn->iBitmap->Handle());
   522 		iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap));
   547 		iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap));
   523 		GLX_LOG_INFO1("### CGlxGridViewContainer::SetIconsL speedTn-Index is %d",index);
   548 		GLX_LOG_INFO1("### CGlxGridViewContainer::SetIconsL speedTn-Index is %d",index);
   524 		}
   549 		}
   525 	else if ( KErrNone != tnError && KErrNotSupported != tnError && KErrCANoRights !=tnError)
   550 	else if ((KErrCANoRights ==tnError) || (KErrDiskFull ==tnError))
   526 		{
   551 		{
   527 		GLX_LOG_INFO2("CGlxGridViewContainer::SetIconsL - image_corrupted tnError(%d), i(%d)",
   552 		/*
   528 				tnError, index);
       
   529 		CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile,
       
   530 				EMbmGlxiconsQgn_prop_image_corrupted);
       
   531 		AknIconUtils::SetSize(bitmap, setSize);
       
   532 		iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap));
       
   533 		}
       
   534 	else if (KErrCANoRights ==tnError)
       
   535 		{
       
   536 		/*fix for EABI-7RKHDG
       
   537 		 * this is a safe code added to show default
   553 		 * this is a safe code added to show default
   538 		 * TNM returns -17452 in case SD DRM files
   554 		 * TNM returns -17452 in case SD DRM files
   539 		 * this code is added as coming from other view to
   555 		 * this code is added as coming from other view to
   540 		 * gridview,it draws broken TN then the callback goes to
   556 		 * gridview,it draws broken TN then the callback goes to
   541 		 * glxgridviewobserver and redraws a not-created TN.
   557 		 * glxgridviewobserver and redraws a not-created TN.
   542 		 * with this part of code that TN swich will not be visible
   558 		 * with this part of code that TN swich will not be visible
       
   559 		 * 
       
   560 		 * The same thing is needs to be done for the case when there is no 
       
   561 		 * disk space for the thumbnails to be created. 
       
   562 		 * In such a case we need to show default thumbnails instead of corrupted. 
       
   563 		 * 
   543 		 */
   564 		 */
   544 		GLX_LOG_INFO2("CGlxGridViewContainer::SetIconsL - image_defaultthumbnail tnError(%d), i(%d)",
   565 		GLX_LOG_INFO2("CGlxGridViewContainer::SetIconsL - image_defaultthumbnail tnError(%d), i(%d)",
   545 				tnError, index);
   566 				tnError, index);
   546 		CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile,
   567 		CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile,
   547 				EMbmGlxiconsQgn_prop_image_notcreated);
   568 				EMbmGlxiconsQgn_prop_image_notcreated);
   548 		AknIconUtils::SetSize(bitmap, setSize);
   569 		AknIconUtils::SetSize(bitmap, setSize);
   549 		iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap));
   570 		iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap));
   550 		}
   571 		}
   551 	else if(KErrNotSupported == tnError)
   572    else if(KErrNone != tnError)
   552 		{
   573         {
   553 		GLX_LOG_INFO2("CGlxGridViewContainer::SetIconsL - image_defaultthumbnail tnError(%d), i(%d)",
   574         GLX_LOG_INFO2("CGlxGridViewContainer::SetIconsL - image_corrupted tnError(%d), i(%d)",
   554 				tnError, index);
   575                 tnError, index);
   555 		CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile,
   576         CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile,
   556 				EMbmGlxiconsQgn_prop_image_corrupted);
   577                 EMbmGlxiconsQgn_prop_image_corrupted);
   557 		AknIconUtils::SetSize(bitmap, setSize);
   578         AknIconUtils::SetSize(bitmap, setSize);
   558 		iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap));
   579         iHgGrid->ItemL(index).SetIcon(CGulIcon::NewL(bitmap));
   559 		}
   580         }
       
   581 
   560 
   582 
   561 	if (item.IsDrmProtected())
   583 	if (item.IsDrmProtected())
   562 		{
   584 		{
   563 		const TDesC& uri = item.Uri();
   585 		const TDesC& uri = item.Uri();
   564 		if( uri.Length() > 0)
   586 		if( uri.Length() > 0)
   852 		case EGlxCmdResetView:
   874 		case EGlxCmdResetView:
   853 			{
   875 			{
   854 			//@ fix for ESLM-7VRGKH
   876 			//@ fix for ESLM-7VRGKH
   855 			if(iHgGrid)
   877 			if(iHgGrid)
   856 				{
   878 				{
   857 				iHgGrid->InitScreenL(iEikonEnv->EikAppUi()->ClientRect());
   879 				iHgGrid->InitScreenL(GetHgGridRect());
   858 				}
   880 				}
   859 			retVal = ETrue;
   881 			retVal = ETrue;
   860 			break;
   882 			break;
   861 			}
   883 			}
   862 		default:
   884 		default:
   873 //
   895 //
   874 void CGlxGridViewContainer::HandleResourceChange(TInt aId)
   896 void CGlxGridViewContainer::HandleResourceChange(TInt aId)
   875 	{
   897 	{
   876 	TRACER("CGlxGridViewContainer::HandleResourceChange()");
   898 	TRACER("CGlxGridViewContainer::HandleResourceChange()");
   877 	CCoeControl::HandleResourceChange(aId);
   899 	CCoeControl::HandleResourceChange(aId);
   878 	if ( iBgContext )
   900     switch (aId)
   879 		{
   901        {
   880 		TRect apRect = iEikonEnv->EikAppUi()->ApplicationRect();
   902         case KEikDynamicLayoutVariantSwitch:
   881 		iBgContext->SetRect( apRect );
   903             {
   882 		}
   904             if ( iBgContext )
   883 	if(iHgGrid)
   905                 {
   884 		{
   906                 TRect apRect = iEikonEnv->EikAppUi()->ApplicationRect();
   885 		TRAP_IGNORE (iHgGrid->InitScreenL(iEikonEnv->EikAppUi()->ClientRect()); )
   907                 iBgContext->SetRect( apRect );
   886 		}
   908                 }
       
   909             if(iHgGrid)
       
   910                 {
       
   911                 TRAP_IGNORE (iHgGrid->InitScreenL(GetHgGridRect());)
       
   912                 }
       
   913             break;
       
   914             }
       
   915         default:
       
   916         break;
       
   917        }
   887 	}
   918 	}
   888 //end of file
   919 //end of file