diff --git a/src/seasideimport.cpp b/src/seasideimport.cpp index bc0bdb3..b9ae190 100644 --- a/src/seasideimport.cpp +++ b/src/seasideimport.cpp @@ -289,6 +289,19 @@ bool updateExistingContact(QContact *updateContact, const QContact &contact) return mergeIntoExistingContact(updateContact, importedContact); } +void setNickname(QContact &contact, const QString &text) +{ + foreach (const QContactNickname &nick, contact.details()) { + if (nick.nickname() == text) { + return; + } + } + + QContactNickname nick; + nick.setNickname(text); + contact.saveDetail(&nick); +} + } QList SeasideImport::buildImportContacts(const QList &details, int *newCount, int *updatedCount) @@ -358,9 +371,7 @@ QList SeasideImport::buildImportContacts(const QList importLabels.insert(label, it); // Modify this contact to have the label as a nickname - QContactNickname nickname; - nickname.setNickname(label); - contact.saveDetail(&nickname); + setNickname(contact, label); } } }