Commit 62c87941 authored by Volker Krause's avatar Volker Krause

Port the QML facing API of timeline model to batches too

This ensures we are always using the batch id for batch operations, rather
than a random one of the batch, which isn't guaranteed to work. With this
live data access for multi-traveler batches should work correctly too.
parent 3a171a4d
...@@ -169,7 +169,7 @@ private Q_SLOTS: ...@@ -169,7 +169,7 @@ private Q_SLOTS:
QCOMPARE(model.rowCount(), 4); QCOMPARE(model.rowCount(), 4);
// delete a split element // delete a split element
const auto resId = model.data(model.index(1, 0), TimelineModel::ReservationIdsRole).toStringList().value(0); const auto resId = model.data(model.index(1, 0), TimelineModel::BatchIdRole).toString();
QVERIFY(!resId.isEmpty()); QVERIFY(!resId.isEmpty());
resMgr.removeReservation(resId); resMgr.removeReservation(resId);
QCOMPARE(rmSpy.size(), 4); QCOMPARE(rmSpy.size(), 4);
...@@ -211,7 +211,7 @@ private Q_SLOTS: ...@@ -211,7 +211,7 @@ private Q_SLOTS:
QCOMPARE(model.index(4, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker); QCOMPARE(model.index(4, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker);
// remove the GB flight should also remove the GB country info // remove the GB flight should also remove the GB country info
auto resId = model.index(1, 0).data(TimelineModel::ReservationIdsRole).toStringList().value(0); auto resId = model.index(1, 0).data(TimelineModel::BatchIdRole).toString();
resMgr.removeReservation(resId); resMgr.removeReservation(resId);
QCOMPARE(model.rowCount(), 3); QCOMPARE(model.rowCount(), 3);
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::CountryInfo); QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::CountryInfo);
...@@ -219,7 +219,7 @@ private Q_SLOTS: ...@@ -219,7 +219,7 @@ private Q_SLOTS:
QCOMPARE(model.index(2, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker); QCOMPARE(model.index(2, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker);
// remove the US flight should also remove the US country info // remove the US flight should also remove the US country info
resId = model.index(1, 0).data(TimelineModel::ReservationIdsRole).toStringList().value(0); resId = model.index(1, 0).data(TimelineModel::BatchIdRole).toString();
resMgr.removeReservation(resId); resMgr.removeReservation(resId);
QCOMPARE(model.rowCount(), 1); QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker); QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker);
...@@ -361,9 +361,9 @@ private Q_SLOTS: ...@@ -361,9 +361,9 @@ private Q_SLOTS:
QCOMPARE(fc.dateTime(), QDateTime(QDate::currentDate().addDays(5), QTime(0, 0))); QCOMPARE(fc.dateTime(), QDateTime(QDate::currentDate().addDays(5), QTime(0, 0)));
// clean up // clean up
auto resId = model.index(13, 0).data(TimelineModel::ReservationIdsRole).toStringList().value(0); auto resId = model.index(13, 0).data(TimelineModel::BatchIdRole).toString();
resMgr.removeReservation(resId); resMgr.removeReservation(resId);
resId = model.index(4, 0).data(TimelineModel::ReservationIdsRole).toStringList().value(0); resId = model.index(4, 0).data(TimelineModel::BatchIdRole).toString();
resMgr.removeReservation(resId); resMgr.removeReservation(resId);
QCOMPARE(model.rowCount(), 11); QCOMPARE(model.rowCount(), 11);
...@@ -401,8 +401,8 @@ private Q_SLOTS: ...@@ -401,8 +401,8 @@ private Q_SLOTS:
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight); QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight);
QCOMPARE(model.index(1, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight); QCOMPARE(model.index(1, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight);
QCOMPARE(model.index(2, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker); QCOMPARE(model.index(2, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker);
QCOMPARE(model.index(0, 0).data(TimelineModel::ReservationIdsRole).toStringList().size(), 2); QCOMPARE(resMgr.reservationsForBatch(model.index(0, 0).data(TimelineModel::BatchIdRole).toString()).size(), 2);
QCOMPARE(model.index(1, 0).data(TimelineModel::ReservationIdsRole).toStringList().size(), 2); QCOMPARE(resMgr.reservationsForBatch(model.index(1, 0).data(TimelineModel::BatchIdRole).toString()).size(), 2);
// already existing data // already existing data
model.setReservationManager(nullptr); model.setReservationManager(nullptr);
...@@ -411,13 +411,13 @@ private Q_SLOTS: ...@@ -411,13 +411,13 @@ private Q_SLOTS:
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight); QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight);
QCOMPARE(model.index(1, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight); QCOMPARE(model.index(1, 0).data(TimelineModel::ElementTypeRole), TimelineModel::Flight);
QCOMPARE(model.index(2, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker); QCOMPARE(model.index(2, 0).data(TimelineModel::ElementTypeRole), TimelineModel::TodayMarker);
QCOMPARE(model.index(0, 0).data(TimelineModel::ReservationIdsRole).toStringList().size(), 2); QCOMPARE(resMgr.reservationsForBatch(model.index(0, 0).data(TimelineModel::BatchIdRole).toString()).size(), 2);
QCOMPARE(model.index(1, 0).data(TimelineModel::ReservationIdsRole).toStringList().size(), 2); QCOMPARE(resMgr.reservationsForBatch(model.index(1, 0).data(TimelineModel::BatchIdRole).toString()).size(), 2);
// update splits element // update splits element
updateSpy.clear(); updateSpy.clear();
insertSpy.clear(); insertSpy.clear();
auto resId = model.index(1, 0).data(TimelineModel::ReservationIdsRole).toStringList().value(0); auto resId = model.index(1, 0).data(TimelineModel::BatchIdRole).toString();
QVERIFY(!resId.isEmpty()); QVERIFY(!resId.isEmpty());
auto res = resMgr.reservation(resId).value<FlightReservation>(); auto res = resMgr.reservation(resId).value<FlightReservation>();
auto flight = res.reservationFor().value<Flight>(); auto flight = res.reservationFor().value<Flight>();
...@@ -467,25 +467,25 @@ private Q_SLOTS: ...@@ -467,25 +467,25 @@ private Q_SLOTS:
model.setWeatherForecastManager(&weatherMgr); model.setWeatherForecastManager(&weatherMgr);
ModelVerificationPoint vp0(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r0.model")); ModelVerificationPoint vp0(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r0.model"));
vp0.setRoleFilter({TimelineModel::ReservationIdsRole}); vp0.setRoleFilter({TimelineModel::BatchIdRole});
QVERIFY(vp0.verify(&model)); QVERIFY(vp0.verify(&model));
// changing the day should move the today marker // changing the day should move the today marker
model.setCurrentDateTime(QDateTime({2196, 10, 15}, {0, 15})); model.setCurrentDateTime(QDateTime({2196, 10, 15}, {0, 15}));
ModelVerificationPoint vp1(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r1.model")); ModelVerificationPoint vp1(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r1.model"));
vp1.setRoleFilter({TimelineModel::ReservationIdsRole}); vp1.setRoleFilter({TimelineModel::BatchIdRole});
QVERIFY(vp1.verify(&model)); QVERIFY(vp1.verify(&model));
// load something to define the current location, so we get weather // load something to define the current location, so we get weather
resMgr.importReservation(readFile(QLatin1String(SOURCE_DIR "/data/flight-txl-lhr-sfo.json"))); resMgr.importReservation(readFile(QLatin1String(SOURCE_DIR "/data/flight-txl-lhr-sfo.json")));
ModelVerificationPoint vp2(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r2.model")); ModelVerificationPoint vp2(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r2.model"));
vp2.setRoleFilter({TimelineModel::ReservationIdsRole}); vp2.setRoleFilter({TimelineModel::BatchIdRole});
QVERIFY(vp2.verify(&model)); QVERIFY(vp2.verify(&model));
// changing the day should move the today marker and weather one day forward // changing the day should move the today marker and weather one day forward
model.setCurrentDateTime(QDateTime({2196, 10, 16}, {19, 30})); model.setCurrentDateTime(QDateTime({2196, 10, 16}, {19, 30}));
ModelVerificationPoint vp3(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r3.model")); ModelVerificationPoint vp3(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r3.model"));
vp3.setRoleFilter({TimelineModel::ReservationIdsRole}); vp3.setRoleFilter({TimelineModel::BatchIdRole});
QVERIFY(vp3.verify(&model)); QVERIFY(vp3.verify(&model));
} }
...@@ -521,7 +521,7 @@ private Q_SLOTS: ...@@ -521,7 +521,7 @@ private Q_SLOTS:
// check state is correct for data imported at the start // check state is correct for data imported at the start
ModelVerificationPoint vp(QLatin1String(SOURCE_DIR "/data/timeline/") + baseName + QLatin1String(".model")); ModelVerificationPoint vp(QLatin1String(SOURCE_DIR "/data/timeline/") + baseName + QLatin1String(".model"));
vp.setRoleFilter({TimelineModel::ReservationIdsRole, TimelineModel::TripGroupIdRole}); vp.setRoleFilter({TimelineModel::BatchIdRole, TimelineModel::TripGroupIdRole});
QVERIFY(vp.verify(&model)); QVERIFY(vp.verify(&model));
// retry with loading during runtime // retry with loading during runtime
......
...@@ -91,22 +91,22 @@ private Q_SLOTS: ...@@ -91,22 +91,22 @@ private Q_SLOTS:
proxy.expand(addSpy.at(2).at(0).toString()); proxy.expand(addSpy.at(2).at(0).toString());
ModelVerificationPoint vp0(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r0.model")); ModelVerificationPoint vp0(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r0.model"));
vp0.setRoleFilter({TimelineModel::ReservationIdsRole, TimelineModel::TripGroupIdRole}); vp0.setRoleFilter({TimelineModel::BatchIdRole, TimelineModel::TripGroupIdRole});
QVERIFY(vp0.verify(&proxy)); QVERIFY(vp0.verify(&proxy));
proxy.collapse(addSpy.at(0).at(0).toString()); proxy.collapse(addSpy.at(0).at(0).toString());
ModelVerificationPoint vp1(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r1.model")); ModelVerificationPoint vp1(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r1.model"));
vp1.setRoleFilter({TimelineModel::ReservationIdsRole, TimelineModel::TripGroupIdRole}); vp1.setRoleFilter({TimelineModel::BatchIdRole, TimelineModel::TripGroupIdRole});
QVERIFY(vp1.verify(&proxy)); QVERIFY(vp1.verify(&proxy));
proxy.collapse(addSpy.at(1).at(0).toString()); proxy.collapse(addSpy.at(1).at(0).toString());
ModelVerificationPoint vp2(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r2.model")); ModelVerificationPoint vp2(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r2.model"));
vp2.setRoleFilter({TimelineModel::ReservationIdsRole, TimelineModel::TripGroupIdRole}); vp2.setRoleFilter({TimelineModel::BatchIdRole, TimelineModel::TripGroupIdRole});
QVERIFY(vp2.verify(&proxy)); QVERIFY(vp2.verify(&proxy));
proxy.collapse(addSpy.at(2).at(0).toString()); proxy.collapse(addSpy.at(2).at(0).toString());
ModelVerificationPoint vp3(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r3.model")); ModelVerificationPoint vp3(QLatin1String(SOURCE_DIR "/data/tripgroupproxy/expand-collapse-r3.model"));
vp3.setRoleFilter({TimelineModel::ReservationIdsRole, TimelineModel::TripGroupIdRole}); vp3.setRoleFilter({TimelineModel::BatchIdRole, TimelineModel::TripGroupIdRole});
QVERIFY(vp3.verify(&proxy)); QVERIFY(vp3.verify(&proxy));
proxy.expand(addSpy.at(2).at(0).toString()); proxy.expand(addSpy.at(2).at(0).toString());
......
...@@ -71,7 +71,7 @@ App.TimelineDelegate { ...@@ -71,7 +71,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.BusPage { App.BusPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -41,7 +41,7 @@ App.DetailsPage { ...@@ -41,7 +41,7 @@ App.DetailsPage {
// ticket barcode // ticket barcode
App.TicketTokenDelegate { App.TicketTokenDelegate {
Kirigami.FormData.isSection: true Kirigami.FormData.isSection: true
resIds: root.resIds resIds: _reservationManager.reservationsForBatch(root.batchId)
} }
// departure data // departure data
......
...@@ -71,7 +71,7 @@ App.TimelineDelegate { ...@@ -71,7 +71,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.CarRentalPage { App.CarRentalPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -25,10 +25,10 @@ import "." as App ...@@ -25,10 +25,10 @@ import "." as App
Kirigami.ScrollablePage { Kirigami.ScrollablePage {
id: root id: root
/** One ore more ids of the reservations shown in this element. */ /** The reservation batch identifier (@see ReservationManager). */
property var resIds property var batchId
/** @deprecated */ /** @deprecated */
readonly property var reservation: _reservationManager.reservation(root.resIds[0]); readonly property var reservation: _reservationManager.reservation(batchId);
/** Reservation::reservationFor, unique for all travelers on a multi-traveler reservation set */ /** Reservation::reservationFor, unique for all travelers on a multi-traveler reservation set */
readonly property var reservationFor: reservation.reservationFor readonly property var reservationFor: reservation.reservationFor
property var editor property var editor
...@@ -48,7 +48,7 @@ Kirigami.ScrollablePage { ...@@ -48,7 +48,7 @@ Kirigami.ScrollablePage {
text: i18n("Delete") text: i18n("Delete")
icon.name: "edit-delete" icon.name: "edit-delete"
onClicked: { onClicked: {
_reservationManager.removeReservations(root.resIds); _reservationManager.removeBatch(root.batchId);
applicationWindow().pageStack.pop(); applicationWindow().pageStack.pop();
} }
} }
......
...@@ -25,9 +25,9 @@ import "." as App ...@@ -25,9 +25,9 @@ import "." as App
Kirigami.ScrollablePage { Kirigami.ScrollablePage {
id: root id: root
property var resIds property var batchId
readonly property string resId: resIds[0] property var resIds: _reservationManager.reservationsForBatch(root.batchId)
readonly property var reservation: _reservationManager.reservation(root.resId); readonly property var reservation: _reservationManager.reservation(root.batchId);
property alias dateTimeEditSheet: _dateTimeEditSheet property alias dateTimeEditSheet: _dateTimeEditSheet
...@@ -35,7 +35,7 @@ Kirigami.ScrollablePage { ...@@ -35,7 +35,7 @@ Kirigami.ScrollablePage {
main: Kirigami.Action { main: Kirigami.Action {
iconName: "document-save" iconName: "document-save"
onTriggered: { onTriggered: {
root.save(resId, reservation); root.save(batchId, reservation);
pageStack.pop(); pageStack.pop();
} }
} }
......
...@@ -61,7 +61,7 @@ App.TimelineDelegate { ...@@ -61,7 +61,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.EventPage { App.EventPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -40,7 +40,7 @@ App.DetailsPage { ...@@ -40,7 +40,7 @@ App.DetailsPage {
App.TicketTokenDelegate { App.TicketTokenDelegate {
Kirigami.FormData.isSection: true Kirigami.FormData.isSection: true
resIds: root.resIds resIds: _reservationManager.reservationsForBatch(root.batchId)
} }
QQC2.Label { QQC2.Label {
......
...@@ -110,7 +110,7 @@ App.TimelineDelegate { ...@@ -110,7 +110,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.FlightPage { App.FlightPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -26,9 +26,10 @@ import "." as App ...@@ -26,9 +26,10 @@ import "." as App
App.DetailsPage { App.DetailsPage {
id: root id: root
title: i18n("Flight") title: i18n("Flight")
property var resIds: _reservationManager.reservationsForBatch(root.batchId)
editor: Component { editor: Component {
App.FlightEditor { App.FlightEditor {
resIds: root.resIds batchId: root.batchId
} }
} }
...@@ -46,7 +47,7 @@ App.DetailsPage { ...@@ -46,7 +47,7 @@ App.DetailsPage {
// ticket barcode // ticket barcode
App.TicketTokenDelegate { App.TicketTokenDelegate {
Kirigami.FormData.isSection: true Kirigami.FormData.isSection: true
resIds: root.resIds resIds: _reservationManager.reservationsForBatch(root.batchId)
} }
// flight details // flight details
......
...@@ -58,7 +58,7 @@ App.TimelineDelegate { ...@@ -58,7 +58,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.HotelPage { App.HotelPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -52,7 +52,7 @@ App.TimelineDelegate { ...@@ -52,7 +52,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.RestaurantPage { App.RestaurantPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -28,7 +28,7 @@ App.DetailsPage { ...@@ -28,7 +28,7 @@ App.DetailsPage {
title: i18n("Restaurant Reservation") title: i18n("Restaurant Reservation")
editor: Component { editor: Component {
App.RestaurantEditor { App.RestaurantEditor {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -24,12 +24,14 @@ import "." as App ...@@ -24,12 +24,14 @@ import "." as App
Kirigami.AbstractCard { Kirigami.AbstractCard {
id: root id: root
/** One ore more ids of the reservations shown in this element. */ /** Reservation batch identifier (@see _reservationManager). */
property var resIds property var batchId
/** All reservations that are part of this patch. */
property var resIds: _reservationManager.reservationsForBatch(root.batchId)
/** A random reservation object, in case there's more than one. /** A random reservation object, in case there's more than one.
* Use this only for accessing properties that will be the same for all travlers. * Use this only for accessing properties that will be the same for all travlers.
*/ */
readonly property var reservation: _reservationManager.reservation(root.resIds[0]); readonly property var reservation: _reservationManager.reservation(root.batchId);
/** Reservation::reservationFor, unique for all travelers on a multi-traveler reservation set */ /** Reservation::reservationFor, unique for all travelers on a multi-traveler reservation set */
readonly property var reservationFor: reservation.reservationFor readonly property var reservationFor: reservation.reservationFor
property var rangeType property var rangeType
......
...@@ -41,56 +41,56 @@ Kirigami.ScrollablePage { ...@@ -41,56 +41,56 @@ Kirigami.ScrollablePage {
Component { Component {
id: flightDelegate id: flightDelegate
App.FlightDelegate { App.FlightDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
Component { Component {
id: hotelDelegate id: hotelDelegate
App.HotelDelegate { App.HotelDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
Component { Component {
id: trainDelegate id: trainDelegate
App.TrainDelegate { App.TrainDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
Component { Component {
id: busDelegate id: busDelegate
App.BusDelegate { App.BusDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
Component { Component {
id: restaurantDelegate id: restaurantDelegate
App.RestaurantDelegate { App.RestaurantDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
Component { Component {
id: touristAttractionDelegate id: touristAttractionDelegate
App.TouristAttractionDelegate { App.TouristAttractionDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
Component { Component {
id: eventDelegate id: eventDelegate
App.EventDelegate { App.EventDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
Component { Component {
id: carRentalDelegate id: carRentalDelegate
App.CarRentalDelegate { App.CarRentalDelegate {
resIds: modelData.reservationIds batchId: modelData.batchId
rangeType: modelData.rangeType rangeType: modelData.rangeType
} }
} }
......
...@@ -24,7 +24,7 @@ import "." as App ...@@ -24,7 +24,7 @@ import "." as App
App.TimelineDelegate { App.TimelineDelegate {
id: root id: root
readonly property var touristAttraction: _reservationManager.reservation(root.resIds[0]).touristAttraction readonly property var touristAttraction: _reservationManager.reservation(root.batchId).touristAttraction
headerIconSource: "meeting-attending" // TODO better icon, e.g. something like 🎢? headerIconSource: "meeting-attending" // TODO better icon, e.g. something like 🎢?
headerItem: RowLayout { headerItem: RowLayout {
...@@ -53,7 +53,7 @@ App.TimelineDelegate { ...@@ -53,7 +53,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.TouristAttractionPage { App.TouristAttractionPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -25,7 +25,7 @@ import "." as App ...@@ -25,7 +25,7 @@ import "." as App
App.DetailsPage { App.DetailsPage {
id: root id: root
readonly property var touristAttraction: _reservationManager.reservation(root.resIds[0]).touristAttraction readonly property var touristAttraction: _reservationManager.reservation(root.batchId).touristAttraction
title: i18n("Tourist Attraction") title: i18n("Tourist Attraction")
Kirigami.FormLayout { Kirigami.FormLayout {
......
...@@ -24,8 +24,8 @@ import "." as App ...@@ -24,8 +24,8 @@ import "." as App
App.TimelineDelegate { App.TimelineDelegate {
id: root id: root
property var arrival: _liveDataManager.arrival(resIds[0]) property var arrival: _liveDataManager.arrival(batchId)
property var departure: _liveDataManager.departure(resIds[0]) property var departure: _liveDataManager.departure(batchId)
headerIconSource: "qrc:///images/train.svg" headerIconSource: "qrc:///images/train.svg"
headerItem: RowLayout { headerItem: RowLayout {
...@@ -104,7 +104,7 @@ App.TimelineDelegate { ...@@ -104,7 +104,7 @@ App.TimelineDelegate {
Component { Component {
id: detailsComponent id: detailsComponent
App.TrainPage { App.TrainPage {
resIds: root.resIds batchId: root.batchId
} }
} }
......
...@@ -26,8 +26,8 @@ import "." as App ...@@ -26,8 +26,8 @@ import "." as App
App.DetailsPage { App.DetailsPage {
id: root id: root
title: i18n("Train Ticket") title: i18n("Train Ticket")
property var arrival: _liveDataManager.arrival(resIds[0]) property var arrival: _liveDataManager.arrival(batchId)
property var departure: _liveDataManager.departure(resIds[0]) property var departure: _liveDataManager.departure(batchId)
Kirigami.FormLayout { Kirigami.FormLayout {
width: root.width width: root.width
...@@ -43,7 +43,7 @@ App.DetailsPage { ...@@ -43,7 +43,7 @@ App.DetailsPage {
// ticket barcode // ticket barcode
App.TicketTokenDelegate { App.TicketTokenDelegate {
Kirigami.FormData.isSection: true Kirigami.FormData.isSection: true
resIds: root.resIds resIds: _reservationManager.reservationsForBatch(root.batchId)
} }
// departure data // departure data
......
...@@ -245,12 +245,6 @@ void ReservationManager::removeReservation(const QString& id) ...@@ -245,12 +245,6 @@ void ReservationManager::removeReservation(const QString& id)
m_reservations.remove(id); m_reservations.remove(id);
} }
void ReservationManager::removeReservations(const QStringList& ids)
{
for (const auto &id : ids)
removeReservation(id);
}
const std::vector<QString>& ReservationManager::batches() const const std::vector<QString>& ReservationManager::batches() const
{ {
return m_batches; return m_batches;
......
...@@ -52,7 +52,6 @@ public: ...@@ -52,7 +52,6 @@ public:
Q_INVOKABLE void addReservation(const QVariant &res); Q_INVOKABLE void addReservation(const QVariant &res);
Q_INVOKABLE void updateReservation(const QString &resId, const QVariant &res); Q_INVOKABLE void updateReservation(const QString &resId, const QVariant &res);
Q_INVOKABLE void removeReservation(const QString &id); Q_INVOKABLE void removeReservation(const QString &id);
Q_INVOKABLE void removeReservations(const QStringList &ids);
void importReservation(const QByteArray &data); void importReservation(const QByteArray &data);
void importReservations(const QVector<QVariant> &resData); void importReservations(const QVector<QVariant> &resData);
......
...@@ -220,8 +220,8 @@ QVariant TimelineModel::data(const QModelIndex& index, int role) const ...@@ -220,8 +220,8 @@ QVariant TimelineModel::data(const QModelIndex& index, int role) const
} }
return i18nc("weekday, date", "%1, %2", QLocale().dayName(elem.dt.date().dayOfWeek(), QLocale::LongFormat), QLocale().toString(elem.dt.date(), QLocale::ShortFormat)); return i18nc("weekday, date", "%1, %2", QLocale().dayName(elem.dt.date().dayOfWeek(), QLocale::LongFormat), QLocale().toString(elem.dt.date(), QLocale::ShortFormat));
} }
case ReservationIdsRole: case BatchIdRole:
return m_resMgr->reservationsForBatch(elem.batchId); return elem.batchId;
case ElementTypeRole: case ElementTypeRole:
return elem.elementType; return elem.elementType;
case TodayEmptyRole: case TodayEmptyRole:
...@@ -269,7 +269,7 @@ QHash<int, QByteArray> TimelineModel::roleNames() const ...@@ -269,7 +269,7 @@ QHash<int, QByteArray> TimelineModel::roleNames() const
{ {
auto names = QAbstractListModel::roleNames(); auto names = QAbstractListModel::roleNames();
names.insert(SectionHeader, "sectionHeader"); names.insert(SectionHeader, "sectionHeader");
names.insert(ReservationIdsRole, "reservationIds");