KPublicTransport

individualtransport.cpp
1/*
2 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
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
14using namespace Qt::Literals::StringLiterals;
15
16namespace KPublicTransport {
17class IndividualTransportPrivate : public QSharedData
18{
19public:
20 IndividualTransport::Mode mode = IndividualTransport::Walk;
22};
23}
24
25using namespace KPublicTransport;
26
27KPUBLICTRANSPORT_MAKE_GADGET(IndividualTransport)
28KPUBLICTRANSPORT_MAKE_PROPERTY(IndividualTransport, IndividualTransport::Mode, mode, setMode)
29KPUBLICTRANSPORT_MAKE_PROPERTY(IndividualTransport, IndividualTransport::Qualifier, qualifier, setQualifier)
30
31IndividualTransport::IndividualTransport(IndividualTransport::Mode mode, IndividualTransport::Qualifier qualifier)
32 : d(new IndividualTransportPrivate)
33{
34 d->mode = mode;
35 d->qualifier = qualifier;
36}
37
38bool IndividualTransport::operator==(const IndividualTransport &other) const
39{
40 return d->mode == other.mode() && d->qualifier == other.qualifier();
41}
42
43bool IndividualTransport::operator!=(const IndividualTransport &other) const
44{
45 return d->mode != other.mode() || d->qualifier != other.qualifier();
46}
47
49{
50 switch (mode) {
51 case IndividualTransport::Bike:
52 return u"qrc:///org.kde.kpublictransport/assets/images/transport-mode-bike.svg"_s;
53 case IndividualTransport::Car:
54 return u"qrc:///org.kde.kpublictransport/assets/images/transport-mode-car.svg"_s;
55 case IndividualTransport::Walk:
56 return u"qrc:///org.kde.kpublictransport/assets/images/transport-mode-walk.svg"_s;
57 }
58
59 return u"question"_s;
60}
61
63{
65}
66
68{
69 return Json::toJson(it);
70}
71
72QJsonArray IndividualTransport::toJson(const std::vector<IndividualTransport> &its)
73{
74 return Json::toJson(its);
75}
76
78{
79 return Json::fromJson<IndividualTransport>(obj);
80}
81
82std::vector<IndividualTransport> IndividualTransport::fromJson(const QJsonArray &array)
83{
84 return Json::fromJson<IndividualTransport>(array);
85}
86
87std::vector<IndividualTransport> IndividualTransport::fromVariant(const QVariantList &v)
88{
89 return Variant::fromVariantList<IndividualTransport>(v);
90}
91
92#include "moc_individualtransport.cpp"
Individual transport mode details for a journey section, and for specifying journey requests.
static std::vector< IndividualTransport > fromVariant(const QVariantList &v)
Mode
Mode of (individual) transportation.
static QJsonObject toJson(const IndividualTransport &it)
Serializes one object to JSON.
Qualifier
Qualifier on how the mode of transport is used.
@ None
not applicable, or bike is taken on public transport legs.
static IndividualTransport fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
QString modeIconName
Name of an icon to represent this transport mode.
Query operations and data types for accessing realtime public transport information from online servi...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.