Commit e88d3437 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add check version. We depend against 5.87

parent bcb55478
Pipeline #91004 passed with stage
in 11 minutes and 12 seconds
......@@ -7,6 +7,7 @@
#include "grantleeprinttest.h"
#include "grantlee/grantleeprint.h"
#include <QTest>
#include <kcontacts_version.h>
GrantleePrintTest::GrantleePrintTest(QObject *parent)
: QObject(parent)
......@@ -39,9 +40,13 @@ void GrantleePrintTest::shouldReturnStringWhenAddContentAndContacts()
KContacts::Addressee::List lst;
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
lst << address;
QCOMPARE(grantleePrint.contactsToHtml(lst), QStringLiteral("foo"));
......@@ -53,9 +58,13 @@ void GrantleePrintTest::shouldReturnEmails()
KContacts::Addressee::List lst;
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
lst << address;
grantleePrint.setTemplateContent(
QStringLiteral("{% if contacts %}{% for contact in contacts %}{% if contact.name %}{{ contact.name }}{% endif %}{% endfor %}{% endif %}"));
......@@ -97,9 +106,13 @@ void GrantleePrintTest::shouldDisplayContactInfo()
address.setGivenName(QStringLiteral("foo-givenname"));
address.setAdditionalName(QStringLiteral("foo-additionalname"));
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
address.setOrganization(QStringLiteral("kde"));
address.insertLang(KContacts::Lang(QStringLiteral("fr")));
address.setNote(QStringLiteral("foo-note"));
......
......@@ -18,6 +18,7 @@
#include <Akonadi/Item>
#include <KColorScheme>
#include <kcontacts_version.h>
using namespace KAddressBookGrantlee;
......@@ -94,9 +95,12 @@ static QVariantHash memberHash(const KContacts::ContactGroup::Data &data)
KContacts::Addressee contact;
contact.setFormattedName(data.name());
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
contact.insertEmail(data.email());
#else
KContacts::Email email(data.email());
contact.addEmail(email);
#endif
const QString emailLink = QStringLiteral("<a href=\"mailto:") + QString::fromLatin1(QUrl::toPercentEncoding(contact.fullEmail()))
+ QStringLiteral("\">%1</a>").arg(contact.preferredEmail());
......
......@@ -26,6 +26,7 @@
#include <KMessageBox>
#include <QPointer>
#include <kcontacts_version.h>
using namespace Akonadi;
......@@ -182,10 +183,13 @@ public:
}
KContacts::Addressee contact;
contact.setNameFromString(mName);
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
contact.insertEmail(mEmail, true);
#else
KContacts::Email email(mEmail);
email.setPreferred(true);
contact.addEmail(email);
#endif
// create the new item
Akonadi::Item item;
item.setMimeType(KContacts::Addressee::mimeType());
......
......@@ -26,7 +26,7 @@
#include <KMessageBox>
#include <QPointer>
#include <kcontacts_version.h>
using namespace Akonadi;
class Akonadi::AddEmailDisplayJobPrivate
......@@ -223,9 +223,13 @@ public:
}
KContacts::Addressee contact;
contact.setNameFromString(mName);
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
contact.insertEmail(mEmail, true);
#else
KContacts::Email email(mEmail);
email.setPreferred(true);
contact.addEmail(email);
#endif
contact.insertCustom(QStringLiteral("KADDRESSBOOK"),
QStringLiteral("MailPreferedFormatting"),
mShowAsHTML ? QStringLiteral("HTML") : QStringLiteral("TEXT"));
......
......@@ -12,7 +12,7 @@
#include <Akonadi/ItemFetchJob>
#include <Akonadi/ItemFetchScope>
#include <Akonadi/ItemSearchJob>
#include <kcontacts_version.h>
using namespace Akonadi;
class Akonadi::ContactGroupExpandJobPrivate
......@@ -37,10 +37,13 @@ public:
KContacts::Addressee contact;
contact.setNameFromString(data.name());
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
contact.insertEmail(data.email(), true);
#else
KContacts::Email email(data.email());
email.setPreferred(true);
contact.addEmail(email);
#endif
mContacts.append(contact);
}
......@@ -100,12 +103,17 @@ public:
const Item item = items.first();
if (item.hasPayload<KContacts::Addressee>()) {
auto contact = item.payload<KContacts::Addressee>();
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
if (!preferredEmail.isEmpty()) {
contact.insertEmail(preferredEmail, true);
}
#else
if (!preferredEmail.isEmpty()) {
KContacts::Email email(preferredEmail);
email.setPreferred(true);
contact.addEmail(email);
}
#endif
mContacts.append(contact);
} else {
qCWarning(AKONADICONTACT_LOG) << "Contact for Akonadi item" << item.id() << "does not exist anymore!";
......
......@@ -12,7 +12,7 @@
#include <Akonadi/Item>
#include <KColorScheme>
#include <KContacts/Addressee>
#include <kcontacts_version.h>
using namespace Akonadi;
class Akonadi::StandardContactGroupFormatterPrivate
......@@ -80,9 +80,12 @@ QString StandardContactGroupFormatter::toHtml(HtmlForm form) const
} else {
KContacts::Addressee contact;
contact.setFormattedName(data.name());
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
contact.insertEmail(data.email());
#else
KContacts::Email email(data.email());
contact.addEmail(email);
#endif
const QString fullEmail = QLatin1String("<a href=\"mailto:") + QString::fromLatin1(QUrl::toPercentEncoding(contact.fullEmail()))
+ QStringLiteral("\">%1</a>").arg(contact.preferredEmail());
......
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