|
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: Sorted field collection for fields. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CFSCPRESENTATIONCONTACTFIELDCOLLECTION_H |
|
20 #define CFSCPRESENTATIONCONTACTFIELDCOLLECTION_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MVPbkStoreContactFieldCollection.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CFscPresentationContactField; |
|
28 class MPbk2FieldPropertyArray; |
|
29 class MPbk2FieldProperty; |
|
30 class CFscFieldPropertyGroup; |
|
31 class MVPbkStoreContactField; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * Phonebook 2 presentation level contact field collection. |
|
37 */ |
|
38 class CFscPresentationContactFieldCollection : public CBase, |
|
39 public MVPbkStoreContactFieldCollection |
|
40 { |
|
41 public: |
|
42 // 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 static CFscPresentationContactFieldCollection* NewL( |
|
53 const MPbk2FieldPropertyArray& aFieldProperties, |
|
54 MVPbkStoreContactFieldCollection& aFieldCollection, |
|
55 MVPbkStoreContact& aParentContact ); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 virtual ~CFscPresentationContactFieldCollection(); |
|
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 CFscPresentationContactField& 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 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 TBool ContainsFieldFromGroup( |
|
91 const CFscFieldPropertyGroup& 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 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 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 */ |
|
126 void AddFieldMappingL( |
|
127 const MVPbkStoreContactField& aField ); |
|
128 |
|
129 /** |
|
130 * Deletes the field mapping from the given index. |
|
131 * |
|
132 * @param aIndex The index from where to remove mapping. |
|
133 */ |
|
134 void RemoveFieldMapping( |
|
135 TInt aIndex ); |
|
136 |
|
137 /** |
|
138 * Destroys all the field mappings. |
|
139 */ |
|
140 void ResetFieldMappings(); |
|
141 |
|
142 public: // From MVPbkStoreContactFieldCollection |
|
143 MVPbkBaseContact& ParentContact() const; |
|
144 TInt FieldCount() const; |
|
145 const MVPbkStoreContactField& FieldAt( |
|
146 TInt aIndex ) const; |
|
147 MVPbkStoreContactField& FieldAt( |
|
148 TInt aIndex ); |
|
149 MVPbkStoreContactField* FieldAtLC( |
|
150 TInt aIndex ) const; |
|
151 MVPbkStoreContact& ParentStoreContact() const; |
|
152 MVPbkStoreContactField* RetrieveField( |
|
153 const MVPbkContactLink& aContactLink ) const; |
|
154 |
|
155 private: // Implementation |
|
156 CFscPresentationContactFieldCollection( |
|
157 const MPbk2FieldPropertyArray& aFieldProperties, |
|
158 MVPbkStoreContactFieldCollection& aFieldCollection, |
|
159 MVPbkStoreContact& aParentContact ); |
|
160 void ConstructL(); |
|
161 |
|
162 private: // Data |
|
163 /// Ref: An array of field properties |
|
164 const MPbk2FieldPropertyArray& iFieldProperties; |
|
165 /// Ref: A collection of store fields |
|
166 MVPbkStoreContactFieldCollection& iFieldCollection; |
|
167 /// Ref: The parent contact of the collection |
|
168 MVPbkStoreContact& iParentContact; |
|
169 /// Own: Phonebook 2 presentation contact fields |
|
170 RPointerArray<CFscPresentationContactField> iFields; |
|
171 }; |
|
172 |
|
173 // INLINE IMPLEMENTATION |
|
174 |
|
175 // -------------------------------------------------------------------------- |
|
176 // CFscPresentationContactFieldCollection::FieldProperties |
|
177 // -------------------------------------------------------------------------- |
|
178 // |
|
179 inline const MPbk2FieldPropertyArray& CFscPresentationContactFieldCollection::FieldProperties() const |
|
180 { |
|
181 return iFieldProperties; |
|
182 } |
|
183 |
|
184 #endif // CFSCPRESENTATIONCONTACTFIELDCOLLECTION_H |
|
185 // End of File |