diff -r 2b40d63a9c3d -r 90517678cc4f qtmobility/examples/qmlcontacts/qmlcontacts.cpp --- a/qtmobility/examples/qmlcontacts/qmlcontacts.cpp Fri Apr 16 15:51:22 2010 +0300 +++ b/qtmobility/examples/qmlcontacts/qmlcontacts.cpp Mon May 03 13:18:40 2010 +0300 @@ -54,10 +54,9 @@ // ![0] QMLContactManagerAsync::QMLContactManagerAsync(QObject *parent) -: QObject(parent) + : QObject(parent) { qc = new QContactManager(); - } QMLContactManagerAsync::~QMLContactManagerAsync() @@ -84,21 +83,17 @@ reader.setDevice(&file); if (reader.startReading() && reader.waitForFinished()) { QVersitContactImporter importer; - QList contacts = importer.importContacts(reader.results()); - QMap errors; - manager->saveContacts(&contacts, &errors); + importer.importDocuments(reader.results()); + QList contacts = importer.contacts(); + manager->saveContacts(&contacts, 0); } } - - } void QMLContactManagerAsync::setManager(QString manager) { delete qc; qc = new QContactManager(manager); - if(!qc) - qc = new QContactManager(); connect(qc, SIGNAL(contactsAdded(QList)), this, SIGNAL(contactsAdded(QList))); connect(qc, SIGNAL(contactsChanged(QList)), this, SIGNAL(contactsChanged(QList))); connect(qc, SIGNAL(contactsRemoved(QList)), this, SIGNAL(contactsRemoved(QList))); @@ -116,11 +111,10 @@ QString QMLContactManagerAsync::contactListToQString(const QList& contactIds) const { QString list; - int i; - for (i = 0; i < contactIds.count(); i++) { - list += QString::number(contactIds.at(i)) + " "; - } + for (int i = 0; i < contactIds.count(); i++) { + list += QString::number(contactIds.at(i)) + ' '; + } return list; } @@ -128,9 +122,8 @@ QStringList QMLContactManagerAsync::contactListToQString(const QList& contact) const { QStringList list; - int i; - for (i = 0; i < contact.count(); i++) { + for (int i = 0; i < contact.count(); i++) { list += qc->synthesizedDisplayLabel(contact.at(i)); } @@ -139,11 +132,7 @@ int QMLContactManagerAsync::numContacts() { - QList qlid; - - qlid = qc->contactIds(); - - return qlid.count(); + return qc->contactIds().count(); } void QMLContactManagerAsync::contacts() @@ -170,8 +159,7 @@ } if(request->contacts().count() > 0) { - QContact c; - foreach(c, request->contacts()) { + foreach(const QContact& c, request->contacts()) { QmlContact qmlc(c); emit contactsLoaded(&qmlc); } @@ -182,7 +170,6 @@ request->deleteLater(); emit contactsLoadedDone(); } - } QString QMLContactManagerAsync::idToName(QString name) @@ -194,5 +181,3 @@ // ![0] #include "moc_qmlcontactsa.cpp" - -QML_DEFINE_TYPE(QMLContactManagerAsync, 1, 0, QMLContactManagerAsync, QMLContactManagerAsync);