meetingrequest/mrgui/src/cesmreditorfieldstorage.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 0 8466d47a6819
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    28 #include "cesmrvalidatorfactory.h"
    28 #include "cesmrvalidatorfactory.h"
    29 #include "cesmrglobalnote.h"
    29 #include "cesmrglobalnote.h"
    30 #include "cesmrfield.h"
    30 #include "cesmrfield.h"
    31 #include "cesmrfieldeventqueue.h"
    31 #include "cesmrfieldeventqueue.h"
    32 
    32 
       
    33 #include <ct/rcpointerarray.h>
       
    34 
    33 //logging
    35 //logging
    34 //performance profiling
    36 //performance profiling
    35 // <cmail> Removed profiling. </cmail>
    37 // <cmail> Removed profiling. </cmail>
    36 
    38 
    37 // Unnamed namespace for local definitions
    39 // Unnamed namespace for local definitions
   129 
   131 
   130         case MESMRFieldValidator::EErrorRescheduleInstance:
   132         case MESMRFieldValidator::EErrorRescheduleInstance:
   131             {
   133             {
   132             CESMRGlobalNote::ExecuteL(
   134             CESMRGlobalNote::ExecuteL(
   133                                 CESMRGlobalNote::EESMRRepeatReSchedule );
   135                                 CESMRGlobalNote::EESMRRepeatReSchedule );
   134             }
   136             break;
   135             break;
   137             }
       
   138         case MESMRFieldValidator::EErrorInstanceOverlapsExistingOne:
       
   139             {
       
   140             CESMRGlobalNote::ExecuteL(
       
   141                                 CESMRGlobalNote::EESMROverlapsExistingInstance );
       
   142             break;
       
   143             }
       
   144             
       
   145         case MESMRFieldValidator::EErrorInstanceAlreadyExistsOnThisDay:
       
   146             {
       
   147             CESMRGlobalNote::ExecuteL(
       
   148                                 CESMRGlobalNote::EESMRInstanceAlreadyExistsOnThisDay );
       
   149             break;
       
   150             }
       
   151             
       
   152         case MESMRFieldValidator::EErrorInstanceOutOfSequence:
       
   153             {
       
   154             CESMRGlobalNote::ExecuteL(
       
   155                                 CESMRGlobalNote::EESMRInstanceOutOfSequence );
       
   156             break;
       
   157             }
   136         default:
   158         default:
   137             {
   159             {
   138             err = KErrNone;
   160             err = KErrNone;
   139             break;
   161             break;
   140             }
   162             }
   172 // ---------------------------------------------------------------------------
   194 // ---------------------------------------------------------------------------
   173 // CESMREditorFieldStorage::NewL
   195 // CESMREditorFieldStorage::NewL
   174 // ---------------------------------------------------------------------------
   196 // ---------------------------------------------------------------------------
   175 //
   197 //
   176 CESMREditorFieldStorage* CESMREditorFieldStorage::NewL(
   198 CESMREditorFieldStorage* CESMREditorFieldStorage::NewL(
   177         CESMRPolicy* aPolicy,
   199         const CESMRPolicy& aPolicy,
   178         MESMRFieldEventObserver& aEventObserver )
   200         MESMRFieldEventObserver& aEventObserver )
   179     {
   201     {
   180     FUNC_LOG;
   202     FUNC_LOG;
   181     CESMREditorFieldStorage* self =
   203     CESMREditorFieldStorage* self =
   182             new (ELeave) CESMREditorFieldStorage( aEventObserver );
   204             new (ELeave) CESMREditorFieldStorage( aEventObserver );
   188 
   210 
   189 // ---------------------------------------------------------------------------
   211 // ---------------------------------------------------------------------------
   190 // CESMREditorFieldStorage::ConstructL
   212 // CESMREditorFieldStorage::ConstructL
   191 // ---------------------------------------------------------------------------
   213 // ---------------------------------------------------------------------------
   192 //
   214 //
   193 void CESMREditorFieldStorage::ConstructL( CESMRPolicy* aPolicy )
   215 void CESMREditorFieldStorage::ConstructL( const CESMRPolicy& aPolicy )
   194     {
   216     {
   195     FUNC_LOG;
   217     FUNC_LOG;
   196     CESMRFieldStorage::BaseConstructL();
   218     CESMRFieldStorage::BaseConstructL();
   197     iValidator =
   219     iValidator =
   198             CESMRValidatorFactory::CreateValidatorL (
   220             CESMRValidatorFactory::CreateValidatorL( aPolicy.EventType() );
   199                     aPolicy->EventType() );
       
   200     
   221     
   201     __ASSERT_DEBUG( iValidator, Panic( EESMREditorFieldStorageNoValidator) );
   222     __ASSERT_DEBUG( iValidator, Panic( EESMREditorFieldStorageNoValidator) );
   202 
   223 
   203     iValidator->SetFieldEventQueue( &EventQueueL() );
   224     iValidator->SetFieldEventQueue( &EventQueueL() );
   204     
   225     
   205     RArray<TESMREntryField> fields = aPolicy->Fields();
   226     RArray<TESMREntryField> fields = aPolicy.Fields();
   206     const TInt count(fields.Count());
   227     const TInt count(fields.Count());
   207     
   228     
   208     for (TInt i(0); i < count; i++ )
   229     for (TInt i(0); i < count; i++ )
   209         {
   230         {
   210         TESMREntryField entryField = fields[i];
   231         TESMREntryField entryField = fields[i];
   211         TBool visible( entryField.iFieldViewMode == EESMRFieldTypeDefault);
   232         TBool visible( entryField.iFieldViewMode == EESMRFieldTypeDefault );
   212         CESMRField* field = CreateEditorFieldL( iValidator, entryField );
   233         CESMRField* field = CreateEditorFieldL( iValidator, entryField );
   213         
   234         
   214         CleanupStack::PushL( field );
   235         if( field->FieldViewMode() != EESMRFieldTypeDisabled )
   215         AddFieldL( field, visible );
   236             {
   216         CleanupStack::Pop( field );
   237             CleanupStack::PushL( field );
   217         }
   238             AddFieldL( field, visible );
   218     
   239             CleanupStack::Pop( field );
       
   240             }
       
   241         else
       
   242             {
       
   243             delete field;
       
   244             field = NULL;
       
   245             }
       
   246         }
   219     }
   247     }
   220         
   248         
   221 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   222 // CESMREditorFieldStorage::ExternalizeL
   250 // CESMREditorFieldStorage::ExternalizeL
   223 // ---------------------------------------------------------------------------
   251 // ---------------------------------------------------------------------------
   263         }
   291         }
   264 
   292 
   265     return err;
   293     return err;
   266     }
   294     }
   267 
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 // CESMREditorFieldStorage::ChangePolicyL
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 void CESMREditorFieldStorage::ChangePolicyL(
       
   301         const CESMRPolicy& aNewPolicy,
       
   302         MESMRCalEntry& /*aEntry*/ )
       
   303     {
       
   304     MESMRFieldValidator* validator =
       
   305         CESMRValidatorFactory::CreateValidatorL( aNewPolicy.EventType() );
       
   306         
       
   307     __ASSERT_DEBUG( validator, Panic( EESMREditorFieldStorageNoValidator) );
       
   308     CleanupDeletePushL( validator );
       
   309     
       
   310     validator->SetFieldEventQueue( &EventQueueL() );
       
   311     
       
   312     // Iterate through policy and create fields into tmp array
       
   313     RArray<TESMREntryField> fields = aNewPolicy.Fields();
       
   314     
       
   315     TInt count( fields.Count() );
       
   316         
       
   317     RCPointerArray< CESMRField > fieldArray;
       
   318     CleanupClosePushL( fieldArray );
       
   319     
       
   320     fieldArray.ReserveL( count );    
       
   321 
       
   322     CESMRField* field = NULL;
       
   323     
       
   324     // Append new fields to array
       
   325     for (TInt i(0); i < count; ++i )
       
   326         {
       
   327         field = CreateEditorFieldL( validator, fields[i] );
       
   328         // Append field
       
   329         if( field->FieldViewMode() != EESMRFieldTypeDisabled )
       
   330             {
       
   331             fieldArray.AppendL( field );
       
   332             }
       
   333         else
       
   334             {
       
   335             delete field;
       
   336             field = NULL;
       
   337             }
       
   338         }
       
   339     
       
   340     // Reseting field array from storage, so that it can be
       
   341     // reused
       
   342     Reset();
       
   343     
       
   344     count = fieldArray.Count();
       
   345 
       
   346     // Reserve space in strorage for all required fields
       
   347     ReserveL( count );
       
   348     
       
   349     // Insert fields from fieldArray into storage
       
   350     for ( TInt i = 0; i < count; ++i )
       
   351         {
       
   352         AddFieldL( fieldArray[ i ] );
       
   353         
       
   354         TBool visible( fields[ i ].iFieldViewMode == EESMRFieldTypeDefault );
       
   355         Field( i )->MakeVisible( visible );
       
   356         }
       
   357     
       
   358     // Remove items from field array
       
   359     for ( TInt i = 0; i < count; ++i )
       
   360         {
       
   361         fieldArray.Remove( 0 );
       
   362         }
       
   363 
       
   364     // Assign new validator
       
   365     delete iValidator;
       
   366     iValidator = validator;
       
   367     CleanupStack::PopAndDestroy( &fieldArray );
       
   368     CleanupStack::Pop( validator );
       
   369     }
       
   370 
   268 // EOF
   371 // EOF
   269 
   372