phonebookui/Phonebook2/UIControls/src/TPbk2AddItemWrapper.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: 
       
    15 *       Wrapper for selectable fields.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "TPbk2AddItemWrapper.h"
       
    23 
       
    24 // Phonebook 2
       
    25 #include <MPbk2FieldProperty.h>
       
    26 #include <CPbk2FieldPropertyGroup.h>
       
    27 
       
    28 namespace
       
    29     {
       
    30     #ifdef _DEBUG
       
    31         enum TPanicCode
       
    32             {
       
    33             EPanic_PropertyAt_OOB = 1
       
    34             };
       
    35             
       
    36         void Panic( TPanicCode aPanic )
       
    37             {
       
    38             _LIT( KPanicCat, "TPbk2AddItemWrapper" );
       
    39             User::Panic( KPanicCat(), aPanic );
       
    40             }
       
    41     #endif // _DEBUG
       
    42     }
       
    43 
       
    44 // ========================== MEBER FUNCTIONS ===============================
       
    45 
       
    46 EXPORT_C TPbk2AddItemWrapper::TPbk2AddItemWrapper
       
    47         ( const MPbk2FieldProperty& aFieldProperty ) :
       
    48         iFieldProperty(&aFieldProperty), iPropertyGroup(NULL)
       
    49     {
       
    50     }
       
    51 
       
    52 EXPORT_C TPbk2AddItemWrapper::TPbk2AddItemWrapper
       
    53         ( const CPbk2FieldPropertyGroup& aPropertyGroup ) :
       
    54 	    iFieldProperty(NULL), iPropertyGroup(&aPropertyGroup)
       
    55     {
       
    56     }
       
    57 
       
    58 EXPORT_C TInt TPbk2AddItemWrapper::PropertyCount() const
       
    59     {
       
    60     if (iFieldProperty)
       
    61         {
       
    62         const TInt oneProperty = 1;
       
    63         return oneProperty;
       
    64         }
       
    65     else
       
    66         {
       
    67         return iPropertyGroup->Count();
       
    68         }
       
    69     }
       
    70 
       
    71 EXPORT_C const MPbk2FieldProperty& TPbk2AddItemWrapper::PropertyAt(
       
    72     TInt aIndex) const
       
    73     {
       
    74     if (iFieldProperty)
       
    75         {
       
    76         return *iFieldProperty;
       
    77         }
       
    78     else
       
    79         {
       
    80         __ASSERT_DEBUG( iPropertyGroup->Count() > aIndex,
       
    81             Panic( EPanic_PropertyAt_OOB ) );
       
    82         return iPropertyGroup->At(aIndex);
       
    83         }
       
    84     }
       
    85 
       
    86 const TDesC& TPbk2AddItemWrapper::Label() const
       
    87     {
       
    88     if (iFieldProperty)
       
    89         {
       
    90         return iFieldProperty->AddItemText();
       
    91         }
       
    92     else
       
    93         {
       
    94         return iPropertyGroup->Label();
       
    95         }
       
    96     }
       
    97 
       
    98 const TPbk2IconId& TPbk2AddItemWrapper::IconId() const
       
    99     {
       
   100     if (iFieldProperty)
       
   101         {
       
   102         return iFieldProperty->IconId();
       
   103         }
       
   104     else
       
   105         {
       
   106         return iPropertyGroup->IconId();        
       
   107         }    
       
   108     }
       
   109 
       
   110 TInt TPbk2AddItemWrapper::AddItemOrdering() const
       
   111     {
       
   112     if (iFieldProperty)
       
   113         {
       
   114         return iFieldProperty->AddItemOrdering();
       
   115         }
       
   116     else
       
   117         {
       
   118         return iPropertyGroup->AddItemOrdering();        
       
   119         }            
       
   120     }
       
   121 
       
   122 const CPbk2FieldPropertyGroup* TPbk2AddItemWrapper::Group() const
       
   123     {
       
   124     return iPropertyGroup;
       
   125     }
       
   126 
       
   127 // End of File