diff --git a/src/datatypes/flight.cpp b/src/datatypes/flight.cpp index d4e0295..73955ff 100644 --- a/src/datatypes/flight.cpp +++ b/src/datatypes/flight.cpp @@ -1,99 +1,101 @@ /* Copyright (C) 2018 Volker Krause 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 . */ #include "flight.h" #include "place.h" #include "organization.h" #include "datatypes_p.h" #include using namespace KItinerary; namespace KItinerary { class FlightPrivate : public QSharedData { public: QString flightNumber; Airline airline; Airport departureAirport; + QString departureGate; + QString departureTerminal; QDateTime departureTime; Airport arrivalAirport; QDateTime arrivalTime; QDateTime boardingTime; - QString departureGate; QDate departureDay; Organization provider; }; KITINERARY_MAKE_SIMPLE_CLASS(Flight) KITINERARY_MAKE_PROPERTY(Flight, QString, flightNumber, setFlightNumber) KITINERARY_MAKE_PROPERTY(Flight, Airline, airline, setAirline) KITINERARY_MAKE_PROPERTY(Flight, Airport, departureAirport, setDepartureAirport) +KITINERARY_MAKE_PROPERTY(Flight, QString, departureGate, setDepartureGate) +KITINERARY_MAKE_PROPERTY(Flight, QString, departureTerminal, setDepartureTerminal) KITINERARY_MAKE_PROPERTY(Flight, QDateTime, departureTime, setDepartureTime) KITINERARY_MAKE_PROPERTY(Flight, Airport, arrivalAirport, setArrivalAirport) KITINERARY_MAKE_PROPERTY(Flight, QDateTime, arrivalTime, setArrivalTime) KITINERARY_MAKE_PROPERTY(Flight, QDateTime, boardingTime, setBoardingTime) -KITINERARY_MAKE_PROPERTY(Flight, QString, departureGate, setDepartureGate) KITINERARY_MAKE_PROPERTY(Flight, Organization, provider, setProvider) QDate Flight::departureDay() const { if (d->departureDay.isValid()) { return d->departureDay; } if (d->departureTime.isValid()) { return d->departureTime.date(); } if (d->boardingTime.isValid()) { return d->boardingTime.date(); } return {}; } void Flight::setDepartureDay(const QDate &value) { d.detach(); d->departureDay = value; } QString Flight::departureTimeLocalized() const { K_D(const Flight); return localizedDateTime(d->departureTime); } QString Flight::arrivalTimeLocalized() const { K_D(const Flight); return localizedDateTime(d->arrivalTime); } QString Flight::boardingTimeLocalized() const { K_D(const Flight); auto s = QLocale().toString(d->boardingTime.time(), QLocale::ShortFormat); if (d->boardingTime.timeSpec() == Qt::TimeZone || d->boardingTime.timeSpec() == Qt::OffsetFromUTC) { s += QLatin1Char(' ') + d->boardingTime.timeZone().abbreviation(d->boardingTime); } return s; } } #include "moc_flight.cpp" diff --git a/src/datatypes/flight.h b/src/datatypes/flight.h index 06c6a10..500a86e 100644 --- a/src/datatypes/flight.h +++ b/src/datatypes/flight.h @@ -1,76 +1,77 @@ /* Copyright (C) 2018 Volker Krause 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 . */ #ifndef KITINERARY_FLIGHT_H #define KITINERARY_FLIGHT_H #include "kitinerary_export.h" #include "datatypes.h" class QDateTime; namespace KItinerary { class Airline; class Airport; class Organization; class FlightPrivate; /** A flight. * @see https://schema.org/Flight * @see https://developers.google.com/gmail/markup/reference/flight-reservation */ class KITINERARY_EXPORT Flight { KITINERARY_GADGET(Flight) KITINERARY_PROPERTY(QString, flightNumber, setFlightNumber) KITINERARY_PROPERTY(KItinerary::Airline, airline, setAirline) KITINERARY_PROPERTY(KItinerary::Airport, departureAirport, setDepartureAirport) + KITINERARY_PROPERTY(QString, departureGate, setDepartureGate) + KITINERARY_PROPERTY(QString, departureTerminal, setDepartureTerminal) KITINERARY_PROPERTY(QDateTime, departureTime, setDepartureTime) KITINERARY_PROPERTY(KItinerary::Airport, arrivalAirport, setArrivalAirport) KITINERARY_PROPERTY(QDateTime, arrivalTime, setArrivalTime) KITINERARY_PROPERTY(KItinerary::Organization, provider, setProvider) // Google extension for boarding pass data KITINERARY_PROPERTY(QDateTime, boardingTime, setBoardingTime) - KITINERARY_PROPERTY(QString, departureGate, setDepartureGate) // KDE extensions /** The scheduled day of departure. * This is part of the unique identification of a flight and part of the IATA BCBP data. * This might be different from departureTime, which reflects the actual time of departure * and thus can in case of delays even move to a following day. */ KITINERARY_PROPERTY(QDate, departureDay, setDepartureDay) Q_PROPERTY(QString departureTimeLocalized READ departureTimeLocalized STORED false CONSTANT) Q_PROPERTY(QString arrivalTimeLocalized READ arrivalTimeLocalized STORED false CONSTANT) Q_PROPERTY(QString boardingTimeLocalized READ boardingTimeLocalized STORED false CONSTANT) private: QString departureTimeLocalized() const; QString arrivalTimeLocalized() const; QString boardingTimeLocalized() const; QExplicitlySharedDataPointer d; }; } Q_DECLARE_METATYPE(KItinerary::Flight) #endif // KITINERARY_FLIGHT_H