uiservicetab/vimpstui/src/cvimpstuisearchfield.cpp
branchRCL_3
changeset 22 3104fc151679
parent 21 2b7283837edb
child 23 9a48e301e94b
equal deleted inserted replaced
21:2b7283837edb 22:3104fc151679
     1 /*
       
     2 * Copyright (c) 2008 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:  search field implemetation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cvimpstuisearchfield.h"
       
    20 
       
    21 // System includes
       
    22 #include <eikedwin.h>
       
    23 #include <eikcapc.h>
       
    24 #include <eikedwin.h>
       
    25 #include <AknUtils.h>
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CVIMPSTUiSearchField::CVIMPSTUiSearchField
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CVIMPSTUiSearchField::CVIMPSTUiSearchField( TVIMPSTSearchDataFieldType aFieldDataType, 
       
    32 											TIMPSTSearchFieldTypes aFieldType, 
       
    33 											TVIMPSTEnums::TVIMPSTSearchKey aSearchKey 
       
    34 											/* =EVIMPSTSearchKeyUknown*/)
       
    35 	:iFieldDataType( aFieldDataType ),
       
    36 	iFieldType(aFieldType ),
       
    37 	iSearchKey( aSearchKey )
       
    38     {
       
    39     iCaptionedCtrl  = NULL;
       
    40     iControl = NULL;
       
    41     }
       
    42    
       
    43 // --------------------------------------------------------------------------
       
    44 // CVIMPSTUiSearchFieldArray::NewL
       
    45 // --------------------------------------------------------------------------
       
    46 //
       
    47 CVIMPSTUiSearchField* CVIMPSTUiSearchField::NewL( const TDesC& aLebal, 
       
    48 							TVIMPSTSearchDataFieldType aFieldDataType,
       
    49 	 						TIMPSTSearchFieldTypes aFieldType ,
       
    50 	 						TVIMPSTEnums::TVIMPSTSearchKey aSearchKey )
       
    51     {
       
    52     CVIMPSTUiSearchField* self = 
       
    53         new ( ELeave ) CVIMPSTUiSearchField( aFieldDataType , aFieldType, aSearchKey );
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL(aLebal);
       
    56     CleanupStack::Pop( self );
       
    57     return self;
       
    58     } 
       
    59 // --------------------------------------------------------------------------
       
    60 // CVIMPSTUiSearchFieldArray::ConstructL
       
    61 // --------------------------------------------------------------------------
       
    62 //
       
    63 void CVIMPSTUiSearchField::ConstructL( const TDesC& aLabel )   
       
    64 	{
       
    65 	iFieldLabel = aLabel.AllocL();
       
    66 	}
       
    67 // -----------------------------------------------------------------------------
       
    68 // CVIMPSTUiSearchField::~CVIMPSTUiSearchField
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CVIMPSTUiSearchField::~CVIMPSTUiSearchField()
       
    72     {
       
    73     delete iFieldLabel;
       
    74     delete iFieldData;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CVIMPSTUiSearchField::ControlId
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 TInt CVIMPSTUiSearchField::ControlId() const
       
    82     {
       
    83     return ( TInt ) this;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CVIMPSTUiSearchField::FieldDataType
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 TVIMPSTSearchDataFieldType CVIMPSTUiSearchField::FieldDataType() const
       
    91     {
       
    92     return iFieldDataType;
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CVIMPSTUiSearchField::FieldLabel
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 TPtrC CVIMPSTUiSearchField::FieldLabel() 
       
   100     {
       
   101     if( iFieldLabel )
       
   102 	    {
       
   103 	     return iFieldLabel->Des();	
       
   104 	    }
       
   105     return KNullDesC();
       
   106     }
       
   107   
       
   108 // -----------------------------------------------------------------------------
       
   109 // CVIMPSTUiSearchField::FieldData
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 TPtrC CVIMPSTUiSearchField::FieldData() 
       
   113     {
       
   114     if( iFieldData )
       
   115 		{
       
   116 		return iFieldData->Des();	
       
   117 		}
       
   118     return KNullDesC();
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CVIMPSTUiSearchField::ResetFieldData
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CVIMPSTUiSearchField::ResetFieldData() 
       
   126     {
       
   127     if( iFieldData )
       
   128 		{
       
   129 		delete iFieldData;
       
   130 		iFieldData = NULL;	
       
   131 		}
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CVIMPSTUiSearchField::GetSearchKey
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 TVIMPSTEnums::TVIMPSTSearchKey CVIMPSTUiSearchField::GetSearchKey() const
       
   139     {
       
   140     return iSearchKey;
       
   141     }
       
   142  // --------------------------------------------------------------------------
       
   143 // CVIMPSTUiSearchField::IsBasicField
       
   144 // --------------------------------------------------------------------------
       
   145 //
       
   146 TBool CVIMPSTUiSearchField::IsBasicField() const
       
   147     {
       
   148     return ( iFieldType == EIMBasicSearch );
       
   149     } 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CVIMPSTUiSearchField::SetFieldDataL
       
   152 // -----------------------------------------------------------------------------
       
   153 //  
       
   154 void CVIMPSTUiSearchField::SetFieldDataL( const TDesC& aFieldData )
       
   155     {
       
   156     if( iFieldData )
       
   157 	    {
       
   158 	    delete iFieldData;
       
   159 	    iFieldData = NULL;	
       
   160 	    }
       
   161 	iFieldData = aFieldData.AllocL();
       
   162     }
       
   163 
       
   164 // --------------------------------------------------------------------------
       
   165 // CVIMPSTUiSearchField::SetControl
       
   166 // --------------------------------------------------------------------------
       
   167 //
       
   168 void CVIMPSTUiSearchField::SetControl(CEikEdwin* aControl, CEikCaptionedControl* aCaptionedCtrl ) 
       
   169     {
       
   170     iControl = NULL;
       
   171     iControl = aControl ;
       
   172     
       
   173     iCaptionedCtrl = NULL;
       
   174     iCaptionedCtrl = aCaptionedCtrl;
       
   175     }
       
   176  // --------------------------------------------------------------------------
       
   177 // CVIMPSTUiSearchField::Control
       
   178 // --------------------------------------------------------------------------
       
   179 //
       
   180 CEikEdwin* CVIMPSTUiSearchField::Control() const
       
   181     {
       
   182     return iControl;
       
   183     }
       
   184 // --------------------------------------------------------------------------
       
   185 // CVIMPSTUiSearchField::ActivateL
       
   186 // --------------------------------------------------------------------------
       
   187 //
       
   188 void CVIMPSTUiSearchField::ActivateL() 
       
   189     {
       
   190     if( !iCaptionedCtrl )
       
   191 	    {
       
   192 	    User::Leave( KErrNotReady );	
       
   193 	    }
       
   194     iCaptionedCtrl->ActivateL();
       
   195     }
       
   196 // -----------------------------------------------------------------------------
       
   197 // CVIMPSTUiSearchField::ControlTextL
       
   198 // -----------------------------------------------------------------------------
       
   199 //  
       
   200 HBufC* CVIMPSTUiSearchField::ControlTextL() const
       
   201     {
       
   202     HBufC* textBuf = NULL;
       
   203 
       
   204    	switch( iFieldDataType )
       
   205 			{
       
   206 
       
   207 			case EVIMPSTEdwinNumber :
       
   208 				{
       
   209 				// number field
       
   210 				break;
       
   211 				}
       
   212 			case EVIMPSTEdwinEmail :
       
   213 				{
       
   214 				// email field
       
   215 				break;
       
   216 				}
       
   217 				
       
   218 			case EVIMPSTEdwinMobile:
       
   219 				{
       
   220 				// mobile field
       
   221 				break;
       
   222 				}
       
   223 			case EVIMPSTEdwinText :
       
   224 				{
       
   225     			if ( iControl )
       
   226 	        		{
       
   227 	        		textBuf = iControl->GetTextInHBufL();
       
   228 	        		}
       
   229 				break;
       
   230 				}
       
   231 			}
       
   232     return textBuf;
       
   233     } 
       
   234 
       
   235 
       
   236 // End of File