QContactDetail Class Reference
The QContactDetail class represents a single, complete detail about a contact. More...
#include <QContactDetail>
Inherited by QContactAddress, QContactAnniversary, QContactAvatar, QContactBirthday, QContactDisplayLabel, QContactEmailAddress, QContactFamily, QContactGender, QContactGeoLocation, QContactGlobalPresence, QContactGuid, QContactName, QContactNickname, QContactNote, QContactOnlineAccount, QContactOrganization, QContactPhoneNumber, QContactPresence, QContactRingtone, QContactSyncTarget, QContactTag, QContactThumbnail, QContactTimestamp, QContactType, and QContactUrl.
Public Types
| enum | AccessConstraint { NoConstraint, ReadOnly, Irremovable } |
| flags | AccessConstraints |
Public Functions
| QContactDetail () | |
| QContactDetail ( const char * thisDefinitionId ) | |
| QContactDetail ( const QString & thisDefinitionId ) | |
| QContactDetail ( const QContactDetail & other ) | |
| ~QContactDetail () | |
| AccessConstraints | accessConstraints () const |
| QStringList | contexts () const |
| QString | definitionName () const |
| QString | detailUri () const |
| bool | hasValue ( const QString & key ) const |
| bool | hasValue ( const QLatin1Constant & key ) const |
| bool | isEmpty () const |
| int | key () const |
| QStringList | linkedDetailUris () const |
| bool | removeValue ( const QString & key ) |
| bool | removeValue ( const QLatin1Constant & key ) |
| void | resetKey () |
| void | setContexts ( const QStringList & contexts ) |
| void | setContexts ( const QString & context ) |
| void | setDetailUri ( const QString & detailUri ) |
| void | setLinkedDetailUris ( const QStringList & linkedDetailUris ) |
| void | setLinkedDetailUris ( const QString & linkedDetailUri ) |
| bool | setValue ( const QString & key, const QVariant & value ) |
| bool | setValue ( const QLatin1Constant & key, const QVariant & value ) |
| T | value ( const QString & key ) const |
| T | value ( const QLatin1Constant & key ) const |
| QString | value ( const QString & key ) const |
| QString | value ( const QLatin1Constant & key ) const |
| QVariant | variantValue ( const QString & key ) const |
| QVariant | variantValue ( const QLatin1Constant & key ) const |
| QVariantMap | variantValues () const |
| bool | operator!= ( const QContactDetail & other ) const |
| QContactDetail & | operator= ( const QContactDetail & other ) |
| bool | operator== ( const QContactDetail & other ) const |
Macros
| Q_DECLARE_CUSTOM_CONTACT_DETAIL |
Detailed Description
The QContactDetail class represents a single, complete detail about a contact.
All of the information for a contact is stored in one or more QContactDetail objects.
A detail is a group of logically related bits of data - for example, a street address is a single detail that has multiple fields (number, region, country etc). Every QContactDetail has the name of an associated QContactDetailDefinition that describes the fields, their data type, and any restrictions on their values. Different contact managers might have different detail definitions for the same name, depending on their capabilities. For example, for the QContactName definition name, one manager might not support the middle name field, while a different manager may add an extra field for specific extra information not present in the default schema.
Both the names of all the fields, and the name of the associated QContactDetailDefinition are stored as 8-bit strings encoded in Latin 1 for memory conservation. Note, however, that the values stored in each field are not constrained in this way, and full unicode QStrings or QVariant data can be stored.
One field which is common to all details is the context field. This field is intended to store one or more contexts that this detail is associated with. Commonly this will be something like "Home" and/or "Work", although no limitations are placed on which values may be stored in this field in the default schema.
There are two other, related fields which are common to all details. The first is QContactDetail::FieldDetailUri, which stores the unique URI of the detail if one exists. The field is not mandatory, and backends are not required to verify that the given URI is indeed unique within the contact. The second field is QContactDetail::LinkedDetailUris, which stores a list of detail URIs to which this detail is linked. The link is one-way, and can be used to show how or where a detail was derived. This is useful for things like presence information and avatars, which are linked to a particular online account detail of the contact.
When a QContactDetail has been retrieved in a QContact from a QContactManager, it may have certain access constraints provided with it, like ReadOnly or Irremovable. This might mean that the supplied detail is calculated or otherwise not modifiable by the user - presence information is a good example. Also, some details may be marked Irremovable. These are typically things that a contact has to have - like a QContactDisplayLabel or a QContactType.
It is possible to inherit from QContactDetail to provide convenience or standardized access to values. For example, QContactPhoneNumber provides a convenient API for manipulating a QContactDetail as a phone number, according to the schema.
In general, QContactDetail and the built in subclasses (like QContactPhoneNumber) provide constants for the names of fields (like QContactPhoneNumber::FieldNumber), and for predefined common values like QContactDetail::ContextHome. Typically the constants for field names start with Field, and the constants for predefined values of a field start with the name of that field (e.g. ContextHome is a predefined constant for FieldContext).
If you wish to create your own, customized contact detail, you should use the Q_DECLARE_CUSTOM_CONTACT_DETAIL macro in order to ensure proper operation, and declare your own field constants with Q_DECLARE_LATIN1_CONSTANT. See the predefined detail subclasses (like QContactPhoneNumber, QContactAddress) for more information.
QContactDetail objects act like type checked values. In general, you can assign them to and fro and have reasonable behaviour, like the following example.
QContactPhoneNumber number;
number.setNumber("555-1212");
// number.value(QContactPhoneNumber::FieldNumber) == "555-1212";
// number.definitionName() == QContactPhoneNumber::DefinitionName
QContactDetail detail = number;
// detail.value(QContactPhoneNumber::FieldNumber) == "555-1212";
// detail.definitionName() == QContactPhoneNumber::DefinitionName
QContactPhoneNumber otherNumber = detail;
// otherNumber.number() == "555-1212";
// otherNumber.definitionName() == QContactPhoneNumber::DefinitionName
QContactAddress address = detail;
// address is now a default constructed QContactAddress
// address.value(QContactPhoneNumber::FieldNumber) is empty
// address.definitionName() == QContactAddress::DefinitionName
QContactAddress otherAddress = number;
// otherAddress is now a default constructed QContactAddress
// otherAddress.value(QContactPhoneNumber::FieldNumber) is empty
// otherAddress.definitionName() == QContactAddress::DefinitionName