photosgallery/viewframework/commandhandlers/commandhandlermarking/src/glxcommandhandlermarking.cpp
changeset 0 4e91876724a2
child 18 bcb43dc84c44
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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:    Marking command handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  *  @internal reviewed 12/06/2007 by Alex Birkett
       
    23  */
       
    24  
       
    25 #include "glxcommandhandlermarking.h"
       
    26 
       
    27 #include <mglxmedialist.h>
       
    28 
       
    29 #include <AknUtils.h>
       
    30 #include <bautils.h>
       
    31 #include <data_caging_path_literals.hrh>
       
    32 
       
    33 #include <glxcommandhandlermarking.rsg>
       
    34 #include <glxuiutility.h>
       
    35 #include <glxscreenfurniture.h>
       
    36 #include <glxtracer.h>
       
    37 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
       
    38 #include <glxvisuallistmanager.h>
       
    39 
       
    40 #include <StringLoader.h>
       
    41 
       
    42 #include "glxcommandhandlers.hrh"
       
    43 #include "glxmarkediconmanager.h"
       
    44 #include <glxicons.mbg>
       
    45 
       
    46 
       
    47 _LIT(KGlxMarkingCmdHandlerRes,"glxcommandhandlermarking.rsc");
       
    48 _LIT(KGlxBlankString," ");
       
    49 
       
    50             
       
    51 // ---------------------------------------------------------------------------
       
    52 // C++ default constructor can NOT contain any code, that
       
    53 // might leave.
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CGlxCommandHandlerMarking::CGlxCommandHandlerMarking(
       
    57                 MGlxMediaListProvider* aMediaListProvider,
       
    58                 TBool aHasToolbarItem /*,TBool aUpdateMiddleSoftkey*/ )
       
    59     : CGlxMediaListCommandHandler( aMediaListProvider, aHasToolbarItem )/*,
       
    60         iKeyHandler( aKeyHandler ), iUpdateMiddleSoftkey( aUpdateMiddleSoftkey )*/
       
    61     {
       
    62     // No implementation required
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Symbian 2nd phase constructor can leave.
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void CGlxCommandHandlerMarking::ConstructL()
       
    70     {
       
    71     TRACER("CGlxCommandHandlerMarking::ConstructL");
       
    72     // Load the view's resources
       
    73     TFileName resourceFile(KDC_APP_RESOURCE_DIR);
       
    74     resourceFile.Append(KGlxMarkingCmdHandlerRes); 
       
    75     CGlxResourceUtilities::GetResourceFilenameL(resourceFile);  
       
    76     iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile);
       
    77     
       
    78     // Add supported commands
       
    79     // mark
       
    80     TCommandInfo markCmd( EAknCmdMark );
       
    81     // Filter out static items
       
    82     markCmd.iMinSelectionLength = 1;
       
    83     AddCommandL( markCmd );
       
    84     
       
    85     // unmark
       
    86     TCommandInfo unMarkCmd( EAknCmdUnmark );
       
    87     // Filter out static items
       
    88     unMarkCmd.iMinSelectionLength = 1;
       
    89     AddCommandL( unMarkCmd );
       
    90     
       
    91     // mark all
       
    92     AddCommandL( TCommandInfo( EAknMarkAll ) );
       
    93     
       
    94     // unmark all
       
    95     TCommandInfo unMarkAllCmd( EAknUnmarkAll );
       
    96     // Filter out static items
       
    97     unMarkAllCmd.iMinSelectionLength = 1;
       
    98     AddCommandL( unMarkAllCmd );    
       
    99     
       
   100     // marking sub-menu
       
   101     AddCommandL( TCommandInfo( EGlxCmdMarkingSubmenu ) );
       
   102     
       
   103     // start multiple marking
       
   104     AddCommandL( TCommandInfo( EGlxCmdStartMultipleMarking ) );
       
   105 
       
   106     // end multiple marking
       
   107     AddCommandL( TCommandInfo( EGlxCmdEndMultipleMarking ) );
       
   108 
       
   109     // Add view state dummy commands
       
   110     AddCommandL( TCommandInfo( EGlxCmdStateView ) );
       
   111     AddCommandL( TCommandInfo( EGlxCmdStateBrowse ) );      
       
   112     
       
   113     iLeftSoftKeyStatus = EGlxLSKUndefined;
       
   114     
       
   115     // get pointer to screen furniture
       
   116     iUiUtility = CGlxUiUtility::UtilityL();
       
   117 	if(!iUiUtility->IsPenSupported())
       
   118 		{
       
   119 	    iScreenFurniture = iUiUtility->ScreenFurniture();
       
   120 	    iRskTextCancel = StringLoader::LoadL( R_GLX_SOFTKEY_CANCEL );
       
   121 	    iRskTextBack = StringLoader::LoadL( R_GLX_SOFTKEY_BACK );
       
   122 	    iMskTextMark = StringLoader::LoadL( R_GLX_MARKING_MARK );
       
   123 	    iMskTextUnMark = StringLoader::LoadL( R_GLX_MARKING_UNMARK );        
       
   124 	    iMskTextOpen = StringLoader::LoadL( R_GLX_SOFTKEY_OPEN );
       
   125 		}
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // Two-phased constructor.
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 EXPORT_C CGlxCommandHandlerMarking* CGlxCommandHandlerMarking::NewL(
       
   133                                 MGlxMediaListProvider* aMediaListProvider,
       
   134                                 TBool aHasToolbarItem/*,
       
   135                                 TBool aUpdateMiddleSoftkey */)
       
   136     {
       
   137     CGlxCommandHandlerMarking* self = 
       
   138         new (ELeave) CGlxCommandHandlerMarking( aMediaListProvider, aHasToolbarItem 
       
   139     								/*, aUpdateMiddleSoftkey */); 
       
   140     CleanupStack::PushL( self );
       
   141     self->ConstructL();
       
   142     CleanupStack::Pop( self );
       
   143     return self;
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // Destructor
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 EXPORT_C CGlxCommandHandlerMarking::~CGlxCommandHandlerMarking()
       
   151     {
       
   152     /// if (but do test this assumption!)
       
   153     if (iResourceOffset)
       
   154         {
       
   155         CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
       
   156         }
       
   157 	if(!iUiUtility->IsPenSupported())		
       
   158 		{
       
   159 		delete iRskTextCancel;
       
   160 	    delete iRskTextBack;
       
   161 	    delete iMskTextMark;
       
   162 	    delete iMskTextUnMark;
       
   163 	    delete iMskTextOpen;
       
   164 		}
       
   165 
       
   166     if(iUiUtility)
       
   167         {
       
   168         iUiUtility->Close();
       
   169         }
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // DoExecuteL
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 TBool CGlxCommandHandlerMarking::DoExecuteL(TInt aCommand, 
       
   177                                             MGlxMediaList& aList)
       
   178     {
       
   179     TRACER("CGlxCommandHandlerMarking::DoExecuteL");
       
   180     TBool consumed = ETrue;
       
   181     switch( aCommand)
       
   182         {
       
   183         case EAknCmdMark:
       
   184            {
       
   185 		   //This is Checking Marking Mode is On or Not 
       
   186            if(iMultipleMarking)
       
   187                {
       
   188                if(!aList.Item(aList.FocusIndex()).IsStatic())
       
   189                    {
       
   190             		aList.SetSelectedL(aList.FocusIndex(), ETrue);          
       
   191                    }
       
   192                 }
       
   193             else 
       
   194                 {
       
   195 			    EnterMultipleMarkingModeL();
       
   196             	}
       
   197             //@ fix for EIZU-7RE43S && ELWU-7RA7NX    
       
   198             consumed = EFalse;  // This Command Should goto View For Further Processing    
       
   199             break;
       
   200             }
       
   201         case EAknCmdUnmark:
       
   202             {
       
   203             if(!aList.Item(aList.FocusIndex()).IsStatic())
       
   204                 {
       
   205                 aList.SetSelectedL(aList.FocusIndex(), EFalse);  
       
   206 				if(!iUiUtility->IsPenSupported())
       
   207 					{
       
   208                 	iScreenFurniture->ModifySoftkeyIdL(
       
   209                         CEikButtonGroupContainer::EMiddleSoftkeyPosition, EAknCmdMark, 0, *iMskTextMark);
       
   210 					}
       
   211 				/*commented out this coz, while select/unselect on a perticular item
       
   212 				 * some events were getting lost. -- sourav                
       
   213 				 */
       
   214 				/*if(aList.SelectionCount() <= 0)
       
   215 		            {
       
   216 		            iMultipleMarking = EFalse;
       
   217 		            }*/
       
   218 		        //@ fix for EIZU-7RE43S && ELWU-7RA7NX    
       
   219 		        consumed = EFalse; // This Command Should goto View For Further Processing                    
       
   220                 }
       
   221             break;
       
   222             }
       
   223         case EAknMarkAll:
       
   224             {
       
   225             if(iMultipleMarking)
       
   226                 {
       
   227             	SelectAllL( ETrue );     
       
   228                 } 
       
   229             else 
       
   230                 {
       
   231                 EnterMultipleMarkingModeL();
       
   232                 }
       
   233 			//@ fix for EIZU-7RE43S             
       
   234             consumed = EFalse; // This Command Should goto View For Further Processing                    
       
   235             break;
       
   236             }
       
   237         case EAknUnmarkAll:
       
   238             {
       
   239             SelectAllL( EFalse );  
       
   240             ExitMultipleMarkingModeL();
       
   241             consumed = EFalse;
       
   242             break;
       
   243             }
       
   244 		// Its For Handling Commands from ToolBar
       
   245         case EGlxCmdStartMultipleMarking:
       
   246             {
       
   247             if(!iMultipleMarking)
       
   248                 {
       
   249             EnterMultipleMarkingModeL();
       
   250             }
       
   251             consumed = EFalse;
       
   252             break;
       
   253             }            
       
   254         case EGlxCmdEndMultipleMarking:
       
   255             {
       
   256             if(iMultipleMarking)
       
   257                 {
       
   258                 SelectAllL( EFalse);
       
   259                 }            
       
   260             ExitMultipleMarkingModeL();
       
   261             consumed = EFalse;
       
   262             break;
       
   263             }
       
   264        /*     
       
   265         case EGlxCmdStateView:
       
   266             {
       
   267             iInFullScreen = ETrue;
       
   268             consumed = EFalse;
       
   269             }
       
   270             break;
       
   271 
       
   272         case EGlxCmdStateBrowse:
       
   273             {
       
   274             iInFullScreen = EFalse;
       
   275             iMskTextResourceId = 0;
       
   276             UpdateMiddleSoftkeyContentsL();
       
   277             UpdateMiddleSoftkeyStatus();
       
   278             consumed = EFalse;
       
   279             }
       
   280             break;*/
       
   281             
       
   282         default:
       
   283             {
       
   284             consumed = EFalse;
       
   285             break;
       
   286         }
       
   287         }
       
   288     return consumed;
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // DoIsDisabled
       
   293 // ---------------------------------------------------------------------------
       
   294 //
       
   295 TBool CGlxCommandHandlerMarking::DoIsDisabled(TInt aCommandId, 
       
   296                                                 MGlxMediaList& aList) const
       
   297     {
       
   298     TBool disabled = EFalse;
       
   299     if( ViewingState() == TCommandInfo::EViewingStateView )
       
   300     	{
       
   301     	return ETrue;
       
   302     	}
       
   303     switch (aCommandId)
       
   304         {
       
   305         case EAknCmdMark:
       
   306             {
       
   307             // Base class has checked for min selection, so no need to check
       
   308             /// for Count() > 0
       
   309             disabled = ( aList.Item( aList.FocusIndex() ).IsStatic() ) ||
       
   310                     aList.IsSelected( aList.FocusIndex() );
       
   311             break;
       
   312             }
       
   313         case EAknCmdUnmark:
       
   314             {
       
   315             // disable if current item is not selected
       
   316             disabled = !( aList.IsSelected(aList.FocusIndex() ) );
       
   317             break;
       
   318             }
       
   319         case EAknMarkAll:
       
   320             {
       
   321             // disable if all items are marked
       
   322             TInt count = aList.Count( NGlxListDefs::ECountNonStatic );
       
   323             TInt selCount = aList.SelectionCount();           
       
   324             disabled = ( selCount >= count );
       
   325             break;
       
   326             }
       
   327         case EAknUnmarkAll:
       
   328             {
       
   329             // set disabled if no items selected
       
   330             disabled = ( aList.SelectionCount() == 0 );
       
   331             break;
       
   332             }
       
   333         case EGlxCmdStartMultipleMarking:
       
   334             {
       
   335             // set disabled if no static items present
       
   336             disabled = ( aList.Count( NGlxListDefs::ECountNonStatic ) == 0 );
       
   337             break;    
       
   338             }
       
   339         case EGlxCmdMarkingSubmenu:
       
   340             {
       
   341             // set disabled if no  static items present
       
   342             disabled = ( aList.Count( NGlxListDefs::ECountNonStatic ) == 0 );
       
   343             break;    
       
   344             }
       
   345         default:
       
   346             break;
       
   347         }
       
   348     
       
   349     return disabled;
       
   350     }
       
   351 
       
   352 // ---------------------------------------------------------------------------
       
   353 // DoDynInitMenuPaneL
       
   354 // ---------------------------------------------------------------------------
       
   355 //
       
   356 void CGlxCommandHandlerMarking::DoDynInitMenuPaneL(TInt /*aResourceId*/, 
       
   357                                                 CEikMenuPane* /*aMenuPane*/)
       
   358     {          
       
   359     }
       
   360   
       
   361 
       
   362     
       
   363 // ---------------------------------------------------------------------------
       
   364 // DoActivateL
       
   365 // ---------------------------------------------------------------------------
       
   366 //
       
   367 void CGlxCommandHandlerMarking::DoActivateL(TInt aViewId)
       
   368     {
       
   369     // store view id
       
   370     iViewId = aViewId;
       
   371     
       
   372     
       
   373     // get media list from provider
       
   374     MGlxMediaList& mlist = MediaList();
       
   375     mlist.AddMediaListObserverL( this );
       
   376     }
       
   377 
       
   378 // ---------------------------------------------------------------------------
       
   379 // Deactivate
       
   380 // ---------------------------------------------------------------------------
       
   381 //
       
   382 void CGlxCommandHandlerMarking::Deactivate()
       
   383     {
       
   384 
       
   385     MediaList().RemoveMediaListObserver( this );
       
   386     if(iMultipleMarking)
       
   387         {
       
   388         iMultipleMarking = EFalse;
       
   389         }
       
   390     // set selection to unmarked
       
   391     TRAP_IGNORE( SelectAllL( EFalse ) );
       
   392     }
       
   393 
       
   394 // ---------------------------------------------------------------------------
       
   395 // OfferKeyEventL
       
   396 // ---------------------------------------------------------------------------
       
   397 //
       
   398 TKeyResponse CGlxCommandHandlerMarking::OfferKeyEventL(const TKeyEvent& 
       
   399                                                     aKeyEvent, TEventCode aType)
       
   400     {
       
   401     
       
   402     // Consume zoom key events in multiple marking mode
       
   403     // to prevent entering full screen view
       
   404     if ( iMultipleMarking && ( EStdKeyIncVolume == aKeyEvent.iScanCode
       
   405                             || EStdKeyDecVolume == aKeyEvent.iScanCode) )
       
   406         {
       
   407         return EKeyWasConsumed;
       
   408         }
       
   409 
       
   410     TBool shiftKeyPressed = ( aKeyEvent.iModifiers & EModifierShift );
       
   411     
       
   412     // marking not available in full-screen mode
       
   413     if( !iInFullScreen )
       
   414         {
       
   415         // get media list from provider
       
   416         MGlxMediaList& mediaList = MediaList();
       
   417         if ( shiftKeyPressed && aType == EEventKeyDown )
       
   418             {
       
   419             if ( !iBasicMarking )
       
   420                 {   
       
   421                 iBasicMarking = ETrue;
       
   422                 // toggle marking mode based on current marked state
       
   423                 if ( mediaList.IsSelected( mediaList.FocusIndex() ) )
       
   424                     {
       
   425                     iMarkingMode=EUnmarking;
       
   426                     }
       
   427                 else
       
   428                     {
       
   429                     iMarkingMode=EMarking;
       
   430                     }
       
   431                 }
       
   432             }
       
   433         else if( shiftKeyPressed && aType == EEventKey )
       
   434             {
       
   435             // handle navi-key select   
       
   436             if( aKeyEvent.iScanCode==EStdKeyDevice3 )
       
   437                 {         
       
   438                 TInt focIdx = mediaList.FocusIndex();
       
   439                 
       
   440                 /// is already in DoExecuteL:
       
   441                 /// Call ExecuteL with EAknCmdMark or EAknCmdUnmark to avoid duplication.
       
   442                 /// Replace with following code with 
       
   443                 /// (void) ExecuteL( mlist.IsSelected( mlist.FocusIndex() ) ? 
       
   444                 ///     EAknCmdUnmark : EAknCmdMark );
       
   445                 if( focIdx != KErrNotFound )
       
   446                     {
       
   447                     if ( mediaList.IsSelected( focIdx ) )
       
   448                         {
       
   449                         // item is marked so unmark
       
   450                         mediaList.SetSelectedL(focIdx, EFalse);
       
   451                         }
       
   452                     else
       
   453                         {
       
   454                         // if not static item set selected
       
   455                         if( !mediaList.Item(focIdx).IsStatic() )
       
   456                             {
       
   457                             mediaList.SetSelectedL( focIdx, ETrue ); 
       
   458                             }
       
   459                         }    
       
   460                     }
       
   461                               
       
   462                 return EKeyWasConsumed;
       
   463                 }
       
   464             }
       
   465         else if( !shiftKeyPressed && aType == EEventKeyUp )
       
   466             {
       
   467             // if in basic marking mode exit basic marking mode
       
   468             if(iBasicMarking)
       
   469                 {
       
   470                 iBasicMarking = EFalse;
       
   471 				if(!iUiUtility->IsPenSupported())
       
   472 					{
       
   473 	                // Change RSK
       
   474 	                iScreenFurniture->ModifySoftkeyIdL(
       
   475 	                        CEikButtonGroupContainer::ERightSoftkeyPosition, 
       
   476 	                        EAknSoftkeyCancel, 0, *iRskTextCancel);
       
   477 
       
   478 	                // Change MSK
       
   479 	                iScreenFurniture->ModifySoftkeyIdL(
       
   480 	                        CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   481 	                        EAknCmdMark, 0, *iMskTextMark);  
       
   482 					}  
       
   483                 }
       
   484             }
       
   485         else
       
   486             {
       
   487             } 
       
   488         }
       
   489   
       
   490     return EKeyWasNotConsumed;
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // HandleItemAddedL
       
   495 // ---------------------------------------------------------------------------
       
   496 void CGlxCommandHandlerMarking::HandleItemAddedL(TInt /*aStartIndex*/, 
       
   497                                     TInt /*aEndIndex*/, MGlxMediaList* /*aList*/)
       
   498     {
       
   499     // No Implementation
       
   500     }
       
   501     
       
   502     
       
   503 // ---------------------------------------------------------------------------
       
   504 // HandleMediaL
       
   505 // ---------------------------------------------------------------------------
       
   506 void CGlxCommandHandlerMarking::HandleMediaL(TInt /*aListIndex*/, 
       
   507                                      MGlxMediaList* /*aList*/)
       
   508     {
       
   509     
       
   510     }
       
   511 
       
   512 // ---------------------------------------------------------------------------
       
   513 // HandleItemRemoved
       
   514 // ---------------------------------------------------------------------------
       
   515 void CGlxCommandHandlerMarking::HandleItemRemovedL(TInt /*aStartIndex*/, 
       
   516                                     TInt /*aEndIndex*/, MGlxMediaList* /*aList*/)
       
   517     {
       
   518     //UpdateMiddleSoftkeyStatus();
       
   519     }
       
   520 
       
   521 // ---------------------------------------------------------------------------
       
   522 // HandleItemModifiedL
       
   523 // ---------------------------------------------------------------------------
       
   524 void CGlxCommandHandlerMarking::HandleItemModifiedL(const RArray<TInt>& 
       
   525                                     /*aItemIndexes*/, MGlxMediaList* /*aList*/)
       
   526     {
       
   527     }
       
   528 
       
   529 // ---------------------------------------------------------------------------
       
   530 // HandleAttributesAvailableL
       
   531 // ---------------------------------------------------------------------------
       
   532 void CGlxCommandHandlerMarking::HandleAttributesAvailableL(TInt aItemIndex,     
       
   533         const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* aList)
       
   534     {
       
   535 	TRACER("CGlxCommandHandlerMarking::HandleAttributesAvailableL");
       
   536 	
       
   537 	if(!iUiUtility->IsPenSupported())
       
   538 		{
       
   539 	    if( aItemIndex == aList->FocusIndex() && iMultipleMarking)
       
   540 	        {
       
   541 	        if(aList->Item(aItemIndex).IsStatic())
       
   542 	            {
       
   543 	            iScreenFurniture->ModifySoftkeyIdL(
       
   544 	                    CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   545 	                    EAknSoftkeyEmpty, 0, KGlxBlankString);    
       
   546 	            }
       
   547 	        else
       
   548 	            {
       
   549 	            if (aList->IsSelected(aItemIndex))
       
   550 	                {
       
   551 	                iScreenFurniture->ModifySoftkeyIdL(
       
   552 	                        CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   553 	                        EAknCmdUnmark, 0, *iMskTextUnMark);    
       
   554 	                }
       
   555 	            else
       
   556 	                {
       
   557 	                iScreenFurniture->ModifySoftkeyIdL(
       
   558 	                        CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   559 	                            EAknCmdMark, 0, *iMskTextMark);    
       
   560 	                }
       
   561 	            	}
       
   562 	        	}
       
   563 			}
       
   564     }
       
   565 
       
   566 // ---------------------------------------------------------------------------
       
   567 // HandleFocusChangedL
       
   568 // ---------------------------------------------------------------------------
       
   569 void CGlxCommandHandlerMarking::HandleFocusChangedL(NGlxListDefs::TFocusChangeType aType, 
       
   570                         TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList)
       
   571     {
       
   572     TRACER("CGlxCommandHandlerMarking::HandleFocusChangedL");
       
   573     if( iBasicMarking )
       
   574         {
       
   575         TInt startIdx = 0;
       
   576         TInt endIdx = 0;
       
   577         
       
   578         TInt count = aList->Count();
       
   579         
       
   580         switch (aType)
       
   581             {
       
   582             case NGlxListDefs::EForward:
       
   583                 {
       
   584                 startIdx = aOldIndex;
       
   585                 endIdx = aNewIndex;
       
   586                 
       
   587                 // if need to go off end of list add count to end index
       
   588                 // so we can iterate sequentally through items
       
   589                 if( aNewIndex < aOldIndex )
       
   590                     {
       
   591                     endIdx += count;   
       
   592                     }            
       
   593                 }
       
   594                 break;
       
   595             case NGlxListDefs::EBackward:
       
   596                 {
       
   597                 startIdx = aNewIndex;
       
   598                 endIdx = aOldIndex;
       
   599                 
       
   600                 // if need to go off end of list add count to end index
       
   601                 // so we can iterate sequentally through items
       
   602                 if( aOldIndex < aNewIndex )
       
   603                     {
       
   604                     endIdx += count;  
       
   605 
       
   606                     }          
       
   607                 }
       
   608                 break;
       
   609             // do nothing if focus type is unknown
       
   610             case NGlxListDefs::EUnknown:
       
   611             // fallthrough
       
   612             default:
       
   613                 break;
       
   614             }
       
   615         
       
   616         // set items in range to selected    
       
   617         if( startIdx != endIdx )
       
   618             {
       
   619             TInt iterator = startIdx;
       
   620             
       
   621             while( iterator <= endIdx )
       
   622                 {
       
   623                 // use modulus of count to take account
       
   624                 // of iterator range going off end of list
       
   625                 TInt listIndex = iterator % count;
       
   626                 SetSelectedL(aList, listIndex);    
       
   627                 iterator++;
       
   628                 }
       
   629             }
       
   630         }
       
   631     else
       
   632         {
       
   633 		if(!iUiUtility->IsPenSupported())
       
   634 			{
       
   635 	        if (aNewIndex >=0)
       
   636 	        {
       
   637 	            // if in multiple marking mode update softkey for current
       
   638 	            // focussed item
       
   639 	            // Update MSK
       
   640 	            if(aList->Item(aNewIndex).IsStatic())
       
   641 	                {
       
   642 	                iScreenFurniture->ModifySoftkeyIdL(
       
   643 	                        CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   644 	                        EAknSoftkeyEmpty, 0, KGlxBlankString);    
       
   645 	                }
       
   646 	            else
       
   647 	                {
       
   648 	                if (aList->IsSelected(aNewIndex))
       
   649 	                    {
       
   650 	                    iScreenFurniture->ModifySoftkeyIdL(
       
   651 	                            CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   652 	                            EAknCmdUnmark, 0, *iMskTextUnMark);    
       
   653 	                    }
       
   654 	                else
       
   655 	                    {
       
   656 	                    iScreenFurniture->ModifySoftkeyIdL(
       
   657 	                            CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
   658 	                                EAknCmdMark, 0, *iMskTextMark);    
       
   659 						if(!iMultipleMarking && (0 == aList->SelectionCount()))	                                
       
   660 							{
       
   661 							ExitMultipleMarkingModeL();
       
   662 							}
       
   663 	                    }
       
   664 	                }
       
   665 	            }
       
   666 			}
       
   667         }
       
   668     }
       
   669 
       
   670 // ---------------------------------------------------------------------------
       
   671 // HandleItemSelected
       
   672 // ---------------------------------------------------------------------------
       
   673 void CGlxCommandHandlerMarking::HandleItemSelectedL(TInt aIndex, 
       
   674                                 TBool /*aSelected*/, MGlxMediaList* aList)
       
   675     {
       
   676     TRACER("CGlxCommandHandlerMarking::HandleItemSelectedL");
       
   677     /**
       
   678     If in the multiple marking mode, and the item selected is the focussed 
       
   679     item, HandleItemSelected causes the left softkey to be updated to 
       
   680     correspond to the marked state of the focussed item. If the item is 
       
   681     marked the softkey is changed to "Unmark" and vice versa.
       
   682     */
       
   683     
       
   684 	if(!iUiUtility->IsPenSupported())
       
   685 		{
       
   686     	if( aIndex == aList->FocusIndex() )
       
   687         	{
       
   688         	// Update MSK
       
   689         	iScreenFurniture->ModifySoftkeyIdL(
       
   690                 CEikButtonGroupContainer::EMiddleSoftkeyPosition, EAknCmdUnmark, 0, *iMskTextUnMark);    
       
   691 
       
   692         	} 
       
   693 		}
       
   694     }
       
   695 
       
   696 // ---------------------------------------------------------------------------
       
   697 // HandleMessageL
       
   698 // ---------------------------------------------------------------------------
       
   699 void CGlxCommandHandlerMarking::HandleMessageL(const CMPXMessage& /*aMessage*/, 
       
   700                                                     MGlxMediaList* /*aList*/)
       
   701     {
       
   702     }
       
   703 
       
   704 // ---------------------------------------------------------------------------
       
   705 // ClearSelectionL
       
   706 // ---------------------------------------------------------------------------
       
   707 //    
       
   708 void CGlxCommandHandlerMarking::SelectAllL( TBool aSelect)
       
   709     {
       
   710     TRACER("CGlxCommandHandlerMarking::SelectAllL");
       
   711     MGlxMediaList& mlist = MediaList();
       
   712     TInt mcount = mlist.Count();
       
   713     for ( TInt i=0; i< mcount; i++ )
       
   714         {
       
   715         mlist.SetSelectedL( i, aSelect );
       
   716         }
       
   717     }
       
   718 
       
   719 // ---------------------------------------------------------------------------
       
   720 // EnterMultipleMarkingModeL
       
   721 // ---------------------------------------------------------------------------
       
   722 //  
       
   723 void CGlxCommandHandlerMarking::EnterMultipleMarkingModeL()
       
   724     {
       
   725     TRACER("CGlxCommandHandlerMarking::EnterMultipleMarkingModeL");
       
   726     
       
   727     iMultipleMarking = ETrue;
       
   728 	
       
   729 	if(!iUiUtility->IsPenSupported())
       
   730 		{
       
   731 	    // change softkeys
       
   732 	    // Change RSK
       
   733 	    iScreenFurniture->ModifySoftkeyIdL(
       
   734 	            CEikButtonGroupContainer::ERightSoftkeyPosition, 
       
   735 	                EAknSoftkeyCancel, 0, *iRskTextCancel);
       
   736 
       
   737 	    // Change MSK
       
   738 	    iScreenFurniture->ModifySoftkeyIdL(
       
   739 	            CEikButtonGroupContainer::EMiddleSoftkeyPosition, EAknCmdMark, 0, *iMskTextMark);    
       
   740 		}
       
   741     }
       
   742 
       
   743 // ---------------------------------------------------------------------------
       
   744 // ExitMultipleMarkingModeL
       
   745 // ---------------------------------------------------------------------------
       
   746 //  
       
   747 void CGlxCommandHandlerMarking::ExitMultipleMarkingModeL()
       
   748     {
       
   749     TRACER("CGlxCommandHandlerMarking::ExitMultipleMarkingModeL");
       
   750     
       
   751     iMultipleMarking = EFalse;
       
   752 
       
   753 	if(!iUiUtility->IsPenSupported())
       
   754 		{
       
   755 	    // rsetore softkeys
       
   756 	    // Change RSK
       
   757 	    iScreenFurniture->ModifySoftkeyIdL(
       
   758 	            CEikButtonGroupContainer::ERightSoftkeyPosition,
       
   759 	                EAknSoftkeyBack, 0, *iRskTextBack);
       
   760 
       
   761 	    iScreenFurniture->ModifySoftkeyIdL(
       
   762 	            CEikButtonGroupContainer::EMiddleSoftkeyPosition,
       
   763 	            EAknCmdOpen, 0, *iMskTextOpen);
       
   764 		}
       
   765     // set basic marking flag to false
       
   766     iBasicMarking = EFalse;
       
   767     }
       
   768 
       
   769 // ---------------------------------------------------------------------------
       
   770 // UpdateMarkedSelection
       
   771 // ---------------------------------------------------------------------------
       
   772 //  
       
   773 void CGlxCommandHandlerMarking::SetSelectedL(MGlxMediaList* aList, 
       
   774                                                                 TInt aIndex)
       
   775     {
       
   776     TRACER("CGlxCommandHandlerMarking::UpdateMarkedSelection");
       
   777     
       
   778     TBool mark = (iMarkingMode==EMarking);
       
   779     aList->SetSelectedL( aIndex, mark );
       
   780     }
       
   781     
       
   782 // ---------------------------------------------------------------------------
       
   783 // PopulateToolbar
       
   784 // ---------------------------------------------------------------------------
       
   785 //
       
   786 void CGlxCommandHandlerMarking::PopulateToolbarL()
       
   787 	{
       
   788 	TRACER("CGlxCommandHandlerMarking::PopulateToolbar");
       
   789 	
       
   790 	}
       
   791