phonebookui/Phonebook2/UIControls/src/CPbk2ContactEditorFieldBase.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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 base class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPbk2ContactEditorFieldBase.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include "MPbk2ContactEditorUiBuilder.h"
       
    23 #include <MPbk2FieldProperty.h>
       
    24 #include <CPbk2PresentationContactField.h>
       
    25 
       
    26 // Virtual Phonebook
       
    27 #include <MVPbkContactStore.h>
       
    28 #include <MVPbkStoreContact.h>
       
    29 #include <MVPbkContactStoreProperties.h>
       
    30 #include <MVPbkContactFieldData.h>
       
    31 #include <MVPbkContactFieldTextData.h>
       
    32 
       
    33 // System includes
       
    34 #include <eikedwin.h>
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CPbk2ContactEditorFieldBase::CPbk2ContactEditorFieldBase
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CPbk2ContactEditorFieldBase::CPbk2ContactEditorFieldBase
       
    41         ( CPbk2PresentationContactField& aContactField,
       
    42           MPbk2ContactEditorUiBuilder& aUiBuilder,
       
    43           CPbk2IconInfoContainer& aIconInfoContainer ) :
       
    44             iContactField( aContactField ),
       
    45             iUiBuilder( aUiBuilder ),
       
    46             iIconInfoContainer( aIconInfoContainer ),
       
    47             iContactDataHasChanged( EFalse )
       
    48     {
       
    49     }
       
    50     
       
    51 // -----------------------------------------------------------------------------
       
    52 // CPbk2ContactEditorFieldBase::~CPbk2ContactEditorFieldBase
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CPbk2ContactEditorFieldBase::~CPbk2ContactEditorFieldBase()
       
    56     {
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CPbk2ContactEditorFieldBase::ControlId
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 TInt CPbk2ContactEditorFieldBase::ControlId() const
       
    64     {
       
    65     return ( TInt ) this;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CPbk2ContactEditorFieldBase::ContactEditorFieldExtension
       
    70 // -----------------------------------------------------------------------------
       
    71 //    
       
    72 TAny* CPbk2ContactEditorFieldBase::ContactEditorFieldExtension(TUid aExtensionUid )
       
    73  {
       
    74      if( aExtensionUid == KMPbk2ContactEditorFieldExtension2Uid )
       
    75          {
       
    76          return static_cast<MPbk2ContactEditorField2*>( this );
       
    77          }    
       
    78      
       
    79     return NULL;
       
    80  }   
       
    81 // CPbk2ContactEditorFieldBase::HandleCustomFieldCommandL
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TBool CPbk2ContactEditorFieldBase::HandleCustomFieldCommandL(TInt /*aCommand*/ )
       
    85     {
       
    86     return EFalse;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CPbk2ContactEditorFieldBase::FieldDataChanged
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 TBool CPbk2ContactEditorFieldBase::FieldDataChanged() const
       
    94     {
       
    95     return iContactDataHasChanged;
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CPbk2ContactEditorFieldBase::FieldLabel
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TPtrC CPbk2ContactEditorFieldBase::FieldLabel() const
       
   103     {
       
   104     return iContactField.FieldLabel();
       
   105     }
       
   106   
       
   107 // -----------------------------------------------------------------------------
       
   108 // CPbk2ContactEditorFieldBase::SetFieldLabelL
       
   109 // -----------------------------------------------------------------------------
       
   110 //  
       
   111 void CPbk2ContactEditorFieldBase::SetFieldLabelL( const TDesC& aLabel )
       
   112     {
       
   113     iUiBuilder.SetCurrentLineCaptionL( aLabel );
       
   114     iContactField.SetFieldLabelL( aLabel );
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CPbk2ContactEditorFieldBase::ControlTextL
       
   119 // -----------------------------------------------------------------------------
       
   120 //  
       
   121 HBufC* CPbk2ContactEditorFieldBase::ControlTextL() const
       
   122     {
       
   123     HBufC* textBuf = NULL;
       
   124 
       
   125     CCoeControl* ctrl = iUiBuilder.Control( ControlId() );
       
   126     TVPbkFieldStorageType fType = iContactField.FieldData().DataType();
       
   127     if ( ctrl && ( ( fType == EVPbkFieldStorageTypeText ) ||
       
   128             (fType == EVPbkFieldStorageTypeUri) ) )
       
   129         {
       
   130         textBuf = static_cast<CEikEdwin*>( ctrl )->GetTextInHBufL();
       
   131         }
       
   132 
       
   133     return textBuf;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CPbk2ContactEditorFieldBase::SetFocus
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CPbk2ContactEditorFieldBase::SetFocus()
       
   141     {
       
   142     // It's not fatal if focusing fails
       
   143     TRAP_IGNORE( iUiBuilder.TryChangeFocusL( ControlId() ) );
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CPbk2ContactEditorFieldBase::ContactField
       
   148 // -----------------------------------------------------------------------------
       
   149 //    
       
   150 MVPbkStoreContactField& CPbk2ContactEditorFieldBase::ContactField() const
       
   151     {
       
   152     return iContactField.StoreField();
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CPbk2ContactEditorFieldBase::FieldProperty
       
   157 // -----------------------------------------------------------------------------
       
   158 //    
       
   159 const MPbk2FieldProperty& CPbk2ContactEditorFieldBase::FieldProperty() const
       
   160     {
       
   161     return iContactField.FieldProperty();
       
   162     }
       
   163     
       
   164 // -----------------------------------------------------------------------------
       
   165 // CPbk2ContactEditorFieldBase::ConsumesKeyEvent
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 TBool CPbk2ContactEditorFieldBase::ConsumesKeyEvent
       
   169         ( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
       
   170     {
       
   171     return EFalse;
       
   172     }   
       
   173 
       
   174 // End of File