photosgallery/controllers/fetcher/src/glxfetchercontainer.cpp
branchRCL_3
changeset 75 01504893d9cb
parent 60 5b3385a43d68
equal deleted inserted replaced
68:5b238bc8ffb6 75:01504893d9cb
    30 #include <ganes/HgItem.h>                           // HG Item 
    30 #include <ganes/HgItem.h>                           // HG Item 
    31 #include <ganes/HgGrid.h>                           // Hg Grid Widget
    31 #include <ganes/HgGrid.h>                           // Hg Grid Widget
    32 #include <AknsBasicBackgroundControlContext.h>      // Background Context
    32 #include <AknsBasicBackgroundControlContext.h>      // Background Context
    33 
    33 
    34 #include <glxuistd.h>                               // KGlxFetchontextPriorityNormal and KGlxIconsFilename           
    34 #include <glxuistd.h>                               // KGlxFetchontextPriorityNormal and KGlxIconsFilename           
       
    35 #include <glxcollectionpluginall.hrh> 	            // All item collection plugin id
    35 #include <glxfilterfactory.h>                       // For Filters required in Medilaits
    36 #include <glxfilterfactory.h>                       // For Filters required in Medilaits
    36 #include <glxresourceutilities.h>                   // for CGlxResourceUtilities
    37 #include <glxresourceutilities.h>                   // for CGlxResourceUtilities
    37 #include <glxfetcherdialog.rsg>                     // FOR GETTING Dialog ID AND RESOURCE ID
    38 #include <glxfetcherdialog.rsg>                     // FOR GETTING Dialog ID AND RESOURCE ID
    38 #include <glxattributecontext.h>                    // TMPXAttribute
    39 #include <glxattributecontext.h>                    // TMPXAttribute
    39 #include <glxattributeretriever.h>  	            // CGlxAttributeRetriever
    40 #include <glxattributeretriever.h>  	            // CGlxAttributeRetriever
    55 #include "mglxeventobserver.h"
    56 #include "mglxeventobserver.h"
    56 #include "glxfetcher.hrh"
    57 #include "glxfetcher.hrh"
    57 #include "glxfetchercommandhandler.h"
    58 #include "glxfetchercommandhandler.h"
    58 
    59 
    59 const TInt KPadding(7);
    60 const TInt KPadding(7);
       
    61 const TInt KNoOfPages(4);
       
    62 const TInt KBufferTreshold(1);
       
    63 const TInt KItemsPerPage(18);
       
    64 const TInt KBufferSize(KNoOfPages * KItemsPerPage);
       
    65 const TInt KBufferTresholdSize(KBufferTreshold * KItemsPerPage);
    60 
    66 
    61 //-----------------------------------------------------------------------------
    67 //-----------------------------------------------------------------------------
    62 // Two-phased constructor.
    68 // Two-phased constructor.
    63 //-----------------------------------------------------------------------------
    69 //-----------------------------------------------------------------------------
    64 CGlxFetcherContainer* CGlxFetcherContainer::NewL(
    70 CGlxFetcherContainer* CGlxFetcherContainer::NewL(
   135         {
   141         {
   136         iUiUtility->Close() ;
   142         iUiUtility->Close() ;
   137         }
   143         }
   138     }
   144     }
   139 
   145 
       
   146 
   140 // ---------------------------------------------------------------------------
   147 // ---------------------------------------------------------------------------
   141 // CreateAndDisplayGridL
   148 // CreateAndDisplayGridL
   142 // ---------------------------------------------------------------------------
   149 // ---------------------------------------------------------------------------
   143 //  
   150 //  
   144 void CGlxFetcherContainer::CreateAndDisplayGridL()
   151 void CGlxFetcherContainer::CreateAndDisplayGridL()
   160 	    
   167 	    
   161 	    iHgGrid->SetFlags( CHgScroller::EHgScrollerSelectionMode );
   168 	    iHgGrid->SetFlags( CHgScroller::EHgScrollerSelectionMode );
   162 	    iMultipleMarkNotStarted = EFalse;
   169 	    iMultipleMarkNotStarted = EFalse;
   163 	    }
   170 	    }
   164 	}
   171 	}
   165 
       
   166 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   167 // CreateMediaListL()
   173 // CreateMediaListL()
   168 // Creates a collection path
   174 // Creates a collection path
   169 // Create a filter as requested filtertype
   175 // Create a filter as requested filtertype
   170 // Creates the medialist
   176 // Creates the medialist
   191 	GLX_LOG_INFO1("CGlxFetcherContainer::MediaListL  - Path level = %d",
   197 	GLX_LOG_INFO1("CGlxFetcherContainer::MediaListL  - Path level = %d",
   192 	                                                     path->Levels());
   198 	                                                     path->Levels());
   193 	
   199 	
   194 	CleanupStack::PopAndDestroy( path );
   200 	CleanupStack::PopAndDestroy( path );
   195 	}
   201 	}
   196 
       
   197 // ---------------------------------------------------------------------------
   202 // ---------------------------------------------------------------------------
   198 // CreateHgGridWidgetL
   203 // CreateHgGridWidgetL
   199 // ---------------------------------------------------------------------------
   204 // ---------------------------------------------------------------------------
   200 //  
   205 //  
   201 void CGlxFetcherContainer::CreateHgGridWidgetL()
   206 void CGlxFetcherContainer::CreateHgGridWidgetL()
   245     // Setting Selction observer for getting callback on key event change
   250     // Setting Selction observer for getting callback on key event change
   246     iHgGrid->SetSelectionObserver(*this);
   251     iHgGrid->SetSelectionObserver(*this);
   247     // This Displays the scrollbar at the opening of the Grid view
   252     // This Displays the scrollbar at the opening of the Grid view
   248     iHgGrid->SetScrollBarTypeL(CHgScroller::EHgScrollerTimeStrip );
   253     iHgGrid->SetScrollBarTypeL(CHgScroller::EHgScrollerTimeStrip );
   249     // Enable Buffer support
   254     // Enable Buffer support
   250     iHgGrid->EnableScrollBufferL(*this, (KNoOfPages
   255     iHgGrid->EnableScrollBufferL(*this, KBufferSize, KBufferTresholdSize);
   251             * iUiUtility->VisibleItemsInPageGranularityL()),
       
   252             KBufferTresholdSize);
       
   253     // Enable Marking support
   256     // Enable Marking support
   254     iHgGrid->SetMarkingObserver(*this);
   257     iHgGrid->SetMarkingObserver(*this);
   255 
   258 
   256 	iHgGrid->SetFocus(ETrue);
   259 	iHgGrid->SetFocus(ETrue);
   257 	}
   260 	}
   260 // CreateGridMediaListObserverL
   263 // CreateGridMediaListObserverL
   261 // ---------------------------------------------------------------------------
   264 // ---------------------------------------------------------------------------
   262 //  
   265 //  
   263 void CGlxFetcherContainer::CreateGridMediaListObserverL()
   266 void CGlxFetcherContainer::CreateGridMediaListObserverL()
   264     {
   267     {
   265     iGlxGridMLObserver = CGlxGridViewMLObserver::NewL(*this, *iMediaList,
   268     iGlxGridMLObserver = CGlxGridViewMLObserver::NewL(*iMediaList, iHgGrid,
   266             iHgGrid, iFilterType);
   269             iFilterType);
   267     }
   270     }
   268     
   271     
   269 // ---------------------------------------------------------------------------
   272 // ---------------------------------------------------------------------------
   270 // Request
   273 // BufferPositionChanged
   271 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   272 //  
   275 //  
   273 void CGlxFetcherContainer::Request(TInt aRequestStart, TInt aRequestEnd,
   276 void CGlxFetcherContainer::Request(TInt aRequestStart, TInt aRequestEnd,
   274         THgScrollDirection /*aDirection*/)
   277         THgScrollDirection /*aDirection*/)
   275     {
   278     {
   276     TRACER("CGlxFetcherContainer::Request()");
   279     TRACER("CGlxFetcherContainer::Request()");
   277     TRAP_IGNORE(RequestL( aRequestStart, aRequestEnd ));
   280     TRAP_IGNORE(RequestL( aRequestStart, aRequestEnd ));
   278     }
   281     }
   279 
       
   280 // ---------------------------------------------------------------------------
   282 // ---------------------------------------------------------------------------
   281 // RequestL
   283 // RequestL
   282 // ---------------------------------------------------------------------------
   284 // ---------------------------------------------------------------------------
   283 //  
   285 //  
   284 void CGlxFetcherContainer::RequestL(TInt aRequestStart, TInt aRequestEnd)
   286 void CGlxFetcherContainer::RequestL(TInt aRequestStart, TInt aRequestEnd)
   299         if(visIndex<0 || mediaCount<=0)
   301         if(visIndex<0 || mediaCount<=0)
   300             {
   302             {
   301             visIndex = 0;
   303             visIndex = 0;
   302             }
   304             }
   303 		
   305 		
   304         GLX_LOG_INFO1("CGlxFetcherContainer::Request - SetVisibleWindowIndex "
   306         GLX_LOG_INFO1("CGlxGridViewImp::Request - SetVisibleWindowIndex "
   305                 "visIndex(%d)", visIndex);
   307                 "visIndex(%d)", visIndex);
   306         iMediaList->SetVisibleWindowIndexL(visIndex);
   308         iMediaList->SetVisibleWindowIndexL(visIndex);
   307         }
   309         }
   308     for (TInt i=aRequestStart; i<= aRequestEnd; i++)
   310     for (TInt i=aRequestStart; i<= aRequestEnd; i++)
   309         {
   311         {
   310         SetIconsL(i);
   312         SetIconsL(i);
   311         TInt firstIndex = iHgGrid->FirstIndexOnScreen();
   313         TInt firstIndex = iHgGrid->FirstIndexOnScreen();
   312         TInt lastOnScreen = firstIndex + iHgGrid->ItemsOnScreen() - 1;
   314         TInt lastOnScreen = firstIndex + iHgGrid->ItemsOnScreen() - 1;
   313         if (i >= firstIndex && i <= lastOnScreen)
   315         if (i >= firstIndex && i <= lastOnScreen)
   314             {
   316             {
   315             GLX_LOG_INFO1("CGlxFetcherContainer::Request - RefreshScreen i(%d)", i);
   317             GLX_LOG_INFO1("CGlxGridViewImp::Request - RefreshScreen i(%d)", i);
   316             iHgGrid->RefreshScreen(i);
   318             iHgGrid->RefreshScreen(i);
   317             }
   319             }
   318         }
   320         }
   319     }
   321     }
   320 
   322 // ---------------------------------------------------------------------------
   321 // ---------------------------------------------------------------------------
   323 // SetIcons
   322 // SetIconsL
       
   323 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   324 //  
   325 //  
   325 void CGlxFetcherContainer::SetIconsL(TInt aIndex)
   326 void CGlxFetcherContainer::SetIconsL(TInt aIndex)
   326     {
   327     {
   327     TRACER("CGlxFetcherContainer::SetIconsL()");
   328     TRACER("CGlxFetcherContainer::SetIconsL()");
   340     if (value)
   341     if (value)
   341         {
   342         {
   342         CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   343         CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   343         bitmap->Duplicate( value->iBitmap->Handle());
   344         bitmap->Duplicate( value->iBitmap->Handle());
   344         iHgGrid->ItemL(aIndex).SetIcon(CGulIcon::NewL(bitmap));
   345         iHgGrid->ItemL(aIndex).SetIcon(CGulIcon::NewL(bitmap));
   345         GLX_LOG_INFO1("### CGlxFetcherContainer::Request value-Index is %d",aIndex);
   346         GLX_LOG_INFO1("### CGlxGridViewImp::Request value-Index is %d",aIndex);
   346         }
   347         }
   347     else if (item.GetIconInfo(icon))
   348     else if (item.GetIconInfo(icon))
   348         {
   349         {
   349         GLX_LOG_INFO1("CGlxFetcherContainer::Request - icon(%d)", aIndex);
   350         GLX_LOG_INFO1("CGlxGridViewImp::Request - icon(%d)", aIndex);
   350         CFbsBitmap* bitmap = NULL;
   351         CFbsBitmap* bitmap = NULL;
   351         CFbsBitmap* mask = NULL;
   352         CFbsBitmap* mask = NULL;
   352         AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
   353         AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
   353                 bitmap, mask, icon.bmpfile, icon.bitmapId, icon.maskId);
   354                 bitmap, mask, icon.bmpfile, icon.bitmapId, icon.maskId);
   354         __ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
   355         __ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
   360                 EAspectRatioPreservedAndUnusedSpaceRemoved);
   361                 EAspectRatioPreservedAndUnusedSpaceRemoved);
   361 
   362 
   362         iHgGrid->ItemL(aIndex).SetIcon(CGulIcon::NewL(bitmap, mask));
   363         iHgGrid->ItemL(aIndex).SetIcon(CGulIcon::NewL(bitmap, mask));
   363         CleanupStack::Pop(mask);
   364         CleanupStack::Pop(mask);
   364         CleanupStack::Pop(bitmap);
   365         CleanupStack::Pop(bitmap);
   365         GLX_LOG_INFO1("### CGlxFetcherContainer::Request GetIconInfo-Index is %d",
   366         GLX_LOG_INFO1("### CGlxGridViewImp::Request GetIconInfo-Index is %d",
   366                 aIndex);
   367                 aIndex);
   367         }
   368         }
   368     else if (KErrNone != tnError && KErrNotSupported != tnError)
   369     else if (KErrNone != tnError && KErrNotSupported != tnError)
   369         {
   370         {
   370         GLX_LOG_INFO2(
   371         GLX_LOG_INFO2(
   371                 "CGlxFetcherContainer::Request - image_corrupted tnError(%d), "
   372                 "CGlxGridViewImp::Request - image_corrupted tnError(%d), "
   372                     "i(%d)", tnError, aIndex);
   373                     "i(%d)", tnError, aIndex);
   373 
   374 
   374         CFbsBitmap* bitmap = NULL;
   375         CFbsBitmap* bitmap = NULL;
   375         CFbsBitmap* mask = NULL;
   376         CFbsBitmap* mask = NULL;
   376         AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
   377         AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
   438     TRACER("CGlxFetcherContainer::Release()");
   439     TRACER("CGlxFetcherContainer::Release()");
   439     // This has to do nothing on default
   440     // This has to do nothing on default
   440     }
   441     }
   441 
   442 
   442 // ---------------------------------------------------------------------------
   443 // ---------------------------------------------------------------------------
   443 // HandleSelectL
   444 // HandleSelect
   444 // ---------------------------------------------------------------------------
   445 // ---------------------------------------------------------------------------
   445 //  
   446 //  
   446 void CGlxFetcherContainer::HandleSelectL( TInt aIndex )
   447 void CGlxFetcherContainer::HandleSelectL( TInt aIndex )
   447     {
   448     {
   448     TRACER("CGlxFetcherContainer::HandleSelectL()");
   449     TRACER("CGlxGridViewImp::HandleSelect()");
   449     GLX_LOG_INFO1("CGlxFetcherContainer::HandleSelectL(%d)", aIndex);
       
   450     // Make sure that the Selection Index is inside medialist count
   450     // Make sure that the Selection Index is inside medialist count
   451     if (aIndex < iMediaList->Count() && aIndex >= 0)
   451     if (aIndex <iMediaList->Count() && aIndex >=0)
   452         {
   452         {
   453         // Setting the focus of the medialist
   453         // Setting the focus of the medialist
   454         iMediaList->SetFocusL(NGlxListDefs::EAbsolute, aIndex);
   454         iMediaList->SetFocusL(NGlxListDefs::EAbsolute, aIndex);        
   455 
   455         }
   456         //Show Left Soft Key when media is selected
   456     }
   457         CEikButtonGroupContainer* cbaContainer =
   457 
   458                 CEikButtonGroupContainer::Current();
   458 // ---------------------------------------------------------------------------
   459         cbaContainer->SetCommandSetL(R_AVKON_SOFTKEYS_OK_CANCEL);
   459 // HandleOpen
   460         cbaContainer->DrawDeferred();
       
   461         }
       
   462     }
       
   463 
       
   464 // ---------------------------------------------------------------------------
       
   465 // HandleOpenL
       
   466 // ---------------------------------------------------------------------------
   460 // ---------------------------------------------------------------------------
   467 //  
   461 //  
   468 void CGlxFetcherContainer::HandleOpenL( TInt aIndex )
   462 void CGlxFetcherContainer::HandleOpenL( TInt aIndex )
   469     {
   463     {
   470     TRACER("CGlxFetcherContainer::HandleOpenL()");
   464     TRACER("CGlxFetcherContainer::HandleOpenL()");
   486 // HandleMarkingL
   480 // HandleMarkingL
   487 // ---------------------------------------------------------------------------
   481 // ---------------------------------------------------------------------------
   488 //  
   482 //  
   489 void CGlxFetcherContainer::HandleMarkingL( TInt aIndex, TBool/* aMarked*/ )
   483 void CGlxFetcherContainer::HandleMarkingL( TInt aIndex, TBool/* aMarked*/ )
   490     {
   484     {
   491     TRACER("CGlxFetcherContainer::HandleMarkingL()");
   485     TRACER("CGlxGridViewImp::HandleMarkingL()");
   492     HandleMultipleMarkingL(aIndex);
   486     HandleMultipleMarkingL(aIndex);
   493     iEventObserver.HandleMarkEventL();    
   487     iEventObserver.HandleMarkEventL();    
   494     }
   488     }
   495 
   489 
   496 // ---------------------------------------------------------------------------
   490 // ---------------------------------------------------------------------------
   497 // HandleMultipleMarkingL
   491 // HandleMultipleMarkingL
   498 // ---------------------------------------------------------------------------
   492 // ---------------------------------------------------------------------------
   499 //  
   493 //  
   500 void CGlxFetcherContainer::HandleMultipleMarkingL(TInt aIndex )
   494 void CGlxFetcherContainer::HandleMultipleMarkingL(TInt aIndex )
   501     {
   495     {
   502     TRACER("CGlxFetcherContainer::HandleMultipleMarkingL()");
   496     TRACER("CGlxGridViewImp::HandleMultipleMarkingL()");
   503     if(iMediaList->IsSelected(aIndex))
   497     if(iMediaList->IsSelected(aIndex))
   504         {
   498         {
   505         if(iHgGrid)
   499         if(iHgGrid)
   506             {
   500             {
   507             if(iMultiSelectionEnabled)
   501             if(iMultiSelectionEnabled)
   607             break;
   601             break;
   608         }    
   602         }    
   609     return retVal;
   603     return retVal;
   610     }
   604     }
   611 
   605 
       
   606 
   612 // -----------------------------------------------------------------------------
   607 // -----------------------------------------------------------------------------
   613 // Retrieve Uris
   608 // Retrieve Uris
   614 // -----------------------------------------------------------------------------
   609 // -----------------------------------------------------------------------------
   615 TBool CGlxFetcherContainer::RetrieveUrisL( CDesCArray& aSelectedFiles, TBool& aFetchUri)
   610 TBool CGlxFetcherContainer::RetrieveUrisL( CDesCArray& aSelectedFiles, TBool& aFetchUri)
   616     {
   611     {