63
|
1 |
/*
|
|
2 |
* Copyright (c) 2004-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: A contact view definition.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CVPBKCONTACTVIEWDEFINITION_H
|
|
20 |
#define CVPBKCONTACTVIEWDEFINITION_H
|
|
21 |
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <VPbkContactView.hrh>
|
|
24 |
|
|
25 |
class TResourceReader;
|
|
26 |
class CVPbkFieldTypeSelector;
|
|
27 |
class MVPbkContactSelector;
|
|
28 |
|
|
29 |
/**
|
|
30 |
* A contact view definition.
|
|
31 |
*
|
|
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.
|
|
36 |
*
|
|
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.
|
|
44 |
*
|
|
45 |
* @see VPBK_CONTACT_VIEW in VPbkContactView.rh
|
|
46 |
* @see CVPbkContactManager::CreateContactViewLC
|
|
47 |
* @lib VPbkEng.lib
|
|
48 |
*/
|
|
49 |
class CVPbkContactViewDefinition : public CBase
|
|
50 |
{
|
|
51 |
public: // Construction & destruction
|
|
52 |
/**
|
|
53 |
* Creates a new contact view definition and initializes
|
|
54 |
* it from resource. Takes a VPBK_CONTACT_VIEW resource
|
|
55 |
* structure as a parameter.
|
|
56 |
*
|
|
57 |
* @param aReader A resource reader to a VPBK_CONTACT_VIEW
|
|
58 |
* structure.
|
|
59 |
* @return A new instance of this class.
|
|
60 |
*/
|
|
61 |
IMPORT_C static CVPbkContactViewDefinition* NewL(
|
|
62 |
TResourceReader& aReader );
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Creates a new empty contact view definition.
|
|
66 |
* Client must then set the needed information.
|
|
67 |
*
|
|
68 |
* @return A new instance of this class.
|
|
69 |
*/
|
|
70 |
IMPORT_C static CVPbkContactViewDefinition* NewL();
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Constructs a new contact view definition from an existing one
|
|
74 |
* by copying the data.
|
|
75 |
*
|
|
76 |
* @param aViewDef A view definition to copy.
|
|
77 |
* @return A new instance of this class.
|
|
78 |
*/
|
|
79 |
IMPORT_C static CVPbkContactViewDefinition* NewL(
|
|
80 |
const CVPbkContactViewDefinition& aViewDef );
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Creates a new contact view definition and initializes
|
|
84 |
* it from resource. Takes a VPBK_CONTACT_VIEW resource
|
|
85 |
* structure as a parameter.
|
|
86 |
*
|
|
87 |
* @param aReader A resource reader to a VPBK_CONTACT_VIEW
|
|
88 |
* structure.
|
|
89 |
* @return A new instance of this class.
|
|
90 |
*/
|
|
91 |
IMPORT_C static CVPbkContactViewDefinition* NewLC(
|
|
92 |
TResourceReader& aReader );
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Creates a new empty contact view definition.
|
|
96 |
* Client must then set the needed information.
|
|
97 |
*
|
|
98 |
* @return A new instance of this class.
|
|
99 |
*/
|
|
100 |
IMPORT_C static CVPbkContactViewDefinition* NewLC();
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Constructs a new contact view definition from an existing one
|
|
104 |
* by copying the data.
|
|
105 |
*
|
|
106 |
* @param aViewDef A view definition to copy.
|
|
107 |
* @return A new instance of this class.
|
|
108 |
*/
|
|
109 |
IMPORT_C static CVPbkContactViewDefinition* NewLC(
|
|
110 |
const CVPbkContactViewDefinition& aViewDef );
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Destructor.
|
|
114 |
*/
|
|
115 |
~CVPbkContactViewDefinition();
|
|
116 |
|
|
117 |
public: // Interface
|
|
118 |
/**
|
|
119 |
* Returns the number of sub views owned by this view.
|
|
120 |
*
|
|
121 |
* @return The number of sub views.
|
|
122 |
*/
|
|
123 |
IMPORT_C TInt SubViewCount() const;
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Returns the sub view definition at aIndex.
|
|
127 |
*
|
|
128 |
* @param aIndex The index of the sub view definition.
|
|
129 |
* @return The sub view definition at aIndex.
|
|
130 |
*/
|
|
131 |
IMPORT_C const CVPbkContactViewDefinition& SubViewAt(
|
|
132 |
TInt aIndex ) const;
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Returns the sub view definition at aIndex.
|
|
136 |
*
|
|
137 |
* @param aIndex The index to query.
|
|
138 |
* @return The sub view definition.
|
|
139 |
*/
|
|
140 |
IMPORT_C CVPbkContactViewDefinition& SubViewAt( TInt aIndex );
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Returns the type of this view.
|
|
144 |
*
|
|
145 |
* @return The type of this view.
|
|
146 |
*/
|
|
147 |
IMPORT_C TVPbkContactViewType Type() const;
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Returns ETrue if aFlag is on, otherwise EFalse.
|
|
151 |
*
|
|
152 |
* @param aFlag The flag to check.
|
|
153 |
* @return A flag state.
|
|
154 |
*/
|
|
155 |
IMPORT_C TBool FlagIsOn( TVPbkContactViewFlag aFlag ) const;
|
|
156 |
|
|
157 |
/**
|
|
158 |
* Returns the URI of this view. KNullDesC if this is not a leaf node.
|
|
159 |
*
|
|
160 |
* @return The URI of this view or KNullDesC.
|
|
161 |
*/
|
|
162 |
IMPORT_C const TDesC& Uri() const;
|
|
163 |
|
|
164 |
/**
|
|
165 |
* Returns the sorting policy of this view.
|
|
166 |
*
|
|
167 |
* @return The sorting policy of this view.
|
|
168 |
*/
|
|
169 |
IMPORT_C TVPbkContactViewSortPolicy SortPolicy() const;
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Returns the name of the view. Default is KNullDesC.
|
|
173 |
*
|
|
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.
|
|
180 |
*
|
|
181 |
* In view type EVPbkFoldingView the name is the label
|
|
182 |
* of the only contact in the view.
|
|
183 |
*
|
|
184 |
* In view type EVPbkCompositeView the name has no meaning.
|
|
185 |
*
|
|
186 |
* @return The name of the view.
|
|
187 |
*/
|
|
188 |
IMPORT_C const TDesC& Name() const;
|
|
189 |
|
|
190 |
/**
|
|
191 |
* Returns the view sharing type. The store can support
|
|
192 |
* a shared view creation for saving RAM.
|
|
193 |
*
|
|
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.
|
|
198 |
*
|
|
199 |
* For view types EVPbkFoldingView and EVPbkCompositeView the
|
|
200 |
* sharing has no effect.
|
|
201 |
*
|
|
202 |
* See also the documentation of Name()
|
|
203 |
*
|
|
204 |
* @return The view sharing type.
|
|
205 |
*
|
|
206 |
*/
|
|
207 |
IMPORT_C TVPbkContactViewSharing Sharing() const;
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Returns the field type selector used to filter the view or NULL.
|
|
211 |
*
|
|
212 |
* The view contains only contacts having the fields defined
|
|
213 |
* by the field type filter.
|
|
214 |
*
|
|
215 |
* @return The field type filter.
|
|
216 |
*/
|
|
217 |
IMPORT_C CVPbkFieldTypeSelector* FieldTypeFilter() const;
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Returns the id of this view.
|
|
221 |
*
|
|
222 |
* @return the id of this view.
|
|
223 |
*/
|
|
224 |
IMPORT_C TInt Id() const;
|
|
225 |
/**
|
|
226 |
* Adds new view as a subview. This object takes ownership
|
|
227 |
* of the subview. If this function leaves ownership is not taken.
|
|
228 |
*
|
|
229 |
* @param aSubView The new subview to add.
|
|
230 |
*/
|
|
231 |
IMPORT_C void AddSubViewL( CVPbkContactViewDefinition* aSubView );
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Sets aType as this views type.
|
|
235 |
*
|
|
236 |
* @param aType The type to set.
|
|
237 |
*/
|
|
238 |
IMPORT_C void SetType( TVPbkContactViewType aType );
|
|
239 |
|
|
240 |
/**
|
|
241 |
* Sets aId as this views id.
|
|
242 |
*
|
|
243 |
* @param aId the id to set.
|
|
244 |
*/
|
|
245 |
IMPORT_C void SetId( TInt aId );
|
|
246 |
/**
|
|
247 |
* Sets the saFlag's state as aState.
|
|
248 |
*
|
|
249 |
* @param aFlag The flag to modify.
|
|
250 |
* @param aState The state to set.
|
|
251 |
*/
|
|
252 |
IMPORT_C void SetFlag( TVPbkContactViewFlag aFlag, TBool aState );
|
|
253 |
|
|
254 |
/**
|
|
255 |
* Sets aUri as this views URI. This function takes a copy of aUri.
|
|
256 |
*
|
|
257 |
* @param aUri The URI to set.
|
|
258 |
*/
|
|
259 |
IMPORT_C void SetUriL( const TDesC& aUri );
|
|
260 |
|
|
261 |
/**
|
|
262 |
* Sets aSortPolicy as this views sorting policy.
|
|
263 |
*
|
|
264 |
* @param aSortPolicy The sort policy to set.
|
|
265 |
*/
|
|
266 |
IMPORT_C void SetSortPolicy( TVPbkContactViewSortPolicy aSortPolicy );
|
|
267 |
|
|
268 |
/**
|
|
269 |
* Sets aName as this views Name. This function takes a copy of aName.
|
|
270 |
*
|
|
271 |
* @param aName The name to set.
|
|
272 |
*/
|
|
273 |
IMPORT_C void SetNameL( const TDesC& aName );
|
|
274 |
|
|
275 |
/**
|
|
276 |
* Sets the view sharing type.
|
|
277 |
*
|
|
278 |
* @param aViewSharing One of the values defined in
|
|
279 |
* VPbkContactView.hrh.
|
|
280 |
*/
|
|
281 |
IMPORT_C void SetSharing( TVPbkContactViewSharing aViewSharing );
|
|
282 |
|
|
283 |
/**
|
|
284 |
* Sets the field type selector used to filter the view.
|
|
285 |
*
|
|
286 |
* The view contains only contacts having the fields defined
|
|
287 |
* by the field type filter.
|
|
288 |
*
|
|
289 |
* @param aFilter The field type filter. Use NULL to
|
|
290 |
* filter nothing.
|
|
291 |
*/
|
|
292 |
IMPORT_C void SetFieldTypeFilterL( CVPbkFieldTypeSelector* aFilter );
|
|
293 |
|
|
294 |
/**
|
|
295 |
* Sets the contact selector used to filter the view.
|
|
296 |
*
|
|
297 |
* The view contains only contacts accepted by the selector.
|
|
298 |
*
|
|
299 |
* @param aContactSelector The contact selector. Use NULL to
|
|
300 |
* filter nothing. Ownership not transferred.
|
|
301 |
*/
|
|
302 |
IMPORT_C void SetContactSelector( MVPbkContactSelector* aContactSelector );
|
|
303 |
|
|
304 |
/**
|
|
305 |
* Gives either the contact selector or NULL. Ownership is not transferred.
|
|
306 |
*/
|
|
307 |
IMPORT_C MVPbkContactSelector* ContactSelector() const;
|
|
308 |
|
|
309 |
private: // Implementation
|
|
310 |
CVPbkContactViewDefinition();
|
|
311 |
void ConstructL();
|
|
312 |
void ConstructL(
|
|
313 |
const CVPbkContactViewDefinition& aViewDef );
|
|
314 |
void ConstructFromResourceL(
|
|
315 |
TResourceReader& aReader );
|
|
316 |
void InitializeSharing();
|
|
317 |
|
|
318 |
private: // Data
|
|
319 |
/// Own: URI of this view, may be NULL if this is inner node
|
|
320 |
HBufC* iUri;
|
|
321 |
/// Own: Type of this view
|
|
322 |
TVPbkContactViewType iType;
|
|
323 |
/// Own: Flags for this view
|
|
324 |
TUint32 iFlags;
|
|
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
|
|
330 |
HBufC* iName;
|
|
331 |
/// Own: Field type filter
|
|
332 |
CVPbkFieldTypeSelector* iFilter;
|
|
333 |
/// Own: Defines the sharing of the view
|
|
334 |
TVPbkContactViewSharing iSharing;
|
|
335 |
/// Not owned
|
|
336 |
MVPbkContactSelector* iContactSelector;
|
|
337 |
/// Own: Id for this view
|
|
338 |
TInt iId;
|
|
339 |
};
|
|
340 |
|
|
341 |
#endif // CVPBKCONTACTVIEWDEFINITION_H
|
|
342 |
|
|
343 |
// End of File
|