summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Krause <[email protected]>2017-12-27 17:12:05 +0100
committerVolker Krause <[email protected]>2017-12-27 17:12:05 +0100
commitc004b8ee776e9f2b71ed55887af436aa33a471c4 (patch)
tree9a0b741aafdad9a4ae6abb2947fbf6f6cb7e3a80
parenta18064e9e22d6b60112543956be7ae8dbbabb694 (diff)
Store geo position in created ical events
-rw-r--r--plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/flight.ics1
-rw-r--r--plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/train.ics1
-rw-r--r--plugins/messageviewer/bodypartformatter/semantic/calendarhandler.cpp15
-rw-r--r--plugins/messageviewer/bodypartformatter/semantic/calendarhandler.h1
4 files changed, 18 insertions, 0 deletions
diff --git a/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/flight.ics b/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/flight.ics
index be7ecdd..c091081 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/flight.ics
+++ b/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/flight.ics
@@ -10,6 +10,7 @@ LAST-MODIFIED:20171227T111649Z
DESCRIPTION:Booking reference: XXX007
SUMMARY:Flight AB 8075 from HEL to TXL
LOCATION:Helsinki
+GEO:60.317200;24.963301
DTSTART;TZID=Europe/Helsinki:20170920T150500
DTEND;TZID=Europe/Berlin:20170920T160000
TRANSP:OPAQUE
diff --git a/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/train.ics b/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/train.ics
index 6fa9818..9b7f486 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/train.ics
+++ b/plugins/messageviewer/bodypartformatter/autotests/calendarhandlerdata/train.ics
@@ -10,6 +10,7 @@ LAST-MODIFIED:20171227T111649Z
DESCRIPTION:Coach: 17\nSeat: 62\nBooking reference: XXX007
SUMMARY:Train 5186 from Nîmes Gare to Lyon Part-Dieu
LOCATION:Nîmes Gare
+GEO:43.832291;4.365845
DTSTART;TZID="UTC+02:00":20170929T182600
DTEND;TZID="UTC+02:00":20170929T195200
TRANSP:OPAQUE
diff --git a/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.cpp b/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.cpp
index 5d36970..0c27c8b 100644
--- a/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.cpp
+++ b/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.cpp
@@ -56,6 +56,7 @@ void CalendarHandler::fillFlightReservation(const QVariant &reservation, const K
JsonLdDocument::readProperty(arrPort, "iataCode").toString()
));
event->setLocation(JsonLdDocument::readProperty(depPort, "name").toString());
+ fillGeoPosition(depPort, event);
event->setDtStart(JsonLdDocument::readProperty(flight, "departureTime").toDateTime());
event->setDtEnd(JsonLdDocument::readProperty(flight, "arrivalTime").toDateTime());
event->setAllDay(false);
@@ -79,6 +80,7 @@ void CalendarHandler::fillTrainReservation(const QVariant &reservation, const KC
JsonLdDocument::readProperty(arrStation, "name").toString()
));
event->setLocation(JsonLdDocument::readProperty(depStation, "name").toString());
+ fillGeoPosition(depStation, event);
event->setDtStart(JsonLdDocument::readProperty(trip, "departureTime").toDateTime());
event->setDtEnd(JsonLdDocument::readProperty(trip, "arrivalTime").toDateTime());
event->setAllDay(false);
@@ -126,6 +128,7 @@ void CalendarHandler::fillLodgingReservation(const QVariant &reservation, const
JsonLdDocument::readProperty(address, "addressLocality").toString(),
JsonLdDocument::readProperty(address, "addressCountry").toString()
));
+ fillGeoPosition(lodgingBusiness, event);
event->setDtStart(QDateTime(JsonLdDocument::readProperty(reservation, "checkinDate").toDate(), QTime()));
event->setDtEnd(QDateTime(JsonLdDocument::readProperty(reservation, "checkoutDate").toDate(), QTime()));
event->setAllDay(true);
@@ -134,3 +137,15 @@ void CalendarHandler::fillLodgingReservation(const QVariant &reservation, const
));
event->setTransparency(Event::Transparent);
}
+
+void CalendarHandler::fillGeoPosition(const QVariant &place, const KCalCore::Event::Ptr &event)
+{
+ const auto geo = JsonLdDocument::readProperty(place, "geo");
+ if (geo.isNull()) {
+ return;
+ }
+
+ event->setHasGeo(true);
+ event->setGeoLatitude(JsonLdDocument::readProperty(geo, "latitude").toFloat());
+ event->setGeoLongitude(JsonLdDocument::readProperty(geo, "longitude").toFloat());
+}
diff --git a/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.h b/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.h
index 0a07005..d53fb90 100644
--- a/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.h
+++ b/plugins/messageviewer/bodypartformatter/semantic/calendarhandler.h
@@ -34,6 +34,7 @@ private:
static void fillFlightReservation(const QVariant &reservation, const KCalCore::Event::Ptr &event);
static void fillTrainReservation(const QVariant &reservation, const KCalCore::Event::Ptr &event);
static void fillLodgingReservation(const QVariant &reservation, const KCalCore::Event::Ptr &event);
+ static void fillGeoPosition(const QVariant &place, const KCalCore::Event::Ptr &event);
};
#endif // CALENDARHANDLER_H