2 * Copyright (c) 2002 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.
15 * This class extends Symbian Contacts model CContactItemField class capabilities
16 * to better suit Phonebook's needs.
21 #ifndef __TPbkContactItemField_H__
22 #define __TPbkContactItemField_H__
26 #include "MPbkFieldData.h"
27 #include <cntdef.h> // TStorageType
28 #include "PbkIconId.hrh"
30 // These two includes are not needed here anymore
31 // and might be removed in the future
32 #include <cntitem.h> // CContactItem
33 #include <cntfldst.h> // CContactItemField storage types
36 // FORWARD DECLARATIONS
38 class CContactItemField;
39 class CContactTextField;
40 class CPbkContactItem;
41 class CContactDateField;
47 * Phonebook Contact item field class.
48 * This class extends Symbian Contacts model CContactItemField class
49 * capabilities to better suit Phonebook's needs.
51 class TPbkContactItemField : public MPbkFieldData
53 public: // Constructors and destructor
55 * C++ default constructor.
57 IMPORT_C TPbkContactItemField();
62 * @param aField Contacts Model field this object is wrapping.
63 * @param aFieldInfo Phonebook field type of aField.
65 IMPORT_C TPbkContactItemField(CContactItemField* aField,
66 CPbkFieldInfo* aFieldInfo);
69 * Sets the contents of this object after construction.
70 * @param aField Contacts Model field this object is wrapping
71 * @param aFieldInfo Phonebook field type of aField
73 IMPORT_C void Set(CContactItemField* aField,
74 CPbkFieldInfo* aFieldInfo);
76 public: // New functions
78 * Returns an Phonebook icon id for this field.
79 * @return The Phonebook icon id for this field.
81 IMPORT_C TPbkIconId IconId() const;
84 * Returns the Phonebook field info object of this field.
85 * @return Field info for this field.
87 IMPORT_C CPbkFieldInfo& FieldInfo() const;
90 * Returns this field's textual content.
91 * @return This field's textual content.
92 * @precond StorageType()==KStorageTypeText.
94 IMPORT_C TPtrC Text() const;
97 * Returns this field's date/time content.
98 * @return This field's date/time content.
99 * @precond StorageType()==KStorageTypeDateTime.
101 IMPORT_C TTime Time() const;
104 * Fills aText with field's text content. If field is of date
105 * type formats the date as text.
106 * @param aText Fills parameter with field's content.
108 * @exception KErrOverflow if aText is not big enough for
109 * the text. aText contents will be clipped to aText.MaxLength().
110 * @exception KErrNotSupported if the field content cannot be
111 * represented as text.
113 IMPORT_C void GetTextL(TDes& aText) const;
116 * Returns the storage type of this field.
117 * @return The storage type of this field.
119 IMPORT_C TStorageType StorageType() const;
122 * Returns the embedded contact item field.
123 * @return The embedded contact item field.
125 IMPORT_C CContactItemField& ItemField() const;
128 * Returns the text storage object of this field. If the storage type is
129 * not KStorageTypeText the function raises a panic.
130 * @return The text storage object of this field.
132 IMPORT_C CContactTextField* TextStorage() const;
135 * Returns the label text of this field.
136 * @return The label text of this field.
138 IMPORT_C TPtrC Label() const;
141 * Sets the label text of this field to aLabel.
142 * @param aLabel Text to set as the label of this field.
144 IMPORT_C void SetLabelL(const TDesC& aLabel);
147 * Marks this field as hidden or unhidden.
148 * @param aHidden ETrue marks as hidden EFalse removes the mark.
150 IMPORT_C void SetHidden(TBool aHidden);
153 * Check if field is marked hidden.
154 * @return ETrue if this field is hidden, EFalse if not.
156 IMPORT_C TBool IsHidden() const;
159 * Returns time storage of this field. If the storage type is
160 * not KStorageTypeDateTime the function raises a panic.
161 * @return The time storage object of this field.
163 IMPORT_C CContactDateField* DateTimeStorage() const;
166 * Returns ETrue if this is the same field as aField.
167 * @return ETrue if this is the same field as aField.
169 IMPORT_C TBool IsSame(const TPbkContactItemField& aField) const;
172 * Converts this field to a CContactItemField.
173 * @return The embedded CContactItemField object.
175 IMPORT_C CContactItemField& ContactItemField();
178 * Converts this field to a const CContactItemField.
179 * @return The embedded CContactItemField object.
181 IMPORT_C const CContactItemField& ContactItemField() const;
184 * Compares two items against the group ordering.
185 * @param aRhs Contact item field to compare to this field.
187 IMPORT_C TInt Compare(const TPbkContactItemField& aRhs) const;
190 * Returns an unique id for this field.
191 * NOTE: Returned id is valid only as long as this object is in memory
192 * in other words the id is not persistent!
193 * @return The unique id for this field.
195 IMPORT_C TInt UniqueFieldIdentity() const;
198 * Returns ETrue if this field's contents is empty.
199 * @return ETrue if this field's contents is empty.
201 IMPORT_C TBool IsEmpty() const;
204 * Returns ETrue if this field's contents is empty or all spaces.
205 * @return ETrue if this field's contents is empty or all spaces.
207 IMPORT_C TBool IsEmptyOrAllSpaces() const;
210 * Returns ETrue is this field is a default phone number field.
211 * @see CPbkContactItem::DefaultPhoneNumberField
212 * @see CPbkContactItem::SetDefaultPhoneNumberField
213 * @return ETrue is this field is a default phone number field.
215 IMPORT_C TBool DefaultPhoneNumberField() const;
218 * Returns ETrue if this field is a default video number field.
219 * @see CPbkContactItem::DefaultVideoNumberField
220 * @see CPbkContactItem::SetDefaultVideoNumberField
221 * @return ETrue if this field is a default video number field.
223 IMPORT_C TBool DefaultVideoNumberField() const;
226 * Returns ETrue is this field is a default SMS field.
227 * @see CPbkContactItem::DefaultSmsField
228 * @see CPbkContactItem::SetDefaultSmsField
229 * @return ETrue is this field is a default SMS field.
231 IMPORT_C TBool DefaultSmsField() const;
234 * Returns ETrue is this field is a default SMS With Email field.
235 * @see CPbkContactItem::DefaultEmailOverSmsField
236 * @see CPbkContactItem::SetDefaultEmailOverSmsField
237 * @return ETrue is this field is a default SMS With Email field.
239 IMPORT_C TBool DefaultEmailOverSmsField() const;
242 * Returns ETrue is this field is a default email field.
243 * @see CPbkContactItem::DefaultEmailField
244 * @see CPbkContactItem::SetDefaultEmailField
245 * @return ETrue is this field is a default email field.
247 IMPORT_C TBool DefaultEmailField() const;
250 * Returns ETrue is this field is a default MMS field.
251 * @see CPbkContactItem::DefaultMmsField
252 * @see CPbkContactItem::SetDefaultMmsField
253 * @return ETrue is this field is a default MMS field.
255 IMPORT_C TBool DefaultMmsField() const;
258 * Returns ETrue is this field is a default POC field.
259 * @see CPbkContactItem::DefaultPocField
260 * @see CPbkContactItem::SetDefaultPocField
261 * @return ETrue is this field is a default POC field.
263 IMPORT_C TBool DefaultPocField() const;
266 * Returns ETrue is this field is a default VOIP field.
267 * @see CPbkContactItem::DefaultVoipField
268 * @see CPbkContactItem::SetDefaultVoipField
269 * @return ETrue is this field is a default VOIP field.
271 IMPORT_C TBool DefaultVoipField() const;
274 * Returns an array of speed dial indexes assigned to this field,
276 * @return An array of speed dial indexes assigned to this field,
279 IMPORT_C CArrayFix<TInt>* SpeedDialIndexesL() const;
281 public: // from MPbkFieldData
282 IMPORT_C TStorageType PbkFieldType() const;
283 IMPORT_C TPbkFieldId PbkFieldId() const;
284 IMPORT_C TPtrC PbkFieldText() const;
285 IMPORT_C TTime PbkFieldTime() const;
287 private: // CPbkContactItem support functions
288 /// CPbkContactItem calls private functions of this class
289 friend class CPbkContactItem;
290 void PrepareForSaveL();
291 void PrepareAfterLoadL();
292 TBool HasInvalidDate();
295 /// Ref: Contact item field to be expanded into greater heights
296 CContactItemField* iField;
297 /// Ref: field info object matching iField's type
298 CPbkFieldInfo* iFieldInfo;
300 private: // Friend declarations
301 friend IMPORT_C TBool operator==
302 (const TPbkContactItemField& aLeft,
303 const TPbkContactItemField& aRight);
307 // FUNCTION DECLARATIONS
310 * Returns ETrue if aLeft has same contents as aRight.
311 * Doesn't compare everything (all field flags etc.) but all the attributes
312 * that could affect how this field looks like in the Phonebook UI. This
313 * function can be used to determine wheter to update this field in the UI.
315 IMPORT_C TBool operator==
316 (const TPbkContactItemField& aLeft,
317 const TPbkContactItemField& aRight);
320 * Returns !(aLeft==aRight).
322 inline TBool operator!=
323 (const TPbkContactItemField& aLeft,
324 const TPbkContactItemField& aRight)
326 return !(aLeft==aRight);
330 #endif // __TPbkContactItemField_H__