Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

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, QContactFavorite, QContactGender, QContactGeoLocation, QContactGlobalPresence, QContactGuid, QContactHobby, QContactName, QContactNickname, QContactNote, QContactOnlineAccount, QContactOrganization, QContactPhoneNumber, QContactPresence, QContactRingtone, QContactSyncTarget, QContactTag, QContactThumbnail, QContactTimestamp, QContactType, and QContactUrl.

This class was introduced in Qt Mobility 1.0.

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

See also QContact, QContactDetailDefinition, QContactDetailFilter, QContactDetailRangeFilter, and Q_DECLARE_CUSTOM_CONTACT_DETAIL.

Member Type Documentation

enum QContactDetail::AccessConstraint
flags QContactDetail::AccessConstraints

This enum defines the access constraints for a detail. This information is typically provided by the manager when a contact is retrieved.

ConstantValueDescription
QContactDetail::NoConstraint0Users can read, write, and otherwise modify this detail in any manner.
QContactDetail::ReadOnly0x01Users cannot write or modify values in this detail.
QContactDetail::Irremovable0x02Users cannot remove this detail from a contact.

The AccessConstraints type is a typedef for QFlags<AccessConstraint>. It stores an OR combination of AccessConstraint values.

Member Function Documentation

QContactDetail::QContactDetail ()

Constructs a new, empty detail

QContactDetail::QContactDetail ( const char * thisDefinitionId )

Constructs a new, empty detail of the definition identified by thisDefinitionId

The supplied pointer must be valid for the lifetime of the program. In general this means it should be a constant, and not allocated on the stack. If you cannot meet this requirement, use the alternative constructor that takes a QString instead.

This function was introduced in Qt Mobility 1.0.

QContactDetail::QContactDetail ( const QString & thisDefinitionId )

Constructs a new, empty detail of the definition identified by thisDefinitionId. The definitionId must be restricted to the Latin 1 character set.

This function was introduced in Qt Mobility 1.0.

QContactDetail::QContactDetail ( const QContactDetail & other )

Constructs a detail that is a copy of other

This function was introduced in Qt Mobility 1.0.

QContactDetail::~QContactDetail ()

Frees the memory used by this detail

AccessConstraints QContactDetail::accessConstraints () const

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.

QStringList QContactDetail::contexts () const

This is a convenience function to return the Context field of this detail.

It is equivalent to the following code:

 value<QStringList>(QContactDetail::FieldContext);

This function was introduced in Qt Mobility 1.0.

See also setContexts() and value().

QString QContactDetail::definitionName () const

Returns the (unique) name of the definition which defines the semantics and structure of this detail. The actual QContactDetailDefinition should be retrieved from the relevant QContactManager using this name.

This function was introduced in Qt Mobility 1.0.

QString QContactDetail::detailUri () const

This is a convenience function to return the DetailUri field of this detail.

It is equivalent to the following code:

 value(QContactDetail::FieldDetailUri);

This function was introduced in Qt Mobility 1.0.

See also setDetailUri() and value().

bool QContactDetail::hasValue ( const QString & key ) const

Returns true if this detail has a field with the given key, or false otherwise.

This function was introduced in Qt Mobility 1.0.

bool QContactDetail::hasValue ( const QLatin1Constant & key ) const

Returns true if this detail has a field with the given key, or false otherwise.

This function was introduced in Qt Mobility 1.0.

bool QContactDetail::isEmpty () const

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.

This function was introduced in Qt Mobility 1.0.

int QContactDetail::key () const

* 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 function was introduced in Qt Mobility 1.0.

QStringList QContactDetail::linkedDetailUris () const

This is a convenience function to return the Context field of this detail.

It is equivalent to the following code:

 value<QStringList>(QContactDetail::FieldLinkedDetailUris);

This function was introduced in Qt Mobility 1.0.

See also setLinkedDetailUris() and value().

bool QContactDetail::removeValue ( const QString & key )

Removes the value stored in this detail for the given key. Returns true if a value was stored for the given key and the operation succeeded, and false otherwise.

This function was introduced in Qt Mobility 1.0.

bool QContactDetail::removeValue ( const QLatin1Constant & key )

Removes the value stored in this detail for the given key. Returns true if a value was stored for the given key and the operation succeeded, and false otherwise.

This function was introduced in Qt Mobility 1.0.

void QContactDetail::resetKey ()

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 function was introduced in Qt Mobility 1.0.

void QContactDetail::setContexts ( const QStringList & contexts )

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);

This function was introduced in Qt Mobility 1.0.

See also contexts() and setValue().

void QContactDetail::setContexts ( const QString & context )

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, QStringList(context));

This function was introduced in Qt Mobility 1.0.

See also setValue().

void QContactDetail::setDetailUri ( const QString & detailUri )

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);

This function was introduced in Qt Mobility 1.0.

See also detailUri() and setValue().

void QContactDetail::setLinkedDetailUris ( const QStringList & linkedDetailUris )

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);

This function was introduced in Qt Mobility 1.0.

See also linkedDetailUris() and setValue().

void QContactDetail::setLinkedDetailUris ( const QString & linkedDetailUri )

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));

This function was introduced in Qt Mobility 1.0.

See also setValue().

bool QContactDetail::setValue ( const QString & key, const QVariant & value )

Inserts value into the detail for the given key if value is valid. If value is invalid, removes the field with the given key from the detail. Returns true if the given value was set for the key (if the value was valid), or if the given key was removed from detail (if the value was invalid), and returns false if the key was unable to be removed (and the value was invalid)

This function was introduced in Qt Mobility 1.0.

See also value().

bool QContactDetail::setValue ( const QLatin1Constant & key, const QVariant & value )

Inserts value into the detail for the given key if value is valid. If value is invalid, removes the field with the given key from the detail. Returns true if the given value was set for the key (if the value was valid), or if the given key was removed from detail (if the value was invalid), and returns false if the key was unable to be removed (and the value was invalid)

This function was introduced in Qt Mobility 1.0.

T QContactDetail::value ( const QString & key ) const

Returns the value of the template type associated with the given key

This function was introduced in Qt Mobility 1.0.

See also setValue().

T QContactDetail::value ( const QLatin1Constant & key ) const

Returns the value stored in this detail for the given key as a QString, or an empty QString if no value for the given key exists

This function was introduced in Qt Mobility 1.0.

QString QContactDetail::value ( const QString & key ) const

This is an overloaded function.

Returns the value stored in this detail for the given key as a QString, or an empty QString if no value for the given key exists

This function was introduced in Qt Mobility 1.0.

QString QContactDetail::value ( const QLatin1Constant & key ) const

This is an overloaded function.

Returns the value of the template type associated with the given key

This function was introduced in Qt Mobility 1.0.

QVariant QContactDetail::variantValue ( const QString & key ) const

Returns the value stored in this detail for the given key as a QVariant, or an invalid QVariant if no value for the given key exists

This function was introduced in Qt Mobility 1.0.

QVariant QContactDetail::variantValue ( const QLatin1Constant & key ) const

Returns the value stored in this detail for the given key as a QVariant, or an invalid QVariant if no value for the given key exists

This function was introduced in Qt Mobility 1.0.

QVariantMap QContactDetail::variantValues () const

Returns the values stored in this detail as a map from value key to value

This function was introduced in Qt Mobility 1.0.

bool QContactDetail::operator!= ( const QContactDetail & other ) const

Returns true if the values or id of this detail is different to those of the other detail

This function was introduced in Qt Mobility 1.0.

QContactDetail & QContactDetail::operator= ( const QContactDetail & other )

Assigns this detail to other

bool QContactDetail::operator== ( const QContactDetail & other ) const

Compares this detail to other. Returns true if the definition, 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.

This function was introduced in Qt Mobility 1.0.

Macro Documentation

Q_DECLARE_CUSTOM_CONTACT_DETAIL

Macro for simplifying declaring custom (leaf) detail classes.

The first argument is the name of the class, and the second argument is a Latin-1 string literal naming the detail type.

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:
 #ifdef Q_QDOC
     static const QLatin1Constant DefinitionName;
     static const QLatin1Constant FieldNumber;
     static const QLatin1Constant FieldSubTypes;
     static const QLatin1Constant SubTypeLandline;
     static const QLatin1Constant SubTypeMobile;
     static const QLatin1Constant SubTypeFax;
     static const QLatin1Constant SubTypePager;
     static const QLatin1Constant SubTypeVoice;
     static const QLatin1Constant SubTypeModem;
     static const QLatin1Constant SubTypeVideo;
     static const QLatin1Constant SubTypeCar;
     static const QLatin1Constant SubTypeBulletinBoardSystem;
     static const QLatin1Constant SubTypeMessagingCapable;
     static const QLatin1Constant SubTypeAssistant;
     static const QLatin1Constant SubTypeDtmfMenu;
 #else
     Q_DECLARE_CUSTOM_CONTACT_DETAIL(QContactPhoneNumber, "PhoneNumber")
     Q_DECLARE_LATIN1_CONSTANT(FieldNumber, "PhoneNumber");
     Q_DECLARE_LATIN1_CONSTANT(FieldSubTypes, "SubTypes");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeLandline, "Landline");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeMobile, "Mobile");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeFax, "Fax");
     Q_DECLARE_LATIN1_CONSTANT(SubTypePager, "Pager");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeVoice, "Voice");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeModem, "Modem");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeVideo, "Video");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeCar, "Car");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeBulletinBoardSystem, "BulletinBoardSystem");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeMessagingCapable, "MessagingCapable");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeAssistant, "Assistant");
     Q_DECLARE_LATIN1_CONSTANT(SubTypeDtmfMenu, "DtmfMenu");
 #endif

     void setNumber(const QString& number) {setValue(FieldNumber, number);}
     QString number() const {return value(FieldNumber);}

     void setSubTypes(const QStringList& subTypes) {setValue(FieldSubTypes, subTypes);}
     void setSubTypes(const QString& subType) {setValue(FieldSubTypes, QStringList(subType));}
     QStringList subTypes() const {return value<QStringList>(FieldSubTypes);}

     // Convenience filter
     static QContactFilter match(const QString& number);
 };
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web