diff options
Diffstat (limited to 'doc/src/snippets/qtcontactsdocsample')
4 files changed, 544 insertions, 35 deletions
diff --git a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp index f49695175f..263f4df4c0 100644 --- a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp +++ b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp @@ -50,6 +50,10 @@ QTM_USE_NAMESPACE +static void loadDefault(); +static void queryManagerCapabilities(); +static void contactDetailManipulation(); +static void contactManipulation(); static void addContact(QContactManager*); static void callContact(QContactManager*); static void matchCall(QContactManager*, const QString&); @@ -88,9 +92,192 @@ int main(int argc, char *argv[]) app.exec(); delete cm; + // more doc snippet examples + loadDefault(); + queryManagerCapabilities(); + contactDetailManipulation(); + contactManipulation(); + + // async doc snippet examples + AsyncRequestExample example; + QTimer::singleShot(10, &example, SLOT(performRequests())); + app.exec(); + return 0; } +void loadDefault() +{ +//! [Loading the default manager for the platform] + QContactManager stackDefaultContactManager; +//! [Loading the default manager for the platform] + +//! [Loading the default manager for the platform on heap] + QContactManager *heapDefaultContactManager = new QContactManager; + // ... perform contact manipulation + delete heapDefaultContactManager; +//! [Loading the default manager for the platform on heap] +} + +void queryManagerCapabilities() +{ +//! [Querying a manager for capabilities] + QContactManager cm; + qDebug() << "The default manager for the platform is:" << cm.managerName(); + qDebug() << "It" << (cm.isRelationshipTypeSupported(QContactRelationship::HasAssistant) ? "supports" : "does not support") << "assistant relationships."; + qDebug() << "It" << (cm.supportedContactTypes().contains(QContactType::TypeGroup) ? "supports" : "does not support") << "groups."; + qDebug() << "It" << (cm.hasFeature(QContactManager::MutableDefinitions) ? "supports" : "does not support") << "mutable detail definitions."; +//! [Querying a manager for capabilities] +} + +void contactDetailManipulation() +{ +//! [Adding a detail to a contact] + QContact exampleContact; + + QContactName nameDetail; + nameDetail.setFirstName("Adam"); + nameDetail.setLastName("Unlikely"); + + QContactPhoneNumber phoneNumberDetail; + phoneNumberDetail.setNumber("+123 4567"); + + exampleContact.saveDetail(&nameDetail); + exampleContact.saveDetail(&phoneNumberDetail); +//! [Adding a detail to a contact] + +//! [Updating a detail in a contact] + phoneNumberDetail.setNumber("+123 9876"); + exampleContact.saveDetail(&phoneNumberDetail); // overwrites old value on save +//! [Updating a detail in a contact] + +//! [Removing a detail from a contact] + exampleContact.removeDetail(&phoneNumberDetail); +//! [Removing a detail from a contact] +} + +void contactManipulation() +{ + QContactManager m_manager("memory"); +//! [Synchronously creating a new contact in a manager] + QContact exampleContact; + + QContactName nameDetail; + nameDetail.setFirstName("Adam"); + nameDetail.setLastName("Unlikely"); + + QContactPhoneNumber phoneNumberDetail; + phoneNumberDetail.setNumber("+123 4567"); + + exampleContact.saveDetail(&nameDetail); + exampleContact.saveDetail(&phoneNumberDetail); + + // save the newly created contact in the manager + if (!m_manager.saveContact(&exampleContact)) + qDebug() << "Error" << m_manager.error() << "occurred whilst saving contact!"; +//! [Synchronously creating a new contact in a manager] + +//! [Synchronously filtering contacts from a manager] + QList<QContact> results = m_manager.contacts(QContactPhoneNumber::match("+123 4567")); +//! [Synchronously filtering contacts from a manager] + +//! [Synchronously retrieving an existing contact from a manager] + QContact existing = m_manager.contact(exampleContact.localId()); +//! [Synchronously retrieving an existing contact from a manager] + +//! [Synchronously updating an existing contact in a manager] + phoneNumberDetail.setNumber("+123 9876"); + exampleContact.saveDetail(&phoneNumberDetail); + m_manager.saveContact(&exampleContact); +//! [Synchronously updating an existing contact in a manager] + +//! [Synchronously removing a contact from a manager] + m_manager.removeContact(exampleContact.localId()); +//! [Synchronously removing a contact from a manager] + +//! [Synchronously creating a new relationship between two contacts] + // first, create the group and the group member + QContact exampleGroup; + exampleGroup.setType(QContactType::TypeGroup); + QContactNickname groupName; + groupName.setNickname("Example Group"); + exampleGroup.saveDetail(&groupName); + + QContact exampleGroupMember; + QContactName groupMemberName; + groupMemberName.setFirstName("Member"); + exampleGroupMember.saveDetail(&groupMemberName); + + // second, save those contacts in the manager + QMap<int, QContactManager::Error> errorMap; + QList<QContact> saveList; + saveList << exampleGroup << exampleGroupMember; + m_manager.saveContacts(&saveList, &errorMap); + + // third, create the relationship between those contacts + QContactRelationship groupRelationship; + groupRelationship.setFirst(exampleGroup.id()); + groupRelationship.setRelationshipType(QContactRelationship::HasMember); + groupRelationship.setSecond(exampleGroupMember.id()); + + // finally, save the relationship in the manager + m_manager.saveRelationship(&groupRelationship); +//! [Synchronously creating a new relationship between two contacts] + +//! [Synchronously retrieving relationships between contacts] + QList<QContactRelationship> groupRelationships = m_manager.relationships(QContactRelationship::HasMember, exampleGroup.id(), QContactRelationship::First); + QList<QContactRelationship> result; + for (int i = 0; i < groupRelationships.size(); i++) { + if (groupRelationships.at(i).second() == exampleGroupMember.id()) { + result.append(groupRelationships.at(i)); + } + } +//! [Synchronously retrieving relationships between contacts] + +//! [Retrieving relationships from cache] + exampleGroup = m_manager.contact(exampleGroup.localId()); // refresh the group contact + groupRelationships = exampleGroup.relationships(QContactRelationship::HasMember); + for (int i = 0; i < groupRelationships.size(); i++) { + if (groupRelationships.at(i).second() == exampleGroupMember.id()) { + result.append(groupRelationships.at(i)); + } + } +//! [Retrieving relationships from cache] + +//! [Synchronously providing a fetch hint] + QContactFetchHint hasMemberRelationshipsOnly; + hasMemberRelationshipsOnly.setRelationshipTypesHint(QStringList(QContactRelationship::HasMember)); + + // retrieve all contacts, with no specified sort order, requesting that + // HasMember relationships be included in the cache of result contacts + QList<QContact> allContacts = m_manager.contacts(QContactFilter(), QList<QContactSortOrder>(), hasMemberRelationshipsOnly); +//! [Synchronously providing a fetch hint] + +//! [Synchronously removing a relationship] + m_manager.removeRelationship(groupRelationship); +//! [Synchronously removing a relationship] + +//! [Synchronously querying the schema supported by a manager] + QMap<QString, QContactDetailDefinition> definitions = m_manager.detailDefinitions(); + qDebug() << "This manager" + << (definitions.value(QContactName::DefinitionName).fields().contains(QContactName::FieldCustomLabel) ? "supports" : "does not support") + << "the custom label field of QContactName"; +//! [Synchronously querying the schema supported by a manager] + +//! [Synchronously modifying the schema supported by a manager] + // modify the name definition, adding a patronym field + QContactDetailDefinition nameDefinition = definitions.value(QContactName::DefinitionName); + QContactDetailFieldDefinition fieldPatronym; + fieldPatronym.setDataType(QVariant::String); + nameDefinition.insertField("Patronym", fieldPatronym); + + // save the updated definition in the manager if supported... + if (m_manager.hasFeature(QContactManager::MutableDefinitions)) { + m_manager.saveDetailDefinition(nameDefinition, QContactType::TypeContact); + } +//! [Synchronously modifying the schema supported by a manager] +} + //! [Creating a new contact] void addContact(QContactManager* cm) { @@ -362,45 +549,18 @@ void RequestExample::stateChanged(QContactAbstractRequest::State state) } //! [Asynchronous contact request] -//! [Loading a specific manager backend] void loadManager() { - QContactManager* cm = new QContactManager("KABC"); - QList<QContactLocalId> contactIds = cm->contactIds(); - if (!contactIds.isEmpty()) { - QContact a = cm->contact(contactIds.first()); - qDebug() << "This manager contains" << a.displayLabel(); - } else { - qDebug() << "This manager contains no contacts"; - } - - delete cm; -} //! [Loading a specific manager backend] + QContactManager contactManager("KABC"); +//! [Loading a specific manager backend] +} -//! [Loading a specific manager backend with parameters] void loadManagerWithParameters() { +//! [Loading a specific manager backend with parameters] QMap<QString, QString> parameters; parameters.insert("Settings", "~/.qcontactmanager-kabc-settings.ini"); - QContactManager* cm = new QContactManager("KABC", parameters); - QMap<QString, QContactDetailDefinition> definitions = cm->detailDefinitions(); - - qDebug() << "This backend currently supports the following detail definitions:"; - QList<QContactDetailDefinition> allDefinitions = definitions.values(); - foreach (const QContactDetailDefinition& defn, allDefinitions) { - QMap<QString, QContactDetailFieldDefinition> fields = defn.fields(); - foreach (const QString& fieldKey, fields.keys()) { - QList<QVariant> allowableValues = fields.value(fieldKey).allowableValues(); - qDebug() << "\t" << fieldKey << "(" << fields.value(fieldKey).dataType() << "):"; - if (allowableValues.isEmpty()) { - qDebug() << "\t\tAny Value Permitted"; - } else { - qDebug() << allowableValues; - } - } - } - - delete cm; -} + QContactManager contactManager("KABC", parameters); //! [Loading a specific manager backend with parameters] +} diff --git a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.pro b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.pro index bf99cf2b58..b74edd13fc 100644 --- a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.pro +++ b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.pro @@ -19,5 +19,5 @@ QMAKE_RPATHDIR+=$$OUTPUT_DIR/lib CONFIG += mobility console MOBILITY = contacts -SOURCES += qtcontactsdocsample.cpp +SOURCES += qtcontactsdocsample.cpp qtcontactsdocsampleasync.cpp HEADERS += requestexample.h diff --git a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsampleasync.cpp b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsampleasync.cpp new file mode 100644 index 0000000000..9cd844c88c --- /dev/null +++ b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsampleasync.cpp @@ -0,0 +1,313 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmobilityglobal.h" +#include "qtcontacts.h" +#include "requestexample.h" + +#include <QDebug> +#include <QCoreApplication> +#include <QObject> +#include <QTimer> + +QTM_USE_NAMESPACE + +AsyncRequestExample::AsyncRequestExample() + : QObject() +{ + m_manager = new QContactManager("memory"); +} + +AsyncRequestExample::~AsyncRequestExample() +{ + delete m_manager; +} + +//! [Example of an asynchronous request slot] +void AsyncRequestExample::contactFetchRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) { + QContactFetchRequest *request = qobject_cast<QContactFetchRequest*>(QObject::sender()); + if (request->error() != QContactManager::NoError) { + qDebug() << "Error" << request->error() << "occurred during fetch request!"; + return; + } + + QList<QContact> results = request->contacts(); + for (int i = 0; i < results.size(); i++) { + qDebug() << "Retrieved contact:" << results.at(i).displayLabel(); + } + } else if (newState == QContactAbstractRequest::CanceledState) { + qDebug() << "Fetch operation canceled!"; + } +} +//! [Example of an asynchronous request slot] + +void AsyncRequestExample::contactSaveRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished saving the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Save operation canceled!"; +} + +void AsyncRequestExample::contactRemoveRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished removing the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Remove operation canceled!"; +} + +void AsyncRequestExample::relationshipFetchRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished fetching the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Fetch operation canceled!"; +} + +void AsyncRequestExample::relationshipSaveRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished saving the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Save operation canceled!"; +} + +void AsyncRequestExample::relationshipRemoveRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished removing the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Remove operation canceled!"; +} + +void AsyncRequestExample::definitionFetchRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished fetching the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Fetch operation canceled!"; +} + +void AsyncRequestExample::definitionSaveRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished saving the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Save operation canceled!"; +} + +void AsyncRequestExample::definitionRemoveRequestStateChanged(QContactAbstractRequest::State newState) +{ + if (newState == QContactAbstractRequest::FinishedState) + qDebug() << "Finished removing the contacts!"; + else if (newState == QContactAbstractRequest::CanceledState) + qDebug() << "Remove operation canceled!"; +} + +void AsyncRequestExample::performRequests() +{ +//! [Creating a new contact in a manager] + QContact exampleContact; + + QContactName nameDetail; + nameDetail.setFirstName("Adam"); + nameDetail.setLastName("Unlikely"); + + QContactPhoneNumber phoneNumberDetail; + phoneNumberDetail.setNumber("+123 4567"); + + exampleContact.saveDetail(&nameDetail); + exampleContact.saveDetail(&phoneNumberDetail); + + // save the newly created contact in the manager + connect(&m_contactSaveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(contactSaveRequestStateChanged(QContactAbstractRequest::State))); + m_contactSaveRequest.setManager(m_manager); + m_contactSaveRequest.setContacts(QList<QContact>() << exampleContact); + m_contactSaveRequest.start(); +//! [Creating a new contact in a manager] + + m_contactSaveRequest.waitForFinished(); + +//! [Creating a new contact in a manager waiting until finished] + m_contactSaveRequest.setManager(m_manager); + m_contactSaveRequest.setContacts(QList<QContact>() << exampleContact); + m_contactSaveRequest.start(); + m_contactSaveRequest.waitForFinished(); + QList<QContact> savedContacts = m_contactSaveRequest.contacts(); +//! [Creating a new contact in a manager waiting until finished] + +//! [Filtering contacts from a manager] + connect(&m_contactFetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(contactFetchRequestStateChanged(QContactAbstractRequest::State))); + m_contactFetchRequest.setManager(m_manager); + m_contactFetchRequest.setFilter(QContactPhoneNumber::match("+123 4567")); + m_contactFetchRequest.start(); +//! [Filtering contacts from a manager] + + m_contactFetchRequest.waitForFinished(); + +//! [Retrieving an existing contact from a manager] + QContactLocalIdFilter idListFilter; + idListFilter.setIds(QList<QContactLocalId>() << exampleContact.localId()); + m_contactFetchRequest.setManager(m_manager); + m_contactFetchRequest.setFilter(idListFilter); + m_contactFetchRequest.start(); +//! [Retrieving an existing contact from a manager] + + m_contactFetchRequest.waitForFinished(); + +//! [Updating an existing contact in a manager] + phoneNumberDetail.setNumber("+123 9876"); + exampleContact.saveDetail(&phoneNumberDetail); + m_contactSaveRequest.setManager(m_manager); + m_contactSaveRequest.setContacts(QList<QContact>() << exampleContact); + m_contactSaveRequest.start(); +//! [Updating an existing contact in a manager] + + m_contactFetchRequest.waitForFinished(); + +//! [Removing a contact from a manager] + connect(&m_contactRemoveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(contactRemoveRequestStateChanged(QContactAbstractRequest::State))); + m_contactRemoveRequest.setManager(m_manager); + m_contactRemoveRequest.setContactIds(QList<QContactLocalId>() << exampleContact.localId()); + m_contactRemoveRequest.start(); +//! [Removing a contact from a manager] + + m_contactFetchRequest.waitForFinished(); + +//! [Creating a new relationship between two contacts] + // first, create the group and the group member + QContact exampleGroup; + exampleGroup.setType(QContactType::TypeGroup); + QContactNickname groupName; + groupName.setNickname("Example Group"); + exampleGroup.saveDetail(&groupName); + + QContact exampleGroupMember; + QContactName groupMemberName; + groupMemberName.setFirstName("Member"); + exampleGroupMember.saveDetail(&groupMemberName); + + // second, save those contacts in the manager + QList<QContact> saveList; + saveList << exampleGroup << exampleGroupMember; + m_contactSaveRequest.setContacts(saveList); + m_contactSaveRequest.start(); + m_contactSaveRequest.waitForFinished(); + + // third, create the relationship between those contacts + QContactRelationship groupRelationship; + groupRelationship.setFirst(exampleGroup.id()); + groupRelationship.setRelationshipType(QContactRelationship::HasMember); + groupRelationship.setSecond(exampleGroupMember.id()); + + // finally, save the relationship in the manager + connect(&m_relationshipSaveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(relationshipSaveRequestStateChanged(QContactAbstractRequest::State))); + m_relationshipSaveRequest.setManager(m_manager); + m_relationshipSaveRequest.setRelationships(QList<QContactRelationship>() << groupRelationship); + m_relationshipSaveRequest.start(); +//! [Creating a new relationship between two contacts] + + m_contactFetchRequest.waitForFinished(); + +//! [Retrieving relationships between contacts] + connect(&m_relationshipFetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(relationshipFetchRequestStateChanged(QContactAbstractRequest::State))); + m_relationshipFetchRequest.setManager(m_manager); + // retrieve the list of relationships between the example group contact and the example member contact + // where the group contact is the first contact in the relationship, and the member contact is the + // second contact in the relationship. In order to fetch all relationships between them, another + // relationship fetch must be performed with their roles reversed, and the results added together. + m_relationshipFetchRequest.setFirst(exampleGroup.id()); + m_relationshipFetchRequest.setSecond(exampleGroupMember.id()); + m_relationshipFetchRequest.start(); +//! [Retrieving relationships between contacts] + + m_contactFetchRequest.waitForFinished(); + +//! [Providing a fetch hint] + QContactFetchHint hasMemberRelationshipsOnly; + hasMemberRelationshipsOnly.setRelationshipTypesHint(QStringList(QContactRelationship::HasMember)); + + m_contactFetchRequest.setManager(m_manager); + m_contactFetchRequest.setFilter(QContactFilter()); // all contacts + m_contactFetchRequest.setFetchHint(hasMemberRelationshipsOnly); + m_contactFetchRequest.start(); +//! [Providing a fetch hint] + +//! [Removing a relationship] + connect(&m_relationshipRemoveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(relationshipRemoveRequestStateChanged(QContactAbstractRequest::State))); + m_relationshipRemoveRequest.setManager(m_manager); + m_relationshipRemoveRequest.setRelationships(QList<QContactRelationship>() << groupRelationship); + m_relationshipRemoveRequest.start(); +//! [Removing a relationship] + + connect(&m_definitionFetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(definitionFetchRequestStateChanged(QContactAbstractRequest::State))); +//! [Querying the schema supported by a manager] + m_definitionFetchRequest.setManager(m_manager); + m_definitionFetchRequest.setDefinitionNames(QStringList(QContactName::DefinitionName)); + m_definitionFetchRequest.start(); + m_definitionFetchRequest.waitForFinished(); + QMap<QString, QContactDetailDefinition> definitions = m_definitionFetchRequest.definitions(); + qDebug() << "This manager" + << (definitions.value(QContactName::DefinitionName).fields().contains(QContactName::FieldCustomLabel) ? "supports" : "does not support") + << "the custom label field of QContactName"; +//! [Querying the schema supported by a manager] + + connect(&m_definitionSaveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(definitionSaveRequestStateChanged(QContactAbstractRequest::State))); + connect(&m_definitionRemoveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(definitionRemoveRequestStateChanged(QContactAbstractRequest::State))); +//! [Modifying the schema supported by a manager] + // modify the name definition, adding a patronym field + QContactDetailDefinition nameDefinition = definitions.value(QContactName::DefinitionName); + QContactDetailFieldDefinition fieldPatronym; + fieldPatronym.setDataType(QVariant::String); + nameDefinition.insertField("Patronym", fieldPatronym); + + // save the updated definition in the manager if supported... + if (m_manager->hasFeature(QContactManager::MutableDefinitions)) { + m_definitionSaveRequest.setManager(m_manager); + m_definitionSaveRequest.setContactType(QContactType::TypeContact); + m_definitionSaveRequest.setDefinitions(QList<QContactDetailDefinition>() << nameDefinition); + m_definitionSaveRequest.start(); + } +//! [Modifying the schema supported by a manager] +} diff --git a/doc/src/snippets/qtcontactsdocsample/requestexample.h b/doc/src/snippets/qtcontactsdocsample/requestexample.h index e8fcbd5e32..b6f2b284dc 100644 --- a/doc/src/snippets/qtcontactsdocsample/requestexample.h +++ b/doc/src/snippets/qtcontactsdocsample/requestexample.h @@ -56,9 +56,45 @@ #include <QObject> #include "qmobilityglobal.h" -#include "qcontactfetchrequest.h" +#include "qcontactrequests.h" +//! [Class setup] QTM_USE_NAMESPACE +class AsyncRequestExample : public QObject +{ + Q_OBJECT + +public: + AsyncRequestExample(); + ~AsyncRequestExample(); + +public slots: + void performRequests(); + +private slots: + void contactFetchRequestStateChanged(QContactAbstractRequest::State newState); + void contactSaveRequestStateChanged(QContactAbstractRequest::State newState); + void contactRemoveRequestStateChanged(QContactAbstractRequest::State newState); + void relationshipFetchRequestStateChanged(QContactAbstractRequest::State newState); + void relationshipSaveRequestStateChanged(QContactAbstractRequest::State newState); + void relationshipRemoveRequestStateChanged(QContactAbstractRequest::State newState); + void definitionFetchRequestStateChanged(QContactAbstractRequest::State newState); + void definitionSaveRequestStateChanged(QContactAbstractRequest::State newState); + void definitionRemoveRequestStateChanged(QContactAbstractRequest::State newState); + +private: + QContactManager *m_manager; + QContactFetchRequest m_contactFetchRequest; + QContactSaveRequest m_contactSaveRequest; + QContactRemoveRequest m_contactRemoveRequest; + QContactRelationshipFetchRequest m_relationshipFetchRequest; + QContactRelationshipSaveRequest m_relationshipSaveRequest; + QContactRelationshipRemoveRequest m_relationshipRemoveRequest; + QContactDetailDefinitionFetchRequest m_definitionFetchRequest; + QContactDetailDefinitionSaveRequest m_definitionSaveRequest; + QContactDetailDefinitionRemoveRequest m_definitionRemoveRequest; +}; +//! [Class setup] class RequestExample : public QObject { |
