phonebookui/Phonebook2/remotecontactlookup/contactactionservice/inc/CFscContactNameFormatter.h
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Declaration of the class CFscContactNameFormatter.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CFSCCONTACTNAMEFORMATTER_H
       
    20 #define CFSCCONTACTNAMEFORMATTER_H
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "CFscContactNameFormatterBase.h"
       
    24 
       
    25 /**
       
    26  * Default contact name formatter.
       
    27  *
       
    28  * Name creation logic:
       
    29  *  1)  Try to create name according to first two field types in the
       
    30  *      sort order.
       
    31  *  2)  If the contact didn't have neither of the two fields
       
    32  *      then create name according to the third -> last type in the
       
    33  *      sort order.
       
    34  *  3)  If the field type is defined in the sort order but not defined
       
    35  *      as a title field type then the field data is not used.
       
    36  *
       
    37  * An example:
       
    38  *      Sort Order: Last name, First Name, Company Name
       
    39  *      Title fields: Last name, First Name, Company Name
       
    40  *
       
    41  *      Name is created using Last name and First name
       
    42  *      If the both first and last name fields are empty 
       
    43  *      then title is created from the company name.
       
    44  */
       
    45 NONSHARABLE_CLASS(CFscContactNameFormatter)
       
    46 : public CFscContactNameFormatterBase
       
    47     {
       
    48 public: // Construction
       
    49 
       
    50     /**
       
    51      * @param aUnnamedText          Text to use for unnamed contacts.
       
    52      * @param aMasterFieldTypeList  Master field type list of
       
    53      *                              Virtual Phonebook.
       
    54      * @param aSortOrderManager     Sort order manager for fetching
       
    55      *                              current sort order.
       
    56      * @param aTitleFieldSelector   Title fields, ownership changes
       
    57      * @return a new instance of this class
       
    58      */
       
    59     static CFscContactNameFormatter* NewL(
       
    60             const TDesC& aUnnamedText,
       
    61             const MVPbkFieldTypeList& aMasterFieldTypeList,
       
    62             const CPbk2SortOrderManager& aSortOrderManager,
       
    63             CVPbkFieldTypeSelector* aTitleFieldSelector );
       
    64 
       
    65     ~CFscContactNameFormatter();
       
    66 
       
    67 private: // From MPbk2ContactNameFormatter
       
    68     void GetContactTitle(
       
    69             const MVPbkBaseContactFieldCollection& aContactFields,
       
    70             TDes& aTitle,
       
    71             TUint32 aFormattingFlags);
       
    72     void GetContactTitleForFind(
       
    73             const MVPbkBaseContactFieldCollection& aContactFields,
       
    74             TDes& aTitle,
       
    75             TUint32 aFormattingFlags);
       
    76     CVPbkBaseContactFieldTypeListIterator* ActualTitleFieldsLC(
       
    77             CVPbkFieldTypeRefsList& aFieldTypeList,
       
    78             const MVPbkBaseContactFieldCollection& aContactFields );
       
    79     TInt MaxTitleLength(
       
    80             const MVPbkBaseContactFieldCollection& aContactFields,
       
    81             const TUint32 aFormattingFlags);
       
    82     TInt MaxTitleLengthForFind(
       
    83             const MVPbkBaseContactFieldCollection& aContactFields,
       
    84             const TUint32 aFormattingFlags);
       
    85     TBool IsFindSeparatorChar( TChar aCh );
       
    86 
       
    87 protected: // Implementation
       
    88     CFscContactNameFormatter(
       
    89             const MVPbkFieldTypeList& aMasterFieldTypeList,
       
    90             const CPbk2SortOrderManager& aSortOrderManager);
       
    91     void ConstructL(
       
    92             const TDesC& aUnnamedText,
       
    93             CVPbkFieldTypeSelector* aTitleFieldSelector );
       
    94     };
       
    95 
       
    96 #endif // CFscContactNameFormatter_H
       
    97 // End of File