calendarui/editors/src/calenalldayfield.cpp
branchRCL_3
changeset 66 bd7edf625bdd
child 67 1539a383d7b6
child 86 ed599363c2d7
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 // user includes
       
    19 #include "calenalldayfield.h"
       
    20 #include "calenunifiededitor.h"
       
    21 #include "CalenDefaultEditors.hrh"
       
    22 #include <calendateutils.h>
       
    23 
       
    24 // system includes
       
    25 #include <CalenDefaultEditorsData.rsg>
       
    26 
       
    27 // debug
       
    28 #include "calendarui_debug.h"
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CCalenAllDayField::NewL()
       
    32 // (other items were commented in a header).
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CCalenAllDayField* CCalenAllDayField::NewL( CCalenUnifiedEditor& aUnifiedEditor )
       
    36     {
       
    37     TRACE_ENTRY_POINT;
       
    38 
       
    39     CCalenAllDayField* self =
       
    40         new( ELeave ) CCalenAllDayField( aUnifiedEditor );
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop();
       
    44 
       
    45     TRACE_EXIT_POINT;
       
    46     return self;
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CCalenAllDayField::CCalenAllDayFiled()
       
    51 // Constructor.
       
    52 // (other items were commented in a header).
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CCalenAllDayField::CCalenAllDayField( CCalenUnifiedEditor& aUnifiedEditor )
       
    56     : iUnifiedEditor( aUnifiedEditor )
       
    57     {
       
    58     TRACE_ENTRY_POINT;
       
    59     TRACE_EXIT_POINT;
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CCalenAllDayField::ConstructL()
       
    64 // Leaving construction.
       
    65 // (other items were commented in a header).
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 void CCalenAllDayField::ConstructL()
       
    69     {
       
    70     TRACE_ENTRY_POINT;
       
    71     
       
    72     // Set initial value 'ENonAllDayEvent' for AllDay event field
       
    73     iIsAllDaySeleceted = CCalenAllDayField::ENonAllDayEvent;
       
    74     
       
    75     TRACE_EXIT_POINT;
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CCalenAllDayFiled::~CCalenAllDayFiled()
       
    80 // Destructor.
       
    81 // (other items were commented in a header).
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CCalenAllDayField::~CCalenAllDayField()
       
    85     {
       
    86     TRACE_ENTRY_POINT;
       
    87 
       
    88     TRACE_EXIT_POINT;
       
    89     }
       
    90 
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CCalenAllDayField::IsAllDayEvent
       
    94 // Checks to see if event is for all day.
       
    95 // (other items were commented in a header).
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 TBool CCalenAllDayField::IsAllDayEvent()
       
    99     {
       
   100     TRACE_ENTRY_POINT;
       
   101     TRACE_EXIT_POINT;
       
   102     
       
   103     return iIsAllDaySeleceted;
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CCalenAllDayField::SetAllDayEvent( TBool aAllDaySelected)
       
   108 // Set AllDay filed value
       
   109 // (other items were commented in a header).
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CCalenAllDayField::SetAllDayEvent( TBool aAllDaySelected )
       
   113     {
       
   114     TRACE_ENTRY_POINT;     
       
   115     
       
   116     iIsAllDaySeleceted = aAllDaySelected;
       
   117     
       
   118     // Update Allday related fields also.
       
   119     TRAP_IGNORE( HandleAllDayFieldChangeL() );
       
   120     
       
   121     TRACE_EXIT_POINT;
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CCalenAllDayField::InitAllDayFieldLayoutL
       
   126 // (other items were commented in a header).
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CCalenAllDayField::InitAllDayFieldLayoutL()
       
   130     {
       
   131     TRACE_ENTRY_POINT
       
   132     
       
   133     iUnifiedEditor.EditorFields().SetAllDayFieldL( iIsAllDaySeleceted );
       
   134     
       
   135     TRACE_EXIT_POINT
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CCalenAllDayField::SetDataToEditorL()
       
   140 // Reads data from the entry and updates the form with the appropriate values.
       
   141 // (other items were commented in a header).
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CCalenAllDayField::SetDataToEditorL()
       
   145     {
       
   146     TRACE_ENTRY_POINT;
       
   147 
       
   148     iIsAllDaySeleceted = iUnifiedEditor.Edited().IsAllDayEvent();
       
   149     
       
   150     //To set the Yes/No strings to the alldayfield
       
   151     iUnifiedEditor.EditorFields().SetAllDayFieldL( iIsAllDaySeleceted );
       
   152     
       
   153     // update Time lines as per new AllDay field value.
       
   154     InsertAllDayRelatedFieldsL( iIsAllDaySeleceted );
       
   155     
       
   156     if( iIsAllDaySeleceted )
       
   157         {
       
   158         TTime startDate = iUnifiedEditor.Edited().StartDateTime();
       
   159         TTime endDate = iUnifiedEditor.Edited().EndDateTime();
       
   160 
       
   161         // In case AllDay event end at "12:00am" 24/06/2009. 
       
   162         // editor should display EndDate as 23/06/2009.
       
   163         if( endDate > startDate )
       
   164             {
       
   165             endDate -= TTimeIntervalDays( 1 );
       
   166             if( endDate < startDate )
       
   167                 {
       
   168                 endDate = startDate;
       
   169                 }
       
   170             }
       
   171 		
       
   172 		iUnifiedEditor.EditorFields().SetDateField( ECalenEditorStartDate, startDate, EFalse );
       
   173         iUnifiedEditor.EditorFields().SetDateField( ECalenEditorEndDate, endDate, EFalse );
       
   174         }
       
   175      else
       
   176         { 
       
   177         if( iUnifiedEditor.GetEntryType()== CCalEntry::EAppt )
       
   178             {
       
   179             // update End date field as per Start date field value
       
   180             TTime startDate = iUnifiedEditor.Edited().StartDateTime();
       
   181             TTime endDate = iUnifiedEditor.Edited().EndDateTime();
       
   182             
       
   183             iUnifiedEditor.EditorFields().SetDateField( ECalenEditorStartDate, startDate, EFalse );
       
   184             iUnifiedEditor.EditorFields().SetTimeField( ECalenEditorStartTime, startDate, EFalse );
       
   185             iUnifiedEditor.EditorFields().SetDateField( ECalenEditorEndDate, endDate, EFalse );
       
   186             iUnifiedEditor.EditorFields().SetTimeField( ECalenEditorEndTime, endDate, EFalse );
       
   187             }
       
   188         else if( iUnifiedEditor.GetEntryType()== CCalEntry::EEvent )
       
   189             {
       
   190             TTime startTime = iUnifiedEditor.Edited().StartDateTime();
       
   191             iUnifiedEditor.EditorFields().SetDateField( ECalenEditorStartDate, startTime, EFalse );
       
   192             iUnifiedEditor.EditorFields().SetTimeField( ECalenEditorStartTime, startTime, EFalse );
       
   193             }
       
   194         }    
       
   195              
       
   196         TRACE_EXIT_POINT
       
   197     }
       
   198 
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // CCalenAllDayField::InsertAllDayRelatedFieldsL
       
   202 // (other items were commented in a header).
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 void CCalenAllDayField::InsertAllDayRelatedFieldsL( TBool aAllDayEvent )
       
   206     {
       
   207     TRACE_ENTRY_POINT;
       
   208     
       
   209     CCoeControl* eventStartTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorStartTime );
       
   210     CCoeControl* eventEndTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorEndTime );
       
   211     
       
   212     if( aAllDayEvent )
       
   213         {
       
   214         // AllDay event, delete Start time & End time fields from form.
       
   215         if( eventStartTimeCtrl )
       
   216             {
       
   217             iUnifiedEditor.DeleteLine( ECalenEditorStartTime,EFalse );
       
   218             }
       
   219         if( eventEndTimeCtrl )
       
   220             {
       
   221             iUnifiedEditor.DeleteLine( ECalenEditorEndTime,EFalse );
       
   222             }
       
   223         }
       
   224     else
       
   225         {
       
   226         // Non AllDay event, add Start time & End time fields to form. 
       
   227         if(!eventStartTimeCtrl)
       
   228             {       
       
   229             iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_TIME_ITEM,
       
   230                     ECalenEditorStartTime, ECalenEditorAllDayItem );
       
   231             }
       
   232         if(!eventEndTimeCtrl)
       
   233             {
       
   234             iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_TIME_ITEM,
       
   235                     ECalenEditorEndTime, ECalenEditorStartTime );
       
   236             }
       
   237         }
       
   238     
       
   239     TRACE_EXIT_POINT;
       
   240     }
       
   241 	
       
   242 // -----------------------------------------------------------------------------
       
   243 // CCalenAllDayField::HandleAllDayFieldChangeL
       
   244 // (other items were commented in a header).
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 void CCalenAllDayField::HandleAllDayFieldChangeL()
       
   248     {
       
   249     TRACE_ENTRY_POINT;
       
   250 
       
   251     // Handle AllDay field change
       
   252     iUnifiedEditor.Edited().SetAllDayEvent( IsAllDayEvent() );
       
   253 
       
   254     if( IsAllDayEvent() )
       
   255         {
       
   256 		// AllDay event set to yes. Change entry type to EEvent
       
   257         if(iUnifiedEditor.GetEntryType() == CCalEntry::EAppt)
       
   258             {
       
   259             iUnifiedEditor.SetEntryType( CCalEntry::EEvent );
       
   260             iUnifiedEditor.Edited().SetEntryType( CCalEntry::EEvent );
       
   261             }
       
   262          }
       
   263     else
       
   264         {
       
   265 		// Non AllDay event set to No. Change entry type to EAppt
       
   266         if( iUnifiedEditor.GetEntryType() == CCalEntry::EEvent )
       
   267             {
       
   268             iUnifiedEditor.SetEntryType( CCalEntry::EAppt );
       
   269             iUnifiedEditor.Edited().SetEntryType( CCalEntry::EAppt );
       
   270             }
       
   271         }
       
   272      SetDataToEditorL();
       
   273      iUnifiedEditor.UpdateFormL();
       
   274 
       
   275     TRACE_EXIT_POINT;
       
   276     }
       
   277  
       
   278 // -----------------------------------------------------------------------------
       
   279 // CCalenAllDayField::PrepareForFocusTransitionL
       
   280 // (other items were commented in a header).
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 void CCalenAllDayField::PrepareForFocusTransitionL( TInt /* aFocusedId */ )
       
   284     {
       
   285     
       
   286     TRACE_ENTRY_POINT;
       
   287     // Nothing to do 
       
   288     TRACE_EXIT_POINT;
       
   289 
       
   290     }
       
   291 
       
   292 
       
   293 
       
   294