Commit b6805130 authored by Volker Krause's avatar Volker Krause

Show tourist attraction visits in the timeline

parent 826b834d
......@@ -72,6 +72,7 @@ qml_lint(
TicketTokenDelegate.qml
TimelineDelegate.qml
TimelinePage.qml
TouristAttractionDelegate.qml
TrainDelegate.qml
TrainPage.qml
)
......
......@@ -83,6 +83,15 @@ Kirigami.ScrollablePage {
rangeType: modelData.rangeType
}
}
Component {
id: touristAttractionDelegate
App.TouristAttractionDelegate {
reservation: modelData.reservation
passId: modelData.passId
pass: modelData.pass
rangeType: modelData.rangeType
}
}
Component {
id: todayDelegate
Item {
......@@ -120,6 +129,7 @@ Kirigami.ScrollablePage {
case TimelineModel.TrainTrip: return trainDelegate;
case TimelineModel.BusTrip: return busDelegate;
case TimelineModel.Restaurant: return restaurantDelegate;
case TimelineModel.TouristAttraction: return touristAttractionDelegate;
case TimelineModel.TodayMarker: return todayDelegate;
case TimelineModel.CountryInfo: return countryInfoDelegate;
}
......
/*
Copyright (C) 2018 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.4 as Kirigami
import org.kde.itinerary 1.0
import "." as App
App.TimelineDelegate {
id: root
header: Rectangle {
id: headerBackground
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
Kirigami.Theme.inherit: false
color: Kirigami.Theme.backgroundColor
implicitHeight: headerLayout.implicitHeight + Kirigami.Units.largeSpacing * 2
anchors.leftMargin: -root.leftPadding
anchors.topMargin: -root.topPadding
anchors.rightMargin: -root.rightPadding
RowLayout {
id: headerLayout
anchors.fill: parent
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: qsTr("🎢 %1").arg(reservation.touristAttraction.name)
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
}
QQC2.Label {
text: Localizer.formatTime(reservation, "arrivalTime")
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
}
}
}
contentItem: ColumnLayout {
id: topLayout
App.PlaceDelegate {
place: reservation.touristAttraction
Layout.fillWidth: true
}
}
}
......@@ -17,6 +17,7 @@
<file>TicketTokenDelegate.qml</file>
<file>TimelineDelegate.qml</file>
<file>TimelinePage.qml</file>
<file>TouristAttractionDelegate.qml</file>
<file>TrainDelegate.qml</file>
<file>TrainPage.qml</file>
</qresource>
......
......@@ -27,6 +27,7 @@
#include <KItinerary/Organization>
#include <KItinerary/Reservation>
#include <KItinerary/TrainTrip>
#include <KItinerary/Visit>
#include <KPkPass/Pass>
......@@ -47,7 +48,7 @@ static bool needsSplitting(const QVariant &res)
static QDateTime relevantDateTime(const QVariant &res, TimelineModel::RangeType range)
{
if (res.userType() == qMetaTypeId<FlightReservation>()) {
if (JsonLd::isA<FlightReservation>(res)) {
const auto flight = res.value<FlightReservation>().reservationFor().value<Flight>();
if (flight.boardingTime().isValid()) {
return flight.boardingTime();
......@@ -56,13 +57,17 @@ static QDateTime relevantDateTime(const QVariant &res, TimelineModel::RangeType
return flight.departureTime();
}
return QDateTime(flight.departureDay(), QTime(23, 59, 59));
} else if (res.userType() == qMetaTypeId<TrainReservation>()) {
}
if (JsonLd::isA<TrainReservation>(res)) {
return res.value<TrainReservation>().reservationFor().value<TrainTrip>().departureTime();
} else if (res.userType() == qMetaTypeId<BusReservation>()) {
}
if (JsonLd::isA<BusReservation>(res)) {
return res.value<BusReservation>().reservationFor().value<BusTrip>().departureTime();
} else if (res.userType() == qMetaTypeId<FoodEstablishmentReservation>()) {
}
if (JsonLd::isA<FoodEstablishmentReservation>(res)) {
return res.value<FoodEstablishmentReservation>().startTime();
} else if (res.userType() == qMetaTypeId<LodgingReservation>()) {
}
if (JsonLd::isA<LodgingReservation>(res)) {
const auto hotel = res.value<LodgingReservation>();
// hotel checkin/checkout is always considered the first/last thing of the day
if (range == TimelineModel::RangeEnd) {
......@@ -71,6 +76,9 @@ static QDateTime relevantDateTime(const QVariant &res, TimelineModel::RangeType
return QDateTime(hotel.checkinTime().date(), QTime(23, 59, 59));
}
}
if (JsonLd::isA<TouristAttractionVisit>(res)) {
return res.value<TouristAttractionVisit>().arrivalTime();
}
return {};
}
......@@ -92,6 +100,7 @@ static TimelineModel::ElementType elementType(const QVariant &res)
if (JsonLd::isA<TrainReservation>(res)) { return TimelineModel::TrainTrip; }
if (JsonLd::isA<BusReservation>(res)) { return TimelineModel::BusTrip; }
if (JsonLd::isA<FoodEstablishmentReservation>(res)) { return TimelineModel::Restaurant; }
if (JsonLd::isA<TouristAttractionVisit>(res)) { return TimelineModel::TouristAttraction; }
return {};
}
......@@ -112,6 +121,9 @@ static QString destinationCountry(const QVariant &res)
if (JsonLd::isA<FoodEstablishmentReservation>(res)) {
return res.value<FoodEstablishmentReservation>().reservationFor().value<FoodEstablishment>().address().addressCountry();
}
if (JsonLd::isA<TouristAttractionVisit>(res)) {
return res.value<TouristAttractionVisit>().touristAttraction().address().addressCountry();
}
return {};
}
......
......@@ -50,6 +50,7 @@ public:
BusTrip,
Hotel,
Restaurant,
TouristAttraction,
TodayMarker,
CountryInfo
};
......
......@@ -245,6 +245,26 @@
"departureTime": "2017-09-13T14:00:00"
}
},
{
"@context": "http://schema.org",
"@type": "TouristAttractionVisit",
"arrivalTime": "2017-09-13T14:30:00",
"departureTime": "2017-09-13T15:30:00",
"touristAttraction": {
"@type": "TouristAttraction",
"name": "Matterhorn",
"address": {
"@type": "PostalAddress",
"addressCountry": "CH",
"addressLocality": "Zermatt"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": 46.01505,
"longitude": 7.74224
}
}
},
{
"@context": "http://schema.org",
"@type": "FoodEstablishmentReservation",
......
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