clock2/clockui/uilayer/clockalarmeditor/src/clockalarmeditorimpl.cpp
branchRCL_3
changeset 30 d68a4b5d5885
parent 27 55d60436f00b
child 48 bf573002ff72
equal deleted inserted replaced
27:55d60436f00b 30:d68a4b5d5885
    43 
    43 
    44 // Constants
    44 // Constants
    45 const TInt KZerothDay( 0 );
    45 const TInt KZerothDay( 0 );
    46 const TInt KDaysInWeek( 7 );
    46 const TInt KDaysInWeek( 7 );
    47 const TInt KFirstLine( 1 );
    47 const TInt KFirstLine( 1 );
    48 const TInt KNextDayIndex( 1 );
       
    49 const TInt KRepeatOnceIndex( 0 );
    48 const TInt KRepeatOnceIndex( 0 );
    50 const TInt KWithIn24HoursIndex( 1 );
    49 const TInt KDailyIndex( 1 );
    51 const TInt KDailyIndex( 2 );
    50 const TInt KWorkdaysIndex( 2 );
    52 const TInt KWorkdaysIndex( 3 );
    51 const TInt KWeeklyIndex( 3 );
    53 const TInt KWeeklyIndex( 4 );
       
    54 const TInt KCurrentDayIndex( 0 );
       
    55 const TInt KMaxCharsInNote( 32 );
    52 const TInt KMaxCharsInNote( 32 );
    56 const TInt KZerothRule( 0 );
    53 const TInt KZerothRule( 0 );
    57 const TInt KOneMinuteInMicrosecond( 1000000 * 60 );
    54 const TInt KOneMinuteInMicrosecond( 1000000 * 60 );
    58 const TInt KNoDifference( 0 );
    55 const TInt KNoDifference( 0 );
    59 const TInt KOneHour( 1 );
    56 const TInt KOneHour( 1 );
   121     
   118     
   122     // If the user is setting a new alarm, the default repeat type is once only alarm.
   119     // If the user is setting a new alarm, the default repeat type is once only alarm.
   123     // The Description is "Alarm" by default too.
   120     // The Description is "Alarm" by default too.
   124     if( !iAlarmForEditing )
   121     if( !iAlarmForEditing )
   125         {
   122         {
   126         iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatNext24Hours;
   123         iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatOnce;
   127         
   124         
   128         // Here we have to load the default description.
   125         // Here we have to load the default description.
   129         HBufC* defaultDescription = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_EDITOR_DESC_DEFAULT, iCoeEnv );
   126         HBufC* defaultDescription = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_EDITOR_DESC_DEFAULT, iCoeEnv );
   130         iAlarmInfo.iMessage.Copy( defaultDescription->Des() );
   127         iAlarmInfo.iMessage.Copy( defaultDescription->Des() );
   131         // Cleanup
   128         // Cleanup
   186     // Let the form update itself first.
   183     // Let the form update itself first.
   187     CAknForm::SetInitialCurrentLine();
   184     CAknForm::SetInitialCurrentLine();
   188         
   185         
   189     // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and
   186     // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and
   190     // workdays. So when this functions is called, we check for the type and update the form accordingly.
   187     // workdays. So when this functions is called, we check for the type and update the form accordingly.
   191     if( KWithIn24HoursIndex == iOccuranceIndex ||
   188     if( KDailyIndex == iOccuranceIndex ||
   192         KDailyIndex == iOccuranceIndex ||
       
   193         KWorkdaysIndex == iOccuranceIndex )
   189         KWorkdaysIndex == iOccuranceIndex )
   194         {
   190         {
   195         DeleteAlmDayCtrlL();
   191         DeleteAlmDayCtrlL();
   196         }
   192         }
   197 	
   193 	
   244     switch( iOccuranceIndex )
   240     switch( iOccuranceIndex )
   245         {
   241         {
   246         case KRepeatOnceIndex:
   242         case KRepeatOnceIndex:
   247             {
   243             {
   248             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatOnce;
   244             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatOnce;
   249             }
   245             break;
   250             break;
   246             }
   251             
       
   252         case KWithIn24HoursIndex:
       
   253             {
       
   254             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatNext24Hours;
       
   255             }
       
   256             break;
       
   257             
       
   258         case KDailyIndex:
   247         case KDailyIndex:
   259             {
   248             {
   260             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatDaily;
   249             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatDaily;
   261             }
   250             break;
   262             break;
   251             }        
   263             
   252         case KWorkdaysIndex:
       
   253             {
       
   254             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWorkday;
       
   255             break;
       
   256             }                        
   264         case KWeeklyIndex:
   257         case KWeeklyIndex:
   265             {
   258             {
   266             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWeekly;
   259             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWeekly;
   267             }
   260             break;
   268             break;
   261             }        
   269             
       
   270         case KWorkdaysIndex:
       
   271             {
       
   272             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWorkday;
       
   273             }
       
   274             break;
       
   275             
       
   276         default:
   262         default:
   277 			{
   263 			{
   278 			// No implementation yet.
   264 			// No implementation yet.
   279 			}
   265 			}
   280             break;
   266             break;
   422     // Cleanup
   408     // Cleanup
   423     CleanupStack::PopAndDestroy( alarmDescription );
   409     CleanupStack::PopAndDestroy( alarmDescription );
   424     
   410     
   425     // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and
   411     // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and
   426     // workdays. So when this functions is called, we check for the type and update the form accordingly.
   412     // workdays. So when this functions is called, we check for the type and update the form accordingly.
   427     if( KWithIn24HoursIndex == iOccuranceIndex ||
   413     if( KDailyIndex == iOccuranceIndex ||
   428         KDailyIndex == iOccuranceIndex ||
       
   429         KWorkdaysIndex == iOccuranceIndex )
   414         KWorkdaysIndex == iOccuranceIndex )
   430         {
   415         {
   431         DeleteAlmDayCtrlL();
   416         DeleteAlmDayCtrlL();
   432         }
   417         }
   433 		
   418 		
   541         aMenuPane->SetItemDimmed( EClockAlarmChange, ETrue );
   526         aMenuPane->SetItemDimmed( EClockAlarmChange, ETrue );
   542         }
   527         }
   543     
   528     
   544     // Do not show Delete option when editing an alarm.
   529     // Do not show Delete option when editing an alarm.
   545     // Do not show Discard changes option if its a new alarm.
   530     // Do not show Discard changes option if its a new alarm.
   546     if( iAlarmForEditing )
   531     if( !iAlarmForEditing )
   547         {
       
   548         aMenuPane->SetItemDimmed( EClockAlarmDelete, ETrue );
       
   549         }
       
   550     else
       
   551         {
   532         {
   552         aMenuPane->SetItemDimmed( EClockAlarmDiscardChanges, ETrue );
   533         aMenuPane->SetItemDimmed( EClockAlarmDiscardChanges, ETrue );
   553         }
   534         }
   554     
   535     
   555     __PRINTS( "CClockAlarmEditorImpl::DynInitMenuPaneL - Exit" ); 
   536     __PRINTS( "CClockAlarmEditorImpl::DynInitMenuPaneL - Exit" ); 
   653             {
   634             {
   654             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatOnce;
   635             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatOnce;
   655             }
   636             }
   656             break;
   637             break;
   657         
   638         
   658         case KWithIn24HoursIndex:
       
   659             {
       
   660             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatNext24Hours;
       
   661             }
       
   662             break;
       
   663         
       
   664         case KDailyIndex:
   639         case KDailyIndex:
   665             {
   640             {
   666             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatDaily;
   641             iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatDaily;
   667             }
   642             }
   668             break;
   643             break;
   689     // Get the new occurance index
   664     // Get the new occurance index
   690     GetSelectedOccIndex();
   665     GetSelectedOccIndex();
   691     
   666     
   692     // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and
   667     // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and
   693     // workdays. So when this functions is called, we check for the type and update the form accordingly.
   668     // workdays. So when this functions is called, we check for the type and update the form accordingly.
   694     if( KWithIn24HoursIndex == iOccuranceIndex ||
   669     if( KDailyIndex == iOccuranceIndex ||
   695         KDailyIndex == iOccuranceIndex ||
       
   696         KWorkdaysIndex == iOccuranceIndex )
   670         KWorkdaysIndex == iOccuranceIndex )
   697         {
   671         {
   698         DeleteAlmDayCtrlL();
   672         DeleteAlmDayCtrlL();
   699         }
   673         }
   700     // If it is not present, we need to create it.
   674     // If it is not present, we need to create it.
   740         case EAlarmRepeatDefintionRepeatOnce:
   714         case EAlarmRepeatDefintionRepeatOnce:
   741             {
   715             {
   742             iOccuranceIndex = KRepeatOnceIndex;
   716             iOccuranceIndex = KRepeatOnceIndex;
   743             }
   717             }
   744             break;
   718             break;
   745             
       
   746         case EAlarmRepeatDefintionRepeatNext24Hours:
       
   747             {
       
   748             iOccuranceIndex = KWithIn24HoursIndex;
       
   749             }
       
   750             break;
       
   751 
       
   752         case EAlarmRepeatDefintionRepeatDaily:
   719         case EAlarmRepeatDefintionRepeatDaily:
   753             {
   720             {
   754             iOccuranceIndex = KDailyIndex;
   721             iOccuranceIndex = KDailyIndex;
   755             }
   722             }
   756             break;
   723             break;
   983     __PRINTS( "CClockAlarmEditorImpl::GetActualAlarmTime - Entry" );
   950     __PRINTS( "CClockAlarmEditorImpl::GetActualAlarmTime - Entry" );
   984 	
   951 	
   985     // Get the current day of the week.
   952     // Get the current day of the week.
   986     TInt currentDay( aHomeTime.DayNoInWeek() );
   953     TInt currentDay( aHomeTime.DayNoInWeek() );
   987         
   954         
   988     if( ( EAlarmRepeatDefintionRepeatOnce == iOccuranceIndex ) ||
   955     if( ( KRepeatOnceIndex == iOccuranceIndex ) ||
   989         ( EAlarmRepeatDefintionRepeatWeekly == iOccuranceIndex ) )
   956         ( KWeeklyIndex == iOccuranceIndex ) )
   990         {
   957         {
   991         TInt dateOffset( KZerothDay );
   958         TInt dateOffset( KZerothDay );
   992 
   959 
   993         if( currentDay < iDayIndex )
   960         if( currentDay < iDayIndex )
   994             {
   961             {
  1011                 dateOffset = KDaysInWeek;
   978                 dateOffset = KDaysInWeek;
  1012                 }
   979                 }
  1013             }
   980             }
  1014         aTimeFromForm += TTimeIntervalDays( dateOffset );
   981         aTimeFromForm += TTimeIntervalDays( dateOffset );
  1015         }
   982         }
  1016     else if( EAlarmRepeatDefintionRepeatNext24Hours == iOccuranceIndex )  
       
  1017         {
       
  1018         TInt dayIndex( KCurrentDayIndex );
       
  1019         if( aTimeFromForm < aHomeTime )
       
  1020             {
       
  1021             dayIndex = KNextDayIndex;   
       
  1022             }
       
  1023         aTimeFromForm += TTimeIntervalDays( dayIndex );
       
  1024         }
       
  1025     
       
  1026     __PRINTS( "CClockAlarmEditorImpl::GetActualAlarmTime - Exit" );
   983     __PRINTS( "CClockAlarmEditorImpl::GetActualAlarmTime - Exit" );
  1027     }
   984     }
  1028 
   985 
  1029 // ---------------------------------------------------------
   986 // ---------------------------------------------------------
  1030 // CClockAlarmEditorImpl::GetAlarmInformationL
   987 // CClockAlarmEditorImpl::GetAlarmInformationL
  1339     stringArray->AppendL( timeString );
  1296     stringArray->AppendL( timeString );
  1340 
  1297 
  1341     // Choose the appropriate Repeat type.
  1298     // Choose the appropriate Repeat type.
  1342     switch( iAlarmInfo.iRepeat )
  1299     switch( iAlarmInfo.iRepeat )
  1343         {
  1300         {
  1344         case EAlarmRepeatDefintionRepeatNext24Hours:
       
  1345         case EAlarmRepeatDefintionRepeatOnce:
  1301         case EAlarmRepeatDefintionRepeatOnce:
  1346             {
  1302             {
  1347             if( oneDayDifference )
  1303             if( oneDayDifference )
  1348                 {
  1304                 {
  1349                 stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_ONCE_NEXT, *stringArray, iEikonEnv );
  1305                 stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_ONCE_NEXT, *stringArray, iEikonEnv );