fmradio/fmradio/src/fmradiochannellistcontainer.cpp
branchRCL_3
changeset 13 4f2584af5a29
parent 9 0004e923f486
child 15 04aa446da81c
equal deleted inserted replaced
12:9f3ff466f56b 13:4f2584af5a29
   279 // CFMRadioChannelListContainer::RemoveChannelL
   279 // CFMRadioChannelListContainer::RemoveChannelL
   280 // Removes channel from container list
   280 // Removes channel from container list
   281 // ----------------------------------------------------
   281 // ----------------------------------------------------
   282 //
   282 //
   283 void CFMRadioChannelListContainer::RemoveChannelL( TInt aIndex )
   283 void CFMRadioChannelListContainer::RemoveChannelL( TInt aIndex )
   284 	{
   284     {
   285 	if ( iChannelItemArray->Count() > 0 )
   285     if ( iChannelItemArray->Count() > 0 )
   286 		{
   286         {
   287 		TInt presetIndex = iRadioEngine.GetPresetIndex();
   287         TInt presetIndex = iRadioEngine.GetPresetIndex();
   288 		
   288         
   289 		iChannelItemArray->Delete( aIndex );
   289         iChannelItemArray->Delete( aIndex );
   290 		iChannelList->HandleItemRemovalL();
   290         iChannelList->HandleItemRemovalL();
   291 		iChannelList->UpdateScrollBarsL();
   291         iChannelList->UpdateScrollBarsL();
   292 		iChannelList->DrawDeferred();
   292 
   293 							
   293         if ( iChannelItemArray->Count() > 0 )
   294 		if ( iChannelItemArray->Count() > 0 )
   294             {
   295 			{
   295             ReIndexAllL();
   296 			ReIndexAllL();
   296             
   297 			
   297             if ( presetIndex > aIndex )			    
   298 			if ( presetIndex > aIndex )			    
   298                 {
   299 			    {
   299                 // update engine settings also
   300 			    // update engine settings also
   300                 iRadioEngine.SetCurrentPresetIndex( presetIndex - 1 );
   301 			    iRadioEngine.SetCurrentPresetIndex( presetIndex - 1 );
       
   302                 UpdateItemIconL( presetIndex - 1, KNowPlayingIconIndexChList );
   301                 UpdateItemIconL( presetIndex - 1, KNowPlayingIconIndexChList );
   303                 }
   302                 }
   304 			else if ( presetIndex == aIndex  )
   303             else if ( presetIndex == aIndex  )
   305                 {
   304                 {
   306                 iRadioEngine.TunePresetL( 0 );	
   305                 iRadioEngine.TunePresetL( 0 );	
   307                 UpdateItemIconL( 0, KNowPlayingIconIndexChList );
   306                 UpdateItemIconL( 0, KNowPlayingIconIndexChList );
   308                 }
   307                 }
   309 			else
   308             else
   310 			    {
   309                 {
   311 			    // NOP
   310                 // NOP
   312 			    }               
   311                 }               
   313             iChannelList->SetCurrentItemIndex( 0 );
   312             iChannelList->SetCurrentItemIndex( 0 );
   314 			}
   313             
   315 		else
   314             }
   316 		    {
   315         else
   317 		    // The last item was deleted, tune to current frequency, out of preset mode
   316             {
   318 		    iRadioEngine.Tune( iRadioEngine.GetTunedFrequency(), CRadioEngine::ERadioTunerMode );
   317             // The last item was deleted, tune to current frequency, out of preset mode
   319 		    }
   318             iRadioEngine.Tune( iRadioEngine.GetTunedFrequency(), CRadioEngine::ERadioTunerMode );
   320 		}
   319             }
   321 	}
   320         iChannelList->DrawDeferred();
       
   321         }
       
   322     }
   322 
   323 
   323 // ----------------------------------------------------
   324 // ----------------------------------------------------
   324 // CFMRadioChannelListContainer::AddChannel
   325 // CFMRadioChannelListContainer::AddChannel
   325 // Adds channels to container list
   326 // Adds channels to container list
   326 // ----------------------------------------------------
   327 // ----------------------------------------------------
   576 // CFMRadioChannelListContainer::OfferKeyEventL
   577 // CFMRadioChannelListContainer::OfferKeyEventL
   577 // Allow the channel list to process key events
   578 // Allow the channel list to process key events
   578 // ---------------------------------------------------------
   579 // ---------------------------------------------------------
   579 //
   580 //
   580 TKeyResponse CFMRadioChannelListContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   581 TKeyResponse CFMRadioChannelListContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   581 														   TEventCode aType )
   582                                                            TEventCode aType )
   582 	{
   583     {
   583 	TKeyResponse response = EKeyWasNotConsumed;
   584     TKeyResponse response = EKeyWasNotConsumed;
   584 
   585 
   585     switch ( aKeyEvent.iCode )
   586     switch ( aKeyEvent.iCode )
   586         {
   587         {
   587         case EKeyOK:
   588         case EKeyBackspace:
   588             {
   589             {
   589             // msk, used to accept move action
   590             if ( iChannelList->IsHighlightEnabled() && !iMoveAction )
       
   591                 {
       
   592                 iChannelView->HandleCommandL( EFMRadioCmdErase );
       
   593                 return EKeyWasConsumed;
       
   594                 }
       
   595             break;
       
   596             }
       
   597         case EKeyOK: // accept both
       
   598         case EKeyEnter:
       
   599             {
       
   600             // used to accept move action
   590             if ( iMoveAction )
   601             if ( iMoveAction )
   591                 {
   602                 {
   592                 iChannelView->MoveActionDoneL();
   603                 iChannelView->MoveActionDoneL();
   593                 return EKeyWasConsumed;
   604                 return EKeyWasConsumed;
       
   605                 }
       
   606             else if ( iChannelList->IsHighlightEnabled() ) // change to main view
       
   607                 {
       
   608                 if ( iChannelView->CurrentlyPlayingChannel() ==
       
   609                         CurrentlySelectedChannel() )
       
   610                     {
       
   611                     CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( iCoeEnv->AppUi() );
       
   612                     appUi->ActivateLocalViewL( KFMRadioMainViewId );
       
   613                     return EKeyWasConsumed;
       
   614                     }
   594                 }
   615                 }
   595             break;
   616             break;
   596             }
   617             }
   597         case EKeyLeftArrow:
   618         case EKeyLeftArrow:
   598         case EKeyRightArrow:
   619         case EKeyRightArrow:
   599         	{
   620             {
   600             return EKeyWasNotConsumed;
   621             return EKeyWasNotConsumed;
   601         	}
   622             }
   602         case EKeyUpArrow:
   623         case EKeyUpArrow:
   603         	if ( iMoveAction )	
   624             if ( iMoveAction )	
   604         		{
   625                 {
   605                 iKeyMoveActivated = ETrue;
   626                 iKeyMoveActivated = ETrue;
   606         		MoveUpL();
   627                 MoveUpL();
   607 	            }
   628                 response = EKeyWasConsumed;
   608         	else
   629                 }
   609         		{
   630             else
   610         		response = iChannelList->OfferKeyEventL(aKeyEvent, aType);
   631                 {
   611 	            if (response == EKeyWasConsumed)
   632                 response = iChannelList->OfferKeyEventL(aKeyEvent, aType);
   612 	                {
   633                 if (response == EKeyWasConsumed)
   613 	                ReportEventL( MCoeControlObserver::EEventRequestFocus );
   634                     {
   614 	                }
   635                     ReportEventL( MCoeControlObserver::EEventRequestFocus );
   615         		}
   636                     }
   616         	return response;
   637                 }
       
   638             return response;
   617         case EKeyDownArrow:
   639         case EKeyDownArrow:
   618         	if ( iMoveAction )	
   640             if ( iMoveAction )	
   619         		{
   641                 {
   620                 iKeyMoveActivated = ETrue;
   642                 iKeyMoveActivated = ETrue;
   621         		MoveDownL();
   643                 MoveDownL();
   622 	            }
   644                 response = EKeyWasConsumed;
   623         	else
   645                 }
   624         		{
   646             else
   625         		response = iChannelList->OfferKeyEventL(aKeyEvent, aType);
   647                 {
   626 	            if (response == EKeyWasConsumed)
   648                 response = iChannelList->OfferKeyEventL(aKeyEvent, aType);
   627 	                {
   649                 if (response == EKeyWasConsumed)
   628 	                ReportEventL( MCoeControlObserver::EEventRequestFocus );
   650                     {
   629 	                }
   651                     ReportEventL( MCoeControlObserver::EEventRequestFocus );
   630         		}
   652                     }
       
   653                 }
   631             return response;
   654             return response;
   632         default:
   655         default:
   633 			switch ( aKeyEvent.iScanCode ) //we need to use the scan code, because we need to process the event wrt the keyUp and keyDown action
   656             switch ( aKeyEvent.iScanCode ) //we need to use the scan code, because we need to process the event wrt the keyUp and keyDown action
   634 				{
   657                 {
   635                 case EKeyboardKey1: // Timed key
   658                 case EKeyboardKey1: // Timed key
   636                 case EKeyboardKey2: // Normal keys
   659                 case EKeyboardKey2: // Normal keys
   637                 case EKeyboardKey3:
   660                 case EKeyboardKey3:
   638                 case EKeyboardKey4:
   661                 case EKeyboardKey4:
   639                 case EKeyboardKey5:
   662                 case EKeyboardKey5:
   640                 case EKeyboardKey6:
   663                 case EKeyboardKey6:
   641                 case EKeyboardKey7:
   664                 case EKeyboardKey7:
   642                 case EKeyboardKey8:
   665                 case EKeyboardKey8:
   643                 case EKeyboardKey9:
   666                 case EKeyboardKey9:
   644                 case EKeyboardKey0:
   667                 case EKeyboardKey0:
   645 					return EKeyWasNotConsumed;
   668                     return EKeyWasNotConsumed;
   646 				default:
   669                 default:
   647 					break;
   670                     break;
   648 				}
   671                 }
   649             break;
   672             break;
   650 		}
   673         }
   651     return iChannelList->OfferKeyEventL(aKeyEvent, aType);
   674     return iChannelList->OfferKeyEventL(aKeyEvent, aType);
   652     }
   675     }
   653 
   676 
   654 // ---------------------------------------------------------------------------
   677 // ---------------------------------------------------------------------------
   655 // CFMRadioChannelListContainer::GetHelpContext
   678 // CFMRadioChannelListContainer::GetHelpContext