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  · 

Contacts Asynchronous API

Introduction

The Contacts Asynchronous API enables a client to asynchronously fetch, update, or remove contact, relationship or schema data from a contact manager. Use of the asynchronous API offers the programmer greater flexibility when requesting information from remote or slow local datastores.

Using the API

The asynchronous API offered by the Contacts module is available through classes derived from the QContactAbstractRequest class. It consists of three major sections:

  • Contact Manipulation
  • Relationship Manipulation
  • Schema Manipulation

The functionality offered by the synchronous API in these three categories is also available through the asynchronous API. There is one category of functionality which is not provided by the asynchronous API which is provided by the synchronous API: some information and reporting functionality is only provided through the synchronous API.

For detailed information about the information and reporting functionality provided, please refer to the documentation for the Contacts Synchronous API.

The functions to set and retrieve the id of the self-contact are also only provided by the synchronous API.

Contact Manipulation

The most common type of operation that clients will perform involves retrieval or modification of contacts. For in-depth information about contact manipulation, please refer to the Contacts Synchronous API.

There are four different types of operation which are supported by the asynchronous API:

  • Fetch contact ids
  • Fetch contacts
  • Save contacts (create or update)
  • Remove contacts

These operations are supported via the QContactLocalIdFetchRequest, QContactFetchRequest, QContactSaveRequest and QContactRemoveRequest classes, respectively.

The synchronous API offered by the QContactManager class to allow manipulation of contacts consists of the following functions:

Relationship Manipulation

Contacts may be related in various ways. The contacts API allows clients to define relationships between contacts. For in-depth information about relationship manipulation, please refer to the Contacts Synchronous API.

There are three different types of operation which are supported by the asynchronous API:

  • Fetch relationships
  • Save relationships (create or update, if supported by the backend)
  • Remove relationships (if supported by the backend)

These operations are supported via the QContactRelationshipFetchRequest, QContactRelationshipSaveRequest and QContactRelationshipRemoveRequest classes respectively.

The synchronous API offered by the QContactManager class to allow manipulation of relationships consists of the following functions:

Schema Manipulation

The schema supported by a plugin is the list of detail definitions which are supported by the plugin. For in-depth information about the schema, please refer to the Contacts Synchronous API.

There are three different types of operation which are supported by the asynchronous API:

  • Fetch detail definitions
  • Save detail definitions (create or update, if supported by the backend)
  • Remove detail definitions (if supported by the backend)

These operations are supported via the the QContactDetailDefinitionFetchRequest, QContactDetailDefinitionSaveRequest and QContactDetailDefinitionRemoveRequest classes, respectively.

The synchronous API offered by the QContactManager class to allow manipulation of the schema consists of the following functions:

Examples Of Usage

Fetching Contacts

The client sets up a request for contacts matching a specific criteria from a particular manager.

Results from the request will be displayed to the user as they are received.

 void RequestExample::performRequest()
 {
     // retrieve any contact whose first name is "Alice"
     QContactDetailFilter dfil;
     dfil.setDetailDefinitionName(QContactName::DefinitionName, QContactName::FieldFirstName);
     dfil.setValue("Alice");
     dfil.setMatchFlags(QContactFilter::MatchExactly);

     // m_fetchRequest was created with m_fetchRequest = new QContactFetchRequest() in the ctor.
     m_fetchRequest->setManager(this->m_manager); // m_manager is a QContactManager*.
     m_fetchRequest->setFilter(dfil);
     connect(m_fetchRequest, SIGNAL(resultsAvailable()), this, SLOT(printContacts()));
     connect(m_fetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)),
             this, SLOT(stateChanged(QContactAbstractRequest::State)));
     if (!m_fetchRequest->start()) {
         qDebug() << "Unable to request contacts!";
         QCoreApplication::exit(0);
     } else {
         qDebug() << "Requested contacts; awaiting results...";
     }
 }

 void RequestExample::printContacts()
 {
     QList<QContact> results = m_fetchRequest->contacts();
     for (m_previousLastIndex = 0; m_previousLastIndex < results.size(); ++m_previousLastIndex) {
         qDebug() << "Found an Alice:" << results.at(m_previousLastIndex).displayLabel();
     }
 }

 void RequestExample::stateChanged(QContactAbstractRequest::State state)
 {
     // once we've finished retrieving results, stop processing events.
     if (state == QContactAbstractRequest::FinishedState
         || state == QContactAbstractRequest::CanceledState) {
         qDebug() << "Finished displaying asynchronously retrieved contacts!";
         QCoreApplication::exit(0);
     }
 }

Other Asynchronous Operations

All other asynchronous operations are performed in a similar manner to the previous example. A request of the desired type (which is derived from QContactAbstractRequest) is created, certain criteria are set which determine the intent of the request, and the signals of the request are connected to slots which deals with the results. The request can then be started.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();
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 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. 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.1
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