clock2/clockui/uilayer/clockmainview/src/clockmainview.cpp
branchRCL_3
changeset 30 d68a4b5d5885
parent 27 55d60436f00b
child 48 bf573002ff72
equal deleted inserted replaced
27:55d60436f00b 30:d68a4b5d5885
    24 #include <StringLoader.h>
    24 #include <StringLoader.h>
    25 #include <tz.h>
    25 #include <tz.h>
    26 #include <vtzrules.h>
    26 #include <vtzrules.h>
    27 #include <clockalarmeditor.h>
    27 #include <clockalarmeditor.h>
    28 #include <hlplch.h>
    28 #include <hlplch.h>
       
    29 #include <touchfeedback.h>
    29 
    30 
    30 // User includes
    31 // User includes
    31 #include "clockmainview.h"
    32 #include "clockmainview.h"
    32 #include "clockmaincontainer.h"
    33 #include "clockmaincontainer.h"
    33 #include "clockalarmarray.h"
    34 #include "clockalarmarray.h"
   226    
   227    
   227 	__PRINTS( "CClockMainView::SetNewAlarmL - Exit" );
   228 	__PRINTS( "CClockMainView::SetNewAlarmL - Exit" );
   228     }
   229     }
   229 
   230 
   230 // ---------------------------------------------------------
   231 // ---------------------------------------------------------
   231 // CClockMainView::RemoveAlarmL
   232 //papercut clock2 Remove_Snooze Start - rajender
   232 // rest of the details are commented in the header
   233 // CClockMainView::RemoveSnoozeL
   233 // ---------------------------------------------------------
   234 // rest of the details are commented in the header
   234 //
   235 // ---------------------------------------------------------
   235 void CClockMainView::RemoveAlarmL()
   236 //
   236     {
   237 void CClockMainView::RemoveSnoozeL()
   237 	__PRINTS( "CClockMainView::RemoveAlarmL - Entry" );
   238     {  
   238 	
   239     __PRINTS( "CClockMainView::RemoveSnoozeL - Entry" );       
   239     // First get the index of the selected item in the list.
   240     // First get the index of the selected item in the list.
   240     TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
   241     TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
   241     
   242     
   242     if( KErrNone >= itemIndex )
   243     if( KErrNone > itemIndex )
   243         {
   244         {
   244 		__PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
   245         __PRINTS( "CClockMainView::RemoveSnoozeL - Exit" );
   245 		
       
   246         return;
   246         return;
   247         }
   247         }
   248     
   248 
   249     
       
   250         SClkAlarmInfo alarmInfo;
   249         SClkAlarmInfo alarmInfo;
   251         TAlarmId alarmId;
   250         TAlarmId alarmId;
   252         // Get the alarm id from alarm model.
   251         // Get the alarm id from alarm model.
   253         iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
   252         iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
   254         
   253         
   255         // Delete the alarm.
   254         // Delete the alarm.
       
   255         User::LeaveIfError( iAlarmModel->AlarmRemoveSnooze( alarmId ) );
       
   256                 
       
   257         // Update the container.
       
   258         iContainer->ListBox()->HandleItemAdditionL();
       
   259         
       
   260         // Display the confirmation note to the user about alarm deletion.
       
   261         //CAknConfirmationNote* confNote = new( ELeave ) CAknConfirmationNote;
       
   262         //HBufC* confNoteText = StringLoader::LoadLC( R_QTN_CLOCK_SNOOZE_NOTE_REMOVED, iCoeEnv );
       
   263         // Display the note.
       
   264         //confNote->ExecuteLD( *confNoteText );
       
   265         // Cleanup.
       
   266         //CleanupStack::PopAndDestroy( confNoteText );
       
   267         
       
   268         __PRINTS( "CClockMainView::RemoveSnoozeL - Exit" );        
       
   269         
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------
       
   273 // CClockMainView::RemoveAlarmL
       
   274 // rest of the details are commented in the header
       
   275 // ---------------------------------------------------------
       
   276 //
       
   277 void CClockMainView::RemoveAlarmL( TAlarmId aAlarmId )
       
   278     {
       
   279     __PRINTS( "CClockMainView::RemoveAlarmL - Entry" );
       
   280     
       
   281     // First get the index of the selected item in the list.
       
   282     TInt itemIndex( iAlarmArray->ListBoxIndex( aAlarmId ) );
       
   283     
       
   284     if( KErrNone > itemIndex )
       
   285         {
       
   286         __PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
       
   287         
       
   288         return;
       
   289         }
       
   290         // Delete the alarm.
       
   291         User::LeaveIfError( iAlarmModel->DeleteClockAlarm( aAlarmId ) );
       
   292         // Update the container.
       
   293         iContainer->RemoveAlarmL( itemIndex );
       
   294         
       
   295     __PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------
       
   299 // CClockMainView::RemoveAlarmL
       
   300 // rest of the details are commented in the header
       
   301 // ---------------------------------------------------------
       
   302 //
       
   303 void CClockMainView::RemoveAlarmL()
       
   304     {
       
   305 	__PRINTS( "CClockMainView::RemoveAlarmL - Entry" );
       
   306 	
       
   307     // First get the index of the selected item in the list.
       
   308     TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
       
   309     
       
   310     if( KErrNone > itemIndex )
       
   311         {
       
   312 		__PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
       
   313 		
       
   314         return;
       
   315         }
       
   316     
       
   317     
       
   318         SClkAlarmInfo alarmInfo;
       
   319         TAlarmId alarmId;
       
   320         // Get the alarm id from alarm model.
       
   321         iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
       
   322         
       
   323         // Delete the alarm.
   256         User::LeaveIfError( iAlarmModel->DeleteClockAlarm( alarmId ) );
   324         User::LeaveIfError( iAlarmModel->DeleteClockAlarm( alarmId ) );
   257         
       
   258         // Display the confirmation note to the user about alarm deletion.
       
   259         CAknConfirmationNote* confNote = new( ELeave ) CAknConfirmationNote;
       
   260         HBufC* confNoteText = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_DELETED, iCoeEnv );
       
   261         // Display the note.
       
   262         confNote->ExecuteLD( *confNoteText );
       
   263         // Cleanup.
       
   264         CleanupStack::PopAndDestroy( confNoteText );
       
   265         
       
   266         // Update the container.
   325         // Update the container.
   267         iContainer->RemoveAlarmL( itemIndex );
   326         iContainer->RemoveAlarmL( itemIndex );
   268         
   327         
   269         
   328         
   270        
   329        
   363 	// Update the title pane text.
   422 	// Update the title pane text.
   364     static_cast< CClockAppUi* > ( AppUi() )->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW );
   423     static_cast< CClockAppUi* > ( AppUi() )->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW );
   365 	
   424 	
   366 	 // Show the navigation pane again.
   425 	 // Show the navigation pane again.
   367     appUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId );
   426     appUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId );
   368     
   427 
       
   428     if(  EClockAlarmDelete == iAlarmId )
       
   429         {
       
   430         // Mark the alarm editor as closed.
       
   431         iAlarmEditorOpen = EFalse;
       
   432     
       
   433         if( alarmEditor )
       
   434             {
       
   435             delete alarmEditor;
       
   436             alarmEditor = NULL;
       
   437             }
       
   438         __PRINTS( "CClockMainView::ResetAlarmL:EClockAlarmDelete - Exit" ); 
       
   439         
       
   440         // do the removing of the alarm
       
   441         RemoveAlarmL( alarmId );
       
   442         
       
   443         return;
       
   444         }    
       
   445 
   369     if( EClockAlarmExit == iAlarmId )
   446     if( EClockAlarmExit == iAlarmId )
   370         {		
   447         {		
   371         // Mark the alarm editor as closed.
   448         // Mark the alarm editor as closed.
   372 		iAlarmEditorOpen = EFalse;
   449 		iAlarmEditorOpen = EFalse;
   373     
   450     
   553       
   630       
   554     // If opened from clock, display the navigation pane again.
   631     // If opened from clock, display the navigation pane again.
   555     clockAppUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId );
   632     clockAppUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId );
   556     
   633     
   557     // Activate the container.
   634     // Activate the container.
   558     iContainer->ActivateL();
   635     if( clockAppUi->TransitionOngoing() )
       
   636         {
       
   637         //clockAppUi->DoAppearTransition( iContainer );
       
   638         iContainer->ActivateL();
       
   639         }
       
   640     else
       
   641         {
       
   642         iContainer->ActivateL();
       
   643         }
   559     
   644     
   560 	__PRINTS( "CClockMainView::DoActivateL - Exit" );
   645 	__PRINTS( "CClockMainView::DoActivateL - Exit" );
   561     }
   646     }
   562 
   647 
   563 // ---------------------------------------------------------
   648 // ---------------------------------------------------------
   573 	CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() );
   658 	CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() );
   574 	TRAP_IGNORE( clockDocument->StoreDataL() );
   659 	TRAP_IGNORE( clockDocument->StoreDataL() );
   575 	
   660 	
   576 	if( iContainer )
   661 	if( iContainer )
   577 		{
   662 		{
   578 	
   663 	    CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) );
       
   664         if( clockAppUi->TransitionOngoing() )
       
   665             {
       
   666             //clockAppUi->DoDisappearTransition( iContainer );
       
   667             }
   579 		// First remove the container from the control stack
   668 		// First remove the container from the control stack
   580 		( AppUi() )->RemoveFromStack( iContainer );
   669 		( AppUi() )->RemoveFromStack( iContainer );
   581 		// And then destroy it.
   670 		// And then destroy it.
   582 		delete iContainer;
   671 		delete iContainer;
   583 		iContainer = NULL;
   672 		iContainer = NULL;
   598 	switch( aCommand )
   687 	switch( aCommand )
   599 		{
   688 		{
   600 		//Single click integration
   689 		//Single click integration
   601 	    case EClockSelect:
   690 	    case EClockSelect:
   602 		    {
   691 		    {
   603 		    if ( iContainer->ListBox()->CurrentItemIndex() == 0 )
   692 		    ResetAlarmL();
   604 		        {
       
   605 		        SetNewAlarmL(); 
       
   606 		        }
       
   607 		    else
       
   608 		        {
       
   609 		        ResetAlarmL(); 
       
   610 		        } 
       
   611 		    }
   693 		    }
   612 		    break; 
   694 		    break; 
   613 
   695 
   614 	    case EClockNewAlarm:
   696 	    case EClockNewAlarm:
   615 		    {
   697 		    {
   643 		    {
   725 		    {
   644 		    // Delete the selected alarm.
   726 		    // Delete the selected alarm.
   645 		    RemoveAlarmL();
   727 		    RemoveAlarmL();
   646 		    }
   728 		    }
   647 		    break;
   729 		    break;
   648 		    
   730 		case EClockRemoveSnooze:
       
   731 		    {
       
   732 		    // Remove snooze on the selected alarm
       
   733 		    RemoveSnoozeL();
       
   734 		    }
       
   735 		    break;
       
   736 	      case EClockSwitchClockType:
       
   737             {
       
   738             // Switches clock type
       
   739             SwitchClockTypeL();
       
   740             }
       
   741             break;
   649 		case EClockSettings:
   742 		case EClockSettings:
   650 		    {
   743 		    {
   651 		    // Let the appui handle the command.
   744 		    // Let the appui handle the command.
   652 		    AppUi()->HandleCommandL( EClockSettings );
   745 		    AppUi()->HandleCommandL( EClockSettings );
   653 		    }
   746 		    }
   703         
   796         
   704         // In case the currently focussed item is invalid,set the focus to last item and set the msk text accordingly. 
   797         // In case the currently focussed item is invalid,set the focus to last item and set the msk text accordingly. 
   705         if( KErrNotFound == currentlyFocussedItem ) 
   798         if( KErrNotFound == currentlyFocussedItem ) 
   706             {
   799             {
   707             TInt itemCount = iContainer->ListBox()->Model()->ItemTextArray()->MdcaCount();
   800             TInt itemCount = iContainer->ListBox()->Model()->ItemTextArray()->MdcaCount();
   708         	iContainer->ListBox()->SetCurrentItemIndexAndDraw( itemCount -1 );
   801 			if( itemCount > 0 )
       
   802                 {
       
   803                 iContainer->ListBox()->SetCurrentItemIndexAndDraw( itemCount -1 );
       
   804                 }
       
   805             else
       
   806                 {
       
   807                 iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZeroAlarms );
       
   808                 }
   709         	
   809         	
   710         	
   810         	
   711             }    
   811             }    
   712         }
   812         }
   713 	
   813 	
   739         aMenuPane->DeleteMenuItem( EAlarmHelpAlarmClock );
   839         aMenuPane->DeleteMenuItem( EAlarmHelpAlarmClock );
   740         }*/
   840         }*/
   741 
   841 
   742 	
   842 	
   743     TInt alarmCount = iAlarmArray->MdcaCount();
   843     TInt alarmCount = iAlarmArray->MdcaCount();
   744 
   844     TBool deleteRemoveSnooze( EFalse );
   745     // There are no alarms set or the current focussed listitem is "New Alarm" then remove alarm specific options 
   845 
   746     if( KZeroAlarms >= alarmCount || ( KErrNone == iContainer->ListBox()->CurrentItemIndex() ) )
   846     // There are no alarms set 
       
   847     if( KZeroAlarms >= alarmCount )
   747         {
   848         {
   748         // There are no alarms set. Remove the irrelevant options from the menu.
   849         // There are no alarms set. Remove the irrelevant options from the menu.
   749         aMenuPane->DeleteMenuItem( EClockNewAlarm );
       
   750         aMenuPane->DeleteMenuItem( EClockResetAlarm );
   850         aMenuPane->DeleteMenuItem( EClockResetAlarm );
   751         aMenuPane->DeleteMenuItem( EClockRemoveAlarm );
   851         aMenuPane->DeleteMenuItem( EClockRemoveAlarm );
   752         aMenuPane->DeleteMenuItem( EClockActivateAlarm );           
   852         aMenuPane->DeleteMenuItem( EClockActivateAlarm );           
   753         aMenuPane->DeleteMenuItem( EClockDeactivateAlarm );                                 
   853         aMenuPane->DeleteMenuItem( EClockDeactivateAlarm );                                 
       
   854         deleteRemoveSnooze = ETrue;
   754         }
   855         }
   755     else
   856     else
   756         {
   857         {
   757         // There is atleast one alarm set. Get the details to update the menu.
   858         // There is atleast one alarm set. Get the details to update the menu.
   758         SClkAlarmInfo alarmInfo;
   859         SClkAlarmInfo alarmInfo;
   771             if( ( EAlarmRepeatDefintionRepeatOnce == alarmInfo.iRepeat ) || 
   872             if( ( EAlarmRepeatDefintionRepeatOnce == alarmInfo.iRepeat ) || 
   772                 ( EAlarmRepeatDefintionRepeatNext24Hours == alarmInfo.iRepeat) )
   873                 ( EAlarmRepeatDefintionRepeatNext24Hours == alarmInfo.iRepeat) )
   773                 {
   874                 {
   774                 // Alarm is not recurring. Remove the deactivate option from the menu.
   875                 // Alarm is not recurring. Remove the deactivate option from the menu.
   775                 aMenuPane->DeleteMenuItem( EClockDeactivateAlarm ); 
   876                 aMenuPane->DeleteMenuItem( EClockDeactivateAlarm ); 
       
   877                 // no snooze removing needed for not recurring
       
   878                 deleteRemoveSnooze = ETrue;
       
   879                 }
       
   880             // if the alarm is not snoozed, Remove the 'Remove snooze' option
       
   881             if (alarmInfo.iState != EAlarmStateSnoozed )
       
   882                 {
       
   883                 deleteRemoveSnooze = ETrue;
   776                 }
   884                 }
   777             }
   885             }
   778         else        
   886         else        
   779             {
   887             {
   780             // Alarm is already inactive. Remove the deactivate option from the menu. 
   888             // Alarm is already inactive. Remove the deactivate option from the menu. 
   781             aMenuPane->DeleteMenuItem( EClockDeactivateAlarm );
   889             aMenuPane->DeleteMenuItem( EClockDeactivateAlarm );
   782             }
   890             deleteRemoveSnooze = ETrue;
   783         }
   891             }
   784 
   892         }
   785    
   893        if( deleteRemoveSnooze )
       
   894            {
       
   895            aMenuPane->DeleteMenuItem( EClockRemoveSnooze );
       
   896            }
   786 		
   897 		
   787 	__PRINTS( "CClockMainView::DynInitMenuPaneL - Exit" );
   898 	__PRINTS( "CClockMainView::DynInitMenuPaneL - Exit" );
   788     }
   899     }
   789 
   900 
   790 // ---------------------------------------------------------
   901 // ---------------------------------------------------------
  1229     __PRINTS( "CClockAlarmEditorImpl::CheckForDstChangesL - Exit" );
  1340     __PRINTS( "CClockAlarmEditorImpl::CheckForDstChangesL - Exit" );
  1230 
  1341 
  1231     return returnValue;
  1342     return returnValue;
  1232     }
  1343     }
  1233 
  1344 
       
  1345 void CClockMainView::GiveVibes()
       
  1346     {
       
  1347     CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) );
       
  1348     if ( clockAppUi->GetFeedback() &&
       
  1349             clockAppUi->GetFeedback()->TouchFeedbackSupported() )
       
  1350         {
       
  1351         clockAppUi->GetFeedback()->InstantFeedback( ETouchFeedbackBasic );
       
  1352         }    
       
  1353     }
       
  1354 
       
  1355 void CClockMainView::SwitchClockTypeL()
       
  1356     {
       
  1357     TLocale phoneLocale;
       
  1358     // Set the new clock format with the locale.
       
  1359     phoneLocale.SetClockFormat( ( EClockAnalog == phoneLocale.ClockFormat() )
       
  1360             ? EClockDigital : EClockAnalog );
       
  1361     phoneLocale.Set();
       
  1362     if( iContainer )
       
  1363         {
       
  1364         iContainer->SwitchClockTypeL();
       
  1365         }
       
  1366     }
       
  1367 
  1234 // End of file
  1368 // End of file