Commit bcb55478 authored by Benjamin Port's avatar Benjamin Port
Browse files

Replace insertEmail (deprecated since 5.88) with addEmail

parent 280e389c
Pipeline #90880 failed with stage
in 6 minutes and 25 seconds
......@@ -39,7 +39,9 @@ void GrantleePrintTest::shouldReturnStringWhenAddContentAndContacts()
KContacts::Addressee::List lst;
KContacts::Addressee address;
address.setName(QStringLiteral("foo1"));
address.insertEmail(QStringLiteral("foo@kde.org"), true);
KContacts::Email email(QStringLiteral("foo@kde.org"));
email.setPreferred(true);
address.addEmail(email);
lst << address;
QCOMPARE(grantleePrint.contactsToHtml(lst), QStringLiteral("foo"));
......@@ -51,7 +53,9 @@ void GrantleePrintTest::shouldReturnEmails()
KContacts::Addressee::List lst;
KContacts::Addressee address;
address.setName(QStringLiteral("foo1"));
address.insertEmail(QStringLiteral("foo@kde.org"), true);
KContacts::Email email(QStringLiteral("foo@kde.org"));
email.setPreferred(true);
address.addEmail(email);
lst << address;
grantleePrint.setTemplateContent(
QStringLiteral("{% if contacts %}{% for contact in contacts %}{% if contact.name %}{{ contact.name }}{% endif %}{% endfor %}{% endif %}"));
......@@ -93,7 +97,9 @@ void GrantleePrintTest::shouldDisplayContactInfo()
address.setGivenName(QStringLiteral("foo-givenname"));
address.setAdditionalName(QStringLiteral("foo-additionalname"));
address.setName(QStringLiteral("foo1"));
address.insertEmail(QStringLiteral("foo@kde.org"), true);
KContacts::Email email(QStringLiteral("foo@kde.org"));
email.setPreferred(true);
address.addEmail(email);
address.setOrganization(QStringLiteral("kde"));
address.insertLang(KContacts::Lang(QStringLiteral("fr")));
address.setNote(QStringLiteral("foo-note"));
......
......@@ -94,7 +94,8 @@ static QVariantHash memberHash(const KContacts::ContactGroup::Data &data)
KContacts::Addressee contact;
contact.setFormattedName(data.name());
contact.insertEmail(data.email());
KContacts::Email email(data.email());
contact.addEmail(email);
const QString emailLink = QStringLiteral("<a href=\"mailto:") + QString::fromLatin1(QUrl::toPercentEncoding(contact.fullEmail()))
+ QStringLiteral("\">%1</a>").arg(contact.preferredEmail());
......
......@@ -182,7 +182,9 @@ public:
}
KContacts::Addressee contact;
contact.setNameFromString(mName);
contact.insertEmail(mEmail, true);
KContacts::Email email(mEmail);
email.setPreferred(true);
contact.addEmail(email);
// create the new item
Akonadi::Item item;
......
......@@ -223,7 +223,9 @@ public:
}
KContacts::Addressee contact;
contact.setNameFromString(mName);
contact.insertEmail(mEmail, true);
KContacts::Email email(mEmail);
email.setPreferred(true);
contact.addEmail(email);
contact.insertCustom(QStringLiteral("KADDRESSBOOK"),
QStringLiteral("MailPreferedFormatting"),
mShowAsHTML ? QStringLiteral("HTML") : QStringLiteral("TEXT"));
......
......@@ -37,7 +37,9 @@ public:
KContacts::Addressee contact;
contact.setNameFromString(data.name());
contact.insertEmail(data.email(), true);
KContacts::Email email(data.email());
email.setPreferred(true);
contact.addEmail(email);
mContacts.append(contact);
}
......@@ -93,13 +95,15 @@ public:
const Item::List items = fetchJob->items();
if (!items.isEmpty()) {
const QString email = fetchJob->property("preferredEmail").toString();
const QString preferredEmail = fetchJob->property("preferredEmail").toString();
const Item item = items.first();
if (item.hasPayload<KContacts::Addressee>()) {
auto contact = item.payload<KContacts::Addressee>();
if (!email.isEmpty()) {
contact.insertEmail(email, true);
if (!preferredEmail.isEmpty()) {
KContacts::Email email(preferredEmail);
email.setPreferred(true);
contact.addEmail(email);
}
mContacts.append(contact);
......
......@@ -80,7 +80,8 @@ QString StandardContactGroupFormatter::toHtml(HtmlForm form) const
} else {
KContacts::Addressee contact;
contact.setFormattedName(data.name());
contact.insertEmail(data.email());
KContacts::Email email(data.email());
contact.addEmail(email);
const QString fullEmail = QLatin1String("<a href=\"mailto:") + QString::fromLatin1(QUrl::toPercentEncoding(contact.fullEmail()))
+ QStringLiteral("\">%1</a>").arg(contact.preferredEmail());
......
  • Given set(KF5_MIN_VERSION "5.87.0") in the toplevel CMakeLists.txt, please either bump the min required version there (ideally discuss before) or add some version check here in the code to know whether the new method is available (only since 5.88). Currently this breaks the build for everyone with 5.87 only now.

  • We need to add check version not increase version yet. It's not release yet.

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