Commit 079955d7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix Bug 403174 - KAddressBook looses contact birthdays when merging two or more contacts

FIXED-IN: 5.10.2
BUG: 403174
parent dd45fdca
......@@ -1121,10 +1121,13 @@ void MergeContactsTest::checkNeedManualSelectionWithBirthday_data()
QTest::newRow("noWithOneNameConflict") << QString() << QString() << QStringLiteral("20150606") << false;
QTest::newRow("noWithOneNameConflict1") << QString() << QStringLiteral("20150606") << QString() << false;
QTest::newRow("noWithOneNameConflict2") << QStringLiteral("20150606") << QString() << QString() << false;
QTest::newRow("noConflictWithSameName") << QStringLiteral("20150606") << QStringLiteral("20150606") << QString() << false;
QTest::newRow("noConflictWithSameName2") << QStringLiteral("20150606") << QStringLiteral("20150606") << QStringLiteral("20150606") << false;
QTest::newRow("noConflictWithSameBirthday") << QStringLiteral("20150606") << QStringLiteral("20150606") << QString() << false;
QTest::newRow("noConflictWithSameBirthday2") << QStringLiteral("20150606") << QStringLiteral("20150606") << QStringLiteral("20150606") << false;
QTest::newRow("conflict") << QStringLiteral("20150606") << QStringLiteral("20150608") << QStringLiteral("20150606") << true;
QTest::newRow("conflict1") << QString() << QStringLiteral("20150606") << QStringLiteral("20150608") << true;
QTest::newRow("conflict2") << QStringLiteral("20150606") << QString() << QStringLiteral("20150608") << true;
QTest::newRow("conflict2") << QStringLiteral("20150606") << QStringLiteral("20150608") << QString() << true;
QTest::newRow("conflict4") << QStringLiteral("20180606") << QStringLiteral("20150608") << QStringLiteral("20150606") << true;
}
void MergeContactsTest::checkNeedManualSelectionWithBirthday()
......
......@@ -95,7 +95,7 @@ void MergeContacts::mergeToContact(KContacts::Addressee &newContact, const KCont
// Merge Phone
const PhoneNumber::List listPhone = fromContact.phoneNumbers();
if (!listPhone.isEmpty()) {
PhoneNumber::List newContactsPhone = newContact.phoneNumbers();
const PhoneNumber::List newContactsPhone = newContact.phoneNumbers();
for (const PhoneNumber &phone : listPhone) {
if (!newContactsPhone.contains(phone)) {
newContact.insertPhoneNumber(phone);
......@@ -106,7 +106,7 @@ void MergeContacts::mergeToContact(KContacts::Addressee &newContact, const KCont
// Merge Address
const Address::List listAddress = fromContact.addresses();
if (!listAddress.isEmpty()) {
Address::List newContactsAddress = newContact.addresses();
const Address::List newContactsAddress = newContact.addresses();
for (const Address &addr : listAddress) {
if (!newContactsAddress.contains(addr)) {
newContact.insertAddress(addr);
......@@ -117,7 +117,7 @@ void MergeContacts::mergeToContact(KContacts::Addressee &newContact, const KCont
// Merge Impp
const Impp::List listImpp = fromContact.imppList();
if (!listImpp.isEmpty()) {
Impp::List newContactsImpp = newContact.imppList();
const Impp::List newContactsImpp = newContact.imppList();
for (const Impp &impp : listImpp) {
if (!newContactsImpp.contains(impp)) {
newContact.insertImpp(impp);
......@@ -163,11 +163,15 @@ void MergeContacts::mergeToContact(KContacts::Addressee &newContact, const KCont
newContact.setPhoto(fromContact.photo());
}
// Merge Birthday
if (!newContact.birthday().isValid() && !fromContact.birthday().isValid()) {
newContact.setBirthday(fromContact.birthday());
}
// Merge Logo
if (newContact.logo().isEmpty() && !fromContact.logo().isEmpty()) {
newContact.setLogo(fromContact.logo());
}
// Merge Birthday TODO
// Merge Blog
mergeCustomValue(fromContact, QStringLiteral("BlogFeed"), newContact);
......
......@@ -116,11 +116,11 @@ void SearchDuplicateResultWidget::slotMergeContact()
}
mMergeContact->setEnabled(false);
if (!conflictFound) {
if (conflictFound) {
mMergeContactWarning->animatedShow();
} else {
//Detect if conflict.
mergeContact();
} else {
mMergeContactWarning->animatedShow();
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment