phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardlistboxmodel.h
branchRCL_3
changeset 21 b3431bff8c19
parent 15 e8e3147d53eb
child 23 5586b4d2ec3e
equal deleted inserted replaced
15:e8e3147d53eb 21:b3431bff8c19
     1 /*
       
     2 * Copyright (c) 2009 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:  Listbox model for MyCard details list
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CCAPPMYCARDLISTBOXMODEL_H
       
    19 #define CCAPPMYCARDLISTBOXMODEL_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <badesca.h>
       
    24 #include <e32hashtab.h>
       
    25 
       
    26 #include "ccappmycard.h"
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MVPbkContactFieldData;
       
    31 class MVPbkBaseContactField;
       
    32 class MVPbkFieldType;
       
    33 class CPbk2PresentationContactField;
       
    34 class CPbk2IconArray;
       
    35 class CPbk2PresentationContact;
       
    36 class CEikListBox;
       
    37 class CCCAppMyCardListBoxRow;
       
    38 class CCoeEnv;
       
    39 
       
    40 /**
       
    41  * Listbox model class for MyCard details list
       
    42  *
       
    43  *
       
    44  *  @lib ccappmycardplugin.dll
       
    45  *  @since S60 9.2
       
    46  */
       
    47 class CCCAppMyCardListBoxModel :
       
    48     public CBase,
       
    49     public MDesCArray,
       
    50     public MMyCardObserver
       
    51 {
       
    52 
       
    53 public:
       
    54 
       
    55     /**
       
    56      * Two-phased constructor.
       
    57      * 
       
    58      * @param aMyCard MyCard reference
       
    59      * @param aCoeEnv UI control environment
       
    60      * @param aListBox Listbox UI control
       
    61      * @param aIconArray Listbox's icon array
       
    62      */
       
    63     static CCCAppMyCardListBoxModel* NewL(
       
    64         CCCAppMyCard& aMyCard,
       
    65         CCoeEnv& aCoeEnv,
       
    66         CEikListBox& aListBox,
       
    67         CPbk2IconArray& aIconArray );
       
    68 
       
    69     /**
       
    70      * Destructor.
       
    71      */
       
    72     ~CCCAppMyCardListBoxModel();
       
    73 
       
    74 
       
    75 public: // From MMyCardObserver
       
    76     
       
    77     void MyCardEventL( TEvent aEvent );
       
    78     
       
    79     
       
    80 public: // From MDesCArray
       
    81     
       
    82     TInt MdcaCount() const;
       
    83     TPtrC MdcaPoint(TInt aIndex) const;
       
    84 
       
    85 public: // New methods
       
    86     
       
    87     /**
       
    88      * Get Presentation Field index for field at aIndex
       
    89      * 
       
    90      * @param aIndex Listbox row index
       
    91      * @return Presentation field index shown at aIndex  
       
    92      */
       
    93     TInt FieldIndex( TInt aIndex );
       
    94     
       
    95 private: // private construction
       
    96 
       
    97     /**
       
    98      * Constructor
       
    99      */
       
   100     CCCAppMyCardListBoxModel(
       
   101         CCCAppMyCard& aMyCard,
       
   102         CCoeEnv& aCoeEnv,
       
   103         CEikListBox& aListBox,
       
   104         CPbk2IconArray& aIconArray );
       
   105 
       
   106     /**
       
   107      * 2nd constructor
       
   108      */
       
   109     void ConstructL();
       
   110 
       
   111 private: // new implementation
       
   112 
       
   113     /**
       
   114      * Helper function for adding contact field items to
       
   115      * listbox data model.
       
   116      *
       
   117      */
       
   118     void AddDataL();
       
   119 
       
   120     /**
       
   121      * Get label for contact field
       
   122      */
       
   123     HBufC* GetLabelLC(const CPbk2PresentationContactField& aField);
       
   124 
       
   125     /**
       
   126      * Should field aFieldType be hidden
       
   127      */
       
   128     TBool IsHiddenField(const MVPbkFieldType* aFieldType);
       
   129 
       
   130     /**
       
   131      * Get field at aIndex
       
   132      */
       
   133     MVPbkBaseContactField* FieldAtLC(TInt aIndex);
       
   134 
       
   135     /**
       
   136      * Field type tester
       
   137      */
       
   138     TBool IsFieldTypeL(TInt aIndex, TInt aSelectorResId);
       
   139 
       
   140     /**
       
   141      * Format generic text -type field
       
   142      */
       
   143     void HandleTextTypeFieldL(
       
   144         TInt aIndex,
       
   145         const MVPbkContactFieldData& aFieldData,
       
   146         CCCAppMyCardListBoxRow* aRow );
       
   147 
       
   148     /**
       
   149      * Format Date -type field
       
   150      */
       
   151     void HandleDateTimeTypeFieldL(
       
   152         const MVPbkContactFieldData& aFieldData,
       
   153         CCCAppMyCardListBoxRow* aRow);
       
   154 
       
   155     /**
       
   156      * Format URI -type field
       
   157      */
       
   158     void HandleUriTypeFieldL(
       
   159         TInt aIndex,
       
   160         const MVPbkContactFieldData& aFieldData,
       
   161         CCCAppMyCardListBoxRow* aRow);
       
   162 
       
   163     /**
       
   164      * Clip aBuffer from beginning to fit into listbox
       
   165      */
       
   166     TBool ClipFromBeginning(TDes& aBuffer, TInt aItemIndex, TInt aSubCellNumber) const;
       
   167 
       
   168     /**
       
   169      * Expand column and line buffers to be sufficient for aRow
       
   170      */
       
   171     void ExpandBuffersL(CCCAppMyCardListBoxRow* aRow);
       
   172 
       
   173     /**
       
   174      * Expand column buffer to aRequiredLength
       
   175      * 
       
   176      * @return new column buffer
       
   177      */
       
   178     TPtr ExpandColumnBufferL(TInt aRequiredLength);
       
   179 
       
   180 
       
   181 private: // data
       
   182 
       
   183     /**
       
   184      * Reference to control environment.
       
   185      * Not own.
       
   186      */
       
   187     CCoeEnv& iCoeEnv;
       
   188     
       
   189     /**
       
   190      * Reference to MyCard instance
       
   191      * Not own.
       
   192      */
       
   193     CCCAppMyCard& iMyCard;
       
   194     
       
   195     /**
       
   196      * Reference to listbox.
       
   197      * Not own.
       
   198      */
       
   199     CEikListBox& iListBox;
       
   200 
       
   201     /**
       
   202      *  Reference to listbox icon array
       
   203      *  Not own.
       
   204      */
       
   205     CPbk2IconArray& iIconArray;
       
   206 
       
   207     /**
       
   208      * Text row array.
       
   209      * Own.
       
   210      */
       
   211     CArrayPtrFlat<CCCAppMyCardListBoxRow> iRows;
       
   212 
       
   213     /**
       
   214      * Buffer for storing one formatted listbox row.
       
   215      * Own.
       
   216      */
       
   217     HBufC* iLineBuf;
       
   218 
       
   219     /**
       
   220      * Buffer for storing one formatted listbox column.
       
   221      * Own.
       
   222      */
       
   223     HBufC* iColumnBuf;
       
   224 
       
   225     /// Not own. Presentation contact
       
   226     CPbk2PresentationContact* iPresentationContact;
       
   227     
       
   228     /// Own: Map current index to Presentation Contact index
       
   229     RHashMap<TInt, TInt> iInxToPresentationIdx; 
       
   230 };
       
   231 
       
   232 #endif // CCAPPMYCARDLISTBOXMODEL_H
       
   233 
       
   234 // End of File