photosgallery/viewframework/views/viewbase/src/glxtoolbarcontroller.cpp
branchRCL_3
changeset 14 2dac0fdba72b
parent 13 bcb43dc84c44
child 15 191387a8b767
equal deleted inserted replaced
13:bcb43dc84c44 14:2dac0fdba72b
    21 #include "glxtoolbarcontroller.h"
    21 #include "glxtoolbarcontroller.h"
    22 #include <aknbutton.h>
    22 #include <aknbutton.h>
    23 #include <akntoolbar.h>                     // For Toolbar
    23 #include <akntoolbar.h>                     // For Toolbar
    24 #include <glxcommandhandlers.hrh>           // For Command ids
    24 #include <glxcommandhandlers.hrh>           // For Command ids
    25 #include <glxtracer.h>                         // For Logs
    25 #include <glxtracer.h>                         // For Logs
       
    26 #include <glxlog.h>                         // For Logs
    26 #include <mglxmedialist.h>
    27 #include <mglxmedialist.h>
    27 
    28 
    28 #include <glxnavigationalstate.h>
    29 #include <glxnavigationalstate.h>
    29 #include <mpxcollectionpath.h>
    30 #include <mpxcollectionpath.h>
    30 #include <glxcollectionpluginimageviewer.hrh>
    31 #include <glxcollectionpluginimageviewer.hrh>
    61     {
    62     {
    62     TRACER("CGlxToolbarController::AddToObserverL");
    63     TRACER("CGlxToolbarController::AddToObserverL");
    63 
    64 
    64     iToolbar = aToolbar;
    65     iToolbar = aToolbar;
    65     iAttributeAvailable = EFalse;
    66     iAttributeAvailable = EFalse;
    66     iToolbar->SetDimmed(ETrue);
       
    67     iToolbar->DrawNow();
       
    68     aList.AddMediaListObserverL ( this );
    67     aList.AddMediaListObserverL ( this );
    69     }
    68     }
    70 
    69 
    71 //----------------------------------------------------------------------------------
    70 //----------------------------------------------------------------------------------
    72 // RemoveFromObserver 
    71 // RemoveFromObserver 
   114     {
   113     {
   115     TRACER("CGlxToolbarController::HandleItemRemovedL");
   114     TRACER("CGlxToolbarController::HandleItemRemovedL");
   116     
   115     
   117     if( aList->Count() <= 0 )
   116     if( aList->Count() <= 0 )
   118         {
   117         {
   119         iToolbar->SetDimmed(ETrue);
   118          SetToolbarItemsDimmed(ETrue);
   120         iToolbar->DrawNow();
       
   121         }
   119         }
   122     }
   120     }
   123 
   121 
   124 //----------------------------------------------------------------------------
   122 //----------------------------------------------------------------------------
   125 // HandleItemModifiedL
   123 // HandleItemModifiedL
   151 
   149 
   152 //----------------------------------------------------------------------------
   150 //----------------------------------------------------------------------------
   153 // HandleFocusChangedL
   151 // HandleFocusChangedL
   154 //----------------------------------------------------------------------------
   152 //----------------------------------------------------------------------------
   155 //
   153 //
   156 void CGlxToolbarController::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, 
   154 void CGlxToolbarController::HandleFocusChangedL(
   157         TInt aNewIndex, TInt /*aOldIndex*/, 
   155         NGlxListDefs::TFocusChangeType /*aType*/, TInt /*aNewIndex*/, 
   158         MGlxMediaList* aList)
   156         TInt /*aOldIndex*/, MGlxMediaList* aList)
   159     {  
   157     {  
   160     TRACER("CGlxToolbarController::HandleFocusChangedL");
   158     TRACER("CGlxToolbarController::HandleFocusChangedL");
   161     
   159     if (aList->Count() <= 0)
   162     // If new index is not equal to -1 (i.e., if there are some items present), 
   160         {
   163     // then check the media item
   161         SetToolbarItemsDimmed(ETrue);
   164     if( (aNewIndex == aList->FocusIndex()) && (KErrNotFound != aNewIndex) )
   162         }
   165         {
       
   166         //Get the current media item from medialist
       
   167         const TGlxMedia& mediaItem = aList->Item(aList->FocusIndex());
       
   168         //Check whether media item is a system item, for example Favourites album
       
   169         TBool isSystemItem = EFalse;
       
   170         mediaItem.GetSystemItem(isSystemItem);
       
   171         if( mediaItem.IsStatic() )
       
   172             {
       
   173             iToolbar->SetDimmed(ETrue);  
       
   174             }
       
   175         else if( iToolbar->IsDimmed() )
       
   176             {
       
   177             iToolbar->SetDimmed(EFalse);
       
   178             }
       
   179         if( isSystemItem )
       
   180              {
       
   181              iToolbar->SetItemDimmed( EGlxCmdRename, ETrue, ETrue );
       
   182              }
       
   183         else
       
   184              {
       
   185              iToolbar->SetItemDimmed( EGlxCmdRename, EFalse, ETrue );   
       
   186             }
       
   187         }
       
   188     //DrawNow must be called since SetDimmed does not redraw the toolbar
       
   189     iToolbar->DrawNow();     
       
   190     }
   163     }
   191 
   164 
   192 //----------------------------------------------------------------------------
   165 //----------------------------------------------------------------------------
   193 // HandleItemSelectedL
   166 // HandleItemSelectedL
   194 //----------------------------------------------------------------------------
   167 //----------------------------------------------------------------------------
   230 // SetStatusOnViewActivationL
   203 // SetStatusOnViewActivationL
   231 //----------------------------------------------------------------------------
   204 //----------------------------------------------------------------------------
   232 //
   205 //
   233 void CGlxToolbarController::SetStatusOnViewActivationL( MGlxMediaList* aList )
   206 void CGlxToolbarController::SetStatusOnViewActivationL( MGlxMediaList* aList )
   234      {
   207      {
   235      	TRACER("CGlxToolbarController::SetStatusOnViewActivationL");
   208     TRACER("CGlxToolbarController::SetStatusOnViewActivationL");
   236      	
   209     GLX_LOG_INFO1("CGlxToolbarController::SetStatusOnViewActivationL(%d)",
   237      // When going back from fullscreen to grid, when the attributes are already 
   210             aList->Count());
   238      // available in the cache, there is no HandleAttributeAvailable callback. Hence,
   211     // When going back from fullscreen to grid, when the attributes are already 
   239      // checking for medialist count.
   212     // available in the cache, there is no HandleAttributeAvailable callback. Hence,
   240      if( !iAttributeAvailable && (aList->Count(NGlxListDefs::ECountNonStatic) > 0))
   213     // checking for medialist count.
   241          {
   214     if (!iAttributeAvailable)
   242          SetStatusL(aList);
   215         {
   243          }    
   216         SetStatusL(aList);
   244      }
   217         }
       
   218     }
   245 
   219 
   246 //----------------------------------------------------------------------------
   220 //----------------------------------------------------------------------------
   247 //SetStatusL
   221 //SetStatusL
   248 //----------------------------------------------------------------------------
   222 //----------------------------------------------------------------------------
   249 //
   223 //
   250 void CGlxToolbarController::SetStatusL(MGlxMediaList* aList)
   224 void CGlxToolbarController::SetStatusL(MGlxMediaList* aList)
   251 	{
   225 	{
   252 	TRACER("CGlxToolbarController::SetStatusL");
   226     TRACER("CGlxToolbarController::SetStatusL");
   253 	if(KErrNotFound != aList->FocusIndex())
   227 
   254 		{
   228     GLX_LOG_INFO1("CGlxToolbarController::SetStatusL(%d)", aList->Count());
   255 		//Get the current media item from medialist
   229     if (aList->Count() <= 0)
   256 		const TGlxMedia& mediaItem = aList->Item(aList->FocusIndex());      
   230         {
   257 
   231         SetToolbarItemsDimmed(ETrue);
   258 		//Check whether media item is a system item, for example Favourites album
   232         }
   259 		TBool isSystemItem = EFalse;    
   233     else if (KErrNotFound != aList->FocusIndex())
   260 		mediaItem.GetSystemItem(isSystemItem);
   234         {
   261 
   235         CGlxNavigationalState* navigationalState =
   262 		if(!mediaItem.IsStatic() && iToolbar->IsDimmed())
   236                 CGlxNavigationalState::InstanceL();
   263 			{
   237         CleanupClosePushL(*navigationalState);
   264 			//Activate (Undim) the toolbar if item in focus is not static
   238         if (navigationalState->ViewingMode() == NGlxNavigationalState::EView)
   265 			iToolbar->SetDimmed(EFalse);            
   239             {
   266 			}    
   240             SetToolbarItemsDimmed(EFalse);
   267 
   241             }
   268 
   242         CleanupStack::PopAndDestroy(navigationalState);
   269 		if( isSystemItem )
   243         }
   270 			{
   244     }
   271 			iToolbar->SetItemDimmed( EGlxCmdRename, ETrue, ETrue );
       
   272 			}
       
   273 		else
       
   274 			{
       
   275 			iToolbar->SetItemDimmed( EGlxCmdRename, EFalse, ETrue );
       
   276 			}    
       
   277 		}    
       
   278 	
       
   279 	//DrawNow must be called since SetDimmed does not redraw the toolbar
       
   280 	iToolbar->DrawNow();
       
   281 	}
       
   282 
   245 
   283 //----------------------------------------------------------------------------
   246 //----------------------------------------------------------------------------
   284 // EnableLatch
   247 // EnableLatch
   285 //----------------------------------------------------------------------------
   248 //----------------------------------------------------------------------------
   286 //
   249 //
   299             {
   262             {
   300             toolbarButton->SetCurrentState( KGlxToolbarButtonUnLatched, ETrue );
   263             toolbarButton->SetCurrentState( KGlxToolbarButtonUnLatched, ETrue );
   301             }
   264             }
   302         }
   265         }
   303     }
   266     }
       
   267 
       
   268 // ----------------------------------------------------------------------------
       
   269 // HandlePopulatedL
       
   270 // ----------------------------------------------------------------------------
       
   271 //
       
   272 void CGlxToolbarController::HandlePopulatedL( MGlxMediaList* aList )
       
   273     {
       
   274     TRACER("CGlxToolbarController::HandlePopulatedL()");
       
   275     if (aList->Count() <= 0)
       
   276         {
       
   277         SetToolbarItemsDimmed(ETrue);
       
   278         }
       
   279     }
       
   280 
       
   281 // ----------------------------------------------------------------------------
       
   282 // SetToolbarItemsDimmed
       
   283 // ----------------------------------------------------------------------------
       
   284 //
       
   285 void CGlxToolbarController::SetToolbarItemsDimmed(TBool aDimmed)
       
   286     {
       
   287     TRACER("CGlxToolbarController::SetToolbarItemsDimmed()");
       
   288     if (iToolbar)
       
   289         {
       
   290         iToolbar->SetItemDimmed(EGlxCmdSlideshowPlay, aDimmed, ETrue);
       
   291         iToolbar->SetItemDimmed(EGlxCmdStartMultipleMarking, aDimmed, ETrue);
       
   292         
       
   293         if (!aDimmed)
       
   294             {
       
   295             CAknButton* uploadButton =
       
   296                     static_cast<CAknButton*> (iToolbar->ControlOrNull(
       
   297                             EGlxCmdUpload));
       
   298             TBool dimmed = EFalse;
       
   299             if (uploadButton)
       
   300                 {
       
   301                 // Get current button state
       
   302                 CAknButtonState* currentState = uploadButton->State();
       
   303                 dimmed = uploadButton->IsDimmed();
       
   304                 iToolbar->SetItemDimmed(EGlxCmdUpload, dimmed, ETrue);
       
   305                 }
       
   306             }
       
   307         else
       
   308             {
       
   309             iToolbar->SetItemDimmed(EGlxCmdUpload, aDimmed, ETrue);
       
   310             }
       
   311         }
       
   312     }
       
   313 
   304 //end of file
   314 //end of file
   305 	
   315