phonebookui/Phonebook2/Presentation/inc/CPbk2ContactNameFormatterBase.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2005-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:  A base class for contact name formatters
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CPBK2CONTACTNAMEFORMATTERBASE_H
       
    21 #define CPBK2CONTACTNAMEFORMATTERBASE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <MPbk2ContactNameFormatter.h>
       
    26 #include <MPbk2ContactNameFormatter2.h>
       
    27 #include <MPbk2ContactNameFormatter3.h>
       
    28 
       
    29 #include "TPbk2SortOrderFieldMapper.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CPbk2SortOrderManager;
       
    33 class MVPbkFieldTypeList;
       
    34 class CVPbkFieldTypeRefsList;
       
    35 class CVPbkFieldTypeSelector;
       
    36 class TResourceReader;
       
    37 
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42 *  A base class for contact name formatters
       
    43 *
       
    44 */
       
    45 NONSHARABLE_CLASS( CPbk2ContactNameFormatterBase )
       
    46         :   public CBase,
       
    47             public MPbk2ContactNameFormatter,
       
    48             public MPbk2ContactNameFormatter2,
       
    49             public MPbk2ContactNameFormatter3
       
    50     {
       
    51     public:  // Constructors and destructor
       
    52 
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56         virtual ~CPbk2ContactNameFormatterBase();
       
    57 
       
    58     public: // Functions from MPbk2ContactNameFormatter
       
    59 
       
    60         HBufC* GetContactTitleOrNullL(
       
    61             const MVPbkBaseContactFieldCollection& aContactFields,
       
    62             TUint32 aFormattingFlags);
       
    63         HBufC* GetContactTitleL(
       
    64            const MVPbkBaseContactFieldCollection& aContactFields,
       
    65            TUint32 aFormattingFlags);
       
    66         virtual void GetContactTitle(
       
    67             const MVPbkBaseContactFieldCollection& aContactFields,
       
    68             TDes& aTitle,
       
    69             TUint32 aFormattingFlags) = 0;
       
    70         virtual void GetContactTitleForFind(
       
    71             const MVPbkBaseContactFieldCollection& aContactFields,
       
    72             TDes& aTitle,
       
    73             TUint32 aFormattingFlags) = 0;
       
    74 
       
    75         const TDesC& UnnamedText() const;
       
    76         TBool IsTitleField(
       
    77             const MVPbkBaseContactField& aContactField) const;
       
    78         TBool IsTitleFieldType(
       
    79             const MVPbkFieldType& aFieldType) const;
       
    80         virtual CVPbkBaseContactFieldTypeListIterator* ActualTitleFieldsLC(
       
    81             CVPbkFieldTypeRefsList& aFieldTypeList,
       
    82             const MVPbkBaseContactFieldCollection& aContactFields ) = 0;
       
    83         virtual TInt MaxTitleLength(
       
    84             const MVPbkBaseContactFieldCollection& aContactFields,
       
    85             const TUint32 aFormattingFlags) = 0;
       
    86         virtual TInt MaxTitleLengthForFind(
       
    87             const MVPbkBaseContactFieldCollection& aContactFields,
       
    88             const TUint32 aFormattingFlags) = 0;
       
    89         virtual TBool IsFindSeparatorChar( TChar aCh ) = 0;
       
    90         
       
    91     public: // from MPbk2ContactNameFormatter2
       
    92         virtual HBufC* GetContactTitleWithCompanyNameL(
       
    93             const MVPbkBaseContactFieldCollection& aContactFields,
       
    94             TUint32 aFormattingFlags ) = 0;
       
    95         
       
    96     public: // from MPbk2ContactNameFormatter3
       
    97        virtual CVPbkBaseContactFieldTypeListIterator* TitleWithCompanyNameFieldsLC(
       
    98                CVPbkFieldTypeRefsList& aFieldTypeList,
       
    99                const MVPbkBaseContactFieldCollection& aContactFields ) = 0;
       
   100 
       
   101     protected:  // New functions
       
   102 
       
   103         /**
       
   104         * Field mapper returns fields from the given contact fields
       
   105         * in the order defined by iSortOrderManager. Must be called
       
   106         * from sub class functions
       
   107         * @param aContactFields current fields
       
   108         */
       
   109         void SetFieldMapper(
       
   110             const MVPbkBaseContactFieldCollection& aContactFields );
       
   111 
       
   112         /**
       
   113         * Get contact title according to given sort order positions
       
   114         *
       
   115         * @param aTitle a descriptor for adding data
       
   116         * @param aFormattingFlags flags from the client
       
   117         * @param aStartingPosition the index of the first type
       
   118         *           in the sort order that is used for title
       
   119         * @param aEndingPosition the index of the last type
       
   120         *           in the sort order that is used for title
       
   121         */
       
   122         void DoGetContactTitle(
       
   123             TDes& aTitle,
       
   124             TUint32 aFormattingFlags,
       
   125             const TInt aStartingPosition,
       
   126             const TInt aEndingPosition);
       
   127 
       
   128         /**
       
   129         * Returns the maximum length of the title
       
   130         *
       
   131         * @param aFormattingFlags flags from the client
       
   132         * @param aStartingPosition the index of the first type
       
   133         *           in the sort order that is used for title
       
   134         * @param aEndingPosition the index of the last type
       
   135         *           in the sort order that is used for title
       
   136         */
       
   137         TInt DoCalculateMaxTitleLength(
       
   138             const TUint32 aFormattingFlags,
       
   139             const TInt aStartingPosition,
       
   140             const TInt aEndingPosition);
       
   141 
       
   142         /**
       
   143         * Return non empty title field types
       
   144         *
       
   145         * @param aFieldTypeList target list where field types are appended
       
   146         * @param aStartingPosition the index of the first type
       
   147         *           in the sort order that is used for title
       
   148         * @param aEndingPosition the index of the last type
       
   149         *           in the sort order that is used for title
       
   150         */
       
   151         void DoAppendNonEmptyTitleFieldTypesL(
       
   152             CVPbkFieldTypeRefsList& aFieldTypeList,
       
   153             const TInt aStartingPosition,
       
   154             const TInt aEndingPosition);
       
   155         
       
   156         /**
       
   157         * Check if title fields are empty
       
   158         *
       
   159         * @param aStartingPosition the index of the first type
       
   160         *           in the sort order that is used for title
       
   161         * @param aEndingPosition the index of the last type
       
   162         *           in the sort order that is used for title
       
   163         * @return ETrue if title fields are empty else EFalse
       
   164         */    
       
   165         TBool AreTitleFieldsEmpty(
       
   166             const TInt aStartingPosition,
       
   167             const TInt aEndingPosition ) const;            
       
   168 
       
   169     protected:
       
   170 
       
   171         /**
       
   172         * C++ default constructor.
       
   173         */
       
   174         CPbk2ContactNameFormatterBase(
       
   175             const MVPbkFieldTypeList& aMasterFieldTypeList,
       
   176             const CPbk2SortOrderManager& aSortOrderManager);
       
   177 
       
   178         /**
       
   179         * By default Symbian 2nd phase constructor is protected.
       
   180         */
       
   181         void BaseConstructL( const TDesC& aUnnamedText,
       
   182             CVPbkFieldTypeSelector* aTitleFieldSelector );
       
   183 
       
   184 
       
   185     private:    // Implementation
       
   186         TBool RequiresSeparatorBetweenNames(
       
   187             const TDesC& aLhs,
       
   188             const TDesC& aRhs) const;
       
   189         void TakePartOfName(
       
   190             const MVPbkBaseContactField* aField,
       
   191             TDes& aTitle,
       
   192             const TUint32 aFormattingFlags,
       
   193             const TBool aUseSeparator) const;
       
   194         void CalculatePartOfName(
       
   195             const MVPbkBaseContactField* aField,
       
   196             TInt& aLength,
       
   197             const TUint32 aFormattingFlags,
       
   198             const TBool aUseSeparator) const;
       
   199 
       
   200     protected: // Data
       
   201         /// Own: Field mapper
       
   202         TPbk2SortOrderFieldMapper iFieldMapper;
       
   203 
       
   204     private:    // Data
       
   205         const MVPbkFieldTypeList& iMasterFieldTypeList;
       
   206         /// Ref: Sort order manager
       
   207         const CPbk2SortOrderManager& iSortOrderManager;
       
   208         /// Own: Text for unnamed contacts
       
   209         HBufC* iUnnamedText;
       
   210         /// Own: Title field selector
       
   211         CVPbkFieldTypeSelector* iTitleFieldSelector;
       
   212     };
       
   213 
       
   214 #endif      // CPBK2CONTACTNAMEFORMATTERBASE_H
       
   215 
       
   216 // End of File