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
37 /** Label shortly describing this transport for display. */
38 Q_PROPERTY(QString label READ label STORED false)
39
40public:
41 /** Qualifier on how the mode of transport is used. */
42 enum Qualifier {
43 None, ///< not applicable, or bike is taken on public transport legs.
44 Park, ///< for access legs, vehicle is parked before taking public transport.
45 Rent, ///< use a rental vehicle
46 Dropoff, ///< for access legs: vehicle is not taken onto public transport but also doesn't need parking
47 Pickup, ///< for egress legs: vehicle is available at the last public transport leg
48 };
49 Q_ENUM(Qualifier)
50 KPUBLICTRANSPORT_PROPERTY(Qualifier, qualifier, setQualifier)
51
52public:
53 IndividualTransport(Mode mode, Qualifier qualifier = None);
54 [[nodiscard]] QString modeIconName() const;
55
56 [[nodiscard]] bool operator==(const IndividualTransport &other) const;
57 [[nodiscard]] bool operator!=(const IndividualTransport &other) const;
58
59 /** Name of an icon to represent @p mode.
60 * Can be an qrc: URL or a icon name compatbile with QIcon::fromTheme.
61 */
62 Q_INVOKABLE [[nodiscard]] static QString modeIconName(KPublicTransport::IndividualTransport::Mode mode);
63
64 [[nodiscard]] QString label() const;
65
66 /** Serializes one object to JSON. */
67 [[nodiscard]] static QJsonObject toJson(const IndividualTransport &it);
68 /** Serializes a vector of objects to JSON. */
69 [[nodiscard]] static QJsonArray toJson(const std::vector<IndividualTransport> &its);
70 /** Deserialize an object from JSON. */
71 [[nodiscard]] static IndividualTransport fromJson(const QJsonObject &obj);
72 /** Deserialize a list of journey from JSON. */
73 [[nodiscard]] static std::vector<IndividualTransport> fromJson(const QJsonArray &array);
74
75 /** @internal for QML bindings only */
76 [[nodiscard]] static std::vector<IndividualTransport> fromVariant(const QVariantList &v);
77};
78
79}
80
82
83#endif // KPUBLICTRANSPORT_INDIVIDUALTRANSPORT_H
Individual transport mode details for a journey section, and for specifying journey requests.
QString label
Label shortly describing this transport for display.
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.
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-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:50:52 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.