Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: cntfield.h
Link against: cntmodel.lib

Class CContactItemField

CContactItemField

Support

Supported from 5.0

Description

A field in a contact item. Fields are stored in a field set (CContactItemFieldSet) and the field set is owned by the contact item.

The contact item field stores the field data. The data may be text, a date/time value, or an agent, as indicated by the storage type (TStorageType). The storage type is also owned by the field. Note that numeric field data is not supported. All numbers, for instance telephone or fax numbers are stored in text fields in the contact database.

Fields also have a content type, attributes and a label. The label is a string which identifies the field to a user e.g. First name, Last name.

The following attributes are supported:

These attributes can be set using member functions of this class, but they are normally set by higher level classes, e.g. when setting a speed dial field, CContactDatabase automatically sets the field's speed dial attribute.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CContactItemFieldA field in a contact item

Defined in CContactItemField:
AddFieldTypeL(), AgentStorage(), ContentType(), DateTimeStorage(), DoSynchronize(), HasExtraStream(), Id(), IsDisabled(), IsHidden(), IsPrivate(), IsReadOnly(), IsSpeedDial(), IsTemplate(), IsTemplateLabelField(), IsValidLabel(), Label(), LabelUnspecified(), NewL(), NewLC(), NumberStorage(), OverRidesLabel(), RemoveFieldType(), ResetStore(), SetDisabled(), SetHidden(), SetId(), SetLabel(), SetLabelL(), SetMapping(), SetPrivate(), SetReadOnly(), SetSpeedDial(), SetSynchronize(), SetTemplateField(), SetUserAddedField(), SetUserFlags(), Storage(), StorageType(), StoreStorage(), TextStorage(), UserAddedField(), UserFlags(), UsesTemplateTypes(), ~CContactItemField()

Inherited from CBase:
operator new()


Construction and destruction


NewL()

static CContactItemField* NewL(TStorageType aType);
static CContactItemField* NewL(TStorageType aType, TFieldType aFieldType);
static CContactItemField* NewL(const CContactItemField& aField);
static CContactItemField* NewL(TStorageType aType, const CContentType& aContentType);

Description

Allocates and constructs a contact item field — overloaded function. The field may be constructed with:

Parameters

TStorageType aType

The field's storage type.

TFieldType aFieldType

The field type as defined in cntdef.h.

const CContactItemField& aField

The contact field to copy.

const CContentType& aContentType

The field's content type.

Return value

CContactItemField*

Pointer to the newly created contact item field.

Leave codes

 

If the aType parameter has an invalid value, the function leaves with KErrNotSupported .


NewLC()

static CContactItemField* NewLC();
static CContactItemField* NewLC(TStorageType aType);
static CContactItemField* NewLC(TStorageType aType, TFieldType aFieldType);
static CContactItemField* NewLC(const CContactItemField& aField);
static CContactItemField* NewLC(TStorageType aType, const CContentType& aContentType);

Description

Allocates and constructs a contact item field, leaving the pointer to it on the cleanup stack — overloaded function. The field may be constructed with:

Parameters

TStorageType aType

The field's storage type.

TFieldType aFieldType

The field type as defined in cntdef.h.

const CContactItemField& aField

The contact field to copy.

const CContentType& aContentType

The field's content type.

Return value

CContactItemField*

Pointer to the newly created contact item field.

Leave codes

 

If the aType parameter has an invalid value, the function leaves with KErrNotSupported .


~CContactItemField()

~CContactItemField();

Description

The destructor frees all resources owned by the field (the label, the stored data and the content type), prior to its destruction.

[Top]


Field storage


StorageType()

TStorageType StorageType() const;

Description

Gets the field's storage type.

Return value

TStorageType

The field's storage type.


Storage()

CContactFieldStorage* Storage() const;

Description

Gets a pointer to the field's base storage. Rather than using this function and then casting to a specific storage class, one of the following functions should almost always be used: — TextStorage(), StoreStorage(), AgentStorage(), or DateTimeStorage().

Return value

CContactFieldStorage*

The field's base storage type.


ResetStore()

void ResetStore();

Support

Supported from 6.0

Description

Resets the field storage. The field's store is deleted, then re-allocated.


TextStorage()

CContactTextField* TextStorage() const;

Description

Gets a pointer to the field's storage as a CContactTextField*. If the field storage type is not KStorageTypeText, this function raises a panic.

Return value

CContactTextField*

Field's storage as a CContactTextField*.


StoreStorage()

CContactStoreField* StoreStorage() const;

Description

Gets a pointer to the field's storage as a CContactStoreField*. This indicates field data stored in a descriptor or descriptor array. If the field storage type is not KStorageTypeStore, this function raises a panic.

Return value

CContactStoreField*

Field's storage as a CContactStoreField*.


AgentStorage()

CContactAgentField* AgentStorage() const;

Description

Gets a pointer to the field's storage as a CContactAgentField*. An agent is a property in a vCard which contains another person's contact details. If the field storage type is not KStorageTypeContactItemId, this function raises a panic.

Return value

CContactAgentField*

Field's storage as a CContactAgentField*.


DateTimeStorage()

CContactDateField* DateTimeStorage() const;

Description

Returns a pointer to the field's storage as a CContactDateField*. If the field storage type is not KStorageTypeDateTime, this function raises a panic.

Return value

CContactDateField*

Field's storage as a CContactDateField*.


NumberStorage()

CContactNumberField* NumberStorage() const;

Description

This function is currently unsupported. Calling it will raise an ECntPanicInvalidStorageType panic.

[Top]


Field type and mapping


ContentType()

const CContentType& ContentType() const;

Description

Gets the field's content type.

Return value

CContentType&

Reference to the field's content type.


AddFieldTypeL()

void AddFieldTypeL(TFieldType aFieldType);

Description

Appends a field type to the field's content type.

Parameters

TFieldType aFieldType

The field type to append to the field's content type.


RemoveFieldType()

void RemoveFieldType(TFieldType aFieldType);

Description

Removes a field type from the field's content type.

Parameters

TFieldType aFieldType

The field type to remove from the field's content type.


SetMapping()

void SetMapping(TUid aMapping);

Description

Sets the vCard mapping for the field's content type.

Parameters

TUid aMapping

The new mapping for the field's content type.

[Top]


Field attributes


SetHidden()

void SetHidden(TBool aHidden);

Description

Sets the status of the hidden attribute. If hidden fields are included in the view definition, the field is displayed like other fields. If the view definition masks hidden fields, it is not displayed. See the TMode enumeration defined in class CContactItemViewDef.

Parameters

TBool aHidden

ETrue for hidden, EFalse for displayed.


IsHidden()

TBool IsHidden() const;

Description

Gets the field's hidden attribute.

Return value

TBool

ETrue if hidden attribute set, EFalse if not set.


SetReadOnly()

void SetReadOnly(TBool aReadOnly);

Description

Sets the status of the field's read only attribute.

Parameters

TBool aReadOnly

ETrue to set the field's read only attribute, EFalse to unset the attribute.


IsReadOnly()

TBool IsReadOnly() const;

Description

Gets the field's read only attribute.

Return value

TBool

ETrue if read only attribute set, EFalse if not set.


SetSynchronize()

void SetSynchronize(TBool aSynchronize);

Description

Sets the status of the field's synchronise attribute.

Parameters

TBool aSynchronize

ETrue to set synchronise attribute, EFalse to unset it.


DoSynchronize()

TBool DoSynchronize() const;

Description

Gets the status of the field's synchronise attribute.

Return value

TBool

ETrue if synchronise attribute set, EFalse if not set.


SetDisabled()

void SetDisabled(TBool aDisabled);

Description

Sets the status of the disabled attribute.

Parameters

TBool aDisabled

ETrue to set the disabled attribute, EFalse to unset the attribute.


IsDisabled()

TBool IsDisabled() const;

Description

Tests the field's disabled attribute.

Return value

TBool

ETrue if disabled attribute set, EFalse if disabled attribute not set.


SetUserAddedField()

void SetUserAddedField(TBool aUserAddedField);

Description

Sets the user added field attribute.

Parameters

TBool aUserAddedField

ETrue to set the field's user added attribute, EFalse to unset it.


UserAddedField()

TBool UserAddedField() const;

Description

Tests the value of the user added field attribute.

Return value

TBool

ETrue if the user added attribute is set, EFalse if not.


IsTemplate()

TBool IsTemplate() const;

Support

Supported from 6.0

Description

Tests whether the field is in a template, as set by SetTemplateField().

Return value

TBool

ETrue if field is a template field. EFalse if not.


SetTemplateField()

void SetTemplateField(TBool aTemplateField);

Support

Supported from 6.0

Description

Sets whether the field is a template field.

Parameters

TBool aTemplateField

ETrue to set the field's Is template attribute. EFalse to unset it.


IsPrivate()

TBool IsPrivate() const;

Support

Supported from 6.0

Description

Tests whether the field's private attribute is set.

Return value

TBool

True if the field's private attribute is set, false if not.


SetPrivate()

void SetPrivate(TBool aTemplateField);

Support

Supported from 6.0

Description

Sets the field's private attribute. This is used by the contact database when exporting a contact item as a vCard, to identify fields which should not be exported.

Parameters

TBool aTemplateField

ETrue to set the field's private attribute, EFalse to unset it.


IsSpeedDial()

TBool IsSpeedDial() const;

Support

Supported from 6.0

Description

Tests whether the field is a speed dial field.

Return value

TBool

True if the field is a speed dial field, false if not.


SetSpeedDial()

void SetSpeedDial(TBool aSpeedDialField);

Support

Supported from 6.0

Description

Sets the value of the field's speed dial attribute.

Parameters

TBool aSpeedDialField

ETrue if the field should be a speed dial field, EFalse if not.

[Top]


Label


SetLabelL()

void SetLabelL(const TDesC& aLabel);

Description

Sets the field label — can leave. The label is allocated using TDesC::AllocL(). Any existing label is replaced.

Parameters

const TDesC& aLabel

The new field label.


SetLabel()

void SetLabel(HBufC* aLabel);

Description

Sets the field label — cannot leave. The CContactItemField takes ownership of aLabel.

Parameters

HBufC* aLabel

The new field label.


Label()

TPtrC Label() const;

Description

Gets the field label.

Return value

TPtrC

The field label. If no label has been set, its length is zero.


IsValidLabel()

static TBool IsValidLabel(const TDesC& aLabel,TInt& aInvalidPos);

Description

Tests whether a field label is valid.

Notes:

The label is invalid if it contains any of the following characters: —

Parameters

const TDesC& aLabel

The field label to test.

TInt& aInvalidPos

On return, contains the character position within the label of the first invalid character. The first character position is zero.

Return value

TBool

ETrue if valid, EFalse if invalid.


OverRidesLabel()

TBool OverRidesLabel() const;

Description

Tests whether the field's label (as set by SetLabel()) overrides the label specified in the field's template.

Return value

TBool

True if the field's label overrides the label specified in the template; false if not.


LabelUnspecified()

TBool LabelUnspecified() const;

Description

Tests whether the field's label has been set, either by a call to SetLabel() or by inheriting a label specified in the template.

Return value

TBool

True if the field's label has been set, false if not.

[Top]


Template


UsesTemplateTypes()

TBool UsesTemplateTypes() const;

Description

Indicates whether or not the field's content type is based on a template.

Return value

TBool

True if the field's content type is based on a template; false if not.


HasExtraStream()

TBool HasExtraStream() const;

Description

Tests whether the field needs an extra stream to store information not contained in the template. This is the case if the field's content type is not based on a template, or if the field has a label which overrides the label specified in the template.

Return value

TBool

True if the field uses an extra stream; false if not.


IsTemplateLabelField()

TBool IsTemplateLabelField() const;

Support

Supported from 6.0

Description

Tests whether the field is a template label field (i.e. a field which holds the label for a contact card template: see class CContactCardTemplate).

Return value

TBool

ETrue if the field is a template label field, EFalse if not.

[Top]


Field ID


SetId()

void SetId(TInt aId);

Description

Sets the ID which uniquely identifies a field within a field set..

Note that the field ID value is initialised when the field is added to the field set (using CContactItemFieldSet::AddL()). It is equivalent to the field's index within the field set array, and it should not normally be changed.

Parameters

TInt aId

The new field ID.


Id()

TInt Id() const;

Description

Retrieves the field ID, as set by SetId().

Return value

TInt

The field ID.

[Top]


User flags


UserFlags()

TUint UserFlags() const;

Description

Gets the value of the user flags, as set by SetUserFlags().

Return value

TUint

The user flags value.


SetUserFlags()

void SetUserFlags(TUint aFlags);

Description

Sets the value of the user flags.

Parameters

TUint aFlags

The user flags value.