2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: A contact view definition.
19 #ifndef CVPBKCONTACTVIEWDEFINITION_H
20 #define CVPBKCONTACTVIEWDEFINITION_H
23 #include <vpbkcontactview.hrh>
25 class TResourceReader;
26 class CVPbkFieldTypeSelector;
27 class MVPbkContactSelector;
30 * A contact view definition.
32 * This class is needed when a client needs to create a contact view.
33 * A client can define a structure of VPBK_CONTACT_VIEW from VPbkContactView.rh
34 * and use this class to read the definition or construct an empty definition
35 * and then set the information to it.
37 * A view definition enables complex view structures. A client can e.g.
38 * create a composite view that contains subviews from multiple contact
39 * stores. However, it's up to client to understand that there are certain
40 * limits for the structure. E.g. a contact view is a leaf view and can
41 * not have subviews. Another important thing to keep in mind is that complex
42 * view structures consumes more RAM that can be a problem if there are
43 * thousands of contacts in the view.
45 * @see VPBK_CONTACT_VIEW in VPbkContactView.rh
46 * @see CVPbkContactManager::CreateContactViewLC
49 class CVPbkContactViewDefinition : public CBase
51 public: // Construction & destruction
53 * Creates a new contact view definition and initializes
54 * it from resource. Takes a VPBK_CONTACT_VIEW resource
55 * structure as a parameter.
57 * @param aReader A resource reader to a VPBK_CONTACT_VIEW
59 * @return A new instance of this class.
61 IMPORT_C static CVPbkContactViewDefinition* NewL(
62 TResourceReader& aReader );
65 * Creates a new empty contact view definition.
66 * Client must then set the needed information.
68 * @return A new instance of this class.
70 IMPORT_C static CVPbkContactViewDefinition* NewL();
73 * Constructs a new contact view definition from an existing one
74 * by copying the data.
76 * @param aViewDef A view definition to copy.
77 * @return A new instance of this class.
79 IMPORT_C static CVPbkContactViewDefinition* NewL(
80 const CVPbkContactViewDefinition& aViewDef );
83 * Creates a new contact view definition and initializes
84 * it from resource. Takes a VPBK_CONTACT_VIEW resource
85 * structure as a parameter.
87 * @param aReader A resource reader to a VPBK_CONTACT_VIEW
89 * @return A new instance of this class.
91 IMPORT_C static CVPbkContactViewDefinition* NewLC(
92 TResourceReader& aReader );
95 * Creates a new empty contact view definition.
96 * Client must then set the needed information.
98 * @return A new instance of this class.
100 IMPORT_C static CVPbkContactViewDefinition* NewLC();
103 * Constructs a new contact view definition from an existing one
104 * by copying the data.
106 * @param aViewDef A view definition to copy.
107 * @return A new instance of this class.
109 IMPORT_C static CVPbkContactViewDefinition* NewLC(
110 const CVPbkContactViewDefinition& aViewDef );
115 ~CVPbkContactViewDefinition();
119 * Returns the number of sub views owned by this view.
121 * @return The number of sub views.
123 IMPORT_C TInt SubViewCount() const;
126 * Returns the sub view definition at aIndex.
128 * @param aIndex The index of the sub view definition.
129 * @return The sub view definition at aIndex.
131 IMPORT_C const CVPbkContactViewDefinition& SubViewAt(
135 * Returns the sub view definition at aIndex.
137 * @param aIndex The index to query.
138 * @return The sub view definition.
140 IMPORT_C CVPbkContactViewDefinition& SubViewAt( TInt aIndex );
143 * Returns the type of this view.
145 * @return The type of this view.
147 IMPORT_C TVPbkContactViewType Type() const;
150 * Returns ETrue if aFlag is on, otherwise EFalse.
152 * @param aFlag The flag to check.
153 * @return A flag state.
155 IMPORT_C TBool FlagIsOn( TVPbkContactViewFlag aFlag ) const;
158 * Returns the URI of this view. KNullDesC if this is not a leaf node.
160 * @return The URI of this view or KNullDesC.
162 IMPORT_C const TDesC& Uri() const;
165 * Returns the sorting policy of this view.
167 * @return The sorting policy of this view.
169 IMPORT_C TVPbkContactViewSortPolicy SortPolicy() const;
172 * Returns the name of the view. Default is KNullDesC.
174 * In view types EVPbkContactsView and EVPbkGroupsView
175 * the name can be used as a shared view identifier by the
176 * store. Shared view creation is indicated by
177 * TVPbkContactViewSharing. If the name is empty for shared
178 * view then store implementation uses its default name.
179 * This is a preferred way to use shared views in the platform.
181 * In view type EVPbkFoldingView the name is the label
182 * of the only contact in the view.
184 * In view type EVPbkCompositeView the name has no meaning.
186 * @return The name of the view.
188 IMPORT_C const TDesC& Name() const;
191 * Returns the view sharing type. The store can support
192 * a shared view creation for saving RAM.
194 * Default value for types EVPbkContactsView and EVPbkGroupsView
195 * is EVPbkSharedView. Store implementation creates
196 * then a shared view if it's possible for the store.
197 * Prefer using the default values for saving resources.
199 * For view types EVPbkFoldingView and EVPbkCompositeView the
200 * sharing has no effect.
202 * See also the documentation of Name()
204 * @return The view sharing type.
207 IMPORT_C TVPbkContactViewSharing Sharing() const;
210 * Returns the field type selector used to filter the view or NULL.
212 * The view contains only contacts having the fields defined
213 * by the field type filter.
215 * @return The field type filter.
217 IMPORT_C CVPbkFieldTypeSelector* FieldTypeFilter() const;
220 * Returns the id of this view.
222 * @return the id of this view.
224 IMPORT_C TInt Id() const;
226 * Adds new view as a subview. This object takes ownership
227 * of the subview. If this function leaves ownership is not taken.
229 * @param aSubView The new subview to add.
231 IMPORT_C void AddSubViewL( CVPbkContactViewDefinition* aSubView );
234 * Sets aType as this views type.
236 * @param aType The type to set.
238 IMPORT_C void SetType( TVPbkContactViewType aType );
241 * Sets aId as this views id.
243 * @param aId the id to set.
245 IMPORT_C void SetId( TInt aId );
247 * Sets the saFlag's state as aState.
249 * @param aFlag The flag to modify.
250 * @param aState The state to set.
252 IMPORT_C void SetFlag( TVPbkContactViewFlag aFlag, TBool aState );
255 * Sets aUri as this views URI. This function takes a copy of aUri.
257 * @param aUri The URI to set.
259 IMPORT_C void SetUriL( const TDesC& aUri );
262 * Sets aSortPolicy as this views sorting policy.
264 * @param aSortPolicy The sort policy to set.
266 IMPORT_C void SetSortPolicy( TVPbkContactViewSortPolicy aSortPolicy );
269 * Sets aName as this views Name. This function takes a copy of aName.
271 * @param aName The name to set.
273 IMPORT_C void SetNameL( const TDesC& aName );
276 * Sets the view sharing type.
278 * @param aViewSharing One of the values defined in
279 * VPbkContactView.hrh.
281 IMPORT_C void SetSharing( TVPbkContactViewSharing aViewSharing );
284 * Sets the field type selector used to filter the view.
286 * The view contains only contacts having the fields defined
287 * by the field type filter.
289 * @param aFilter The field type filter. Use NULL to
292 IMPORT_C void SetFieldTypeFilterL( CVPbkFieldTypeSelector* aFilter );
295 * Sets the contact selector used to filter the view.
297 * The view contains only contacts accepted by the selector.
299 * @param aContactSelector The contact selector. Use NULL to
300 * filter nothing. Ownership not transferred.
302 IMPORT_C void SetContactSelector( MVPbkContactSelector* aContactSelector );
305 * Gives either the contact selector or NULL. Ownership is not transferred.
307 IMPORT_C MVPbkContactSelector* ContactSelector() const;
309 private: // Implementation
310 CVPbkContactViewDefinition();
313 const CVPbkContactViewDefinition& aViewDef );
314 void ConstructFromResourceL(
315 TResourceReader& aReader );
316 void InitializeSharing();
319 /// Own: URI of this view, may be NULL if this is inner node
321 /// Own: Type of this view
322 TVPbkContactViewType iType;
323 /// Own: Flags for this view
325 /// Own: Sorting policy for this view
326 TVPbkContactViewSortPolicy iSortPolicy;
327 /// Own: Subviews of this view
328 RPointerArray<CVPbkContactViewDefinition> iSubViews;
329 /// Own: Name of the view, may be NULL if name is not applicable
331 /// Own: Field type filter
332 CVPbkFieldTypeSelector* iFilter;
333 /// Own: Defines the sharing of the view
334 TVPbkContactViewSharing iSharing;
336 MVPbkContactSelector* iContactSelector;
337 /// Own: Id for this view
341 #endif // CVPBKCONTACTVIEWDEFINITION_H