From c795c73d28416d2e429b2ec2df730c4969f893dc Mon Sep 17 00:00:00 2001 From: Kevin Wu Won Date: Fri, 5 Feb 2010 17:03:48 +1000 Subject: Updated qtcontactdocsample snippet for new API. --- .../qtcontactsdocsample/qtcontactsdocsample.cpp | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp') diff --git a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp index 05143379fd..b7ae65c46d 100644 --- a/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp +++ b/doc/src/snippets/qtcontactsdocsample/qtcontactsdocsample.cpp @@ -332,7 +332,9 @@ void RequestExample::performRequest() // 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(progress(QContactFetchRequest*,bool)), this, SLOT(printContacts(QContactFetchRequest*,bool))); + 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); @@ -341,23 +343,19 @@ void RequestExample::performRequest() } } -void RequestExample::printContacts(QContactFetchRequest* request, bool appendOnly) +void RequestExample::printContacts() { - QList results = request->contacts(); - if (appendOnly) { - // we know that the results are still in the same order; just display the new results. - for (m_previousLastIndex += 1; m_previousLastIndex < results.size(); m_previousLastIndex++) { - qDebug() << "Found another Alice:" << results.at(m_previousLastIndex).displayLabel(); - } - } else { - // the order of results has changed; display them all. - for (m_previousLastIndex = 0; m_previousLastIndex < results.size(); m_previousLastIndex++) { - qDebug() << "Found another Alice:" << results.at(m_previousLastIndex).displayLabel(); - } + QList 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 (request->state() == QContactAbstractRequest::FinishedState || request->state() == QContactAbstractRequest::CanceledState) { + if (state == QContactAbstractRequest::FinishedState + || state == QContactAbstractRequest::CanceledState) { qDebug() << "Finished displaying asynchronously retrieved contacts!"; QCoreApplication::exit(0); } -- cgit v1.2.3