KItinerary

traintrip.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 "traintrip.h"
8#include "datatypes_impl.h"
9#include "datatypes_p.h"
10
11#include <QDateTime>
12
13using namespace KItinerary;
14
15namespace KItinerary {
16
17class TrainTripPrivate : public QSharedData
18{
19public:
20 QString arrivalPlatform;
21 TrainStation arrivalStation;
22 QDateTime arrivalTime;
23 QString departurePlatform;
24 TrainStation departureStation;
25 Organization provider;
26 QDateTime departureTime;
27 QDate departureDay;
28 QString trainName;
29 QString trainNumber;
30};
31
32KITINERARY_MAKE_CLASS(TrainTrip)
33KITINERARY_MAKE_PROPERTY(TrainTrip, QString, arrivalPlatform, setArrivalPlatform)
34KITINERARY_MAKE_PROPERTY(TrainTrip, TrainStation, arrivalStation, setArrivalStation)
35KITINERARY_MAKE_PROPERTY(TrainTrip, QDateTime, arrivalTime, setArrivalTime)
36KITINERARY_MAKE_PROPERTY(TrainTrip, QString, departurePlatform, setDeparturePlatform)
37KITINERARY_MAKE_PROPERTY(TrainTrip, TrainStation, departureStation, setDepartureStation)
38KITINERARY_MAKE_PROPERTY(TrainTrip, QDateTime, departureTime, setDepartureTime)
39KITINERARY_MAKE_PROPERTY(TrainTrip, Organization, provider, setProvider)
40KITINERARY_MAKE_PROPERTY_OPERATOR(TrainTrip, QDate, departureDay)
41KITINERARY_MAKE_PROPERTY(TrainTrip, QString, trainName, setTrainName)
42KITINERARY_MAKE_PROPERTY(TrainTrip, QString, trainNumber, setTrainNumber)
43KITINERARY_MAKE_OPERATOR(TrainTrip)
44
46{
47 if (d->departureDay.isValid()) {
48 return d->departureDay;
49 }
50 // pre-1970 dates are used as transient state when we only know the time
51 if (d->departureTime.isValid() && d->departureTime.date().year() > 1970) {
52 return d->departureTime.date();
53 }
54 return {};
55}
56
57void TrainTrip::setDepartureDay(const QDate &value)
58{
59 if (departureDay() != value) {
60 d.detach();
61 d->departureDay = value;
62 }
63}
64
65}
66
67#include "moc_traintrip.cpp"
Train station.
Definition place.h:126
A train trip.
Definition traintrip.h:24
QDate departureDay
The scheduled day of departure.
Definition traintrip.h:42
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 Mon Nov 4 2024 16:28:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.