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  · 

QContactAbstractRequest Class Reference

The QContactAbstractRequest class provides a mechanism for asynchronous requests to be made of a manager if it supports them. More...

 #include <QContactAbstractRequest>

Inherits: QObject.

Inherited by: QContactDetailDefinitionFetchRequest, QContactDetailDefinitionRemoveRequest, QContactDetailDefinitionSaveRequest, QContactFetchByIdRequest, QContactFetchRequest, QContactLocalIdFetchRequest, QContactRelationshipFetchRequest, QContactRelationshipRemoveRequest, QContactRelationshipSaveRequest, QContactRemoveRequest, and QContactSaveRequest.

This class was introduced in Qt Mobility 1.0.

Public Types

enum RequestType { InvalidRequest, ContactFetchRequest, ContactLocalIdFetchRequest, ContactRemoveRequest, ..., ContactFetchByIdRequest }
enum State { InactiveState, ActiveState, CanceledState, FinishedState }

Public Functions

~QContactAbstractRequest ()
QContactManager::Error error () const
bool isActive () const
bool isCanceled () const
bool isFinished () const
bool isInactive () const
QContactManager * manager () const
void setManager ( QContactManager * manager )
State state () const
RequestType type () const
  • 29 public functions inherited from QObject

Public Slots

bool cancel ()
bool start ()
bool waitForFinished ( int msecs = 0 )
  • 1 public slot inherited from QObject

Signals

void resultsAvailable ()
void stateChanged ( QContactAbstractRequest::State newState )

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QContactAbstractRequest class provides a mechanism for asynchronous requests to be made of a manager if it supports them.

It allows a client to asynchronously request some functionality of a particular QContactManager. Instances of the class will emit signals when the state of the request changes, or when more results become available.

Clients should not attempt to create instances of this class directly, but should instead use the use-case-specific classes derived from this class.

All such request classes have a similar interface: clients set the parameters of the asynchronous call, including which manager the request will be made of, and then call the start() slot of the request. The manager will then enqueue or begin to process the request, at which point the request's state will transition from InactiveState to ActiveState. After any state transition, the request will emit the stateChanged() signal. The manager may periodically update the request with results, at which point the request will emit the resultsAvailable() signal. These results are not guaranteed to have a stable ordering. Error information is considered a result, so some requests will emit the resultsAvailable() signal even if no results are possible from the request (for example, a contact remove request) when the manager updates the request with information about any errors which may have occurred.

Please see the class documentation of each of the use-case-specific classes derived from this class for information about how to retrieve the results of a request (including error information). In all cases, those functions are synchronous, and will return the cached result set with which the manager has updated the request instance if the resultsAvailable() signal has been emitted.

Clients can choose which signals they wish to handle from a request. If the client is not interested in interim results, they can choose to handle only the stateChanged() signal, and in the slot to which that signal is connected, check whether the state has changed to either FinishedState or CanceledState (both of which signify that the manager has finished handling the request, and that the request will not be updated with any more results). If the client is not interested in any results (including error information), they may choose to delete the request after calling start(), or simply not connect the request's signals to any slots.

If the request is allocated via operator new, the client must delete the request when they are no longer using it in order to avoid leaking memory. That is, the client retains ownership of the request.

The client may delete a heap-allocated request in various ways: by deleting it directly (but not within a slot connected to a signal emitted by the request), or by using the deleteLater() slot to schedule the request for deletion when control returns to the event loop (from within a slot connected to a signal emitted by the request, for example stateChanged()).

An active request may be deleted by the client, but the client will not receive any notifications about whether the request succeeded or not, nor any results of the request.

Because clients retain ownership of any request object, and may delete a request object at any time, manager engine implementors must be careful to ensure that they do not assume that a request has not been deleted at some point during processing of a request, particularly if the engine has a multithreaded implementation. It is suggested that engine implementors read the Qt Contacts Manager Engines documentation for more information on this topic.

Member Type Documentation

enum QContactAbstractRequest::RequestType

Enumerates the various possible types of asynchronous requests

ConstantValueDescription
QContactAbstractRequest::InvalidRequest0An invalid request
QContactAbstractRequest::ContactFetchRequest1A request to fetch a list of contacts
QContactAbstractRequest::ContactLocalIdFetchRequest2A request to fetch a list of local contact ids
QContactAbstractRequest::ContactRemoveRequest3A request to remove a list of contacts
QContactAbstractRequest::ContactSaveRequest4A request to save a list of contacts
QContactAbstractRequest::DetailDefinitionFetchRequest5A request to fetch a collection of detail definitions
QContactAbstractRequest::DetailDefinitionRemoveRequest6A request to remove a list of detail definitions
QContactAbstractRequest::DetailDefinitionSaveRequest7A request to save a list of detail definitions
QContactAbstractRequest::RelationshipFetchRequest8A request to fetch relationships between contacts
QContactAbstractRequest::RelationshipRemoveRequest9A request to remove any relationships which match the request criteria
QContactAbstractRequest::RelationshipSaveRequest10A request to save a list of relationships
QContactAbstractRequest::ContactFetchByIdRequest11A request to fetch a list of contacts given a list of ids

enum QContactAbstractRequest::State

Enumerates the various states that a request may be in at any given time

ConstantValueDescription
QContactAbstractRequest::InactiveState0Operation not yet started
QContactAbstractRequest::ActiveState1Operation started, not yet finished
QContactAbstractRequest::CanceledState2Operation is finished due to cancellation
QContactAbstractRequest::FinishedState3Operation successfully completed

Member Function Documentation

QContactAbstractRequest::~QContactAbstractRequest ()

Cleans up the memory used by this request

bool QContactAbstractRequest::cancel () [slot]

Attempts to cancel the request. Returns false if the request is not in the QContactAbstractRequest::Active state, or if the request is unable to be cancelled by the manager engine; otherwise returns true.

This function was introduced in Qt Mobility 1.0.

QContactManager::Error QContactAbstractRequest::error () const

Returns the overall error of the most recent asynchronous operation

This function was introduced in Qt Mobility 1.0.

bool QContactAbstractRequest::isActive () const

Returns true if the request is in the QContactAbstractRequest::ActiveState state; otherwise, returns false

This function was introduced in Qt Mobility 1.0.

See also state().

bool QContactAbstractRequest::isCanceled () const

Returns true if the request is in the QContactAbstractRequest::CanceledState; otherwise, returns false

This function was introduced in Qt Mobility 1.0.

See also state().

bool QContactAbstractRequest::isFinished () const

Returns true if the request is in the QContactAbstractRequest::FinishedState; otherwise, returns false

This function was introduced in Qt Mobility 1.0.

See also state().

bool QContactAbstractRequest::isInactive () const

Returns true if the request is in the QContactAbstractRequest::InactiveState state; otherwise, returns false

This function was introduced in Qt Mobility 1.0.

See also state().

QContactManager * QContactAbstractRequest::manager () const

Returns a pointer to the manager of which this request instance requests operations

This function was introduced in Qt Mobility 1.0.

See also setManager().

void QContactAbstractRequest::resultsAvailable () [signal]

This signal is emitted when new results are available. Results can include the operation error which may be accessed via error(), or derived-class-specific results which are accessible through the derived class API.

This function was introduced in Qt Mobility 1.0.

See also error().

void QContactAbstractRequest::setManager ( QContactManager * manager )

Sets the manager of which this request instance requests operations to manager

If the request is currently active, this function will return without updating the manager object.

This function was introduced in Qt Mobility 1.0.

See also manager().

bool QContactAbstractRequest::start () [slot]

Attempts to start the request. Returns false if the request is not in the QContactAbstractRequest::Inactive, QContactAbstractRequest::Finished or QContactAbstractRequest::Cancelled states, or if the request was unable to be performed by the manager engine; otherwise returns true.

This function was introduced in Qt Mobility 1.0.

State QContactAbstractRequest::state () const

Returns the current state of the request.

This function was introduced in Qt Mobility 1.0.

void QContactAbstractRequest::stateChanged ( QContactAbstractRequest::State newState ) [signal]

This signal is emitted when the state of the request is changed. The new state of the request will be contained in newState.

This function was introduced in Qt Mobility 1.0.

RequestType QContactAbstractRequest::type () const

Returns the type of this asynchronous request

This function was introduced in Qt Mobility 1.0.

bool QContactAbstractRequest::waitForFinished ( int msecs = 0 ) [slot]

Blocks until the request has been completed by the manager engine, or until msecs milliseconds has elapsed. If msecs is zero or negative, this function will block until the request is complete, regardless of how long it takes. Returns true if the request was cancelled or completed successfully within the given period, otherwise false. Some backends are unable to support this operation safely, and will return false immediately.

Note that any signals generated while waiting for the request to complete may be queued and delivered some time after this function has returned, when the calling thread's event loop is dispatched. If your code depends on your slots being invoked, you may need to process events after calling this function.

This function was introduced in Qt Mobility 1.0.

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 94
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  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. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

Livre blanc de l'outillage de Qt Quick

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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.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