QContactDetail ClassThe QContactDetail class represents a single, complete detail about a contact. More... #include <QContactDetail>
Public Types
Public Functions
Macros
Detailed DescriptionThe 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). Different contact managers might have different fields for the same detail type, depending on their capabilities. For example, for the QContactName detail 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. 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 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 QContactExtendedDetail detail. QContactDetail objects act like type checked values. In general, you can assign them to and from and have reasonable behaviour, like the following example. QContactPhoneNumber number; number.setNumber("555-1212"); // number.value(QContactPhoneNumber::FieldNumber) == "555-1212"; // number.type() == QContactPhoneNumber::Type QContactDetail detail = number; // detail.value(QContactPhoneNumber::FieldNumber) == "555-1212"; // detail.type() == QContactPhoneNumber::Type QContactPhoneNumber otherNumber = detail; // otherNumber.number() == "555-1212"; // otherNumber.type() == QContactPhoneNumber::Type QContactAddress address = detail; // address is now a default constructed QContactAddress // address.value(QContactPhoneNumber::FieldNumber) is empty // address.type() == QContactAddress::Type QContactAddress otherAddress = number; // otherAddress is now a default constructed QContactAddress // otherAddress.value(QContactPhoneNumber::FieldNumber) is empty // otherAddress.type() == QContactAddress::Type See also QContact, QContactDetail::DetailType, QContactDetailFilter, QContactDetailRangeFilter, and Q_DECLARE_CUSTOM_CONTACT_DETAIL. Member Type Documentation
flags QContactDetail::AccessConstraints |
Constant | Value | Description |
---|---|---|
QContactDetail::NoConstraint | 0 | Users can read, write, and otherwise modify this detail in any manner. |
QContactDetail::ReadOnly | 0x01 | Users cannot write or modify values in this detail. |
QContactDetail::Irremovable | 0x02 | Users cannot remove this detail from a contact. |
The AccessConstraints type is a typedef for QFlags<AccessConstraint>. It stores an OR combination of AccessConstraint values.
This enum defines the contexts for a detail.
Constant | Value | Description |
---|---|---|
QContactDetail::ContextHome | 0 | The detail data relates to home / private detail about the contact. |
QContactDetail::ContextWork | 1 | The detail data relates to business / work detail about the contact. |
QContactDetail::ContextOther | 2 | Generic context, neither ContextHome nor ContextWork |
See also setContexts() and contexts().
This enum defines the common fields supported by any detail.
Constant | Value | Description |
---|---|---|
QContactDetail::FieldContext | 5000 | The field containing the contexts of a detail. |
QContactDetail::FieldDetailUri | 5001 | The field containing the detail URI of a detail. |
QContactDetail::FieldLinkedDetailUris | 5002 | The field containing the URIs of other details linked to a detail. |
See also setContexts(), contexts(), setDetailUri(), detailUri(), setLinkedDetailUris(), and linkedDetailUris().
This enumeration defines the detail types provided by the contacts API.
Constant | Value | Description |
---|---|---|
QContactDetail::TypeUndefined | 0 | Convenience value used to represent unknown / undefined detail types. |
QContactDetail::TypeAddress | 1 | Detail type of a QContactAddress detail. |
QContactDetail::TypeAnniversary | 2 | Detail type of a QContactAnniversary detail. |
QContactDetail::TypeAvatar | 3 | Detail type of a QContactAvatar detail. |
QContactDetail::TypeBirthday | 4 | Detail type of a QContactBirthday detail. |
QContactDetail::TypeDisplayLabel | 5 | Detail type of a QContactDisplayLabel detail. |
QContactDetail::TypeEmailAddress | 6 | Detail type of a QContactEmailAddress detail. |
QContactDetail::TypeExtendedDetail | 7 | Detail type of a QContactExtendedDetail detail. |
QContactDetail::TypeFamily | 8 | Detail type of a QContactFamily detail. |
QContactDetail::TypeFavorite | 9 | Detail type of a QContactFavorite detail. |
QContactDetail::TypeGender | 10 | Detail type of a QContactGender detail. |
QContactDetail::TypeGeoLocation | 11 | Detail type of a QContactGeoLocation detail. |
QContactDetail::TypeGlobalPresence | 12 | Detail type of a QContactGlobalPresence detail. |
QContactDetail::TypeGuid | 13 | Detail type of a QContactGuid detail. |
QContactDetail::TypeHobby | 14 | Detail type of a QContactHobby detail. |
QContactDetail::TypeName | 15 | Detail type of a QContactName detail. |
QContactDetail::TypeNickname | 16 | Detail type of a QContactNickname detail. |
QContactDetail::TypeNote | 17 | Detail type of a QContactNote detail. |
QContactDetail::TypeOnlineAccount | 18 | Detail type of a QContactOnlineAccount detail. |
QContactDetail::TypeOrganization | 19 | Detail type of a QContactOrganization detail. |
QContactDetail::TypePhoneNumber | 20 | Detail type of a QContactPhoneNumber detail. |
QContactDetail::TypePresence | 21 | Detail type of a QContactPresence detail. |
QContactDetail::TypeRingtone | 22 | Detail type of a QContactRingtone detail. |
QContactDetail::TypeSyncTarget | 23 | Detail type of a QContactSyncTarget detail. |
QContactDetail::TypeTag | 24 | Detail type of a QContactTag detail. |
QContactDetail::TypeTimestamp | 25 | Detail type of a QContactTimestamp detail. |
QContactDetail::TypeType | 26 | Detail type of a QContactType detail. |
QContactDetail::TypeUrl | 27 | Detail type of a QContactUrl detail. |
QContactDetail::TypeVersion | 28 | Detail type of a QContactVersion detail. |
See also type().
Constructs a new, empty detail
Constructs a new, empty detail of the type identified by type.
Constructs a detail that is a copy of other
Frees the memory used by this detail
Returns the access constraints associated with the detail.
Some details may not be written to, while other details may not be removed from a contact.
See also QContactDetail::AccessConstraints.
This is a convenience function to return the Context field of this detail.
It is equivalent to the following code:
value<QStringList>(QContactDetail::FieldContext);
See also setContexts() and value().
This is a convenience function to return the DetailUri field of this detail.
It is equivalent to the following code:
value(QContactDetail::FieldDetailUri);
See also setDetailUri() and value().
Returns true if this detail has a field with the given field, or false otherwise.
Returns true if no values are contained in this detail. Note that context is stored as a value; hence, if a context is set, this function will return false.
An empty value (for example, the string "") is still a value contained in this detail, so this function will return false.
Returns the key of this detail.
Be aware that if a contact is retrieved (or reloaded) from the backend, the keys of any details it contains may have been changed by the backend, or other threads may have modified the contact details in the backend. Therefore, clients should reload the detail that they wish to save in or remove from a contact after retrieving the contact from the backend, in order to ascertain the keys of any such details.
This is a convenience function to return the Context field of this detail.
It is equivalent to the following code:
value<QStringList>(QContactDetail::FieldLinkedDetailUris);
See also setLinkedDetailUris() and value().
Removes the value stored in this detail for the given field. Returns true if a value was stored for the given field and the operation succeeded, and false otherwise.
Causes the implicitly-shared detail to be detached from any other copies, and generates a new key for it. This ensures that calling QContact::saveDetail() will result in a new detail being saved, rather than another detail being updated.
This is a convenience function that sets the Context field of this detail to the given context. It is useful if the detail is only valid in a single context.
It is equivalent to the following code:
setValue(FieldContext, QList<int>() << context);
See also contexts() and setValue().
This is a convenience function that sets the Context field of this detail to the given contexts.
It is equivalent to the following code:
setValue(QContactDetail::FieldContext, contexts);
See also setValue().
This is a convenience function that sets the DetailUri field of this detail to the given detailUri. In order to be linked to, a detail must have a specific and (per-contact) unique detail URI set.
It is equivalent to the following code:
setValue(FieldDetailUri, detailUri);
See also detailUri() and setValue().
This is a convenience function that sets the LinkedDetailUris field of this detail to the given linkedDetailUris.
It is equivalent to the following code:
setValue(QContactDetail::FieldLinkedDetailUris, linkedDetailUris);
See also linkedDetailUris() and setValue().
This is a convenience function that sets the LinkedDetailUris field of this detail to the given linkedDetailUri. It is useful if the detail is linked to a single other detail in the contact.
It is equivalent to the following code:
setValue(FieldLinkedDetailUris, QStringList(linkedDetailUri));
See also setValue().
Inserts value into the detail for the given field if value is valid. If value is invalid, removes the field with the given field from the detail. Returns true if the given value was set for the field (if the value was valid), or if the given field was removed from detail (if the value was invalid), and returns false if the field could not be removed (and the value was invalid)
See also value().
Returns the (unique) enum of the type which defines the semantics and structure of this detail.
Returns the value stored in this detail for the given field. An invalid QVariant is returned if the value of field is not set.
See also setValue().
Returns the values stored in this detail as a field-to-value map.
Returns true if the values or id of this detail is different to those of the other detail
Assigns this detail to other
Compares this detail to other. Returns true if the type, access constraints and values of other are equal to those of this detail. The keys of each detail are not considered during the comparison, in order to allow details from different contacts to be compared according to their values.
Macro for simplifying declaring custom (leaf) detail classes.
The first argument is the detail type of the class.
If you are creating a convenience class for a type of QContactDetail, you should use this macro when declaring your class to ensure that it interoperates with other contact functionality.
Here is an example of a class (QContactPhoneNumber) using this macro. Note that the class provides some predefined constants and some convenience methods that return values associated with schema fields.
class Q_CONTACTS_EXPORT QContactPhoneNumber : public QContactDetail { public: #ifndef Q_QDOC Q_DECLARE_CUSTOM_CONTACT_DETAIL(QContactPhoneNumber) #else static const DetailType Type; #endif enum PhoneNumberField { FieldNumber = 0, FieldSubTypes }; enum SubType { SubTypeLandline = 0, SubTypeMobile, SubTypeFax, SubTypePager, SubTypeVoice, SubTypeModem, SubTypeVideo, SubTypeCar, SubTypeBulletinBoardSystem, SubTypeMessagingCapable, SubTypeAssistant, SubTypeDtmfMenu }; void setNumber(const QString& number) {setValue(FieldNumber, number);} QString number() const {return value(FieldNumber).toString();} void setSubTypes(const QList<int> &subTypes) {setValue(FieldSubTypes, QVariant::fromValue(subTypes));} QList<int> subTypes() const {return value< QList<int> >(FieldSubTypes);} // Convenience filter static QContactFilter match(const QString& number); };