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 provides access to a single, complete detail about a contact. More...

    #include <QContactDetail>

Inherited by QContactAddress, QContactAnniversary, QContactAvatar, QContactBirthday, QContactDisplayLabel, QContactEmailAddress, QContactFamily, QContactGender, QContactGeolocation, QContactGuid, QContactName, QContactNickname, QContactNote, QContactOnlineAccount, QContactOrganization, QContactPhoneNumber, QContactSyncTarget, QContactTimestamp, QContactType, and QContactUrl.


Public Functions

QContactDetail ()
QContactDetail ( const QString & thisDefinitionId )
QContactDetail ( const QContactDetail & other )
virtual ~QContactDetail ()
QStringList contexts () const
QString definitionName () const
bool hasValue ( const QString & key ) const
bool isEmpty () const
QList<QContactActionDescriptor> preferredActions () const
bool removeValue ( const QString & key )
void setContexts ( const QStringList & contexts )
void setContexts ( const QString & context )
void setPreferredActions ( const QList<QContactActionDescriptor> & preferredActions )
bool setValue ( const QString & key, const QVariant & value )
T value ( const QString & key ) const
QString value ( const QString & key ) const
QVariantMap values () const
QVariant variantValue ( const QString & key ) const
bool operator!= ( const QContactDetail & other ) const
QContactDetail & operator= ( const QContactDetail & other )
bool operator== ( const QContactDetail & other ) const

Protected Functions

QContactDetail ( const QContactDetail & other, const QString & expectedDefinitionId )
QContactDetail & assign ( const QContactDetail & other, const QString & expectedDefinitionId )

Macros

Q_DECLARE_CUSTOM_CONTACT_DETAIL

Detailed Description

The QContactDetail class provides access to 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 an associated QContactDetailDefinition id that describes the fields, their data type, any restrictions on their values, and any restrictions on creating or updating details of that definition.

A field which is common to all details is the context field. This field is intended to store the context that this detail is associated with. Commonly this will be something like "Home" or "Work", although no limitations are placed on which values may be stored in this field.

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.

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. See the predefined leaf classes (like QContactPhoneNumber, QContactAddress) for more information.

QContactDetail objects act like 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::staticType()

    QContactDetail detail = number;
    // detail.value(QContactPhoneNumber::FieldNumber) == "555-1212";
    // detail.definitionName() == QContactPhoneNumber::staticType()

    QContactPhoneNumber otherNumber = detail;
    // otherNumber.number() == "555-1212";
    // otherNumber.definitionName() == QContactPhoneNumber::staticType()

    QContactAddress address = detail;
    // address is now a default constructed QContactAddress
    // address.error() == QContactDetail::IncompatibleAssignmentError
    // address.value(QContactPhoneNumber::FieldNumber) is empty
    // address.definitionName() == QContactAddress::staticType()

    QContactAddress otherAddress = number;
    // otherAddress is now a default constructed QContactAddress
    // otherAddress.error() == QContactDetail::IncompatibleAssignmentError
    // otherAddress.value(QContactPhoneNumber::FieldNumber) is empty
    // otherAddress.definitionName() == QContactAddress::staticType()

See also QContact, QContactDetailDefinition, and Q_DECLARE_CUSTOM_CONTACT_DETAIL.


Member Function Documentation

QContactDetail::QContactDetail ()

Constructs a new, empty detail

QContactDetail::QContactDetail ( const QString & thisDefinitionId )

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

QContactDetail::QContactDetail ( const QContactDetail & other )

Constructs a detail that is a copy of other

QContactDetail::QContactDetail ( const QContactDetail & other, const QString & expectedDefinitionId )   [protected]

Constructs a detail that is a copy of other if other is of the expected definition identified by expectedDefinitionId, else constructs a new, empty detail of the definition identified by the expectedDefinitionId

QContactDetail::~QContactDetail ()   [virtual]

Frees the memory used by this detail

QContactDetail & QContactDetail::assign ( const QContactDetail & other, const QString & expectedDefinitionId )   [protected]

Assigns this detail to other if the definition of other is that identified by the given expectedDefinitionId, else assigns this detail to be a new, empty detail of the definition identified by the given expectedDefinitionId

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(QContactDetail::FieldContext);

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

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

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

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.

QList<QContactActionDescriptor> QContactDetail::preferredActions () const

Returns the list of preferred actions for this detail

See also setPreferredActions().

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

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

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

See also setValue().

void QContactDetail::setPreferredActions ( const QList<QContactActionDescriptor> & preferredActions )

Sets the preferred actions for this detail to be the given list of preferredActions

See also preferredActions().

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)

See also value().

T QContactDetail::value ( const QString & 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

See also setValue().

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

This is an overloaded function.

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

QVariantMap QContactDetail::values () const

Returns the values stored in this detail

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

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

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 and values of other are equal to those of this detail


Macro Documentation

Q_DECLARE_CUSTOM_CONTACT_DETAIL

Macro for simplifying declaring custom (leaf) detail classes.

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
        const char* DefinitionName;
        const char* FieldNumber;
        const char* FieldSubType;
        const char* SubTypeLandline;
        const char* SubTypeMobile;
        const char* SubTypeFacsimile;
        const char* SubTypePager;
        const char* SubTypeVoice;
        const char* SubTypeModem;
        const char* SubTypeVideo;
        const char* SubTypeCar;
        const char* SubTypeBulletinBoardSystem;
        const char* SubTypeMessagingCapable;
        const char* SubTypeAssistant;
        const char* SubTypeDtmfMenu;
    #else
        Q_DECLARE_CUSTOM_CONTACT_DETAIL(QContactPhoneNumber, "PhoneNumber")
        Q_DECLARE_LATIN1_LITERAL(FieldNumber, "PhoneNumber");
        Q_DECLARE_LATIN1_LITERAL(FieldSubTypes, "SubTypes");
        Q_DECLARE_LATIN1_LITERAL(SubTypeLandline, "Landline");
        Q_DECLARE_LATIN1_LITERAL(SubTypeMobile, "Mobile");
        Q_DECLARE_LATIN1_LITERAL(SubTypeFacsimile, "Facsimile");
        Q_DECLARE_LATIN1_LITERAL(SubTypePager, "Pager");
        Q_DECLARE_LATIN1_LITERAL(SubTypeVoice, "Voice");
        Q_DECLARE_LATIN1_LITERAL(SubTypeModem, "Modem");
        Q_DECLARE_LATIN1_LITERAL(SubTypeVideo, "Video");
        Q_DECLARE_LATIN1_LITERAL(SubTypeCar, "Car");
        Q_DECLARE_LATIN1_LITERAL(SubTypeBulletinBoardSystem, "BulletinBoardSystem");
        Q_DECLARE_LATIN1_LITERAL(SubTypeMessagingCapable, "MessagingCapable");
        Q_DECLARE_LATIN1_LITERAL(SubTypeAssistant, "Assistant");
        Q_DECLARE_LATIN1_LITERAL(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);}
    };

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 56
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 97
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 32
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 231
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Quarterly au hasard

Logo

Services de localisation et de cartographie avec Qt Mobility

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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.0-tp
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