phonebookui/Phonebook2/UIControls/inc/CPbk2ContactEditorFieldArray.h
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Phonebook 2 contact editor field array.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2CONTACTEDITORFIELDARRAY_H
       
    20 #define CPBK2CONTACTEDITORFIELDARRAY_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "MPbk2ContactEditorFieldArray.h"
       
    25 #include "TPbk2ContactEditorParams.h"
       
    26 #include "CPbk2ContactEditorArrayItem.h"
       
    27 #include "Pbk2UIFieldProperty.hrh"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MPbk2ContactEditorUiBuilder;
       
    31 class CPbk2PresentationContact;
       
    32 class CPbk2PresentationContactField;
       
    33 class CPbk2IconInfoContainer;
       
    34 class MPbk2ContactEditorField;
       
    35 class MVPbkFieldType;
       
    36 class CVPbkContactManager;
       
    37 class CPbk2ReadingFieldEditorVisitor;
       
    38 class MPbk2ContactEditorFieldVisitor;
       
    39 class MPbk2ContactEditorExtension;
       
    40 class CPbk2ContactEditorFieldFactory;
       
    41 class CPbkIconInfoContainer;
       
    42 class CPbk2UIFieldArray;
       
    43 class MPbk2ApplicationServices;
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47  *  An array of editor fields.
       
    48  *
       
    49  */
       
    50 NONSHARABLE_CLASS(CPbk2ContactEditorFieldArray) : 
       
    51         public CBase,
       
    52         public MPbk2ContactEditorFieldArray
       
    53     {
       
    54     public:  // Constructors and destructor
       
    55         
       
    56         /**
       
    57          * Creates a new instance of this class.
       
    58          *
       
    59          * @param aManager          Virtual Phonebook contact manager.
       
    60          * @param aContact          The presentation level contact.
       
    61          * @param aUiBuilder        A reference to the dialog builder.
       
    62          * @param aEditorExtension  Contact editor extension. 
       
    63          * @return  A new instance of this class.
       
    64          */
       
    65         static CPbk2ContactEditorFieldArray* NewL(
       
    66                 CVPbkContactManager& aContactManager,
       
    67                 CPbk2PresentationContact& aContact,
       
    68                 MPbk2ContactEditorUiBuilder& aUiBuilder,
       
    69                 CPbk2ContactEditorFieldFactory& aFieldFactory);
       
    70         
       
    71         /**
       
    72 		 * Creates a new instance of this class.
       
    73 		 *
       
    74 		 * @param aManager          Virtual Phonebook contact manager.
       
    75 		 * @param aContact          The presentation level contact.
       
    76 		 * @param aUiBuilder        A reference to the dialog builder.
       
    77 		 * @param aEditorExtension  Contact editor extension. 
       
    78 		 * @param aAppServices	    Pointer to application services
       
    79 		 * @return  A new instance of this class.
       
    80 		 */
       
    81 		static CPbk2ContactEditorFieldArray* NewL(
       
    82 				CVPbkContactManager& aContactManager,
       
    83 				CPbk2PresentationContact& aContact,
       
    84 				MPbk2ContactEditorUiBuilder& aUiBuilder,
       
    85 				CPbk2ContactEditorFieldFactory& aFieldFactory,
       
    86 				MPbk2ApplicationServices* aAppServices );
       
    87         
       
    88         /**
       
    89          * Destructor.
       
    90          */
       
    91         ~CPbk2ContactEditorFieldArray();
       
    92 
       
    93     public: // Interface
       
    94 
       
    95         /**
       
    96          * Creates editor fields from the store contact.
       
    97          */
       
    98         void CreateFieldsFromContactL(TPbk2ContactEditorParams& aParams);
       
    99 
       
   100     public: // From MPbk2ContactEditorFieldArray
       
   101         inline TInt Count() const;
       
   102         inline CPbk2ContactEditorArrayItem& At(
       
   103                 TInt aIndex );
       
   104         void SaveFieldsL();
       
   105         TBool FieldsChanged() const;
       
   106         TBool AreAllUiFieldsEmpty() const;
       
   107         void SetFocus(
       
   108                 TInt aFieldIndex );
       
   109         CPbk2ContactEditorArrayItem* Find(
       
   110                 TInt aControlId );
       
   111         TInt FindIndex(
       
   112                 TInt aControlId );
       
   113         TInt AddNewFieldL(
       
   114                 const MVPbkFieldType& aFieldType );
       
   115         void AddNewFieldL(
       
   116                 const TPbk2FieldGroupId aAddressGroup );
       
   117         void RemoveField(
       
   118         		CPbk2ContactEditorArrayItem& aField );
       
   119         void RemoveFieldFromUI( 
       
   120         		TInt aIndex );
       
   121         TInt AddNewFieldL(
       
   122                 const MVPbkFieldType& aFieldType, const TDesC& aName );
       
   123         void UpdateControlsL();
       
   124         
       
   125     public: // Implementation
       
   126         TBool IsEditorFieldControlEmpty( TInt aIndex ) const;
       
   127         TBool IsEditorUiFieldControlEmpty( TInt aIndex ) const;
       
   128   
       
   129     private: // Implementation
       
   130         CPbk2ContactEditorFieldArray(
       
   131                 CPbk2PresentationContact& aContact,
       
   132                 MPbk2ContactEditorUiBuilder& aUiBuilder,
       
   133                 CPbk2ContactEditorFieldFactory& aFieldFactory,
       
   134                 MPbk2ApplicationServices* aAppServices = NULL );
       
   135         void ConstructL(
       
   136                 CVPbkContactManager& aContactManager );
       
   137         TInt GetUiFieldIndex(
       
   138                 TInt aContactFieldIndex );
       
   139         TInt GetUiFieldIndex(
       
   140         		TPbk2FieldGroupId aContactAddressGroupID );
       
   141         void AcceptL(
       
   142                 MPbk2ContactEditorFieldVisitor& aVisitor );
       
   143         void __DbgTestInvariant() const;
       
   144         TBool IsFieldPartOfAddress(CPbk2PresentationContactField& aField);
       
   145         void CreateUIFieldL(
       
   146         		CPbk2UIFieldArray& aFieldsArr, 
       
   147         		TPbk2FieldGroupId aAddressGroup,
       
   148 				TPbk2FieldOrder aOrder, 
       
   149         		TInt& aNextFreePos );
       
   150         
       
   151     private: // Data
       
   152         /// Ref: The contact that is edited
       
   153         CPbk2PresentationContact& iContact;
       
   154         /// Ref: Editor UI creator
       
   155         MPbk2ContactEditorUiBuilder& iUiBuilder;
       
   156 		/// Own: An array of dialog fields
       
   157 		RPointerArray<CPbk2ContactEditorArrayItem> iFieldArray;
       
   158         /// Own: Reading field visitor
       
   159         CPbk2ReadingFieldEditorVisitor* iReadingFieldBinder;
       
   160         /// Ref:Field factory
       
   161         CPbk2ContactEditorFieldFactory& iFieldFactory;
       
   162         /// Own:Contact editor params
       
   163         TPbk2ContactEditorParams iParams;
       
   164 		/// Own: icon info container
       
   165         CPbk2IconInfoContainer* iIconInfoContainer;
       
   166         // Ref: Pointer to Pbk2 application services
       
   167         MPbk2ApplicationServices* iAppServices;
       
   168     };
       
   169 
       
   170 // INLINE FUNCTIONS
       
   171 
       
   172 // --------------------------------------------------------------------------
       
   173 // CPbk2ContactEditorFieldArray::Count
       
   174 // --------------------------------------------------------------------------
       
   175 //
       
   176 inline TInt CPbk2ContactEditorFieldArray::Count() const
       
   177     {
       
   178     return iFieldArray.Count();
       
   179     }
       
   180 
       
   181 // --------------------------------------------------------------------------
       
   182 // CPbk2ContactEditorFieldArray::At
       
   183 // --------------------------------------------------------------------------
       
   184 //    
       
   185 inline CPbk2ContactEditorArrayItem& CPbk2ContactEditorFieldArray::At
       
   186         ( TInt aIndex )
       
   187     {
       
   188     return *iFieldArray[aIndex];
       
   189     }
       
   190 
       
   191 #endif // CPBK2CONTACTEDITORFIELDARRAY_H
       
   192             
       
   193 // End of File