phonebookui/Phonebook/View/inc/CPbkFieldListBoxModel.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     List box model class for field listboxes displaying Phonebook fields.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CPbkFieldListBoxModel_H__
       
    21 #define __CPbkFieldListBoxModel_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>        // CBase
       
    25 #include <bamdesca.h>       // MDesCArray
       
    26 #include "PbkIconId.hrh"    // TPbkIconId
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CPbkFieldArray;
       
    31 class CPbkIconArray;
       
    32 class CDesC16Array;
       
    33 class TPbkContactItemField;
       
    34 class MPbkClipListBoxText;
       
    35 class MPbkFieldAnalyzer;
       
    36 class CPbkFieldFormatter;
       
    37 class CPbkInputAbsorber;
       
    38 
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43  * @internal Only Phonebook internal use supported!
       
    44  *
       
    45  * List box model row class for listboxes displaying Phonebook fields.
       
    46  *
       
    47  * @see CPbkContactInfoControl
       
    48  */
       
    49 NONSHARABLE_CLASS(CPbkFieldListBoxRow) :
       
    50         public CBase
       
    51     {
       
    52     public:
       
    53         /**
       
    54          * Creates a new instance of this class.
       
    55          */
       
    56         static CPbkFieldListBoxRow* NewL();
       
    57 
       
    58         /**
       
    59          * Destructor.
       
    60          */
       
    61         ~CPbkFieldListBoxRow();
       
    62 
       
    63     public: // interface
       
    64         /**
       
    65          * Returns the number of columns in this row.
       
    66          */
       
    67         TInt ColumnCount() const;
       
    68 
       
    69         /**
       
    70          * Returns the descriptor at the aColumnIndex position.
       
    71          */
       
    72         TPtrC At(TInt aColumnIndex) const;
       
    73 
       
    74         /**
       
    75          * Appends a column aColumnText to the row.
       
    76          */
       
    77         void AppendColumnL(const TDesC& aColumnText);
       
    78 
       
    79         /**
       
    80          * Returns the total descriptor length of all the columns.
       
    81          */
       
    82         TInt TotalLength() const;
       
    83 
       
    84         /**
       
    85          * Returns the maximum column length of this row.
       
    86          */
       
    87         TInt MaxColumnLength() const;
       
    88 
       
    89     private: // implementation
       
    90         CPbkFieldListBoxRow();
       
    91 
       
    92     private:
       
    93         /// Own: column array
       
    94         RPointerArray<HBufC> iColumns;
       
    95     };
       
    96 
       
    97 /**
       
    98  * @internal Only Phonebook internal use supported!
       
    99  *
       
   100  * List box model class for listboxes displaying Phonebook fields.
       
   101  *
       
   102  * @see CPbkContactInfoControl
       
   103  */
       
   104 NONSHARABLE_CLASS(CPbkFieldListBoxModel) :
       
   105         public CBase,
       
   106         public MDesCArray
       
   107     {
       
   108     public:  // Types
       
   109         enum TColumnIndex
       
   110             {
       
   111             EIconColumn = 0,
       
   112             ELabelColumn,
       
   113             EContentColumn
       
   114             };
       
   115 
       
   116     public:  // Constructors and destructor
       
   117         /**
       
   118          * Construction parameters for CPbkFieldListBoxModel.
       
   119          */
       
   120         class TParams
       
   121             {
       
   122             public:
       
   123                 /**
       
   124                  * Constructor.
       
   125                  *
       
   126                  * @param aFields array of fields to display
       
   127                  * @param aTimeFormat time formatting string to use
       
   128                  * @param aIconArray icon array to use
       
   129                  */
       
   130                 TParams
       
   131                     (const CPbkFieldArray& aFields,
       
   132                     const TDesC& aTimeFormat,
       
   133                     const CPbkIconArray& aIconArray);
       
   134                 /// Ref: array of fields to display
       
   135                 const CPbkFieldArray& iFields;
       
   136                 /// Ref: time formatting string
       
   137                 const TDesC& iTimeFormat;
       
   138                 /// Ref: icon array
       
   139                 const CPbkIconArray& iIconArray;
       
   140                 /// Own: default icon id
       
   141                 TPbkIconId iDefaultIconId;
       
   142                 /// Ref: interface for analyzing field
       
   143                 MPbkFieldAnalyzer* iFieldAnalyzer;
       
   144             };
       
   145 
       
   146         /**
       
   147          * Creates a new instance of this class.
       
   148          *
       
   149          * @param aParams @see TParams
       
   150          */
       
   151         static CPbkFieldListBoxModel* NewL(TParams& aParams);
       
   152 
       
   153         /**
       
   154          * Destructor.
       
   155          */
       
   156         ~CPbkFieldListBoxModel();
       
   157 
       
   158         /**
       
   159          * Returns the internal field array set in NewL.
       
   160          */
       
   161         const CPbkFieldArray& Array() const;
       
   162 
       
   163         /**
       
   164          * Appends a row aLine to the end of the model.
       
   165          */
       
   166         void AppendRowL(CPbkFieldListBoxRow* aLine);
       
   167 
       
   168         /**
       
   169          * Set the text clipper aTextClipper.
       
   170          */
       
   171         void SetClipper(MPbkClipListBoxText& aTextClipper);
       
   172 
       
   173     public: // from MDesCArray
       
   174         TInt MdcaCount() const;
       
   175         TPtrC16 MdcaPoint(TInt aIndex) const;
       
   176 
       
   177     private:  // Implementation
       
   178         CPbkFieldListBoxModel();
       
   179         void FormatFieldL
       
   180             (const TPbkContactItemField& aField, TParams& aParams);
       
   181         void ConstructL(TParams& aParams);
       
   182         void ExpandBuffersL(const CPbkFieldListBoxRow& aRow);
       
   183         TPtr ExpandColumnBufferL(TInt aRequiredLength);
       
   184 
       
   185     private:    // Data
       
   186         /// Own: text row array
       
   187         CArrayPtrFlat<CPbkFieldListBoxRow> iRows;
       
   188         /// Own: buffer storing one formatted listbox row
       
   189         HBufC* iLineBuf;
       
   190         /// Own: buffer for storing one formatted listbox column
       
   191         HBufC* iColumnBuf;
       
   192         /// Own: field content formatter
       
   193         CPbkFieldFormatter* iFieldFormatter;
       
   194         /// Ref: array of fields
       
   195         const CPbkFieldArray* iFields;
       
   196         /// Ref: object for clipping text
       
   197         MPbkClipListBoxText* iTextClipper;
       
   198         /// Own: Input absorber to protect model creation from
       
   199         /// NssVas active wait
       
   200         CPbkInputAbsorber* iAbsorber;
       
   201     };
       
   202 
       
   203 #endif // __CPbkFieldListBoxModel_H__
       
   204 
       
   205 // End of File