Commit 57b803d7 authored by Volker Krause's avatar Volker Krause
Browse files

Add delegate for bus trips

parent cd7bcbcf
/*
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.0 as Kirigami
import "." as App
App.TimelineDelegate {
id: root
implicitHeight: topLayout.implicitHeight
ColumnLayout {
id: topLayout
width: root.width
Rectangle {
id: headerBackground
Layout.fillWidth: true
color: Kirigami.Theme.complementaryBackgroundColor
implicitHeight: headerLayout.implicitHeight
RowLayout {
id: headerLayout
anchors.left: parent.left
anchors.right: parent.right
QQC2.Label {
text: qsTr("🚌 %1 %2")
.arg(reservation.reservationFor.busName)
.arg(reservation.reservationFor.busNumber)
color: Kirigami.Theme.complementaryTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1.6
Layout.fillWidth: true
}
QQC2.Label {
text: reservation.reservationFor.departureTimeLocalized
color: Kirigami.Theme.complementaryTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1.6
}
}
}
QQC2.Label {
text: qsTr("From: %1")
.arg(reservation.reservationFor.departureStation.name)
color: Kirigami.Theme.textColor
}
QQC2.Label {
text: qsTr("To: %1 ")
.arg(reservation.reservationFor.arrivalStation.name)
color: Kirigami.Theme.textColor
}
}
}
......@@ -27,8 +27,7 @@ App.TimelineDelegate {
ColumnLayout {
id: topLayout
anchors.left: parent.left
anchors.right: parent.right
width: root.width
Rectangle {
id: headerBackground
......
......@@ -26,8 +26,7 @@ App.TimelineDelegate {
ColumnLayout {
id: topLayout
anchors.left: parent.left
anchors.right: parent.right
width: root.width
Rectangle {
id: headerBackground
......
......@@ -22,8 +22,5 @@ Item {
property var pass
property string passId
anchors.left: parent.left
anchors.right: parent.right
signal showBoardingPass(var pass, string passId)
}
......@@ -51,6 +51,10 @@ Kirigami.ScrollablePage {
id: trainDelegate
App.TrainDelegate {}
}
Component {
id: busDelegate
App.BusDelegate {}
}
ListView {
model: _timelineModel
......@@ -60,13 +64,14 @@ Kirigami.ScrollablePage {
property var modelData: model
height: item.implicitHeight
width: ListView.view.width
anchors.left: parent.left
anchors.right: parent.right
sourceComponent: {
switch (modelData.type) {
case TimelineModel.Flight: return flightDelegate;
case TimelineModel.Hotel: return hotelDelegate;
case TimelineModel.TrainTrip: return trainDelegate;
// TODO complete this
case TimelineModel.BusTrip: return busDelegate;
}
}
......
......@@ -27,8 +27,7 @@ App.TimelineDelegate {
ColumnLayout {
id: topLayout
anchors.left: parent.left
anchors.right: parent.right
width: root.width
Rectangle {
id: headerBackground
......
......@@ -2,6 +2,7 @@
<qresource prefix="/">
<file>main.qml</file>
<file>BoardingPass.qml</file>
<file>BusDelegate.qml</file>
<file>FlightDelegate.qml</file>
<file>HotelDelegate.qml</file>
<file>TimelineDelegate.qml</file>
......
......@@ -42,8 +42,9 @@ static QDate relevantDate(const QVariant &res)
return res.value<LodgingReservation>().checkinDate().date();
} else if (res.userType() == qMetaTypeId<TrainReservation>()) {
return res.value<TrainReservation>().reservationFor().value<TrainTrip>().departureTime().date();
} else if (res.userType() == qMetaTypeId<BusReservation>()) {
return res.value<BusReservation>().reservationFor().value<BusTrip>().departureTime().date();
}
// TODO: bus
return {};
}
......@@ -57,8 +58,9 @@ static QDateTime relevantDateTime(const QVariant &res)
return flight.departureTime();
} else if (res.userType() == qMetaTypeId<TrainReservation>()) {
return res.value<TrainReservation>().reservationFor().value<TrainTrip>().departureTime();
} else if (res.userType() == qMetaTypeId<BusReservation>()) {
return res.value<BusReservation>().reservationFor().value<BusTrip>().departureTime();
}
// TODO: bus
return {};
}
......
......@@ -96,6 +96,25 @@
"url": "https://randa-meetings.ch/"
}
},
{
"@context": "http://schema.org",
"@type": "BusReservation",
"reservationFor": {
"@type": "BusTrip",
"arrivalStation": {
"@type": "BusStation",
"name": "Zermatt"
},
"arrivalTime": "2017-09-13T14:20:00",
"busName": "Zermatt Taxi",
"busNumber": "",
"departureStation": {
"@type": "BusStation",
"name": "Randa"
},
"departureTime": "2017-09-13T14:00:00"
}
},
{
"@context": "http://schema.org",
"@type": "FlightReservation",
......
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