Commit 7eac8256 authored by Volker Krause's avatar Volker Krause

Support departure/arrival platforms in journeys

parent 67cebdf0
......@@ -280,6 +280,8 @@ std::vector<Journey> HafasMgateParser::parseTripSearch(const QJsonObject &obj) c
if ((unsigned int)locIdx < locs.size()) {
section.setFrom(locs[locIdx]);
}
section.setScheduledDeparturePlatform(dep.value(QLatin1String("dPlatfS")).toString());
section.setExpectedDeparturePlatform(dep.value(QLatin1String("dPlatfR")).toString());
const auto arr = secObj.value(QLatin1String("arr")).toObject();
section.setScheduledArrivalTime(QDateTime::fromString(dateStr + arr.value(QLatin1String("aTimeS")).toString(), QLatin1String("yyyyMMddhhmmss")));
......@@ -291,6 +293,8 @@ std::vector<Journey> HafasMgateParser::parseTripSearch(const QJsonObject &obj) c
if ((unsigned int)locIdx < locs.size()) {
section.setTo(locs[locIdx]);
}
section.setScheduledArrivalPlatform(dep.value(QLatin1String("aPlatfS")).toString());
section.setExpectedArrivalPlatform(dep.value(QLatin1String("aPlatfR")).toString());
const auto typeStr = secObj.value(QLatin1String("type")).toString();
if (typeStr == QLatin1String("JNY")) {
......
......@@ -35,6 +35,10 @@ public:
Location from;
Location to;
Route route;
QString scheduledDeparturePlatform;
QString expectedDeparturePlatform;
QString scheduledArrivalPlatform;
QString expectedArrivalPlatform;
};
class JourneyPrivate : public QSharedData
......@@ -166,6 +170,70 @@ void JourneySection::setRoute(const Route &route)
d->route = route;
}
QString JourneySection::scheduledDeparturePlatform() const
{
return d->scheduledDeparturePlatform;
}
void JourneySection::setScheduledDeparturePlatform(const QString &platform)
{
d.detach();
d->scheduledDeparturePlatform = platform;
}
QString JourneySection::expectedDeparturePlatform() const
{
return d->expectedDeparturePlatform;
}
void JourneySection::setExpectedDeparturePlatform(const QString &platform)
{
d.detach();
d->expectedDeparturePlatform = platform;
}
bool JourneySection::hasExpectedDeparturePlatform() const
{
return !d->expectedDeparturePlatform.isEmpty();
}
bool JourneySection::departurePlatformChanged() const
{
return hasExpectedDeparturePlatform() && d->expectedDeparturePlatform != d->scheduledDeparturePlatform;
}
QString JourneySection::scheduledArrivalPlatform() const
{
return d->scheduledArrivalPlatform;
}
void JourneySection::setScheduledArrivalPlatform(const QString &platform)
{
d.detach();
d->scheduledArrivalPlatform = platform;
}
QString JourneySection::expectedArrivalPlatform() const
{
return d->expectedArrivalPlatform;
}
void JourneySection::setExpectedArrivalPlatform(const QString &platform)
{
d.detach();
d->expectedArrivalPlatform = platform;
}
bool JourneySection::hasExpectedArrivalPlatform() const
{
return !d->expectedArrivalPlatform.isEmpty();
}
bool JourneySection::arrivalPlatformChanged() const
{
return hasExpectedArrivalPlatform() && d->scheduledArrivalPlatform != d->expectedArrivalPlatform;
}
KPUBLICTRANSPORT_MAKE_GADGET(Journey)
......
......@@ -69,7 +69,23 @@ class JourneySection
/** Route to take on this segment. */
Q_PROPERTY(KPublicTransport::Route route READ route WRITE setRoute)
// TODO: platforms
/** Planned departure platform. */
Q_PROPERTY(QString scheduledDeparturePlatform READ scheduledDeparturePlatform WRITE setScheduledDeparturePlatform)
/** Actual departure platform, in case real-time information are available. */
Q_PROPERTY(QString expectedDeparturePlatform READ expectedDeparturePlatform WRITE setExpectedDeparturePlatform)
/** @c true if real-time platform information are available. */
Q_PROPERTY(bool hasExpectedDeparturePlatform READ hasExpectedDeparturePlatform STORED false)
/** @c true if we have real-time platform information and the platform changed. */
Q_PROPERTY(bool departurePlatformChanged READ departurePlatformChanged STORED false)
/** Planned arrival platform. */
Q_PROPERTY(QString scheduledArrivalPlatform READ scheduledArrivalPlatform WRITE setScheduledArrivalPlatform)
/** Actual arrival platform, in case real-time information are available. */
Q_PROPERTY(QString expectedArrivalPlatform READ expectedArrivalPlatform WRITE setExpectedArrivalPlatform)
/** @c true if real-time platform information are available. */
Q_PROPERTY(bool hasExpectedArrivalPlatform READ hasExpectedArrivalPlatform STORED false)
/** @c true if we have real-time platform information and the platform changed. */
Q_PROPERTY(bool arrivalPlatformChanged READ arrivalPlatformChanged STORED false)
public:
/** Mode of transport. */
......@@ -106,6 +122,20 @@ public:
void setTo(const Location &to);
Route route() const;
void setRoute(const Route &route);
QString scheduledDeparturePlatform() const;
void setScheduledDeparturePlatform(const QString &platform);
QString expectedDeparturePlatform() const;
void setExpectedDeparturePlatform(const QString &platform);
bool hasExpectedDeparturePlatform() const;
bool departurePlatformChanged() const;
QString scheduledArrivalPlatform() const;
void setScheduledArrivalPlatform(const QString &platform);
QString expectedArrivalPlatform() const;
void setExpectedArrivalPlatform(const QString &platform);
bool hasExpectedArrivalPlatform() const;
bool arrivalPlatformChanged() const;
};
class JourneyPrivate;
......
......@@ -166,10 +166,16 @@ Kirigami.ApplicationWindow {
ColumnLayout {
Layout.fillWidth: true
QQC2.Label {
text: "From: " + modelData.from.name
RowLayout {
QQC2.Label {
text: "From: " + modelData.from.name + " Platform: " + modelData.scheduledDeparturePlatform
}
QQC2.Label {
text: modelData.expectedDeparturePlatform
color: modelData.departurePlatformChanged ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
visible: modelData.hasExpectedDeparturePlatform
}
}
// TODO platform
RowLayout {
QQC2.Label {
text: "Departure: " + modelData.scheduledDepartureTime.toTimeString()
......@@ -194,11 +200,16 @@ Kirigami.ApplicationWindow {
return "???";
}}
}
QQC2.Label {
text: "To: " + modelData.to.name
RowLayout {
QQC2.Label {
text: "To: " + modelData.to.name + " Platform: " + modelData.scheduledArrivalPlatform
}
QQC2.Label {
text: modelData.expectedArrivalPlatform
color: modelData.arrivalPlatformChanged ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
visible: modelData.hasExpectedArrivalPlatform
}
}
// TODO platform
RowLayout {
QQC2.Label {
text: "Arrival: " + modelData.scheduledArrivalTime.toTimeString()
......
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