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

Replace use of removed insertEmail with addEmail

(see KContacts commit 779da83bcfa42ddc55a17a039e2d9ae9370266d0)
parent 06ae9ac5
Pipeline #91063 passed with stage
in 9 minutes and 26 seconds
......@@ -20,6 +20,7 @@
#include <KLDAP/LdapClientSearch>
#include <KContacts/VCardConverter>
#include <kcontacts_version.h>
#include <Akonadi/Job>
#include <KConfigGroup>
......@@ -298,7 +299,13 @@ void AddresseeLineEdit::dropEvent(QDropEvent *event)
// email-address.
if (url.scheme() == QLatin1String("mailto")) {
KContacts::Addressee addressee;
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
addressee.insertEmail(KEmailAddress::decodeMailtoUrl(url), true /* preferred */);
#else
KContacts::Email email(KEmailAddress::decodeMailtoUrl(url));
email.setPreferred(true);
addressee.addEmail(email);
#endif
list += addressee;
} else { // Otherwise, download the vCard to which the Url points
KContacts::VCardConverter converter;
......@@ -380,7 +387,13 @@ void AddresseeLineEdit::dropEvent(QDropEvent *event)
QUrl url(dropData);
if (url.scheme() == QLatin1String("mailto")) {
KContacts::Addressee addressee;
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
addressee.insertEmail(KEmailAddress::decodeMailtoUrl(url), true /* preferred */);
#else
KContacts::Email email(KEmailAddress::decodeMailtoUrl(url));
email.setPreferred(true);
addressee.addEmail(email);
#endif
insertEmails(addressee.emails());
} else {
setText(KEmailAddress::normalizeAddressesAndDecodeIdn(dropData));
......@@ -622,7 +635,7 @@ void AddresseeLineEdit::loadContacts()
const QStringList recent =
AddresseeLineEditManager::self()->cleanupRecentAddressEmailList(PimCommon::RecentAddresses::self(recentAddressConfig())->addresses());
QString name;
QString email;
QString emailString;
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimcompletionorder"));
KConfigGroup group(config, "CompletionWeights");
......@@ -632,8 +645,8 @@ void AddresseeLineEdit::loadContacts()
for (const QString &recentAdr : recent) {
KContacts::Addressee addr;
KEmailAddress::extractEmailAddressAndName(recentAdr, email, name);
if (email.isEmpty()) {
KEmailAddress::extractEmailAddressAndName(recentAdr, emailString, name);
if (emailString.isEmpty()) {
continue;
}
name = KEmailAddress::quoteNameIfNecessary(name);
......@@ -642,8 +655,14 @@ void AddresseeLineEdit::loadContacts()
name.chop(1);
}
addr.setNameFromString(name);
addr.insertEmail(email, true);
addContact({email}, addr, weight, idx);
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
addr.insertEmail(emailString, true);
#else
KContacts::Email email(emailString);
email.setPreferred(true);
addr.addEmail(email);
#endif
addContact({emailString}, addr, weight, idx);
}
} else {
removeCompletionSource(recentAddressGroupName);
......
......@@ -13,6 +13,7 @@
#include <KEmailAddress>
#include <KSharedConfig>
#include <QCoreApplication>
#include <kcontacts_version.h>
using namespace PimCommon;
......@@ -54,18 +55,24 @@ RecentAddresses::~RecentAddresses()
void RecentAddresses::load(KConfig *config)
{
QString name;
QString email;
QString emailString;
m_addresseeList.clear();
KConfigGroup cg(config, "General");
m_maxCount = cg.readEntry("Maximum Recent Addresses", 200);
const QStringList addresses = cg.readEntry("Recent Addresses", QStringList());
for (const QString &address : addresses) {
KContacts::Addressee::parseEmailAddress(address, name, email);
if (!email.isEmpty()) {
KContacts::Addressee::parseEmailAddress(address, name, emailString);
if (!emailString.isEmpty()) {
KContacts::Addressee addr;
addr.setNameFromString(name);
addr.insertEmail(email, true);
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
addr.insertEmail(emailString, true);
#else
KContacts::Email email(emailString);
email.setPreferred(true);
addr.addEmail(email);
#endif
m_addresseeList.append(addr);
}
}
......@@ -88,22 +95,28 @@ void RecentAddresses::add(const QString &entry)
if (errorCode != KEmailAddress::AddressOk) {
continue;
}
QString email;
QString emailString;
QString fullName;
KContacts::Addressee addr;
KContacts::Addressee::parseEmailAddress(str, fullName, email);
KContacts::Addressee::parseEmailAddress(str, fullName, emailString);
KContacts::Addressee::List::Iterator end(m_addresseeList.end());
for (KContacts::Addressee::List::Iterator it = m_addresseeList.begin(); it != end; ++it) {
if (email == (*it).preferredEmail()) {
if (emailString == (*it).preferredEmail()) {
// already inside, remove it here and add it later at pos==1
m_addresseeList.erase(it);
break;
}
}
addr.setNameFromString(fullName);
addr.insertEmail(email, true);
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
addr.insertEmail(emailString, true);
#else
KContacts::Email email(emailString);
email.setPreferred(true);
addr.addEmail(email);
#endif
m_addresseeList.prepend(addr);
adjustSize();
}
......
......@@ -15,6 +15,7 @@
#include <KLDAP/LdapSearchClientReadConfigServerJob>
#include <Libkdepim/LineEditCatchReturnKey>
#include <Libkdepim/ProgressIndicatorLabel>
#include <kcontacts_version.h>
#include <QApplication>
#include <QCheckBox>
......@@ -161,7 +162,13 @@ static KContacts::Addressee convertLdapAttributesToAddressee(const KLDAP::LdapAt
KLDAP::LdapAttrValue::ConstIterator it = lst.constBegin();
bool pref = true;
while (it != lst.constEnd()) {
#if KContacts_VERSION < QT_VERSION_CHECK(5, 88, 0)
addr.insertEmail(asUtf8(*it), pref);
#else
KContacts::Email email(asUtf8(*it));
email.setPreferred(pref);
addr.addEmail(email);
#endif
pref = false;
++it;
}
......
Supports Markdown
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