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

Improve description for hotel booking ical events

Contains all details now, and properly handles multi-traveler bookings.

BUG: 416444
parent fee37667
...@@ -7,7 +7,7 @@ DTSTAMP:20171227T111649Z ...@@ -7,7 +7,7 @@ DTSTAMP:20171227T111649Z
CREATED:20171227T111649Z CREATED:20171227T111649Z
UID:KIT-1234567890-1b22236a-21ff-4885-8c99-b3b2bbca062c UID:KIT-1234567890-1b22236a-21ff-4885-8c99-b3b2bbca062c
LAST-MODIFIED:20171227T111649Z LAST-MODIFIED:20171227T111649Z
DESCRIPTION:Check-in: 3:00 PM\nCheck-out: 12:00 PM\nBooking reference: 1234567890 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 SUMMARY:Hotel reservation: Glo Hotel Sello
LOCATION:Leppävaarankatu 1\, 02600 ESPOO\, FINLAND LOCATION:Leppävaarankatu 1\, 02600 ESPOO\, FINLAND
DTSTART;VALUE=DATE:20170919 DTSTART;VALUE=DATE:20170919
......
...@@ -72,7 +72,7 @@ using namespace KCalendarCore; ...@@ -72,7 +72,7 @@ using namespace KCalendarCore;
static void fillFlightReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event); static void fillFlightReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event);
static void fillTrainReservation(const TrainReservation &reservation, const KCalendarCore::Event::Ptr &event); static void fillTrainReservation(const TrainReservation &reservation, const KCalendarCore::Event::Ptr &event);
static void fillBusReservation(const BusReservation &reservation, const KCalendarCore::Event::Ptr &event); static void fillBusReservation(const BusReservation &reservation, const KCalendarCore::Event::Ptr &event);
static void fillLodgingReservation(const LodgingReservation &reservation, const KCalendarCore::Event::Ptr &event); static void fillLodgingReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event);
static void fillEventReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event); static void fillEventReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event);
static void fillGeoPosition(const QVariant &place, const KCalendarCore::Event::Ptr &event); static void fillGeoPosition(const QVariant &place, const KCalendarCore::Event::Ptr &event);
static void fillFoodReservation(const FoodEstablishmentReservation &reservation, const KCalendarCore::Event::Ptr &event); static void fillFoodReservation(const FoodEstablishmentReservation &reservation, const KCalendarCore::Event::Ptr &event);
...@@ -133,7 +133,7 @@ void CalendarHandler::fillEvent(const QVector<QVariant> &reservations, const QSh ...@@ -133,7 +133,7 @@ void CalendarHandler::fillEvent(const QVector<QVariant> &reservations, const QSh
if (typeId == qMetaTypeId<FlightReservation>()) { if (typeId == qMetaTypeId<FlightReservation>()) {
fillFlightReservation(reservations, event); fillFlightReservation(reservations, event);
} else if (typeId == qMetaTypeId<LodgingReservation>()) { } else if (typeId == qMetaTypeId<LodgingReservation>()) {
fillLodgingReservation(reservation.value<LodgingReservation>(), event); fillLodgingReservation(reservations, event);
} else if (typeId == qMetaTypeId<TrainReservation>()) { } else if (typeId == qMetaTypeId<TrainReservation>()) {
fillTrainReservation(reservation.value<TrainReservation>(), event); fillTrainReservation(reservation.value<TrainReservation>(), event);
} else if (typeId == qMetaTypeId<BusReservation>()) { } else if (typeId == qMetaTypeId<BusReservation>()) {
...@@ -290,8 +290,9 @@ static void fillBusReservation(const BusReservation &reservation, const KCalenda ...@@ -290,8 +290,9 @@ static void fillBusReservation(const BusReservation &reservation, const KCalenda
event->setDescription(desc.join(QLatin1Char('\n'))); event->setDescription(desc.join(QLatin1Char('\n')));
} }
static void fillLodgingReservation(const LodgingReservation &reservation, const KCalendarCore::Event::Ptr &event) static void fillLodgingReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event)
{ {
const auto reservation = reservations.at(0).value<LodgingReservation>();
const auto lodgingBusiness = reservation.reservationFor().value<LodgingBusiness>(); const auto lodgingBusiness = reservation.reservationFor().value<LodgingBusiness>();
event->setSummary(i18n("Hotel reservation: %1", lodgingBusiness.name())); event->setSummary(i18n("Hotel reservation: %1", lodgingBusiness.name()));
...@@ -301,11 +302,36 @@ static void fillLodgingReservation(const LodgingReservation &reservation, const ...@@ -301,11 +302,36 @@ static void fillLodgingReservation(const LodgingReservation &reservation, const
event->setDtStart(QDateTime(reservation.checkinTime().date(), QTime())); event->setDtStart(QDateTime(reservation.checkinTime().date(), QTime()));
event->setDtEnd(QDateTime(reservation.checkoutTime().date(), QTime())); event->setDtEnd(QDateTime(reservation.checkoutTime().date(), QTime()));
event->setAllDay(true); event->setAllDay(true);
event->setDescription(i18n("Check-in: %1\nCheck-out: %2\nBooking reference: %3",
QLocale().toString(reservation.checkinTime().time(), QLocale::ShortFormat),
QLocale().toString(reservation.checkoutTime().time(), QLocale::ShortFormat),
reservation.reservationNumber()));
event->setTransparency(KCalendarCore::Event::Transparent); event->setTransparency(KCalendarCore::Event::Transparent);
QStringList desc;
if (reservation.checkinTime().isValid()) {
desc.push_back(i18n("Check-in: %1", QLocale().toString(reservation.checkinTime().time(), QLocale::ShortFormat)));
}
if (reservation.checkoutTime().isValid()) {
desc.push_back(i18n("Check-out: %1", QLocale().toString(reservation.checkoutTime().time(), QLocale::ShortFormat)));
}
if (!lodgingBusiness.telephone().isEmpty()) {
desc.push_back(i18n("Phone: %1", lodgingBusiness.telephone()));
}
if (!lodgingBusiness.email().isEmpty()) {
desc.push_back(i18n("Email: %1", lodgingBusiness.email()));
}
if (!lodgingBusiness.url().isEmpty()) {
desc.push_back(i18n("Website: %1", lodgingBusiness.url().toString()));
}
for (const auto &r : reservations) {
const auto reservation = r.value<LodgingReservation>();
const auto person = reservation.underName().value<KItinerary::Person>();
if (!person.name().isEmpty()) {
desc.push_back(person.name());
}
if (!reservation.reservationNumber().isEmpty()) {
desc.push_back(i18n("Booking reference: %1", reservation.reservationNumber()));
}
}
event->setDescription(desc.join(QLatin1Char('\n')));
} }
static void fillEventReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event) static void fillEventReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event)
......
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