int GoogleSession::updateContacts(QList<QContact> &contacts, bool skip) { setState(UpdatingContacts); QContactModel filter; qDebug() << "PIM source" << filter.defaultSource().identity; for (int i = 0; i < contacts.size(); ++i) { QContact gContact = contacts.at(i); qDebug() << "process contact" << gContact.label(); // skip contacts with no phonenumbers if (skip && (! gContact.phoneNumbers().size() )) continue; /* filter.addContact(gContact, filter.phoneSource()); continue; */ filter.setFilter(gContact.label()); // single match. merging if (filter.count() == 1) { qDebug() << "Merging"; filter.updateContact( merge(filter.contact(0), gContact) ); } // no match. saving directly else if (filter.count() == 0) { qDebug() << "Adding"; filter.addContact(gContact); } else qDebug() << "WTF?! Multiple matches"; } setState(Authenticated); }