Home · All Classes · All Functions ·

QContactManager Class Reference

The QContactManager class provides clients with access to contact information stored in a particular backend. More...

    #include <QContactManager>

Inherits QObject.


Public Types

enum Error { NoError, DoesNotExistError, AlreadyExistsError, InvalidDetailError, ..., UnspecifiedError }
enum ManagerFeature { Groups, ActionPreferences, DetailOrdering, Relationships, ..., Anonymous }

Public Functions

QContactManager ( const QString & managerName = QString(), const QMap<QString, QString> & parameters = 0, QObject * parent = 0 )
QContactManager ( const QString & managerName, int implementationVersion, const QMap<QString, QString> & parameters = 0, QObject * parent = 0 )
QContactManager ( QObject * parent )
~QContactManager ()
QContact contact ( const QContactLocalId & contactId, const QStringList & definitionRestrictions = QStringList() ) const
QList<QContactLocalId> contactIds ( const QList<QContactSortOrder> & sortOrders = QList<QContactSortOrder> () ) const
QList<QContactLocalId> contactIds ( const QContactFilter & filter, const QList<QContactSortOrder> & sortOrders = QList<QContactSortOrder> () ) const
QList<QContact> contacts ( const QList<QContactSortOrder> & sortOrders, const QStringList & definitionRestrictions ) const
QList<QContact> contacts ( const QContactFilter & filter, const QList<QContactSortOrder> & sortOrders, const QStringList & definitionRestrictions ) const
QContactDetailDefinition detailDefinition ( const QString & definitionName, const QString & contactType = QContactType::TypeContact ) const
QMap<QString, QContactDetailDefinition> detailDefinitions ( const QString & contactType = QContactType::TypeContact ) const
QContactManager::Error error () const
bool hasFeature ( QContactManager::ManagerFeature feature, const QString & contactType = QContactType::TypeContact ) const
bool isFilterSupported ( const QContactFilter & filter ) const
QString managerName () const
QMap<QString, QString> managerParameters () const
QString managerUri () const
int managerVersion () const
QList<QContactRelationship> relationships ( const QContactId & participantId, QContactRelationshipFilter::Role role = QContactRelationshipFilter::Either ) const
QList<QContactRelationship> relationships ( const QString & relationshipType = QString(), const QContactId & participantId = QContactId(), QContactRelationshipFilter::Role role = QContactRelationshipFilter::Either ) const
bool removeContact ( const QContactLocalId & contactId )
bool removeContacts ( QList<QContactLocalId> * contactIds, QMap<int, QContactManager::Error> * errorMap )
bool removeDetailDefinition ( const QString & definitionName, const QString & contactType = QContactType::TypeContact )
bool removeRelationship ( const QContactRelationship & relationship )
QList<QContactManager::Error> removeRelationships ( const QList<QContactRelationship> & relationships )
bool saveContact ( QContact * contact )
bool saveContacts ( QList<QContact> * contacts, QMap<int, QContactManager::Error> * errorMap )
bool saveDetailDefinition ( const QContactDetailDefinition & def, const QString & contactType = QContactType::TypeContact )
bool saveRelationship ( QContactRelationship * relationship )
QList<QContactManager::Error> saveRelationships ( QList<QContactRelationship> * relationships )
QContactLocalId selfContactId () const
bool setSelfContactId ( const QContactLocalId & contactId )
QStringList supportedContactTypes () const
QList<QVariant::Type> supportedDataTypes () const
QStringList supportedRelationshipTypes ( const QString & contactType = QContactType::TypeContact ) const
QString synthesizedDisplayLabel ( const QContact & contact ) const

Signals

void contactsAdded ( const QList<QContactLocalId> & contactIds )
void contactsChanged ( const QList<QContactLocalId> & contactIds )
void contactsRemoved ( const QList<QContactLocalId> & contactIds )
void dataChanged ()
void relationshipsAdded ( const QList<QContactLocalId> & affectedContactIds )
void relationshipsRemoved ( const QList<QContactLocalId> & affectedContactIds )
void selfContactIdChanged ( const QContactLocalId & oldId, const QContactLocalId & newId )

Static Public Members

QStringList availableManagers ()
QString buildUri ( const QString & managerName, const QMap<QString, QString> & params, int implementationVersion = -1 )
QContactManager * fromUri ( const QString & storeUri, QObject * parent = 0 )
bool parseUri ( const QString & uri, QString * pManagerId, QMap<QString, QString> * pParams )

Additional Inherited Members


Detailed Description

The QContactManager class provides clients with access to contact information stored in a particular backend.

This class provides adding, updating and removal of contacts. It also provides definitions for details and fields that can be found in contacts.


Member Type Documentation

enum QContactManager::Error

This enum specifies an error that occurred during the most recent operation:

ConstantValueDescription
QContactManager::NoError0The most recent operation was successful
QContactManager::DoesNotExistError1The most recent operation failed because the requested contact or detail definition does not exist
QContactManager::AlreadyExistsError2The most recent operation failed because the specified contact or detail definition already exists
QContactManager::InvalidDetailError3The most recent operation failed because the specified contact contains details which do not conform to their definition
QContactManager::InvalidRelationshipError4The most recent operation failed because the specified relationship is circular or references an invalid local contact
QContactManager::InvalidContactTypeError14The most recent operation failed because the contact type specified was not valid for the operation
QContactManager::LockedError5The most recent operation failed because the datastore specified is currently locked
QContactManager::DetailAccessError6The most recent operation failed because a detail was modified or removed and its access method does not allow that
QContactManager::PermissionsError7The most recent operation failed because the caller does not have permission to perform the operation
QContactManager::OutOfMemoryError8The most recent operation failed due to running out of memory
QContactManager::VersionMismatchError12The most recent operation failed because the backend of the manager is not of the required version
QContactManager::LimitReachedError13The most recent operation failed because the limit for that type of object has been reached
QContactManager::NotSupportedError9The most recent operation failed because the requested operation is not supported in the specified store
QContactManager::BadArgumentError10The most recent operation failed because one or more of the parameters to the operation were invalid
QContactManager::UnspecifiedError11The most recent operation failed for an undocumented reason

enum QContactManager::ManagerFeature

This enum describes the possible features that a particular manager may support

ConstantValueDescription
QContactManager::Groups0The manager supports all QContactGroup related operations, and emits the appropriate signals
QContactManager::ActionPreferences1The manager supports saving preferred details per action per contact
QContactManager::DetailOrdering6When a contact is retrieved, the manager will return the details in the same order in which they were saved
QContactManager::Relationships3The manager supports at least some types of relationships between contacts
QContactManager::ArbitraryRelationshipTypes4The manager supports relationships of arbitrary types between contacts
QContactManager::RelationshipOrdering5The manager supports relationships (re)ordering
QContactManager::MutableDefinitions2The manager supports saving, updating or removing detail definitions. Some built-in definitions may still be immutable
QContactManager::SelfContact7The manager supports the concept of saving a contact which represents the current user
QContactManager::ChangeLogs9The manager supports reporting of timestamps of changes, and filtering and sorting by those timestamps
QContactManager::Anonymous8The manager is isolated from other managers


Member Function Documentation

QContactManager::QContactManager ( const QString & managerName = QString(), const QMap<QString, QString> & parameters = 0, QObject * parent = 0 )

Constructs a QContactManager whose implementation is identified by managerName with the given parameters.

The parent QObject will be used as the parent of this QContactManager.

If an empty managerName is specified, the default implementation for the platform will be used.

QContactManager::QContactManager ( const QString & managerName, int implementationVersion, const QMap<QString, QString> & parameters = 0, QObject * parent = 0 )

Constructs a QContactManager whose backend has the name managerName and version implementationVersion, where the manager is constructed with the provided parameters.

The parent QObject will be used as the parent of this QContactManager.

If an empty managerName is specified, the default implementation for the platform will be instantiated. If the specified implementation version is not available, the manager with the name managerName with the default implementation version is instantiated.

QContactManager::QContactManager ( QObject * parent )

Constructs a QContactManager whose parent QObject is parent. The default implementation for the platform will be created.

QContactManager::~QContactManager ()

Frees the memory used by the QContactManager

QStringList QContactManager::availableManagers ()   [static]

Returns a list of available manager ids that can be used when constructing a QContactManager. If an empty id is specified to the constructor, the first value in this list will be used instead.

QString QContactManager::buildUri ( const QString & managerName, const QMap<QString, QString> & params, int implementationVersion = -1 )   [static]

Returns a URI that completely describes a manager implementation, datastore, and the parameters with which to instantiate the manager, from the given managerName, params and an optional implementationVersion

QContact QContactManager::contact ( const QContactLocalId & contactId, const QStringList & definitionRestrictions = QStringList() ) const

Returns the contact in the database identified by contactId. If the list of detail definition names definitionRestrictions given is non-empty, the contact returned will contain at least those details which are of a definition whose name is contained in the definitionRestrictions list. Note that the returned contact may also contain other details, but this function guarantees that all details whose definition name is included in the given list of definition names definitionRestrictions will be included in the returned contact.

QList<QContactLocalId> QContactManager::contactIds ( const QList<QContactSortOrder> & sortOrders = QList<QContactSortOrder> () ) const

Return the list of added contact ids, sorted according to the given list of sortOrders

QList<QContactLocalId> QContactManager::contactIds ( const QContactFilter & filter, const QList<QContactSortOrder> & sortOrders = QList<QContactSortOrder> () ) const

Returns a list of contact ids that match the given filter, sorted according to the given list of sortOrders. Depending on the backend, this filtering operation may involve retrieving all the contacts.

QList<QContact> QContactManager::contacts ( const QList<QContactSortOrder> & sortOrders, const QStringList & definitionRestrictions ) const

Returns the list of contacts stored in the manager sorted according to the given list of sortOrders. If the given list of detail definition names definitionRestrictions is empty, each contact returned will include all of the details which are stored in it, otherwise only those details which are of a definition whose name is included in the definitionRestrictions list will be included.

QList<QContact> QContactManager::contacts ( const QContactFilter & filter, const QList<QContactSortOrder> & sortOrders, const QStringList & definitionRestrictions ) const

Returns a list of contacs that match the given filter, sorted according to the given list of sortOrders. Depending on the backend, this filtering operation may involve retrieving all the contacts. If the given list of detail definition names definitionRestrictions is empty, each contact returned will include all of the details which are stored in it, otherwise only those details which are of a definition whose name is included in the definitionRestrictions list will be included.

void QContactManager::contactsAdded ( const QList<QContactLocalId> & contactIds )   [signal]

This signal is emitted at some point once the contacts identified by contactIds have been added to a datastore managed by this manager. This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.

void QContactManager::contactsChanged ( const QList<QContactLocalId> & contactIds )   [signal]

This signal is emitted at some point once the contacts identified by contactIds have been modified in a datastore managed by this manager. This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.

void QContactManager::contactsRemoved ( const QList<QContactLocalId> & contactIds )   [signal]

This signal is emitted at some point once the contacts identified by contactIds have been removed from a datastore managed by this manager. This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.

void QContactManager::dataChanged ()   [signal]

This signal is emitted by the manager if its internal state changes, and it is unable to determine the changes which occurred, or if the manager considers the changes to be radical enough to require clients to reload all data. If this signal is emitted, no other signals will be emitted for the associated changes.

QContactDetailDefinition QContactManager::detailDefinition ( const QString & definitionName, const QString & contactType = QContactType::TypeContact ) const

Returns the definition identified by the given definitionName that is valid for the contacts whose type is the given contactType in this store, or a default-constructed QContactDetailDefinition if no such definition exists

QMap<QString, QContactDetailDefinition> QContactManager::detailDefinitions ( const QString & contactType = QContactType::TypeContact ) const

Returns a map of identifier to detail definition for the registered detail definitions which are valid for contacts whose type is the given contactType which are valid for the contacts in this store

QContactManager::Error QContactManager::error () const

Return the error code of the most recent operation

QContactManager * QContactManager::fromUri ( const QString & storeUri, QObject * parent = 0 )   [static]

Constructs a QContactManager whose implementation, store and parameters are specified in the given storeUri, and whose parent object is parent.

bool QContactManager::hasFeature ( QContactManager::ManagerFeature feature, const QString & contactType = QContactType::TypeContact ) const

Returns true if the given feature feature is supported by the manager, for the specified type of contact contactType

bool QContactManager::isFilterSupported ( const QContactFilter & filter ) const

Returns true if the given filter is supported natively by the manager, and false if the filter behaviour would be emulated.

Note: In some cases, the behaviour of an unsupported filter cannot be emulated. For example, a filter that requests contacts that have changed since a given time depends on having that information available. In these cases, the filter will fail.

QString QContactManager::managerName () const

Returns the manager name for this QContactManager

QMap<QString, QString> QContactManager::managerParameters () const

Return the parameters relevant to the creation of this QContactManager

QString QContactManager::managerUri () const

Return the uri describing this QContactManager, consisting of the manager name and any parameters.

int QContactManager::managerVersion () const

Returns the engine backend implementation version number

bool QContactManager::parseUri ( const QString & uri, QString * pManagerId, QMap<QString, QString> * pParams )   [static]

Splits the given uri into the manager, store, and parameters that it describes, and places the information into the memory addressed by pManagerId and pParams respectively. Returns true if uri could be split successfully, otherwise returns false

QList<QContactRelationship> QContactManager::relationships ( const QContactId & participantId, QContactRelationshipFilter::Role role = QContactRelationshipFilter::Either ) const

Returns a list of relationships in which the contact identified by the given participantId participates in the given role. If participantId is the default-constructed id, role is ignored and all relationships are returned.

QList<QContactRelationship> QContactManager::relationships ( const QString & relationshipType = QString(), const QContactId & participantId = QContactId(), QContactRelationshipFilter::Role role = QContactRelationshipFilter::Either ) const

Returns a list of relationships of the given relationshipType in which the contact identified by the given participantId participates in the given role. If participantId is the default-constructed id, role is ignored and all relationships of the given relationshipType are returned. If relationshipType is empty, relationships of any type are returned.

void QContactManager::relationshipsAdded ( const QList<QContactLocalId> & affectedContactIds )   [signal]

This signal is emitted at some point after relationships have been added to the manager which involve the contacts identified by affectedContactIds. This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.

void QContactManager::relationshipsRemoved ( const QList<QContactLocalId> & affectedContactIds )   [signal]

This signal is emitted at some point after relationships have eben removed from the manager which involve the contacts identified by affectedContactIds. This signal must not be emitted if the dataChanged() signal was previously emitted for these changes.

bool QContactManager::removeContact ( const QContactLocalId & contactId )

Remove the contact identified by contactId from the database, and also removes any relationships in which the contact was involved. Returns true if the contact was removed successfully, otherwise returns false.

bool QContactManager::removeContacts ( QList<QContactLocalId> * contactIds, QMap<int, QContactManager::Error> * errorMap )

Remove every contact whose id is contained in the list of contacts ids contactIds. Returns true if all contacts were removed successfully, otherwise false.

The manager might populate errorMap (the map of indices of the contactIds list to the error which occurred when saving the contact at that index) for every index for which the contact could not be removed, if it is able. The QContactManager::error() function will only return QContactManager::NoError if all contacts were removed successfully.

For each contact that was removed succesfully, the corresponding id in the contactIds list will be retained but set to zero. The id of contacts that were not successfully removed will be left alone.

Any contact that was removed successfully will have the relationships in which it was involved removed also.

See also QContactManager::removeContact().

bool QContactManager::removeDetailDefinition ( const QString & definitionName, const QString & contactType = QContactType::TypeContact )

Removes the detail definition identified by definitionName from the database, which is valid for contacts whose type is the given contactType. Returns true if the definition was removed successfully, otherwise returns false

bool QContactManager::removeRelationship ( const QContactRelationship & relationship )

Removes the given relationship from the manager. If the relationship exists in the manager, the relationship will be removed, the error will be set to QContactManager::NoError and this function will return true. If no such relationship exists in the manager, the error will be set to QContactManager::DoesNotExistError and this function will return false.

The priority of the relationship is ignored when determining existence of the relationship.

QList<QContactManager::Error> QContactManager::removeRelationships ( const QList<QContactRelationship> & relationships )

Removes the given relationships from the database and returns a list of error codes.

bool QContactManager::saveContact ( QContact * contact )

Adds the given contact to the database if contact has a default-constructed id, or an id with the manager URI set to the URI of this manager and a local id of zero.

If the manager URI of the id of the contact is neither empty nor equal to the URI of this manager, or local id of the contact is non-zero but does not exist in the manager, the operation will fail and calling error() will return QContactManager::DoesNotExistError.

Alternatively, the function will update the existing contact in the database if contact has a non-zero id and currently exists in the database.

If the contact contains one or more details whose definitions have not yet been saved with the manager, the operation will fail and calling error() will return QContactManager::UnsupportedError.

If the contact has had its relationships reordered, the manager will check to make sure that every relationship that the contact is currently involved in is included in the reordered list, and that no relationships which either do not involve the contact, or have not been saved in the manager are included in the list. If these conditions are not met, the function will return false and calling error() will return QContactManager::InvalidRelationshipError.

Returns false on failure, or true on success. On successful save of a contact with an id of zero, its id will be set to a new, valid id with the manager URI set to the URI of this manager, and the local id set to a new, valid local id. The manager will automatically synthesize the display label of the contact when it is saved. The manager is not required to fetch updated details of the contact on save, and as such, clients should fetch a contact if they want the most up-to-date information by calling QContactManager::contact().

See also managerUri().

bool QContactManager::saveContacts ( QList<QContact> * contacts, QMap<int, QContactManager::Error> * errorMap )

Adds the list of contacts given by contacts list to the database. Returns true if the contacts were saved successfully, otherwise false.

The manager might populate errorMap (the map of indices of the contacts list to the error which occurred when saving the contact at that index) for every index for which the contact could not be saved, if it is able. The QContactManager::error() function will only return QContactManager::NoError if all contacts were saved successfully.

For each newly saved contact that was successful, the id of the contact in the contacts list will be updated with the new value. If a failure occurs when saving a new contact, the id will be cleared.

See also QContactManager::saveContact().

bool QContactManager::saveDetailDefinition ( const QContactDetailDefinition & def, const QString & contactType = QContactType::TypeContact )

Persists the given definition def in the database, which is valid for contacts whose type is the given contactType. Returns true if the definition was saved successfully, otherwise returns false

bool QContactManager::saveRelationship ( QContactRelationship * relationship )

Saves the given relationship in the database. If the relationship already exists in the database, this function will return false and the error will be set to QContactManager::AlreadyExistsError. If the relationship is saved successfully, this function will return true and error will be set to QContactManager::NoError. Note that relationships cannot be updated directly using this function; in order to update a relationship, you must remove the old relationship, make the required modifications, and then save it.

The given relationship is invalid if it is circular (one of the destination contacts is also the source contact), or if it references a non-existent local contact (either source or destination). If the given relationship is invalid, the function will return false and the error will be set to QContactManager::InvalidRelationshipError. If the given relationship could not be saved in the database (due to backend limitations) the function will return false and error will be set to QContactManager::NotSupportedError.

If any destination contact manager URI is not set in the relationship, these will be automatically set to the URI of this manager, before the relationship is saved.

QList<QContactManager::Error> QContactManager::saveRelationships ( QList<QContactRelationship> * relationships )

Saves the given relationships in the database and returns a list of error codes.

QContactLocalId QContactManager::selfContactId () const

Returns the id of the "self" contact which has previously been set. If no "self" contact has been set, or if the self contact was removed from the manager after being set, or if the backend does not support the concept of a "self" contact, an invalid id will be returned and the error will be set to QContactManager::DoesNotExistError.

See also setSelfContactId().

void QContactManager::selfContactIdChanged ( const QContactLocalId & oldId, const QContactLocalId & newId )   [signal]

This signal is emitted at some point after the id of the self-contact is changed from oldId to newId in the manager. If the newId is the invalid, zero id, then the self contact was deleted or no self contact exists. This signal must not be emitted if the dataChanged() signal was previously emitted for this change.

bool QContactManager::setSelfContactId ( const QContactLocalId & contactId )

Sets the id of the "self" contact to the given contactId. Returns true if the "self" contact id was set successfully. If the given contactId does not identify a contact stored in this manager, the error will be set to QContactManager::DoesNotExistError and the function will return false; if the backend does not support the concept of a "self" contact then the error will be set to QContactManager::NotSupportedError and the function will return false.

See also selfContactId().

QStringList QContactManager::supportedContactTypes () const

Returns the list of contact types which are supported by this manager. This is a convenience function, equivalent to retrieving the allowable values for the QContactType::FieldType field of the QContactType definition which is valid in this manager.

QList<QVariant::Type> QContactManager::supportedDataTypes () const

Returns the list of data types supported by the manager

QStringList QContactManager::supportedRelationshipTypes ( const QString & contactType = QContactType::TypeContact ) const

Returns the list of relationship types which are supported by this manager for contacts of the given contactType. If the backend does not support the QContactManager::Relationships feature, this list should be empty. If the backend supports the QContactManager::Relationships feature and also supports the QContactManager::ArbitraryRelationshipTypes feature, the list will contain the natively supported (well-known) relationship types contained in the list, but clients are able to add relationships of any custom type also.

QString QContactManager::synthesizedDisplayLabel ( const QContact & contact ) const

Returns a display label for a contact which is synthesized from its details in a platform-specific manner


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Mobility Project 1.0.0