calendarui/editors/src/calenunifiededitorcontrol.cpp
branchRCL_3
changeset 66 bd7edf625bdd
child 67 1539a383d7b6
child 74 97232defd20e
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 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 : calendar unified editor fields control
       
    15 *
       
    16 */
       
    17 
       
    18 // system includes
       
    19 #include <eikedwin.h>
       
    20 #include <eikmfne.h>
       
    21 #include <StringLoader.h>
       
    22 #include <e32des16.h>
       
    23 #include <calentry.h>
       
    24 #include <CalenDefaultEditorsData.rsg>
       
    25 #include <calendateutils.h>
       
    26 #include <calenservices.h>
       
    27 
       
    28 // user includes
       
    29 #include "calenunifiededitorcontrol.h"
       
    30 #include "calenunifiededitor.h"
       
    31 #include "CalenDefaultEditors.hrh"
       
    32 #include "calenentryutil.h"
       
    33 #include "caleneventtypefield.h"
       
    34 #include "calenreminderfield.h"
       
    35 #include "calenrepeatfield.h"
       
    36 #include "calenalldayfield.h"
       
    37 #include "calenpriorityfield.h"
       
    38 #include "calendbfield.h"
       
    39 #include "CalenDescription.h"
       
    40 
       
    41 // debug
       
    42 #include "calendarui_debug.h"
       
    43 
       
    44 // Constants
       
    45 const TInt KOneDay( 1 );
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CCalenUnifiedEditorControl::NewL
       
    50 // Two phased constructor
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CCalenUnifiedEditorControl* CCalenUnifiedEditorControl::NewL( CCalenUnifiedEditor& aUnifiedEditor,
       
    54                                                     MCalenServices& aServices )
       
    55     {
       
    56     TRACE_ENTRY_POINT;
       
    57  
       
    58     CCalenUnifiedEditorControl* self = new (ELeave)CCalenUnifiedEditorControl( aUnifiedEditor );
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL(aServices);
       
    61     CleanupStack::Pop();
       
    62 
       
    63     TRACE_EXIT_POINT;
       
    64     return self;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CCalenUnifiedEditorControl::CCalenUnifiedEditorControl
       
    69 // Destructor
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CCalenUnifiedEditorControl::~CCalenUnifiedEditorControl()
       
    73     {
       
    74     TRACE_ENTRY_POINT;
       
    75     
       
    76     delete iEventTypeField;
       
    77     delete iReminderField;
       
    78     delete iRepeatField;
       
    79     delete iAllDayField;
       
    80     delete iPriorityField;
       
    81     delete iDbField;
       
    82     delete iDescription;
       
    83     
       
    84     TRACE_EXIT_POINT;
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CCalenUnifiedEditorControl::ConstructL
       
    89 // Second phased construction
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CCalenUnifiedEditorControl::ConstructL(MCalenServices& aServices)
       
    93     {
       
    94     TRACE_ENTRY_POINT;
       
    95     
       
    96     iEventTypeField = CCalenEventTypeField::NewL( iUnifiedEditor );
       
    97     iReminderField = CCalenReminderField::NewL( iUnifiedEditor );
       
    98     iRepeatField = CCalenRepeatField::NewL( iUnifiedEditor );
       
    99     iAllDayField = CCalenAllDayField::NewL( iUnifiedEditor );
       
   100     iPriorityField = CCalenPriorityField::NewL( iUnifiedEditor );
       
   101     iDbField = CCalenDbField::NewL( iUnifiedEditor,aServices );
       
   102     iDescription = CCalenDescription::NewL( iUnifiedEditor );
       
   103     
       
   104     TRACE_EXIT_POINT;    
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CCalenUnifiedEditorControl::CCalenUnifiedEditorControl
       
   109 // Default constructor
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 CCalenUnifiedEditorControl::CCalenUnifiedEditorControl( CCalenUnifiedEditor& aUnifiedEditor )
       
   113     :iUnifiedEditor( aUnifiedEditor )
       
   114     {
       
   115     TRACE_ENTRY_POINT;
       
   116     TRACE_EXIT_POINT;
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CCalenUnifiedEditorControl::MakeUnifiedEditorL
       
   121 // Initializes the dialog's controls before the dialog is sized
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CCalenUnifiedEditorControl::MakeUnifiedEditorL()
       
   125     {
       
   126     TRACE_ENTRY_POINT;
       
   127 
       
   128     // Add default editor fields.
       
   129     AddDefaultEditorL();
       
   130     // Initialise editor fields.
       
   131     InitDefaultEditorsL();
       
   132     // Set data to editor fields.
       
   133     SetDataToEditorL();
       
   134     
       
   135     // Update MSK string.
       
   136     iUnifiedEditor.SetMskFromResourceL();
       
   137     iUnifiedEditor.UpdateFormL();
       
   138         
       
   139     TRACE_EXIT_POINT;
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CCalenUnifiedEditorControl::SetDataToEditorL
       
   144 // Set data to the collapsed unified editor
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CCalenUnifiedEditorControl::SetDataToEditorL(TBool onLocaleUpdate)
       
   148     {
       
   149     TRACE_ENTRY_POINT;
       
   150     
       
   151     // Set Editor field values
       
   152     
       
   153     // Set data to EventType fields   
       
   154     iEventTypeField->SetDataToEditorL();
       
   155     
       
   156     TPtrC subject = iUnifiedEditor.Edited().Summary().Left(
       
   157                         iUnifiedEditor.MaxTextEditorLength() );
       
   158     
       
   159     if(!onLocaleUpdate)
       
   160         iUnifiedEditor.SetEditorTextL( ECalenEditorSubject, &subject );
       
   161    
       
   162 
       
   163     
       
   164     // update duration for EndTime update, with StartTime change
       
   165     UpdateMeetingDurationL();
       
   166 
       
   167     switch( iUnifiedEditor.GetEntryType() )
       
   168         {
       
   169         case CCalEntry::EEvent:
       
   170             {
       
   171               iAllDayField->SetDataToEditorL();
       
   172             }
       
   173             break;
       
   174         case CCalEntry::EAnniv:
       
   175             {
       
   176             TTime birthDayYear = iUnifiedEditor.Edited().EventDateTime();
       
   177             SetDateField( ECalenEditorStartDate, birthDayYear, ETrue );
       
   178             }
       
   179             break;
       
   180         case CCalEntry::EAppt:
       
   181             {
       
   182             if( iUnifiedEditor.Edited().IsAllDayEvent() )
       
   183                 {
       
   184                 iAllDayField->SetDataToEditorL();
       
   185                 }
       
   186             else
       
   187                 {
       
   188                 // Entry is Non-AllDay event
       
   189                 TTime firstRDate; 
       
   190                 TTime rruleEndTime ;             
       
   191                 TTimeIntervalMinutes duration;                
       
   192                 
       
   193                 TTime entryStartTime = iUnifiedEditor.Edited().StartDateTime();
       
   194                 TTime entryEndTime = iUnifiedEditor.Edited().EndDateTime();
       
   195                 
       
   196                 User::LeaveIfError( entryEndTime.MinutesFrom( entryStartTime, duration ) );
       
   197                 
       
   198                 ReadRruleL(firstRDate,rruleEndTime);                                           
       
   199                 
       
   200                 if( firstRDate <= entryStartTime)
       
   201                     {                    
       
   202                     SetTimeField( ECalenEditorStartTime, firstRDate, ETrue );
       
   203                     SetTimeField( ECalenEditorEndTime, rruleEndTime, ETrue );                
       
   204                     SetDateField( ECalenEditorStartDate, firstRDate, ETrue);
       
   205                     SetDateField( ECalenEditorEndDate, rruleEndTime, ETrue);
       
   206                     }
       
   207                 else{
       
   208                     SetTimeField( ECalenEditorStartTime, entryStartTime, ETrue );
       
   209                     SetTimeField( ECalenEditorEndTime, entryEndTime, ETrue );                
       
   210                     SetDateField( ECalenEditorStartDate, entryStartTime, ETrue);
       
   211                     SetDateField( ECalenEditorEndDate, entryEndTime, ETrue);
       
   212                     }                
       
   213                }
       
   214             
       
   215             }
       
   216             break;
       
   217         case CCalEntry::ETodo:
       
   218             {
       
   219             TTime dueDate = iUnifiedEditor.Edited().EventDateTime();
       
   220             
       
   221             // update date field with todays date
       
   222             SetDateField(ECalenEditorStartDate, dueDate, ETrue);
       
   223             // set priority field value 
       
   224             iPriorityField->SetDataToEditorL();
       
   225 
       
   226             }
       
   227             break;
       
   228         default:
       
   229             break;
       
   230         }
       
   231     
       
   232     iReminderField->SetDataToEditorL();
       
   233     
       
   234     // Anniversary, To-do, exceptional and single instance of repeat entry 
       
   235     // do not have Repeat field.
       
   236     if( CCalEntry::EAnniv != iUnifiedEditor.GetEntryType()
       
   237             && CCalEntry::ETodo != iUnifiedEditor.GetEntryType() )
       
   238         {
       
   239         iRepeatField->SetDataToEditorL();
       
   240         }
       
   241     
       
   242     if(!iDbField->IsCalendarEdited())
       
   243         {
       
   244         iDbField->SetDataToEditorL();
       
   245         }
       
   246 
       
   247     if( CCalEntry::ETodo != iUnifiedEditor.GetEntryType() )
       
   248         {
       
   249         TPtrC location = iUnifiedEditor.Edited().Location().Left(
       
   250                             iUnifiedEditor.MaxTextEditorLength() );
       
   251         
       
   252         if(!onLocaleUpdate)
       
   253             iUnifiedEditor.SetEditorTextL( ECalenEditorPlace, &location );
       
   254         }
       
   255     
       
   256     // TODO: Uncomment this when enabling attachment support
       
   257       iUnifiedEditor.SetAttachmentNamesToEditorL();
       
   258 
       
   259     TRACE_EXIT_POINT;
       
   260     }
       
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // CCalenUnifiedEditorControl::AddDefaultEditorL
       
   264 // Adds editor fields
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 void CCalenUnifiedEditorControl::AddDefaultEditorL()
       
   268     {
       
   269     TRACE_ENTRY_POINT;
       
   270     
       
   271     switch( iUnifiedEditor.GetEntryType() )
       
   272         {
       
   273         case CCalEntry::EEvent:
       
   274             {
       
   275             AddDefaultMeetingEditorL();
       
   276             }
       
   277             break;
       
   278         case CCalEntry::EAnniv:
       
   279             {
       
   280             AddDefaultBirthDayEditorL();
       
   281             }
       
   282             break;            
       
   283         case CCalEntry::EAppt:
       
   284             {
       
   285             AddDefaultMeetingEditorL();
       
   286             }
       
   287             break;
       
   288         case CCalEntry::ETodo:
       
   289             {
       
   290             AddDefaultTodoEditorL();
       
   291             }            
       
   292             break;
       
   293         default:
       
   294             break;
       
   295         }
       
   296     
       
   297     TRACE_EXIT_POINT;
       
   298     }
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CCalenUnifiedEditorControl::InitDefaultEditorsL
       
   302 // Initialise default editor contents
       
   303 // -----------------------------------------------------------------------------
       
   304 //
       
   305 void CCalenUnifiedEditorControl::InitDefaultEditorsL()
       
   306     {
       
   307     TRACE_ENTRY_POINT;
       
   308     
       
   309     // Set editor lengths
       
   310     CEikEdwin* edwin = static_cast<CEikEdwin*>( iUnifiedEditor.Control( ECalenEditorSubject ) );
       
   311     edwin->SetTextLimit( iUnifiedEditor.MaxTextEditorLength() );
       
   312     
       
   313     iEventTypeField->InitEventTypeFieldLayoutL();
       
   314     
       
   315     //Currently nothig to be initalized 
       
   316     //as its intial value depend on entry
       
   317     iAllDayField->InitAllDayFieldLayoutL();
       
   318     
       
   319 
       
   320     iReminderField->InitReminderFieldLdayoutL();
       
   321 
       
   322     // To Initialise priority field for meeting tyrpe entry
       
   323     if( CCalEntry::ETodo == iUnifiedEditor.GetEntryType() )
       
   324         {
       
   325         iPriorityField->InitPriorityFieldLayoutL();
       
   326         }
       
   327 
       
   328     // Initialise repeat field, if it's not Anniversary.
       
   329     // To-do entry don't have repeat field, for now
       
   330     if( CCalEntry::EAnniv != iUnifiedEditor.GetEntryType() && 
       
   331                 CCalEntry::ETodo != iUnifiedEditor.GetEntryType() )
       
   332         {
       
   333         iRepeatField->InitRepetFieldLayoutL();
       
   334         }
       
   335 
       
   336     RPointerArray<CCalCalendarInfo> calendarInfoList; 
       
   337     iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList);
       
   338     CleanupClosePushL( calendarInfoList );
       
   339     if( calendarInfoList.Count() > 1 )
       
   340       {
       
   341         iDbField->InitDbFieldLayoutL();
       
   342       }
       
   343     CleanupStack::PopAndDestroy( &calendarInfoList );
       
   344     
       
   345     iDescription->InitDescritpionFieldLayoutL();
       
   346     
       
   347     TRACE_EXIT_POINT;
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CCalenUnifiedEditorControl::AddDefaultBirthDayEditorL
       
   352 // Add collapsed birthday editor contents
       
   353 // -----------------------------------------------------------------------------
       
   354 //
       
   355 void CCalenUnifiedEditorControl::AddDefaultBirthDayEditorL()
       
   356     {
       
   357     TRACE_ENTRY_POINT;
       
   358     // event type, subject, date & year,more details
       
   359     
       
   360     RPointerArray<CCalCalendarInfo> calendarInfoList; 
       
   361     iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList);
       
   362     CleanupClosePushL( calendarInfoList );
       
   363 
       
   364     if( calendarInfoList.Count() > 1 )
       
   365         {
       
   366         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
       
   367             ECalenEditorDBName, ECalenEditorSubject );
       
   368 
       
   369         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
       
   370             ECalenEditorStartDate, ECalenEditorDBName );
       
   371         }
       
   372     else
       
   373         {
       
   374         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
       
   375             ECalenEditorStartDate, ECalenEditorSubject );
       
   376         }
       
   377 
       
   378     CleanupStack::PopAndDestroy( &calendarInfoList );
       
   379     
       
   380     // "Start Date" Label should be "Date of Birth" for Birthday
       
   381     iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
       
   382                     R_QTN_CALEN_EDITOR_DATE_OF_BIRTH );
       
   383 
       
   384     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM,
       
   385                     ECalenEditorReminder, ECalenEditorStartDate );
       
   386 
       
   387     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PLACE_ITEM,
       
   388                     ECalenEditorPlace, ECalenEditorReminder );
       
   389 /*    iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PEOPLE_ITEM,
       
   390                     ECalenEditorPeople, ECalenEditorPlace );
       
   391 */   /* iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
       
   392                     ECalenEditorDBName, ECalenEditorPlace );*/
       
   393 
       
   394     // TODO: Uncomment this when enabling attachment support
       
   395     // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement
       
   396     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ATTACHMENT_ITEM,
       
   397                     ECalenEditorAttachment, ECalenEditorPlace );
       
   398 
       
   399     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DESCRIPTION_ITEM,
       
   400                     ECalenEditorDescription, ECalenEditorAttachment );
       
   401     iUnifiedEditor.UpdateFormL();
       
   402     TRACE_EXIT_POINT;
       
   403     }
       
   404 
       
   405 // -----------------------------------------------------------------------------
       
   406 // CCalenUnifiedEditorControl::AddDefaultMeetingEditorL
       
   407 // Add meeting editor contents
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 void CCalenUnifiedEditorControl::AddDefaultMeetingEditorL()
       
   411     {
       
   412     TRACE_ENTRY_POINT;
       
   413     // non all day event 
       
   414     // event type,subject,all day,start time,end time,start date,
       
   415     // end date,place,more details
       
   416     
       
   417     // all day event 
       
   418     // subject,event type,all day,start date,end date,place,more details 
       
   419     
       
   420     RPointerArray<CCalCalendarInfo> calendarInfoList; 
       
   421     iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList);
       
   422     CleanupClosePushL( calendarInfoList );
       
   423 
       
   424     if( calendarInfoList.Count() > 1 )
       
   425         {
       
   426     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
       
   427             ECalenEditorDBName, ECalenEditorSubject );
       
   428 
       
   429     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ALL_DAY_ITEM,
       
   430             ECalenEditorAllDayItem, ECalenEditorDBName );
       
   431         }
       
   432     else
       
   433         {
       
   434     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ALL_DAY_ITEM, 
       
   435             ECalenEditorAllDayItem, ECalenEditorSubject );
       
   436         }
       
   437 
       
   438     CleanupStack::PopAndDestroy( &calendarInfoList );
       
   439     
       
   440     if( !iUnifiedEditor.Edited().IsAllDayEvent() )
       
   441         {
       
   442         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_TIME_ITEM, 
       
   443                 ECalenEditorStartTime, ECalenEditorAllDayItem );
       
   444         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_TIME_ITEM,
       
   445                 ECalenEditorEndTime, ECalenEditorStartTime );
       
   446         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM,
       
   447                     ECalenEditorStartDate, ECalenEditorEndTime );        
       
   448         }
       
   449      else
       
   450          {
       
   451          iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM,
       
   452                      ECalenEditorStartDate, ECalenEditorAllDayItem );   
       
   453          }
       
   454     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM,
       
   455             ECalenEditorEndDate, ECalenEditorStartDate );
       
   456     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PLACE_ITEM,
       
   457                   ECalenEditorPlace, ECalenEditorEndDate );
       
   458     
       
   459     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM,
       
   460                     ECalenEditorReminder, ECalenEditorPlace );
       
   461     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REPEAT_ITEM,
       
   462                     ECalenEditorRepeat, ECalenEditorReminder );
       
   463     /*iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PEOPLE_ITEM,
       
   464                     ECalenEditorPeople, ECalenEditorRepeat );
       
   465     */
       
   466    /* iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
       
   467                     ECalenEditorDBName, ECalenEditorRepeat );
       
   468     */
       
   469     // TODO: Uncomment this when enabling attachment support
       
   470     // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement
       
   471     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ATTACHMENT_ITEM,
       
   472                     ECalenEditorAttachment, ECalenEditorRepeat );
       
   473     
       
   474     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DESCRIPTION_ITEM,
       
   475                     ECalenEditorDescription, ECalenEditorAttachment );
       
   476     iUnifiedEditor.UpdateFormL();
       
   477     TRACE_EXIT_POINT;
       
   478     }
       
   479 
       
   480 // -----------------------------------------------------------------------------
       
   481 // CCalenUnifiedEditorControl::AddDefaultTodoEditorL
       
   482 // Add collapsed todo editor contents
       
   483 // -----------------------------------------------------------------------------
       
   484 //
       
   485 void CCalenUnifiedEditorControl::AddDefaultTodoEditorL()
       
   486     {
       
   487     TRACE_ENTRY_POINT;
       
   488     // event type,subject,due date,more details
       
   489    RPointerArray<CCalCalendarInfo> calendarInfoList; 
       
   490    iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList);
       
   491    CleanupClosePushL( calendarInfoList );
       
   492    
       
   493     if( calendarInfoList.Count() > 1 )
       
   494         {
       
   495         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
       
   496                         ECalenEditorDBName, ECalenEditorSubject );
       
   497         
       
   498         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
       
   499                             ECalenEditorStartDate, ECalenEditorDBName );
       
   500         }
       
   501     else
       
   502         {
       
   503         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
       
   504                                ECalenEditorStartDate, ECalenEditorSubject );
       
   505         }
       
   506     
       
   507     CleanupStack::PopAndDestroy( &calendarInfoList );
       
   508 
       
   509     // "Start Date" Label should be "Due date" for To-Do
       
   510     iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
       
   511                     R_QTN_CALEN_EDITOR_DUE_DATE );
       
   512     
       
   513     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM,
       
   514                     ECalenEditorReminder, ECalenEditorStartDate );
       
   515     
       
   516     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PRIORITY_ITEM, 
       
   517                     ECalenEditorPriority, ECalenEditorReminder );
       
   518 
       
   519     /*iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
       
   520                     ECalenEditorDBName, ECalenEditorPriority );*/
       
   521     
       
   522     // TODO: Uncomment this when enabling attachment support
       
   523     // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement
       
   524     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ATTACHMENT_ITEM,
       
   525                     ECalenEditorAttachment, ECalenEditorPriority );
       
   526     
       
   527     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DESCRIPTION_ITEM,
       
   528                     ECalenEditorDescription, ECalenEditorAttachment );
       
   529     iUnifiedEditor.UpdateFormL();
       
   530     TRACE_EXIT_POINT;
       
   531     }
       
   532 
       
   533 // -----------------------------------------------------------------------------
       
   534 // CCalenUnifiedEditorControl::SetTimeField
       
   535 // Sets the time field in touch layouts
       
   536 // -----------------------------------------------------------------------------
       
   537 //
       
   538 void CCalenUnifiedEditorControl::SetTimeField( TInt aControlId, const TTime& aTime ,
       
   539                                               TBool aDoDraw )
       
   540     {
       
   541     TRACE_ENTRY_POINT;    
       
   542 
       
   543     CEikTimeEditor* timeField = 
       
   544         static_cast<CEikTimeEditor*>( iUnifiedEditor.ControlOrNull( aControlId ) );
       
   545     if( timeField )
       
   546         {
       
   547         timeField->SetTime( aTime );
       
   548         if ( aDoDraw )
       
   549             {
       
   550             timeField->DrawDeferred();
       
   551             }
       
   552         }
       
   553     
       
   554     TRACE_EXIT_POINT;
       
   555     }
       
   556 
       
   557 // -----------------------------------------------------------------------------
       
   558 // CCalenUnifiedEditorControl::SetDateField
       
   559 // Sets a date field to the given TTime.
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 void CCalenUnifiedEditorControl::SetDateField( TInt aControlId, const TTime& aTime,
       
   563                                               TBool aDoDraw )
       
   564     {
       
   565     TRACE_ENTRY_POINT;
       
   566 
       
   567     CEikDateEditor* dateField = NULL;
       
   568     dateField = static_cast<CEikDateEditor*>( iUnifiedEditor.ControlOrNull( aControlId ) );
       
   569     if( dateField )
       
   570         {
       
   571         dateField->SetDate( aTime );
       
   572         if( aDoDraw )
       
   573             {
       
   574             dateField->DrawDeferred();
       
   575             }
       
   576         }
       
   577 
       
   578     TRACE_EXIT_POINT;
       
   579     }
       
   580 
       
   581 // -----------------------------------------------------------------------------
       
   582 // CCalenUnifiedEditorControl::SetDateTimeField
       
   583 // Update date and time field
       
   584 // -----------------------------------------------------------------------------
       
   585 void CCalenUnifiedEditorControl::SetDateTimeField( TInt aControlId, const TTime& aTime,
       
   586                                                   TBool aDoDraw )
       
   587     {
       
   588     TRACE_ENTRY_POINT;
       
   589 
       
   590     CEikTimeAndDateEditor* dateTimeField = NULL;
       
   591     dateTimeField = static_cast<CEikTimeAndDateEditor*>( iUnifiedEditor.ControlOrNull( aControlId  ) );
       
   592     if( dateTimeField )
       
   593       {
       
   594       dateTimeField->SetTimeAndDate( aTime );
       
   595       if( aDoDraw )
       
   596           {
       
   597           dateTimeField->DrawDeferred();
       
   598           }
       
   599       }
       
   600     
       
   601     TRACE_EXIT_POINT;
       
   602     }
       
   603 
       
   604 // -----------------------------------------------------------------------------
       
   605 // CCalenUnifiedEditorControl::SetAlarmFieldOnOffL
       
   606 // Set alarm field on or off
       
   607 // -----------------------------------------------------------------------------
       
   608 //
       
   609 void CCalenUnifiedEditorControl::SetAlarmFieldOnOffL( TBool aOnOff )
       
   610     {
       
   611     TRACE_ENTRY_POINT;
       
   612     
       
   613     iUnifiedEditor.SetAlarmFieldOnOffL( aOnOff );
       
   614     
       
   615     TRACE_EXIT_POINT;
       
   616     } 
       
   617 
       
   618 // -----------------------------------------------------------------------------
       
   619 // CCalenUnifiedEditorControl::SetAlarmFieldOnOffL
       
   620 // Set alarm field on or off
       
   621 // -----------------------------------------------------------------------------
       
   622 //
       
   623 void CCalenUnifiedEditorControl::SetAllDayFieldL( TBool aYesNo )
       
   624     {
       
   625     TRACE_ENTRY_POINT;
       
   626     
       
   627     iUnifiedEditor.SetAllDayFieldL( aYesNo );
       
   628     
       
   629     TRACE_EXIT_POINT;
       
   630     } 
       
   631 
       
   632 
       
   633 // -----------------------------------------------------------------------------
       
   634 // CCalenUnifiedEditorControl::IsAlarmActiveInForm
       
   635 // Check for whether alarm is activated or not
       
   636 // -----------------------------------------------------------------------------
       
   637 //
       
   638 TBool CCalenUnifiedEditorControl::IsAlarmActiveInForm()
       
   639     {
       
   640     TRACE_ENTRY_POINT;
       
   641     TRACE_EXIT_POINT;
       
   642     return iReminderField->IsAlarmActiveInForm();
       
   643     }
       
   644 
       
   645 // -----------------------------------------------------------------------------
       
   646 // CCalenUnifiedEditorControl::CheckAlarmActive
       
   647 // check alarm active based on the input
       
   648 // -----------------------------------------------------------------------------
       
   649 //
       
   650 void CCalenUnifiedEditorControl::CheckAlarmActive( TBool aActive )
       
   651     {
       
   652     TRACE_ENTRY_POINT;
       
   653     
       
   654     iReminderField->CheckAlarmActive( aActive );
       
   655     
       
   656     TRACE_EXIT_POINT
       
   657     }
       
   658 
       
   659 // -----------------------------------------------------------------------------
       
   660 // CCalenUnifiedEditorControl::IsAllDayEvent
       
   661 // To check value of AllDay field
       
   662 // -----------------------------------------------------------------------------
       
   663 //
       
   664 TBool CCalenUnifiedEditorControl::IsAllDayEvent()
       
   665     {
       
   666     TRACE_ENTRY_POINT;
       
   667     
       
   668     return iAllDayField->IsAllDayEvent();
       
   669     
       
   670     TRACE_EXIT_POINT;
       
   671     }
       
   672 
       
   673 // -----------------------------------------------------------------------------
       
   674 // CCalenUnifiedEditorControl::SetAllDayEvent
       
   675 // To Set AllDay field value
       
   676 // -----------------------------------------------------------------------------
       
   677 //
       
   678 void CCalenUnifiedEditorControl::SetAllDayEventL( TBool aActive )
       
   679     {
       
   680     TRACE_ENTRY_POINT;
       
   681     
       
   682     iAllDayField->SetAllDayEvent( aActive );
       
   683     //set defalut alarmtime when allday field is activated/deactivated
       
   684     if(iUnifiedEditor.EditorFields().IsAlarmActiveInForm())
       
   685         {
       
   686         iUnifiedEditor.EditorDataHandler().SetDefaultAlarmDateTimeL();
       
   687         iReminderField->SetDataToEditorL();
       
   688         }
       
   689     
       
   690     TRACE_EXIT_POINT
       
   691     }
       
   692 
       
   693 // -----------------------------------------------------------------------------
       
   694 // CCalenUnifiedEditorControl::HandleControlStateChangeL
       
   695 // Handles a state change in the control with id aControlId. 
       
   696 // -----------------------------------------------------------------------------
       
   697 //
       
   698 void CCalenUnifiedEditorControl::HandleControlStateChangeL( TInt aControlId )
       
   699     {
       
   700     TRACE_ENTRY_POINT;
       
   701     
       
   702     switch( aControlId )
       
   703         {
       
   704         case ECalenEditorEventType:
       
   705             {
       
   706             iEventTypeField->HandleControlStateChangeL( aControlId );
       
   707             }
       
   708             break;
       
   709         case ECalenEditorReminder:
       
   710             {
       
   711             iReminderField->HandleControlStateChangeL( aControlId );
       
   712             }
       
   713             break;
       
   714         case ECalenEditorRepeat:
       
   715             {
       
   716             iRepeatField->HandleControlStateChangeL( aControlId );
       
   717             }
       
   718             break;
       
   719         case ECalenEditorDBName:
       
   720             {
       
   721             iDbField->HandleControlStateChangeL( aControlId );
       
   722             }
       
   723             break;
       
   724         default:
       
   725             break;
       
   726         }
       
   727    
       
   728     TRACE_EXIT_POINT;
       
   729     }
       
   730 
       
   731 // -----------------------------------------------------------------------------
       
   732 // CCalenUnifiedEditorControl::PrepareForFocusTransitionL
       
   733 // Tries to change focus to the specified line.
       
   734 // -----------------------------------------------------------------------------
       
   735 //
       
   736 void CCalenUnifiedEditorControl::PrepareForFocusTransitionL( TInt aFocusedId )
       
   737     {
       
   738     switch( aFocusedId )
       
   739         {
       
   740         case ECalenEditorSubject:
       
   741             {
       
   742             ReadSubjectFromEditorL();
       
   743             }
       
   744             break;
       
   745         case ECalenEditorEventType:
       
   746             {
       
   747             iEventTypeField->PrepareForFocusTransitionL( aFocusedId );
       
   748             }
       
   749             break;
       
   750             
       
   751         case ECalenEditorStartTime:    
       
   752         case ECalenEditorStartDate:
       
   753             {
       
   754             ReadStartDateTimeFromEditorL( ETrue, aFocusedId );
       
   755             UpdateMeetingDurationL();
       
   756             }
       
   757             break;
       
   758             
       
   759         case ECalenEditorEndDate:
       
   760         case ECalenEditorEndTime:
       
   761             {
       
   762             ReadEndDateTimeFromEditorL( ETrue );
       
   763             UpdateMeetingDurationL();
       
   764             }
       
   765             break;
       
   766             
       
   767         case ECalenEditorBirthDayYear:
       
   768             break;
       
   769             
       
   770         case ECalenEditorDueDate:   
       
   771             break;
       
   772         
       
   773         // todo: Need to check, ECalenEditorDueDate can be removed?    
       
   774         case ECalenEditorAllDayItem:
       
   775             {
       
   776             iAllDayField->PrepareForFocusTransitionL( aFocusedId );
       
   777             }
       
   778             break;
       
   779             
       
   780         case ECalenEditorPriority:
       
   781             {
       
   782             iPriorityField->PrepareForFocusTransitionL( aFocusedId );
       
   783             }
       
   784             break;
       
   785             
       
   786         case ECalenEditorPlace:
       
   787             {
       
   788             ReadPlaceFieldFromEditorL( ETrue );
       
   789             }
       
   790             break;
       
   791             
       
   792         case ECalenEditorRepeat:
       
   793             {
       
   794             iRepeatField->PrepareForFocusTransitionL( aFocusedId );
       
   795             }
       
   796             break;
       
   797             
       
   798         case ECalenEditorDBName:
       
   799             {
       
   800             iDbField->PrepareForFocusTransitionL( aFocusedId );
       
   801             }
       
   802             break;
       
   803         case ECalenEditorAttachment:
       
   804             break;
       
   805         case ECalenEditorDescription:
       
   806             break;
       
   807         default:
       
   808             break;
       
   809         }
       
   810     
       
   811     iReminderField->PrepareForFocusTransitionL( aFocusedId );
       
   812     
       
   813     }
       
   814 
       
   815 // -----------------------------------------------------------------------------
       
   816 // CCalenUnifiedEditorControl::OnEventTypeChangedL
       
   817 // Handles event type changed
       
   818 // -----------------------------------------------------------------------------
       
   819 //
       
   820 void CCalenUnifiedEditorControl::OnEventTypeChangedL( CCalEntry::TType aNewEventType )
       
   821     {
       
   822     TRACE_ENTRY_POINT;
       
   823     
       
   824     if(iUnifiedEditor.GetEntryType() != aNewEventType)
       
   825     	{
       
   826 	    // update Entry type of Edited entry
       
   827 	    iUnifiedEditor.Edited().SetEntryType( aNewEventType );
       
   828 	
       
   829 	    // Delete, previous entry type fields from editor
       
   830 	    DeletePreviousEntryTypeFieldsL();
       
   831 	    
       
   832 	    // Add new fiedls to editor
       
   833 	    AddNewEntryTypeFieldsL( aNewEventType );
       
   834 	    iUnifiedEditor.SetEntryType( aNewEventType );
       
   835 	
       
   836 	    // after changing the event type, update the fields with default values
       
   837 	    InitDefaultEditorsL();
       
   838 	    SetDataToEditorL();
       
   839 	    
       
   840 	    iUnifiedEditor.UpdateFormL();
       
   841 	  	}
       
   842     
       
   843     TRACE_EXIT_POINT;
       
   844     }
       
   845 
       
   846 // -----------------------------------------------------------------------------
       
   847 // CCalenUnifiedEditorControl::DeletePreviousEntryTypeFieldsL
       
   848 // Delete previous entry type fields on selcting 
       
   849 // the new entry type
       
   850 // -----------------------------------------------------------------------------
       
   851 //
       
   852 void CCalenUnifiedEditorControl::DeletePreviousEntryTypeFieldsL()
       
   853     {
       
   854     TRACE_ENTRY_POINT;
       
   855     CCalEntry::TType previousEntryType = iUnifiedEditor.GetEntryType();
       
   856     switch( previousEntryType )
       
   857         {
       
   858         case CCalEntry::EEvent:
       
   859             {
       
   860             // Delete AllDay, StartDate, EndDate, and Place fields
       
   861             iUnifiedEditor.DeleteLine( ECalenEditorAllDayItem, EFalse );
       
   862             iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
   863             iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse );
       
   864             iUnifiedEditor.DeleteLine( ECalenEditorPlace, EFalse );
       
   865             }
       
   866             break;
       
   867         case CCalEntry::EAnniv:
       
   868             {
       
   869             iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
   870             }
       
   871             break;
       
   872         case CCalEntry::EAppt:
       
   873             {
       
   874             if( iUnifiedEditor.Edited().IsAllDayEvent() ) 
       
   875                 {
       
   876                 // Delete, AllDay event fields from Editor
       
   877                 iUnifiedEditor.DeleteLine( ECalenEditorAllDayItem, EFalse );
       
   878                 }
       
   879             else
       
   880                 {
       
   881                 // Delete, Non-AllDay event fields from Editor
       
   882                 iUnifiedEditor.DeleteLine( ECalenEditorAllDayItem, EFalse );
       
   883                 iUnifiedEditor.DeleteLine( ECalenEditorStartTime, EFalse );
       
   884                 iUnifiedEditor.DeleteLine( ECalenEditorEndTime, EFalse );
       
   885                 }
       
   886             iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
   887             iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse );
       
   888             iUnifiedEditor.DeleteLine( ECalenEditorPlace, EFalse );
       
   889 				
       
   890 				
       
   891             }
       
   892             break;
       
   893         case CCalEntry::ETodo:
       
   894             {
       
   895             iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
   896             iUnifiedEditor.DeleteLine( ECalenEditorPriority, EFalse );
       
   897             }
       
   898             break;
       
   899         default:
       
   900             break;
       
   901         }
       
   902     
       
   903         // Delete, extra fields added to editor for more entry details
       
   904         DeleteExtendedEntryFields( previousEntryType );
       
   905 
       
   906     TRACE_EXIT_POINT;
       
   907     }
       
   908 
       
   909 // -----------------------------------------------------------------------------
       
   910 // CCalenUnifiedEditorControl::DeleteExtendedEntryfields
       
   911 // Delete previous entry type more information fields 
       
   912 // -----------------------------------------------------------------------------
       
   913 //
       
   914 void CCalenUnifiedEditorControl::DeleteExtendedEntryFields( CCalEntry::TType aPreviousEntryType )
       
   915     {
       
   916     
       
   917     // If Reminder field is in 'ON' state, delete Reminder Date, time fields
       
   918     if( iReminderField->IsAlarmActiveInForm() )
       
   919         {
       
   920         CCoeControl* alarmDateCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorReminderDate );
       
   921         CCoeControl* alarmTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorReminderTime );
       
   922                 
       
   923         if( alarmTimeCtrl )
       
   924             {
       
   925             iUnifiedEditor.DeleteLine( ECalenEditorReminderTime, EFalse );
       
   926             }
       
   927         if( alarmDateCtrl )
       
   928             {
       
   929             iUnifiedEditor.DeleteLine( ECalenEditorReminderDate, EFalse );
       
   930             }
       
   931         }
       
   932 
       
   933     iUnifiedEditor.DeleteLine( ECalenEditorReminder,EFalse );
       
   934     
       
   935     /*CCoeControl* PeopleFieldCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorPeople );
       
   936     if( PeopleFieldCtrl )
       
   937         {
       
   938         iUnifiedEditor.DeleteLine( ECalenEditorPeople );
       
   939         }
       
   940     */
       
   941     CCoeControl* dbNameCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorDBName );
       
   942     if( dbNameCtrl )
       
   943         {
       
   944         iUnifiedEditor.DeleteLine( ECalenEditorDBName,EFalse );
       
   945         }
       
   946     // TODO: Uncomment this when enabling attachment support
       
   947     iUnifiedEditor.DeleteLine( ECalenEditorAttachment,EFalse );
       
   948     
       
   949     iUnifiedEditor.DeleteLine( ECalenEditorDescription,EFalse );
       
   950     
       
   951     // To-Do do not have place field
       
   952     CCoeControl* editorPlaceCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorPlace );
       
   953     if( editorPlaceCtrl )
       
   954         {
       
   955         iUnifiedEditor.DeleteLine( ECalenEditorPlace,EFalse );
       
   956         }
       
   957     
       
   958     // Anniversary & To-Do entry, do not have Repeat field
       
   959     if( ( aPreviousEntryType != CCalEntry::EAnniv ) ||
       
   960             ( aPreviousEntryType != CCalEntry::ETodo ) )
       
   961         {
       
   962         // Delete Repeat field.
       
   963         CCoeControl* repeatCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorRepeat );
       
   964         CCoeControl* repeatUntilCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorRepeatUntil );
       
   965         if( repeatCtrl )
       
   966             {
       
   967             iUnifiedEditor.DeleteLine( ECalenEditorRepeat,EFalse );
       
   968             }
       
   969         if( repeatUntilCtrl )
       
   970             {
       
   971             iUnifiedEditor.DeleteLine( ECalenEditorRepeatUntil,EFalse );
       
   972             }
       
   973         }
       
   974     }
       
   975 
       
   976 // -----------------------------------------------------------------------------
       
   977 // CCalenUnifiedEditorControl::AddNewEntryTypeFieldsL
       
   978 // Add new entry type's editor fields
       
   979 // -----------------------------------------------------------------------------
       
   980 //
       
   981 void CCalenUnifiedEditorControl::AddNewEntryTypeFieldsL( CCalEntry::TType aNewEventType )
       
   982     {
       
   983     TRACE_ENTRY_POINT;
       
   984     
       
   985     switch( aNewEventType )
       
   986         {
       
   987         case CCalEntry::EEvent:
       
   988         case CCalEntry::EAppt:
       
   989             {
       
   990             AddDefaultMeetingEditorL();
       
   991             }
       
   992             break;
       
   993         case CCalEntry::EAnniv:
       
   994             {
       
   995             AddDefaultBirthDayEditorL();
       
   996             }
       
   997             break;
       
   998         case CCalEntry::ETodo:
       
   999             {
       
  1000             AddDefaultTodoEditorL();
       
  1001             }
       
  1002             break;
       
  1003         default:
       
  1004             break;
       
  1005         }
       
  1006     TRACE_EXIT_POINT;
       
  1007     }
       
  1008 
       
  1009 // -----------------------------------------------------------------------------
       
  1010 // CCalenUnifiedEditorControl::AskRepeatingNoteQueriesL
       
  1011 // Add new entry type's editor fields
       
  1012 // -----------------------------------------------------------------------------
       
  1013 //
       
  1014 CCalenEditorDataHandler::TError CCalenUnifiedEditorControl::AskRepeatingNoteQueriesL(
       
  1015      CalCommon::TRecurrenceRange& aRepeatType )
       
  1016     {
       
  1017     TRACE_ENTRY_POINT;
       
  1018     TRACE_EXIT_POINT;
       
  1019     return iRepeatField->AskRepeatingNoteQueriesL( aRepeatType );
       
  1020     
       
  1021     }
       
  1022 
       
  1023 // -----------------------------------------------------------------------------
       
  1024 // CCalenUnifiedEditorControl::ReadDataFromEditorL
       
  1025 // Reads editor data mainly for collapsed editor
       
  1026 // -----------------------------------------------------------------------------
       
  1027 //
       
  1028 void CCalenUnifiedEditorControl::ReadDataFromEditorL( TBool aContinueOnError )
       
  1029     {
       
  1030     TRACE_ENTRY_POINT;
       
  1031     // Read data from the editor
       
  1032     ReadSubjectFromEditorL();
       
  1033     ReadStartDateTimeFromEditorL( aContinueOnError );
       
  1034     ReadEndDateTimeFromEditorL( aContinueOnError );        
       
  1035     
       
  1036     // ToDo do not have Place field
       
  1037     if( iUnifiedEditor.GetEntryType() != CCalEntry::ETodo )
       
  1038         {
       
  1039         ReadPlaceFieldFromEditorL( aContinueOnError );
       
  1040         }
       
  1041     
       
  1042     // TODO: Uncomment this when enabling attachment support
       
  1043     ReadAttachmentFieldFromEditorL( aContinueOnError );
       
  1044     ReadDescriptionFieldFromEditorL( aContinueOnError );
       
  1045     
       
  1046     iReminderField->ReadDataFromFormL( aContinueOnError );
       
  1047     
       
  1048     if( iUnifiedEditor.GetEntryType() == CCalEntry::ETodo )
       
  1049         {
       
  1050         iUnifiedEditor.Edited().SetNonRepeatingL();
       
  1051         iPriorityField->ReadDataFromFormL( aContinueOnError );
       
  1052         }
       
  1053     else
       
  1054         {
       
  1055         // Anniversary, Exceptional and Single instance of repeat enty
       
  1056         // do not have repeat field in editor
       
  1057         CCoeControl* repeatCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorRepeat );
       
  1058         if( repeatCtrl )
       
  1059             {
       
  1060             iRepeatField->ReadDataFromFormL( aContinueOnError );
       
  1061             }
       
  1062         }
       
  1063     
       
  1064     iDbField->ReadDataFromFormL( aContinueOnError );
       
  1065     
       
  1066     TRACE_EXIT_POINT;
       
  1067     }
       
  1068 
       
  1069 // -----------------------------------------------------------------------------
       
  1070 // CCalenUnifiedEditorControl::ReadSubjectFromEditorL
       
  1071 // Reads subject field from editor
       
  1072 // -----------------------------------------------------------------------------
       
  1073 //
       
  1074 void CCalenUnifiedEditorControl::ReadSubjectFromEditorL()
       
  1075     {
       
  1076     TRACE_ENTRY_POINT;
       
  1077     iUnifiedEditor.ReadSubjectFromEditorL();
       
  1078     TRACE_ENTRY_POINT;
       
  1079     }
       
  1080 
       
  1081 // -----------------------------------------------------------------------------
       
  1082 // CCalenUnifiedEditorControl::ReadStartDateTimeFromEditorL
       
  1083 // Reads start date time from the editor
       
  1084 // -----------------------------------------------------------------------------
       
  1085 //
       
  1086 void CCalenUnifiedEditorControl::ReadStartDateTimeFromEditorL( TBool aContinueOnError , TInt /* aFocusedId */ )
       
  1087     {
       
  1088     TRACE_ENTRY_POINT;
       
  1089     
       
  1090     TTime start = iUnifiedEditor.Edited().StartDateTime();
       
  1091     TDateTime startDT = start.DateTime();
       
  1092     
       
  1093     // Reading time field leaves, if it contains empty values.
       
  1094     // When editors are forced to exit, we want to continue reading
       
  1095     // other fields, even if one time field contains empty values
       
  1096     if( aContinueOnError )
       
  1097         {
       
  1098         PIM_TRAPD_HANDLE( ( start = GetStartDateTimeL() ) );
       
  1099         }
       
  1100     else
       
  1101         {
       
  1102         // Allow this function to leave.
       
  1103         start = GetStartDateTimeL();
       
  1104         }
       
  1105     startDT = start.DateTime();
       
  1106     iUnifiedEditor.Edited().SetStartDateTimeL( start );
       
  1107     
       
  1108     UpdateEndTimeL();
       
  1109 		
       
  1110     TRACE_EXIT_POINT;
       
  1111     }
       
  1112 
       
  1113 // -----------------------------------------------------------------------------
       
  1114 // CCalenUnifiedEditorControl::ReadStartDateTimeFromEditorL
       
  1115 // Reads End date time from the editor
       
  1116 // -----------------------------------------------------------------------------
       
  1117 //
       
  1118 void CCalenUnifiedEditorControl::ReadEndDateTimeFromEditorL( TBool aContinueOnError )
       
  1119     {
       
  1120     TRACE_ENTRY_POINT;
       
  1121     
       
  1122     TTime end;
       
  1123     TDateTime endDT;
       
  1124     
       
  1125     // Reading time field leaves, if it contains empty values.
       
  1126     // When editors are forced to exit, we want to continue reading
       
  1127     // other fields, even if one time field contains empty values
       
  1128     if( aContinueOnError )
       
  1129         {
       
  1130         PIM_TRAPD_HANDLE( ( end = GetEndDateTimeL() ) );
       
  1131         }
       
  1132     else
       
  1133         {
       
  1134         // Allow this function to leave.
       
  1135         end = GetEndDateTimeL();
       
  1136         }
       
  1137     endDT = end.DateTime();
       
  1138     
       
  1139     iUnifiedEditor.Edited().SetEndDateTimeL( end );
       
  1140     
       
  1141     TRACE_EXIT_POINT;
       
  1142     }
       
  1143 
       
  1144 // -----------------------------------------------------------------------------
       
  1145 // CCalenUnifiedEditorControl::GetStartDateTimeL
       
  1146 // Get start date time from editor
       
  1147 // -----------------------------------------------------------------------------
       
  1148 //
       
  1149 TTime CCalenUnifiedEditorControl::GetStartDateTimeL()
       
  1150     {
       
  1151     TRACE_ENTRY_POINT;
       
  1152     
       
  1153     TTime result = ReadTimeField( ECalenEditorStartDate );
       
  1154     TDateTime resDT = result.DateTime();
       
  1155     CCoeControl* startTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorStartTime );
       
  1156 
       
  1157     // For non-timed event and AllDay event StatTime field 
       
  1158     // does n't exit, so do not read StartTime.
       
  1159     if( startTimeCtrl )
       
  1160         {
       
  1161         TTime timeOfDate = ReadTimeField( ECalenEditorStartTime );
       
  1162         if( timeOfDate > 0 )
       
  1163             {
       
  1164             TDateTime timeOfDayTime = timeOfDate.DateTime();
       
  1165             result += TTimeIntervalHours( timeOfDayTime.Hour() );
       
  1166             result += TTimeIntervalMinutes( timeOfDayTime.Minute() );
       
  1167             }
       
  1168         }
       
  1169     else
       
  1170         {
       
  1171         // To set time as beginning of the day
       
  1172         result = CalenDateUtils::BeginningOfDay( result );
       
  1173         }
       
  1174     
       
  1175     if( iAllDayField->IsAllDayEvent() )
       
  1176         {
       
  1177         TTime endDate = iUnifiedEditor.Edited().EndDateTime();
       
  1178         endDate = CalenDateUtils::BeginningOfDay( endDate );
       
  1179         iUnifiedEditor.Edited().SetEndDateTimeL(endDate);
       
  1180         }
       
  1181     
       
  1182     resDT = result.DateTime();
       
  1183     TRACE_EXIT_POINT;
       
  1184     return result;
       
  1185     }
       
  1186 
       
  1187 // -----------------------------------------------------------------------------
       
  1188 // CCalenUnifiedEditorControl::GetEndDateTimeL
       
  1189 // Get end date time from editor
       
  1190 // -----------------------------------------------------------------------------
       
  1191 //
       
  1192 TTime CCalenUnifiedEditorControl::GetEndDateTimeL()
       
  1193     {
       
  1194     TRACE_ENTRY_POINT;
       
  1195     TTime result;
       
  1196     CCoeControl* endDateCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorEndDate);
       
  1197     if( endDateCtrl )
       
  1198         {
       
  1199         result = ReadDateField( ECalenEditorEndDate );
       
  1200         CCoeControl* endTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorEndTime );
       
  1201         // for AllDay event do not have EndTime
       
  1202         // so, do not read EndTime for them.
       
  1203         if( endTimeCtrl )
       
  1204             {
       
  1205             TTime timeOfDate = ReadTimeField( ECalenEditorEndTime );
       
  1206             if( timeOfDate > 0 )
       
  1207                 {
       
  1208                 TDateTime timeOfDayTime = timeOfDate.DateTime();
       
  1209                 result += TTimeIntervalHours( timeOfDayTime.Hour() );
       
  1210                 result += TTimeIntervalMinutes( timeOfDayTime.Minute() );
       
  1211                 }
       
  1212             }
       
  1213         else
       
  1214             {
       
  1215             // To set time as beginning of the day
       
  1216             result = CalenDateUtils::BeginningOfDay( result );
       
  1217             }
       
  1218         
       
  1219         if( iAllDayField->IsAllDayEvent() )
       
  1220             {
       
  1221             // For allday (1 day) event Eg. "Start:- 12:00am, 15-08-2010 &  End:-12:00am, 16-08-2010"
       
  1222             // In Editor it should be displayed as "StartDate: 15-08-2010 & EndDate:15-08-2010" 
       
  1223             // But, while saving EndDate is saved as 12:00am, 16-08-2010. 
       
  1224             TTime startDate = iUnifiedEditor.Edited().StartDateTime();
       
  1225             startDate = CalenDateUtils::BeginningOfDay( startDate );
       
  1226             iUnifiedEditor.Edited().SetStartDateTimeL(startDate);
       
  1227 
       
  1228             if( result >= startDate && (!iUnifiedEditor.iCheck ) || iUnifiedEditor.Edited().EntryType() == CCalEntry::EEvent)
       
  1229                 {
       
  1230                 result += TTimeIntervalDays( KOneDay );
       
  1231                 }
       
  1232             }
       
  1233 
       
  1234         }
       
  1235     else
       
  1236         {
       
  1237         // For entries Anniversary/Todo there is no EndDate field
       
  1238         // For them EndDate is same as StartDate
       
  1239         result = ReadDateField( ECalenEditorStartDate );
       
  1240         }
       
  1241     
       
  1242     TRACE_EXIT_POINT;
       
  1243     return result;
       
  1244     }
       
  1245 
       
  1246 // -----------------------------------------------------------------------------
       
  1247 // CCalenUnifiedEditorControl::ReadTimeField
       
  1248 // Reads time from editor
       
  1249 // -----------------------------------------------------------------------------
       
  1250 //
       
  1251 TTime CCalenUnifiedEditorControl::ReadTimeField( TInt aControlId )
       
  1252     {
       
  1253     TRACE_ENTRY_POINT;
       
  1254     TRACE_EXIT_POINT;
       
  1255     return static_cast<CEikTTimeEditor*>( iUnifiedEditor.Control( aControlId ) )->GetTTime();
       
  1256     }
       
  1257 
       
  1258 // -----------------------------------------------------------------------------
       
  1259 // CCalenUnifiedEditorControl::ReadDateField
       
  1260 // Reads date from editor
       
  1261 // -----------------------------------------------------------------------------
       
  1262 //
       
  1263 TTime CCalenUnifiedEditorControl::ReadDateField( TInt aControlId )
       
  1264     {
       
  1265     TRACE_ENTRY_POINT;
       
  1266     TRACE_EXIT_POINT;
       
  1267     return static_cast<CEikDateEditor*>( iUnifiedEditor.Control( aControlId ) )->Date();
       
  1268     }
       
  1269 
       
  1270 // -----------------------------------------------------------------------------
       
  1271 // CCalenUnifiedEditorControl::ReadPlaceFieldFromEditorL
       
  1272 // Reads place field from editor
       
  1273 // -----------------------------------------------------------------------------
       
  1274 //
       
  1275 void CCalenUnifiedEditorControl::ReadPlaceFieldFromEditorL( TBool /*aContinueOnError*/ )
       
  1276     {
       
  1277     TRACE_ENTRY_POINT;
       
  1278     
       
  1279     iUnifiedEditor.ReadPlaceFromEditorL();
       
  1280 
       
  1281     TRACE_ENTRY_POINT; 
       
  1282     }
       
  1283 
       
  1284 // -----------------------------------------------------------------------------
       
  1285 // CCalenUnifiedEditorControl::ReadPeopleFieldFromEditorL
       
  1286 // Reads people field from editor
       
  1287 // -----------------------------------------------------------------------------
       
  1288 //
       
  1289 void CCalenUnifiedEditorControl::ReadPeopleFieldFromEditorL( TBool /*aContinueOnError*/ )
       
  1290     {
       
  1291     TRACE_ENTRY_POINT;
       
  1292     
       
  1293     TRACE_ENTRY_POINT;    
       
  1294     }
       
  1295 
       
  1296 // -----------------------------------------------------------------------------
       
  1297 // CCalenUnifiedEditorControl::ReadAttachmentFieldFromEditorL
       
  1298 // Reads attachment field from editor
       
  1299 // -----------------------------------------------------------------------------
       
  1300 //
       
  1301 void CCalenUnifiedEditorControl::ReadAttachmentFieldFromEditorL( TBool /*aContinueOnError*/ )
       
  1302     {
       
  1303     TRACE_ENTRY_POINT;
       
  1304     
       
  1305     TRACE_ENTRY_POINT;    
       
  1306     }
       
  1307 
       
  1308 // -----------------------------------------------------------------------------
       
  1309 // CCalenUnifiedEditorControl::ReadDescriptionFieldFromEditorL
       
  1310 // Reads description field from editor
       
  1311 // -----------------------------------------------------------------------------
       
  1312 //
       
  1313 void CCalenUnifiedEditorControl::ReadDescriptionFieldFromEditorL( TBool /*aContinueOnError*/ )
       
  1314     {
       
  1315     TRACE_ENTRY_POINT;
       
  1316     
       
  1317     TRACE_ENTRY_POINT;
       
  1318     }
       
  1319 
       
  1320 // -----------------------------------------------------------------------------
       
  1321 // CCalenUnifiedEditorControl::Description
       
  1322 // Access to the decription field
       
  1323 // -----------------------------------------------------------------------------
       
  1324 //
       
  1325 CCalenDescription* CCalenUnifiedEditorControl::Description()
       
  1326     {
       
  1327     TRACE_ENTRY_POINT;
       
  1328     TRACE_EXIT_POINT;
       
  1329     return iDescription;
       
  1330     }
       
  1331 
       
  1332 // -----------------------------------------------------------------------------
       
  1333 // CCalenUnifiedEditorControl::UpdateLinesOnLocaleChangeL
       
  1334 // Update editor lines on environment change notifications
       
  1335 // -----------------------------------------------------------------------------
       
  1336 //
       
  1337 void CCalenUnifiedEditorControl::UpdateLinesOnLocaleChangeL()
       
  1338     {
       
  1339     TRACE_ENTRY_POINT;
       
  1340     
       
  1341     TInt lastFocusedItem = iUnifiedEditor.IdOfFocusedControl();
       
  1342     switch( iUnifiedEditor.GetEntryType() )
       
  1343         {
       
  1344         case CCalEntry::EEvent:
       
  1345             {
       
  1346             iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
  1347             iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM,
       
  1348                         ECalenEditorStartDate, ECalenEditorAllDayItem );
       
  1349             
       
  1350             iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse );
       
  1351             iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM,
       
  1352                     ECalenEditorEndDate, ECalenEditorStartDate );
       
  1353             }
       
  1354             break;
       
  1355             
       
  1356         case CCalEntry::EAnniv:
       
  1357             {
       
  1358             iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
  1359             iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
       
  1360                     ECalenEditorStartDate, ECalenEditorEventType );
       
  1361             
       
  1362             // "Start Date" Label should be "Date of Birth" for Birthday
       
  1363             iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
       
  1364                             R_QTN_CALEN_EDITOR_DATE_OF_BIRTH );
       
  1365             
       
  1366             }
       
  1367             break;
       
  1368             
       
  1369         case CCalEntry::EAppt:
       
  1370             {
       
  1371             
       
  1372             if( iUnifiedEditor.Edited().IsAllDayEvent() )
       
  1373                 {
       
  1374                 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
  1375                 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM,
       
  1376                             ECalenEditorStartDate, ECalenEditorAllDayItem );
       
  1377                 
       
  1378                 iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse );
       
  1379                 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM,
       
  1380                         ECalenEditorEndDate, ECalenEditorStartDate );
       
  1381                 }
       
  1382             else
       
  1383                 {
       
  1384                 iUnifiedEditor.DeleteLine( ECalenEditorStartTime, EFalse );
       
  1385                 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_TIME_ITEM,
       
  1386                         ECalenEditorStartTime, ECalenEditorAllDayItem );
       
  1387                 
       
  1388                 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
  1389                 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM,
       
  1390                         ECalenEditorStartDate, ECalenEditorStartTime );
       
  1391 
       
  1392                 iUnifiedEditor.DeleteLine( ECalenEditorEndTime, EFalse );
       
  1393                 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_TIME_ITEM,
       
  1394                         ECalenEditorEndTime, ECalenEditorStartDate );
       
  1395                 
       
  1396                 iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse );
       
  1397                 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM,
       
  1398                         ECalenEditorEndDate, ECalenEditorEndTime );
       
  1399                 }
       
  1400 
       
  1401             }
       
  1402             break;
       
  1403             
       
  1404         case CCalEntry::ETodo:
       
  1405             {
       
  1406             iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
       
  1407             iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
       
  1408                           ECalenEditorStartDate, ECalenEditorEventType );
       
  1409                         
       
  1410             }
       
  1411             break;
       
  1412         default:
       
  1413             break;
       
  1414         }
       
  1415     
       
  1416     if( iUnifiedEditor.ControlOrNull( ECalenEditorReminderDate ) )
       
  1417         {
       
  1418         iUnifiedEditor.DeleteLine( ECalenEditorReminderDate, EFalse );
       
  1419         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_DATE_ITEM,
       
  1420                 ECalenEditorReminderDate, ECalenEditorReminder );
       
  1421         
       
  1422         }
       
  1423     if( iUnifiedEditor.ControlOrNull( ECalenEditorReminderTime ) )
       
  1424         {
       
  1425         iUnifiedEditor.DeleteLine( ECalenEditorReminderTime, EFalse );
       
  1426         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_TIME_ITEM,
       
  1427                 ECalenEditorReminderTime, ECalenEditorReminderDate );                    
       
  1428         }
       
  1429     if( iUnifiedEditor.ControlOrNull( ECalenEditorRepeatUntil ) )
       
  1430         {
       
  1431         iUnifiedEditor.DeleteLine( ECalenEditorRepeatUntil, EFalse );
       
  1432         iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REPEAT_UNTIL_ITEM,
       
  1433                 ECalenEditorRepeatUntil, ECalenEditorRepeat );                    
       
  1434 
       
  1435         }
       
  1436 
       
  1437     iUnifiedEditor.TryChangeFocusToL( lastFocusedItem );
       
  1438     SetDataToEditorL(ETrue);
       
  1439     iUnifiedEditor.UpdateFormL();
       
  1440     TRACE_EXIT_POINT;
       
  1441     }
       
  1442 
       
  1443 TInt CCalenUnifiedEditorControl::GetCalendarIndexForEntryL()
       
  1444     {
       
  1445     TRACE_ENTRY_POINT;
       
  1446     TRACE_EXIT_POINT;
       
  1447     
       
  1448     return iDbField->GetCalendarIndexForEntryL();
       
  1449     }
       
  1450 
       
  1451 // -----------------------------------------------------------------------------
       
  1452 // CCalenUnifiedEditorControl::GetCalendarNameForEntryL()
       
  1453 // -----------------------------------------------------------------------------
       
  1454 //
       
  1455 const TDesC& CCalenUnifiedEditorControl::GetCalendarNameForEntryL()
       
  1456     {
       
  1457     TRACE_ENTRY_POINT;
       
  1458     TRACE_EXIT_POINT;
       
  1459     
       
  1460     return iDbField->GetCalendarNameForEntryL();
       
  1461     }
       
  1462 
       
  1463 TInt CCalenUnifiedEditorControl::GetCalendarNameForEntryL(const TDesC& aCalendarFileName)
       
  1464     {
       
  1465     TRACE_ENTRY_POINT;
       
  1466     TRACE_EXIT_POINT;
       
  1467     
       
  1468     return iDbField->GetCalendarNameForEntryL(aCalendarFileName);
       
  1469     }
       
  1470 
       
  1471 // -----------------------------------------------------------------------------
       
  1472 // CCalenUnifiedEditorControl::UpdateMeetingDurationL()
       
  1473 // This function leaves if the end date/time is before the start date/time.
       
  1474 // (other items were commented in a header).
       
  1475 // -----------------------------------------------------------------------------
       
  1476 //
       
  1477 void CCalenUnifiedEditorControl::UpdateMeetingDurationL()
       
  1478     {
       
  1479     TRACE_ENTRY_POINT;
       
  1480 
       
  1481     TTime start = iUnifiedEditor.Edited().StartDateTime();
       
  1482     TTime end = iUnifiedEditor.Edited().EndDateTime();
       
  1483     User::LeaveIfError(
       
  1484         end.MinutesFrom(start, iMeetingInterval ) );
       
  1485 
       
  1486     TRACE_EXIT_POINT;
       
  1487     }
       
  1488 
       
  1489 // -----------------------------------------------------------------------------
       
  1490 // CCalenUnifiedEditorControl::UpdateEndTimeL()
       
  1491 // Updates the end date/time when the start date/time is changed.
       
  1492 // (other items were commented in a header).
       
  1493 // -----------------------------------------------------------------------------
       
  1494 //
       
  1495 void CCalenUnifiedEditorControl::UpdateEndTimeL()
       
  1496     {
       
  1497     TRACE_ENTRY_POINT;
       
  1498 
       
  1499     TTime start = iUnifiedEditor.Edited().StartDateTime();
       
  1500     
       
  1501     // Update EndTime in the Editor for meeting Entry
       
  1502     TTime end = start;
       
  1503     end += iMeetingInterval;
       
  1504     end = CalenDateUtils::LimitToValidTime( end );
       
  1505 
       
  1506     // update data model
       
  1507     iUnifiedEditor.Edited().SetEndDateTimeL( end );
       
  1508 
       
  1509     // update form fields
       
  1510     UpdateMeetingDurationL();
       
  1511 
       
  1512     if( iAllDayField->IsAllDayEvent() && 
       
  1513             CCalEntry::EEvent == iUnifiedEditor.Edited().EntryType() )
       
  1514         {
       
  1515         // For allday (1 day) event Eg. "Start:- 12:00am, 15-08-2010 &  End:-12:00am, 16-08-2010"
       
  1516         // In Editor it should be displayed as "StartDate: 15-08-2010 & EndDate:15-08-2010" 
       
  1517         // No time filed is displayed.
       
  1518         end -= TTimeIntervalDays( KOneDay );
       
  1519         if ( end < start )                         
       
  1520             {
       
  1521             end = start;
       
  1522             }
       
  1523         }
       
  1524     
       
  1525     SetDateField( ECalenEditorEndDate, end, ETrue );
       
  1526     SetTimeField( ECalenEditorEndTime, end, ETrue );
       
  1527     TRACE_EXIT_POINT;
       
  1528     }
       
  1529 
       
  1530 // -----------------------------------------------------------------------------
       
  1531 // CCalenUnifiedEditorControl::ReadRrule()
       
  1532 // Checks the Rdates and RRule if there is any with the CCalEntry
       
  1533 // (other items were commented in a header).
       
  1534 // -----------------------------------------------------------------------------
       
  1535 //
       
  1536 void CCalenUnifiedEditorControl::ReadRruleL(TTime& firstRdatestartTime, TTime& endTime)
       
  1537     {   
       
  1538     TRACE_ENTRY_POINT;
       
  1539     
       
  1540     RArray<TCalTime> rDateList;
       
  1541     CleanupClosePushL( rDateList );    
       
  1542     rDateList = iUnifiedEditor.Edited().GetRdatesL();
       
  1543     
       
  1544     TInt count = rDateList.Count();    
       
  1545     TBool hasRDates = ( count > 0 );    
       
  1546     
       
  1547     // Get the firstRDate only if the entry has RDates.
       
  1548     if( hasRDates )
       
  1549         {
       
  1550         firstRdatestartTime = rDateList[ 0 ].TimeLocalL();
       
  1551         TDateTime firstRDateTime = firstRdatestartTime.DateTime();
       
  1552         
       
  1553         TTimeIntervalMinutes duration;                            
       
  1554         TTime entryStartTime = iUnifiedEditor.Edited().StartDateTime();
       
  1555         TTime entryEndTime = iUnifiedEditor.Edited().EndDateTime();
       
  1556         
       
  1557         User::LeaveIfError( entryEndTime.MinutesFrom( entryStartTime, duration ) );                
       
  1558         endTime= firstRdatestartTime + duration;  
       
  1559         }       
       
  1560     else
       
  1561         {
       
  1562         firstRdatestartTime = iUnifiedEditor.Edited().StartDateTime();
       
  1563         endTime =  iUnifiedEditor.Edited().EndDateTime();
       
  1564         }
       
  1565     
       
  1566     CleanupStack::PopAndDestroy();
       
  1567     
       
  1568     TRACE_EXIT_POINT;
       
  1569     }
       
  1570 // -----------------------------------------------------------------------------
       
  1571 // CCalenUnifiedEditorControl::HandleErrorL()
       
  1572 // Handles errors. This function may be called on saving note.
       
  1573 // (other items were commented in a header).
       
  1574 // -----------------------------------------------------------------------------
       
  1575 //
       
  1576 void CCalenUnifiedEditorControl::HandleErrorL(const TInt& aError)
       
  1577     {
       
  1578     TRACE_ENTRY_POINT;
       
  1579     if( aError == CCalenEditorDataHandler::EFormErrDurationGreaterThanRepeatInterval )
       
  1580         {
       
  1581         iUnifiedEditor.TryChangeFocusToL(ECalenEditorRepeat);
       
  1582         }
       
  1583     else if( aError == CCalenEditorDataHandler::EFormErrOutOfSequence )
       
  1584         {
       
  1585         iUnifiedEditor.TryChangeFocusToL(ECalenEditorStartDate);
       
  1586         }
       
  1587     else if( aError == CCalenEditorDataHandler::EFormErrOverlapsExistingInstance )
       
  1588         {
       
  1589         iUnifiedEditor.TryChangeFocusToL(ECalenEditorStartDate);
       
  1590         }
       
  1591     else
       
  1592         {
       
  1593         if( aError == CCalenEditorDataHandler::EFormErrInstanceAlreadyExistsOnThisDay )
       
  1594             {   
       
  1595             iUnifiedEditor.TryChangeFocusToL(ECalenEditorStartDate);
       
  1596             }    
       
  1597         }
       
  1598 
       
  1599     if (iReminderField->HandleErrorL(aError) )
       
  1600         {
       
  1601         TRACE_EXIT_POINT;
       
  1602         return;
       
  1603         }
       
  1604     if ( iRepeatField->HandleErrorL(aError) )
       
  1605         {
       
  1606         TRACE_EXIT_POINT;
       
  1607         return;
       
  1608         }
       
  1609 
       
  1610     TRACE_EXIT_POINT;
       
  1611     }
       
  1612 // End of file
       
  1613 
       
  1614