KPublicTransport

individualtransport.cpp
1 /*
2  SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "individualtransport.h"
8 #include "json_p.h"
9 #include "datatypes_p.h"
10 #include "variant_p.h"
11 
12 #include <QDebug>
13 
14 namespace KPublicTransport {
15 class IndividualTransportPrivate : public QSharedData
16 {
17 public:
18  IndividualTransport::Mode mode = IndividualTransport::Walk;
20 };
21 }
22 
23 using namespace KPublicTransport;
24 
25 KPUBLICTRANSPORT_MAKE_GADGET(IndividualTransport)
26 KPUBLICTRANSPORT_MAKE_PROPERTY(IndividualTransport, IndividualTransport::Mode, mode, setMode)
27 KPUBLICTRANSPORT_MAKE_PROPERTY(IndividualTransport, IndividualTransport::Qualifier, qualifier, setQualifier)
28 
29 IndividualTransport::IndividualTransport(IndividualTransport::Mode mode, IndividualTransport::Qualifier qualifier)
30  : d(new IndividualTransportPrivate)
31 {
32  d->mode = mode;
33  d->qualifier = qualifier;
34 }
35 
36 bool IndividualTransport::operator==(const IndividualTransport &other) const
37 {
38  return d->mode == other.mode() && d->qualifier == other.qualifier();
39 }
40 
41 bool IndividualTransport::operator!=(const IndividualTransport &other) const
42 {
43  return d->mode != other.mode() || d->qualifier != other.qualifier();
44 }
45 
47 {
48  return Json::toJson(it);
49 }
50 
51 QJsonArray IndividualTransport::toJson(const std::vector<IndividualTransport> &its)
52 {
53  return Json::toJson(its);
54 }
55 
57 {
58  return Json::fromJson<IndividualTransport>(obj);
59 }
60 
61 std::vector<IndividualTransport> IndividualTransport::fromJson(const QJsonArray &array)
62 {
63  return Json::fromJson<IndividualTransport>(array);
64 }
65 
66 std::vector<IndividualTransport> IndividualTransport::fromVariant(const QVariantList &v)
67 {
68  return Variant::fromVariantList<IndividualTransport>(v);
69 }
70 
71 #include "moc_individualtransport.cpp"
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
Individual transport mode details for a journey section, and for specifying journey requests...
not applicable, or bike is taken on public transport legs.
Qualifier
Qualifier on how the mode of transport is used.
Mode
Mode of (individual) transportation.
static QJsonObject toJson(const IndividualTransport &it)
Serializes one object to JSON.
static IndividualTransport fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
static std::vector< IndividualTransport > fromVariant(const QVariantList &v)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:07:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.