|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * Default contact name formatter. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CPBK2CONTACTNAMEFORMATTER_H |
|
21 #define CPBK2CONTACTNAMEFORMATTER_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "CPbk2ContactNameFormatterBase.h" |
|
25 |
|
26 /** |
|
27 * Default contact name formatter. |
|
28 * |
|
29 * Name creation logic: |
|
30 * 1) Try to create name according to first two field types in the |
|
31 * sort order. |
|
32 * 2) If the contact didn't have neither of the two fields |
|
33 * then create name according to the third -> last type in the |
|
34 * sort order. |
|
35 * 3) If the field type is defined in the sort order but not defined |
|
36 * as a title field type then the field data is not used. |
|
37 * |
|
38 * An example: |
|
39 * Sort Order: Last name, First Name, Company Name |
|
40 * Title fields: Last name, First Name, Company Name |
|
41 * |
|
42 * Name is created using Last name and First name |
|
43 * If the both first and last name fields are empty |
|
44 * then title is created from the company name. |
|
45 */ |
|
46 NONSHARABLE_CLASS(CPbk2ContactNameFormatter) |
|
47 : public CPbk2ContactNameFormatterBase |
|
48 { |
|
49 public: // Construction |
|
50 |
|
51 /** |
|
52 * @param aUnnamedText Text to use for unnamed contacts. |
|
53 * @param aMasterFieldTypeList Master field type list of |
|
54 * Virtual Phonebook. |
|
55 * @param aSortOrderManager Sort order manager for fetching |
|
56 * current sort order. |
|
57 * @param aTitleFieldSelector Title fields, ownership changes |
|
58 * @return a new instance of this class |
|
59 */ |
|
60 static CPbk2ContactNameFormatter* NewL( |
|
61 const TDesC& aUnnamedText, |
|
62 const MVPbkFieldTypeList& aMasterFieldTypeList, |
|
63 const CPbk2SortOrderManager& aSortOrderManager, |
|
64 CVPbkFieldTypeSelector* aTitleFieldSelector ); |
|
65 |
|
66 ~CPbk2ContactNameFormatter(); |
|
67 |
|
68 private: // From MPbk2ContactNameFormatter |
|
69 void GetContactTitle( |
|
70 const MVPbkBaseContactFieldCollection& aContactFields, |
|
71 TDes& aTitle, |
|
72 TUint32 aFormattingFlags); |
|
73 void GetContactTitleForFind( |
|
74 const MVPbkBaseContactFieldCollection& aContactFields, |
|
75 TDes& aTitle, |
|
76 TUint32 aFormattingFlags); |
|
77 CVPbkBaseContactFieldTypeListIterator* ActualTitleFieldsLC( |
|
78 CVPbkFieldTypeRefsList& aFieldTypeList, |
|
79 const MVPbkBaseContactFieldCollection& aContactFields ); |
|
80 TInt MaxTitleLength( |
|
81 const MVPbkBaseContactFieldCollection& aContactFields, |
|
82 const TUint32 aFormattingFlags); |
|
83 TInt MaxTitleLengthForFind( |
|
84 const MVPbkBaseContactFieldCollection& aContactFields, |
|
85 const TUint32 aFormattingFlags); |
|
86 TBool IsFindSeparatorChar( TChar aCh ); |
|
87 |
|
88 TAny* ContactNameFormatterExtension( TUid aExtensionUid ); |
|
89 |
|
90 public: // From MPbk2ContactNameFormatter2 |
|
91 |
|
92 HBufC* GetContactTitleWithCompanyNameL( |
|
93 const MVPbkBaseContactFieldCollection& aContactFields, |
|
94 TUint32 aFormattingFlags ); |
|
95 |
|
96 public: // From MPbk2ContactNameFormatter3 |
|
97 CVPbkBaseContactFieldTypeListIterator* TitleWithCompanyNameFieldsLC( |
|
98 CVPbkFieldTypeRefsList& aFieldTypeList, |
|
99 const MVPbkBaseContactFieldCollection& aContactFields ); |
|
100 |
|
101 private: |
|
102 |
|
103 void GetContactTitleWithCompanyName( |
|
104 const MVPbkBaseContactFieldCollection& aContactFields, |
|
105 TDes& aTitle, TUint32 aFormattingFlags); |
|
106 |
|
107 TInt MaxTitleLengthWithCompanyName( |
|
108 const MVPbkBaseContactFieldCollection& aContactFields, |
|
109 const TUint32 aFormattingFlags ); |
|
110 |
|
111 TBool IsCompanyNameField(); |
|
112 |
|
113 void TitleFieldsL( CVPbkFieldTypeRefsList& aFieldTypeList, |
|
114 const MVPbkBaseContactFieldCollection& aContactFields, |
|
115 const TInt aStartingPosition, const TInt aEndingPosition ); |
|
116 |
|
117 protected: // Implementation |
|
118 CPbk2ContactNameFormatter( |
|
119 const MVPbkFieldTypeList& aMasterFieldTypeList, |
|
120 const CPbk2SortOrderManager& aSortOrderManager); |
|
121 void ConstructL( |
|
122 const TDesC& aUnnamedText, |
|
123 CVPbkFieldTypeSelector* aTitleFieldSelector ); |
|
124 }; |
|
125 |
|
126 #endif // CPBK2CONTACTNAMEFORMATTER_H |
|
127 |
|
128 // End of File |