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

Add action to jump directly to the current ticket

That's a useful shortcut when finding yourself confronted with a ticket
check. Requires some rearranging of how we create reservation details pages
though.
parent 2b0f781c
......@@ -85,13 +85,5 @@ App.TimelineDelegate {
}
}
Component {
id: detailsComponent
App.BusPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(busDetailsPage, root.batchId)
}
......@@ -65,13 +65,5 @@ App.TimelineDelegate {
}
}
Component {
id: detailsComponent
App.CarRentalPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(carRentalDetailsPage, root.batchId)
}
......@@ -65,12 +65,5 @@ App.TimelineDelegate {
}
}
Component {
id: detailsComponent
App.EventPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(eventDetailsPage, root.batchId)
}
......@@ -102,12 +102,5 @@ App.TimelineDelegate {
}
}
Component {
id: detailsComponent
App.FlightPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(flightDetailsPage, root.batchId)
}
......@@ -49,12 +49,5 @@ App.TimelineDelegate {
}
Component {
id: detailsComponent
App.HotelPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(hotelDetailsPage, root.batchId)
}
......@@ -40,12 +40,5 @@ App.TimelineDelegate {
}
}
Component {
id: detailsComponent
App.RestaurantPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(restaurantDetailsPage, root.batchId)
}
......@@ -24,6 +24,12 @@ Kirigami.ScrollablePage {
text: i18n("Today")
iconName: "view-calendar-day"
onTriggered: listView.positionViewAtIndex(TripGroupProxyModel.todayRow, ListView.Beginning);
},
Kirigami.Action {
text: i18n("Current Ticket")
iconName: "view-barcode-qr"
enabled: TimelineModel.currentBatchId !== ""
onTriggered: showDetailsPageForReservation(TimelineModel.currentBatchId)
}
]
}
......@@ -61,6 +67,72 @@ Kirigami.ScrollablePage {
onAccepted: ApplicationController.exportTripToGpx(tripGroupId, file)
}
Component {
id: flightDetailsPage
App.FlightPage {}
}
Component {
id: trainDetailsPage
App.TrainPage {}
}
Component {
id: busDetailsPage
App.BusPage {}
}
Component {
id: hotelDetailsPage
App.HotelPage {}
}
Component {
id: eventDetailsPage
App.EventPage {}
}
Component {
id: restaurantDetailsPage
App.RestaurantPage {}
}
Component {
id: carRentalDetailsPage
App.CarRentalPage {}
}
Component {
id: touristAttractionDetailsPage
App.TouristAttractionPage {}
}
function detailsComponent(batchId) {
const res = ReservationManager.reservation(batchId);
if (!res) {
return undefined;
}
switch (res.className) {
case "FlightReservation": return flightDetailsPage;
case "TrainReservation": return trainDetailsPage;
case "BusReservation": return busDetailsPage;
case "LodgingReservation": return hotelDetailsPage;
case "EventReservation": return eventDetailsPage;
case "FoodEstablishmentReservation": return restaurantDetailsPage;
case "RentalCarReservation": return carRentalDetailsPage;
case "TouristAttractionVisit": return touristAttractionDetailsPage;
}
console.log("unhandled reservation type:", res.className);
return undefined;
}
function showDetailsPageForReservation(batchId) {
const c = detailsComponent(batchId);
if (c) {
showDetailsPage(c, batchId);
}
}
function showDetailsPage(detailsComponent, batchId) {
while (applicationWindow().pageStack.depth > 1) {
applicationWindow().pageStack.pop();
}
applicationWindow().pageStack.push(detailsComponent, { batchId: batchId });
}
Models.DelegateChooser {
id: chooser
role: "type"
......
......@@ -41,12 +41,5 @@ App.TimelineDelegate {
}
}
Component {
id: detailsComponent
App.TouristAttractionPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(touristAttractionDetailsPage, root.batchId)
}
......@@ -100,12 +100,5 @@ App.TimelineDelegate {
}
}
Component {
id: detailsComponent
App.TrainPage {
batchId: root.batchId
}
}
onClicked: showDetails(detailsComponent)
onClicked: showDetailsPage(trainDetailsPage, root.batchId)
}
......@@ -156,6 +156,9 @@ Kirigami.ApplicationWindow {
pageStack.layers.pop();
}
switch (page) {
case "currentTicket":
applicationWindow().pageStack.get(0, false).showDetailsPageForReservation(TimelineModel.currentBatchId);
break;
case "stats":
statsAction.trigger();
break;
......
......@@ -82,7 +82,12 @@ MimeType=application/vnd.apple.pkpass;application/ld+json;application/pdf;text/c
Categories=Qt;KDE;Utility;
X-KDE-HasTempFileOption=true
X-KDE-FormFactor=desktop;tablet;handset;
Actions=statistics;healthCert;
Actions=currentTicket;statistics;healthCert;
[Desktop Action currentTicket]
Name=Current Ticket
Icon=view-barcode-qr
Exec=itinerary --page currentTicket
[Desktop Action statistics]
Name=Statistics
......
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