From c0228b9484fb9b82ca8ff816332a3396b86f815a Mon Sep 17 00:00:00 2001 From: Matt Vogt Date: Wed, 22 Jan 2014 20:48:28 -0800 Subject: [PATCH] [libcontacts] Remove details that cannot be imported Some detail types cannot be supported by the qtcontacts-sqlite backend; remove them from contacts before attempting to import. --- src/seasideimport.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/seasideimport.cpp b/src/seasideimport.cpp index 4fc421a..3849f11 100644 --- a/src/seasideimport.cpp +++ b/src/seasideimport.cpp @@ -338,11 +338,26 @@ QList SeasideImport::buildImportContacts(const QList QHash importNames; QHash importLabels; + QSet unimportableDetailTypes; + unimportableDetailTypes.insert(QContactDetail::TypeFamily); + unimportableDetailTypes.insert(QContactDetail::TypeGeoLocation); + unimportableDetailTypes.insert(QContactDetail::TypeGlobalPresence); + unimportableDetailTypes.insert(QContactDetail::TypeSyncTarget); + unimportableDetailTypes.insert(QContactDetail::TypeVersion); + // Merge any duplicates in the import list QList::iterator it = importedContacts.begin(); while (it != importedContacts.end()) { QContact &contact(*it); + // Remove any details that our backend can't store + foreach (QContactDetail detail, contact.details()) { + if (unimportableDetailTypes.contains(detail.type())) { + qDebug() << " Removing unimportable detail:" << detail; + contact.removeDetail(&detail); + } + } + const QString guid = contact.detail().guid(); const QString name = contactNameString(contact); const bool emptyName = name.isEmpty();