Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Do not add multiple instances of contact nickname.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvogt committed Nov 5, 2013
1 parent 5da09cc commit 05d4a85
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/seasideimport.cpp
Expand Up @@ -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<QContactNickname>()) {
if (nick.nickname() == text) {
return;
}
}

QContactNickname nick;
nick.setNickname(text);
contact.saveDetail(&nick);
}

}

QList<QContact> SeasideImport::buildImportContacts(const QList<QVersitDocument> &details, int *newCount, int *updatedCount)
Expand Down Expand Up @@ -358,9 +371,7 @@ QList<QContact> SeasideImport::buildImportContacts(const QList<QVersitDocument>
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);
}
}
}
Expand Down

0 comments on commit 05d4a85

Please sign in to comment.