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