Verified Commit ce4313ad authored by Marco Rebhan's avatar Marco Rebhan
Browse files

Replace removed insertEmail with addEmail

(see KContacts commit 779da83bcfa42ddc55a17a039e2d9ae9370266d0)
parent 398f545c
Pipeline #91051 passed with stage
in 50 minutes and 37 seconds
......@@ -19,6 +19,7 @@
#include <QTextStream>
#include <QUrl>
#include <importexportengine.h>
#include <kcontacts_version.h>
#include <KAddressBookImportExport/ContactSelectionDialog>
......@@ -551,11 +552,19 @@ void GMXImportExportPluginInterface::importGMX()
if (!itemList[8].isEmpty()) {
addressee->insertPhoneNumber(KContacts::PhoneNumber(itemList[8], cellType));
}
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
bool preferred = false;
if (itemList[19].toInt() & 1) {
preferred = true;
}
addressee->insertEmail(itemList[10], preferred);
#else
KContacts::Email email(itemList[10]);
if (itemList[19].toInt() & 1) {
email.setPreferred(true);
}
addressee->addEmail(email);
#endif
if (!itemList[11].isEmpty()) {
KContacts::ResourceLocatorUrl url;
url.setUrl(QUrl(itemList[11]));
......
......@@ -8,6 +8,7 @@
#include "mailsenderjob.h"
#include <KContacts/Addressee>
#include <kcontacts_version.h>
#include <QSignalSpy>
#include <QTest>
......@@ -56,7 +57,13 @@ void MailSenderJobTest::shouldSendSignalWhenOneEmail()
Akonadi::Item item;
KContacts::Addressee address;
address.setName(QStringLiteral("foo1"));
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
address.insertEmail(QStringLiteral("foo@kde.org"), true);
#else
KContacts::Email email(QStringLiteral("foo@kde.org"));
email.setPreferred(true);
address.addEmail(email);
#endif
item.setPayload<KContacts::Addressee>(address);
lst << item;
KABMailSender::MailSenderJob mailsender(lst);
......@@ -73,7 +80,13 @@ void MailSenderJobTest::shouldNotSendTwiceEmails()
Akonadi::Item item;
KContacts::Addressee address;
address.setName(QStringLiteral("foo1"));
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
address.insertEmail(QStringLiteral("foo@kde.org"), true);
#else
KContacts::Email email(QStringLiteral("foo@kde.org"));
email.setPreferred(true);
address.addEmail(email);
#endif
item.setPayload<KContacts::Addressee>(address);
lst << item << item;
KABMailSender::MailSenderJob mailsender(lst);
......@@ -90,7 +103,13 @@ void MailSenderJobTest::shouldNotAddInvalidEmail()
KContacts::Addressee address;
address.setName(QStringLiteral("foo1"));
// Invalid email
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
address.insertEmail(QStringLiteral("foo2"), true);
#else
KContacts::Email email(QStringLiteral("foo2"));
email.setPreferred(true);
address.addEmail(email);
#endif
item.setPayload<KContacts::Addressee>(address);
lst << item;
KABMailSender::MailSenderJob mailsender(lst);
......@@ -106,28 +125,52 @@ void MailSenderJobTest::shouldEmitSignalIfThereIsAValidEmail()
KContacts::Addressee address;
address.setName(QStringLiteral("foo1"));
// Invalid email
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
address.insertEmail(QStringLiteral("foo2"), true);
#else
KContacts::Email email(QStringLiteral("foo2"));
email.setPreferred(true);
address.addEmail(email);
#endif
item.setPayload<KContacts::Addressee>(address);
lst << item;
Akonadi::Item item2;
KContacts::Addressee address2;
address2.setName(QStringLiteral("foo2"));
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
address2.insertEmail(QStringLiteral("foo2@kde.org"), true);
#else
KContacts::Email email2(QStringLiteral("foo2@kde.org"));
email2.setPreferred(true);
address2.addEmail(email);
#endif
item2.setPayload<KContacts::Addressee>(address2);
lst << item2;
Akonadi::Item item3;
KContacts::Addressee address3;
address3.setName(QStringLiteral("foo3"));
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
address3.insertEmail(QStringLiteral("foo3@"), true);
#else
KContacts::Email email3(QStringLiteral("foo3@"));
email3.setPreferred(true);
address3.addEmail(email);
#endif
item3.setPayload<KContacts::Addressee>(address3);
lst << item3;
Akonadi::Item item4;
KContacts::Addressee address4;
address4.setName(QStringLiteral("foo4"));
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
address4.insertEmail(QStringLiteral("foo4@kde.org"), true);
#else
KContacts::Email email4(QStringLiteral("foo4@kde.org"));
email4.setPreferred(true);
address4.addEmail(email);
#endif
item4.setPayload<KContacts::Addressee>(address4);
lst << item4;
......
......@@ -21,6 +21,7 @@
#include <PimCommon/PimUtil>
#include <QPointer>
#include <akonadi/contact/selectaddressbookdialog.h>
#include <kcontacts_version.h>
AutomaticAddContactsJob::AutomaticAddContactsJob(QObject *parent)
: QObject(parent)
......@@ -198,7 +199,13 @@ void AutomaticAddContactsJob::slotSearchDone(KJob *job)
} else if (searchJob->contacts().isEmpty()) {
KContacts::Addressee contact;
contact.setNameFromString(mName);
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
contact.insertEmail(mProcessEmail, true);
#else
KContacts::Email email(mProcessEmail);
email.setPreferred(true);
contact.addEmail(email);
#endif
// create the new item
Akonadi::Item item;
......
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