phonebookui/Phonebook2/inc/spbcontactdatamodel.h
branchRCL_3
changeset 6 e8e3147d53eb
child 13 a6539d1e8e43
equal deleted inserted replaced
5:81f8547efd4f 6:e8e3147d53eb
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Contact model class
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CSPBCONTACTDATAMODEL_H
       
    19 #define CSPBCONTACTDATAMODEL_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <bamdesca.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CPbk2IconArray;
       
    27 class CPbk2PresentationContact;
       
    28 class CCoeEnv;
       
    29 class MVPbkContactLink;
       
    30 class MPbk2ClipListBoxText;
       
    31 class CSpbContactDataModelPrivate;
       
    32 class CVPbkContactManager;
       
    33 class RWriteStream;
       
    34 class RReadStream;
       
    35 
       
    36 /**
       
    37  *  Contact data model class
       
    38  *
       
    39  *  @lib pbk2spbcontentprovider.dll
       
    40  *  @since S60 9.2
       
    41  */
       
    42 class CSpbContactDataModel : public CBase
       
    43 {
       
    44 public:
       
    45 
       
    46     /**
       
    47      * Two-phased constructor.
       
    48      * 
       
    49      * @param aCntManager Contact manager
       
    50      * @param aCoeEnv UI control environment
       
    51      * @param aFieldTypeSelectorRes field type selector. 
       
    52      *        Used to determine fields that get clipped from the beginning.
       
    53      * @param aClip listbox text clipper
       
    54      * @param aIconArray Listbox's icon array
       
    55      */
       
    56     IMPORT_C static CSpbContactDataModel* NewL(
       
    57         CVPbkContactManager& aCntManager,
       
    58         CCoeEnv& aCoeEnv,
       
    59         TInt aFieldTypeSelectorRes,
       
    60         MPbk2ClipListBoxText* aClip = NULL );
       
    61 
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     ~CSpbContactDataModel();
       
    66     
       
    67 
       
    68 public: // data types
       
    69     
       
    70     /// Text types (16-bit) 
       
    71     enum TTextTypes
       
    72         {
       
    73         /// Contact's first name
       
    74         ETextFirstName,
       
    75         /// Contact's last name
       
    76         ETextLastName,
       
    77         /// Filename of contact's image
       
    78         ETextImageFileName,
       
    79         };
       
    80     
       
    81     /// Data types (8-bit)
       
    82     enum TBinaryTypes
       
    83         {
       
    84         /// Thumbnail data of contact 
       
    85         EDataImageContent
       
    86         };
       
    87     
       
    88 public: // New methods
       
    89     
       
    90     /**
       
    91      * Get Presentation Field index for field at aIndex
       
    92      * 
       
    93      * @param aListIndex Listbox row index
       
    94      * @return Presentation field index shown at aListIndex  
       
    95      */
       
    96     IMPORT_C TInt PresentationFieldIndex( TInt aListIndex );
       
    97 
       
    98     /**
       
    99      * Externalize model into stream
       
   100      */
       
   101     IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
       
   102     
       
   103     /**
       
   104      * Internalize model from stream. 
       
   105      * Any previous data will be deleted.
       
   106      */
       
   107     IMPORT_C void InternalizeL( RReadStream& aStream );
       
   108     
       
   109     /**
       
   110      * Sets the models content according to given contact. 
       
   111      * Any previous data will be deleted.
       
   112      *  
       
   113      * @param aContact new contact
       
   114      * @param aIconArray icon array that holds the field icons (can be NULL)
       
   115      */
       
   116     IMPORT_C void SetDataL( 
       
   117         const CPbk2PresentationContact& aContact,
       
   118         const CPbk2IconArray* aIconArray );
       
   119     
       
   120     /**
       
   121      * Reset Model's content.
       
   122      */
       
   123     IMPORT_C void Reset();
       
   124     
       
   125     /**
       
   126      * Getter for text elements
       
   127      * 
       
   128      * @param aType text id
       
   129      */
       
   130     IMPORT_C TPtrC Text( TTextTypes aType ) const;
       
   131 
       
   132     /**
       
   133      * Getter for data (binary) elements
       
   134      * 
       
   135      * @param aType element id
       
   136      */
       
   137     IMPORT_C TPtrC8 Data( TBinaryTypes aType ) const;
       
   138     
       
   139     /**
       
   140      * Update icon indexes according to aIconArray.
       
   141      * 
       
   142      * @param aIconArray new icon array
       
   143      */
       
   144     IMPORT_C void UpdateIconsL( const CPbk2IconArray& aIconArray );
       
   145 
       
   146     /**
       
   147      * Set list box clipper for the model. Used to clip long list text.
       
   148      * 
       
   149      * @param aClip text clipper 
       
   150      */
       
   151     IMPORT_C void SetClipListBoxText( MPbk2ClipListBoxText* aClip );
       
   152     
       
   153     /**
       
   154      * Link of the active contact. Link refers to contact set with SetDataL().
       
   155      */
       
   156     IMPORT_C MVPbkContactLink* ContactLink();
       
   157     
       
   158     /**
       
   159      * Check if model is empty
       
   160      */
       
   161     IMPORT_C TBool IsEmpty();
       
   162 
       
   163     /**
       
   164      * Listbox model of the contact's details.
       
   165      */
       
   166     IMPORT_C MDesCArray& ListBoxModel();
       
   167     
       
   168 private: // data
       
   169 
       
   170     /// Own. Private implementation
       
   171     CSpbContactDataModelPrivate* iImpl;
       
   172 };
       
   173 
       
   174 #endif // CSPBCONTACTDATAMODEL_H
       
   175 
       
   176 // End of File