|
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: Phonebook 2 presentation level contact field collection. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CPBK2PRESENTATIONCONTACTFIELDCOLLECTION_H |
|
21 #define CPBK2PRESENTATIONCONTACTFIELDCOLLECTION_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <MVPbkStoreContactFieldCollection.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CPbk2PresentationContactField; |
|
29 class MPbk2FieldPropertyArray; |
|
30 class MPbk2FieldProperty; |
|
31 class CPbk2FieldPropertyGroup; |
|
32 class MVPbkStoreContactField; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Phonebook 2 presentation level contact field collection. |
|
38 */ |
|
39 class CPbk2PresentationContactFieldCollection : public CBase, |
|
40 public MVPbkStoreContactFieldCollection |
|
41 { |
|
42 public: // Constructors and destructor |
|
43 |
|
44 /** |
|
45 * Creates a new instance of this class. |
|
46 * |
|
47 * @param aFieldProperties An array of field properties. |
|
48 * @param aFieldCollection A collection of store fields. |
|
49 * @param aParentContact The contact that owns this collection. |
|
50 * @return A new instance of this class. |
|
51 */ |
|
52 IMPORT_C static CPbk2PresentationContactFieldCollection* NewL( |
|
53 const MPbk2FieldPropertyArray& aFieldProperties, |
|
54 MVPbkStoreContactFieldCollection& aFieldCollection, |
|
55 MVPbkStoreContact& aParentContact ); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 virtual ~CPbk2PresentationContactFieldCollection(); |
|
61 |
|
62 public: // Interface |
|
63 |
|
64 /** |
|
65 * Returns the presentation level field. |
|
66 * |
|
67 * @param aIndex The index of the field in the array. |
|
68 * @return Presentation level field. |
|
69 */ |
|
70 IMPORT_C CPbk2PresentationContactField& At( |
|
71 TInt aIndex ) const; |
|
72 |
|
73 /** |
|
74 * Checks if there is a field with given property in the collection. |
|
75 * |
|
76 * @param aProperty The property to search for. |
|
77 * @return The index of the field or KErrNotFound. |
|
78 */ |
|
79 IMPORT_C TInt ContainsField( |
|
80 const MPbk2FieldProperty& aProperty ) const; |
|
81 |
|
82 /** |
|
83 * Checks if the collection contains a field from the group of |
|
84 * properties. |
|
85 * |
|
86 * @param aPropertyGroup A group of field properties. |
|
87 * @return ETrue if the collection has at least one field |
|
88 * with the property in the group. |
|
89 */ |
|
90 IMPORT_C TBool ContainsFieldFromGroup( |
|
91 const CPbk2FieldPropertyGroup& aPropertyGroup ) const; |
|
92 |
|
93 /** |
|
94 * Returns the index of the given field or |
|
95 * KErrNotFound if not found. |
|
96 * |
|
97 * @param aField The field that is searched for. |
|
98 * @return The index of the field in this collection. |
|
99 */ |
|
100 IMPORT_C TInt FindFieldIndex( |
|
101 const MVPbkStoreContactField& aField ) const; |
|
102 |
|
103 /** |
|
104 * Gets the index of the field in the store contact. |
|
105 * |
|
106 * @param aFieldIndex The index of the field in this collection. |
|
107 * @return The index of the field in the |
|
108 * store contact field collection. |
|
109 */ |
|
110 IMPORT_C TInt StoreIndexOfField( |
|
111 TInt aFieldIndex ) const; |
|
112 |
|
113 /** |
|
114 * Returns the field properties. |
|
115 * |
|
116 * @return Field properties. |
|
117 */ |
|
118 inline const MPbk2FieldPropertyArray& FieldProperties() const; |
|
119 |
|
120 /** |
|
121 * Adds a new field mapping. The field must belong to |
|
122 * the same contact as this field collection. |
|
123 * |
|
124 * @param aField A new store contact field for the mapping. |
|
125 * @param aName A new store contact field property name for the mapping. |
|
126 */ |
|
127 void AddFieldMappingL(const MVPbkStoreContactField& aField, |
|
128 const TDesC& aName); |
|
129 |
|
130 /** |
|
131 * Deletes the field mapping from the given index. |
|
132 * |
|
133 * @param aIndex The index from where to remove mapping. |
|
134 */ |
|
135 void RemoveFieldMapping( |
|
136 TInt aIndex ); |
|
137 |
|
138 /** |
|
139 * Destroys all the field mappings. |
|
140 */ |
|
141 void ResetFieldMappings(); |
|
142 |
|
143 public: // From MVPbkStoreContactFieldCollection |
|
144 MVPbkBaseContact& ParentContact() const; |
|
145 TInt FieldCount() const; |
|
146 const MVPbkStoreContactField& FieldAt( |
|
147 TInt aIndex ) const; |
|
148 MVPbkStoreContactField& FieldAt( |
|
149 TInt aIndex ); |
|
150 MVPbkStoreContactField* FieldAtLC( |
|
151 TInt aIndex ) const; |
|
152 MVPbkStoreContact& ParentStoreContact() const; |
|
153 MVPbkStoreContactField* RetrieveField( |
|
154 const MVPbkContactLink& aContactLink ) const; |
|
155 |
|
156 private: // Implementation |
|
157 CPbk2PresentationContactFieldCollection( |
|
158 const MPbk2FieldPropertyArray& aFieldProperties, |
|
159 MVPbkStoreContactFieldCollection& aFieldCollection, |
|
160 MVPbkStoreContact& aParentContact ); |
|
161 void ConstructL(); |
|
162 |
|
163 private: // Data |
|
164 /// Ref: An array of field properties |
|
165 const MPbk2FieldPropertyArray& iFieldProperties; |
|
166 /// Ref: A collection of store fields |
|
167 MVPbkStoreContactFieldCollection& iFieldCollection; |
|
168 /// Ref: The parent contact of the collection |
|
169 MVPbkStoreContact& iParentContact; |
|
170 /// Own: Phonebook 2 presentation contact fields |
|
171 RPointerArray<CPbk2PresentationContactField> iFields; |
|
172 }; |
|
173 |
|
174 // INLINE IMPLEMENTATION |
|
175 |
|
176 // -------------------------------------------------------------------------- |
|
177 // CPbk2PresentationContactFieldCollection::FieldProperties |
|
178 // -------------------------------------------------------------------------- |
|
179 // |
|
180 inline const MPbk2FieldPropertyArray& |
|
181 CPbk2PresentationContactFieldCollection::FieldProperties() const |
|
182 { |
|
183 return iFieldProperties; |
|
184 } |
|
185 |
|
186 #endif // CPBK2PRESENTATIONCONTACTFIELDCOLLECTION_H |
|
187 |
|
188 // End of File |