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

Add restaurant reservation delegate

parent 5d9f7288
/*
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").arg(reservation.reservationFor.name)
color: Kirigami.Theme.complementaryTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
}
QQC2.Label {
text: reservation.startTime
color: Kirigami.Theme.complementaryTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
}
}
}
QQC2.Label {
text: qsTr("Address:\n%1\n%2 %3\n%4 ")
.arg(reservation.reservationFor.address.streetAddress)
.arg(reservation.reservationFor.address.postalCode)
.arg(reservation.reservationFor.address.addressLocality)
.arg(reservation.reservationFor.address.addressCountry)
color: Kirigami.Theme.textColor
}
QQC2.Label {
text: qsTr("Person: %1")
.arg(reservation.partySize)
color: Kirigami.Theme.textColor
}
QQC2.Label {
text: qsTr("End: %1")
.arg(reservation.endTime)
color: Kirigami.Theme.textColor
}
}
}
......@@ -55,6 +55,10 @@ Kirigami.ScrollablePage {
id: busDelegate
App.BusDelegate {}
}
Component {
id: restaurantDelegate
App.RestaurantDelegate {}
}
Component {
id: todayDelegate
Item {
......@@ -86,6 +90,7 @@ Kirigami.ScrollablePage {
case TimelineModel.Hotel: return hotelDelegate;
case TimelineModel.TrainTrip: return trainDelegate;
case TimelineModel.BusTrip: return busDelegate;
case TimelineModel.Restaurant: return restaurantDelegate;
case TimelineModel.TodayMarker: return todayDelegate;
}
}
......
......@@ -5,6 +5,7 @@
<file>BusDelegate.qml</file>
<file>FlightDelegate.qml</file>
<file>HotelDelegate.qml</file>
<file>RestaurantDelegate.qml</file>
<file>TimelineDelegate.qml</file>
<file>TimelinePage.qml</file>
<file>TrainDelegate.qml</file>
......
......@@ -22,6 +22,7 @@
#include <KItinerary/BusTrip>
#include <KItinerary/Flight>
#include <KItinerary/JsonLdDocument>
#include <KItinerary/Organization>
#include <KItinerary/Reservation>
#include <KItinerary/TrainTrip>
......@@ -48,6 +49,8 @@ static QDate relevantDate(const QVariant &res)
return res.value<TrainReservation>().reservationFor().value<TrainTrip>().departureTime().date();
} else if (res.userType() == qMetaTypeId<BusReservation>()) {
return res.value<BusReservation>().reservationFor().value<BusTrip>().departureTime().date();
} else if (res.userType() == qMetaTypeId<FoodEstablishmentReservation>()) {
return res.value<FoodEstablishmentReservation>().startTime().date();
}
return {};
......@@ -64,6 +67,8 @@ static QDateTime relevantDateTime(const QVariant &res)
return res.value<TrainReservation>().reservationFor().value<TrainTrip>().departureTime();
} else if (res.userType() == qMetaTypeId<BusReservation>()) {
return res.value<BusReservation>().reservationFor().value<BusTrip>().departureTime();
} else if (res.userType() == qMetaTypeId<FoodEstablishmentReservation>()) {
return res.value<FoodEstablishmentReservation>().startTime();
}
return {};
......@@ -158,6 +163,8 @@ QVariant TimelineModel::data(const QModelIndex& index, int role) const
return TrainTrip;
else if (res.userType() == qMetaTypeId<BusReservation>())
return BusTrip;
else if (res.userType() == qMetaTypeId<FoodEstablishmentReservation>())
return Restaurant;
return {};
case TodayEmptyRole:
if (res.isNull()) {
......
......@@ -44,6 +44,7 @@ public:
TrainTrip,
BusTrip,
Hotel,
Restaurant,
TodayMarker
};
Q_ENUM(ElementType)
......
......@@ -181,7 +181,7 @@
},
"partySize": 20,
"startTime": "2017-09-14T19:00:00+02:00",
"modifiedTime": "2017-09-14T22:00:00+02:00"
"endTime": "2017-09-14T22:00:00+02:00"
},
{
"@context": "http://schema.org",
......
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