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

Compute transfer anchor times using realtime data when available

parent 98b4105c
......@@ -12,6 +12,7 @@
#include <reservationmanager.h>
#include <tripgroupmanager.h>
#include <favoritelocationmodel.h>
#include <livedatamanager.h>
#include <QtTest/qtest.h>
#include <QSignalSpy>
......@@ -52,12 +53,15 @@ private Q_SLOTS:
favLocModel.setFavoriteLocations({favLoc});
QCOMPARE(favLocModel.rowCount(), 1);
LiveDataManager liveDataMgr;
TransferManager::clear();
TransferManager mgr;
mgr.setFavoriteLocationModel(&favLocModel);
mgr.overrideCurrentDateTime(QDateTime({2017, 1, 1}, {}));
mgr.setReservationManager(&resMgr);
mgr.setTripGroupManager(&tgMgr);
mgr.setLiveDataManager(&liveDataMgr);
QSignalSpy addSpy(&mgr, &TransferManager::transferAdded);
QSignalSpy changeSpy(&mgr, &TransferManager::transferChanged);
QSignalSpy removeSpy(&mgr, &TransferManager::transferRemoved);
......
......@@ -419,6 +419,10 @@ void TransferManager::determineAnchorDeltaDefault(Transfer &transfer, const QVar
QDateTime TransferManager::anchorTimeBefore(const QString &resId, const QVariant &res) const
{
if (JsonLd::isA<TrainReservation>(res)) {
const auto departure = m_liveDataMgr->departure(resId);
if (departure.hasExpectedDepartureTime()) {
return departure.expectedDepartureTime();
}
return res.value<TrainReservation>().reservationFor().value<TrainTrip>().departureTime();
}
if (JsonLd::isA<BusReservation>(res)) {
......@@ -447,6 +451,10 @@ QDateTime TransferManager::anchorTimeBefore(const QString &resId, const QVariant
QDateTime TransferManager::anchorTimeAfter(const QString &resId, const QVariant &res) const
{
if (JsonLd::isA<TrainReservation>(res)) {
const auto arrival = m_liveDataMgr->arrival(resId);
if (arrival.hasExpectedArrivalTime()) {
return arrival.expectedArrivalTime();
}
return res.value<TrainReservation>().reservationFor().value<TrainTrip>().arrivalTime();
}
if (JsonLd::isA<BusReservation>(res)) {
......
Supports Markdown
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