KPublicTransport

individualtransport.h
1/*
2 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KPUBLICTRANSPORT_INDIVIDUALTRANSPORT_H
8#define KPUBLICTRANSPORT_INDIVIDUALTRANSPORT_H
9
10#include "kpublictransport_export.h"
11#include "datatypes.h"
12
13namespace KPublicTransport {
14
15class IndividualTransportPrivate;
16
17/** Individual transport mode details for a journey section, and for specifying journey requests. */
18class KPUBLICTRANSPORT_EXPORT IndividualTransport
19{
20 KPUBLICTRANSPORT_GADGET(IndividualTransport)
21public:
22 /** Mode of (individual) transportation. */
23 enum Mode {
24 Walk,
25 Bike,
26 Car
27 };
28 Q_ENUM(Mode)
29 KPUBLICTRANSPORT_PROPERTY(Mode, mode, setMode)
30
31 /** Name of an icon to represent this transport mode.
32 * This does not consider the Qualifier value.
33 * Can be an qrc: URL or a icon name compatbile with QIcon::fromTheme.
34 */
35 Q_PROPERTY(QString modeIconName READ modeIconName STORED false)
36
37public:
38 /** Qualifier on how the mode of transport is used. */
39 enum Qualifier {
40 None, ///< not applicable, or bike is taken on public transport legs.
41 Park, ///< for access legs, vehicle is parked before taking public transport.
42 Rent, ///< use a rental vehicle
43 Dropoff, ///< for access legs: vehicle is not taken onto public transport but also doesn't need parking
44 Pickup, ///< for egress legs: vehicle is available at the last public transport leg
45 };
46 Q_ENUM(Qualifier)
47 KPUBLICTRANSPORT_PROPERTY(Qualifier, qualifier, setQualifier)
48
49public:
50 IndividualTransport(Mode mode, Qualifier qualifier = None);
51 [[nodiscard]] QString modeIconName() const;
52
53 [[nodiscard]] bool operator==(const IndividualTransport &other) const;
54 [[nodiscard]] bool operator!=(const IndividualTransport &other) const;
55
56 /** Name of an icon to represent @p mode.
57 * Can be an qrc: URL or a icon name compatbile with QIcon::fromTheme.
58 */
59 Q_INVOKABLE [[nodiscard]] static QString modeIconName(KPublicTransport::IndividualTransport::Mode mode);
60
61 /** Serializes one object to JSON. */
62 [[nodiscard]] static QJsonObject toJson(const IndividualTransport &it);
63 /** Serializes a vector of objects to JSON. */
64 [[nodiscard]] static QJsonArray toJson(const std::vector<IndividualTransport> &its);
65 /** Deserialize an object from JSON. */
66 [[nodiscard]] static IndividualTransport fromJson(const QJsonObject &obj);
67 /** Deserialize a list of journey from JSON. */
68 [[nodiscard]] static std::vector<IndividualTransport> fromJson(const QJsonArray &array);
69
70 /** @internal for QML bindings only */
71 [[nodiscard]] static std::vector<IndividualTransport> fromVariant(const QVariantList &v);
72};
73
74}
75
77
78#endif // KPUBLICTRANSPORT_INDIVIDUALTRANSPORT_H
Individual transport mode details for a journey section, and for specifying journey requests.
Mode
Mode of (individual) transportation.
Qualifier
Qualifier on how the mode of transport is used.
@ Pickup
for egress legs: vehicle is available at the last public transport leg
@ Dropoff
for access legs: vehicle is not taken onto public transport but also doesn't need parking
@ None
not applicable, or bike is taken on public transport legs.
@ Park
for access legs, vehicle is parked before taking public transport.
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 Fri Nov 8 2024 12:04:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.