KItinerary

flight.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "flight.h"
8#include "datatypes_impl.h"
9#include "datatypes_p.h"
10
11#include <QDateTime>
12#include <QVariant>
13
14using namespace KItinerary;
15
16namespace KItinerary {
17
18class FlightPrivate : public QSharedData
19{
20public:
21 QString flightNumber;
22 Airline airline;
23 Airport departureAirport;
24 QString departureGate;
25 QString departureTerminal;
26 QDateTime departureTime;
27 Airport arrivalAirport;
28 QString arrivalTerminal;
29 QDateTime arrivalTime;
30 QDateTime boardingTime;
31 QDate departureDay;
32};
33
34KITINERARY_MAKE_CLASS(Flight)
35KITINERARY_MAKE_PROPERTY(Flight, QString, flightNumber, setFlightNumber)
36KITINERARY_MAKE_PROPERTY(Flight, Airline, airline, setAirline)
37KITINERARY_MAKE_PROPERTY(Flight, Airport, departureAirport, setDepartureAirport)
38KITINERARY_MAKE_PROPERTY(Flight, QString, departureGate, setDepartureGate)
39KITINERARY_MAKE_PROPERTY(Flight, QString, departureTerminal, setDepartureTerminal)
40KITINERARY_MAKE_PROPERTY(Flight, QDateTime, departureTime, setDepartureTime)
41KITINERARY_MAKE_PROPERTY(Flight, Airport, arrivalAirport, setArrivalAirport)
42KITINERARY_MAKE_PROPERTY(Flight, QDateTime, arrivalTime, setArrivalTime)
43KITINERARY_MAKE_PROPERTY(Flight, QString, arrivalTerminal, setArrivalTerminal)
44KITINERARY_MAKE_PROPERTY(Flight, QDateTime, boardingTime, setBoardingTime)
45KITINERARY_MAKE_PROPERTY_OPERATOR(Flight, QDate, departureDay)
46KITINERARY_MAKE_OPERATOR(Flight)
47
49{
50 if (d->departureDay.isValid()) {
51 return d->departureDay;
52 }
53 // pre-1970 dates are used as transient state when we only know the time
54 if (d->departureTime.isValid() && d->departureTime.date().year() > 1970) {
55 return d->departureTime.date();
56 }
57 if (d->boardingTime.isValid() && d->boardingTime.date().year() > 1970) {
58 return d->boardingTime.date();
59 }
60 return {};
61}
62
63void Flight::setDepartureDay(const QDate &value)
64{
65 d.detach();
66 d->departureDay = value;
67}
68
69}
70
71#include "moc_flight.cpp"
A flight.
Definition flight.h:25
QDate departureDay
The scheduled day of departure.
Definition flight.h:46
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:00:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.