Commit a8d390d4 authored by Volker Krause's avatar Volker Krause
Browse files

Use the new KContacts address formatting API properly

This also restores compatibility with KF 5.91 after 16aecd95, which is
still the required version in the stable branch (and the highest released
one).
parent aa4df9ec
Pipeline #149202 passed with stages
in 4 minutes and 17 seconds
......@@ -20,7 +20,7 @@ UID:KIT-1234567890-1b22236a-21ff-4885-8c99-b3b2bbca062c
LAST-MODIFIED:20171227T111649Z
SUMMARY:Akademy 2019
LOCATION:University of Milano-Bicocca
DESCRIPTION:Piazza dell'Ateneo Nuovo\, 1\n20126 MILAN LOMBARDY\n\nITALY\n
DESCRIPTION:Piazza dell'Ateneo Nuovo\, 1\n20126 Milan Lombardy\nItaly\n
DTSTART;TZID=Europe/Rome:20190907T093000
DTEND;TZID=Europe/Rome:20190713T163000
TRANSP:OPAQUE
......
......@@ -29,7 +29,7 @@ X-KDE-KITINERARY-RESERVATION:[{"@context":"http://schema.org"\,"@type":
CREATED:20171227T111649Z
UID:KIT-1234567890-1b22236a-21ff-4885-8c99-b3b2bbca062c
LAST-MODIFIED:20171227T111649Z
DESCRIPTION:Piazza dell'Ateneo Nuovo\, 1\n20126 MILAN LOMBARDY\n\nITALY\n\nDr Konqui\nBooking reference: 42\nKatie Dragon\nBooking reference: 42
DESCRIPTION:Piazza dell'Ateneo Nuovo\, 1\n20126 Milan Lombardy\nItaly\n\nDr Konqui\nBooking reference: 42\nKatie Dragon\nBooking reference: 42
SUMMARY:Akademy 2019
LOCATION:University of Milano-Bicocca
DTSTART;TZID=Europe/Rome:20190907T093000
......
......@@ -9,7 +9,7 @@ UID:KIT-1234567890-1b22236a-21ff-4885-8c99-b3b2bbca062c
LAST-MODIFIED:20171227T111649Z
DESCRIPTION:Check-in: 3:00 PM\nCheck-out: 12:00 PM\nPhone: +358101234567\nWebsite: https://www.booking.com/hotel/fi/palace-sello.html?aid=123456&label=postbooking_confemail\nJohn Doe\nBooking reference: 1234567890
SUMMARY:Hotel reservation: Glo Hotel Sello
LOCATION:Leppävaarankatu 1\, FI-02600 Espoo\, FINLAND
LOCATION:Leppävaarankatu 1\, FI-02600 Espoo\, Finland
DTSTART;VALUE=DATE:20170919
DTEND;VALUE=DATE:20170921
TRANSP:TRANSPARENT
......
......@@ -23,7 +23,7 @@ CREATED:20171227T111649Z
UID:KIT-1234567890-1b22236a-21ff-4885-8c99-b3b2bbca062c
LAST-MODIFIED:20171227T111649Z
DESCRIPTION:Pickup location: Hertz San Diego Airport\n1500 Orange
Avenue\nSAN DIEGO\, CA 94043\n\nUNITED STATES\n\nDropoff location: Hertz LAX\n1234 First Street\nLOS ANGELES\, CA 94043\n\nUNITED STATES\n\nBooking reference: 546323\nUnder name: John Smith
Avenue\nSan Diego\, CA 94043\nUnited States\n\nDropoff location: Hertz LAX\n1234 First Street\nLos Angeles\, CA 94043\nUnited States\n\nBooking reference: 546323\nUnder name: John Smith
SUMMARY:Rental car reservation: Economy Class Car
LOCATION:Hertz San Diego Airport
DTSTART;TZID=America/Los_Angeles:20270805T160000
......
......@@ -29,6 +29,7 @@
#include <KCalendarCore/Event>
#endif
#include <kcontacts_version.h>
#include <KContacts/Address>
#include <KLocalizedString>
......@@ -39,7 +40,7 @@
using namespace KItinerary;
static QString formatAddress(const PostalAddress &addr)
static KContacts::Address convertAddress(const PostalAddress &addr)
{
KContacts::Address a;
a.setStreet(addr.streetAddress());
......@@ -47,12 +48,25 @@ static QString formatAddress(const PostalAddress &addr)
a.setLocality(addr.addressLocality());
a.setRegion(addr.addressRegion());
a.setCountry(addr.addressCountry());
return a.formatted(KContacts::AddressFormatStyle::Postal);
return a;
}
static QString formatAddress(const PostalAddress &addr)
{
#if KContacts_VERSION >= QT_VERSION_CHECK(5, 92, 0)
return convertAddress(addr).formatted(KContacts::AddressFormatStyle::MultiLineInternational);
#else
return convertAddress(addr).formattedAddress();
#endif
}
static QString formatAddressSingleLine(const PostalAddress &addr)
{
#if KContacts_VERSION >= QT_VERSION_CHECK(5, 92, 0)
return convertAddress(addr).formatted(KContacts::AddressFormatStyle::SingleLineInternational);
#else
return formatAddress(addr).replace(QLatin1String("\n\n"), QLatin1String("\n")).replace(QLatin1Char('\n'), QLatin1String(", "));
#endif
}
#ifdef HAVE_KCAL
......
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