KPublicTransport

equipment.cpp
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "equipment.h"
8
9#include "datatypes_p.h"
10#include "json_p.h"
11#include "notesutil_p.h"
12#include "path.h"
13
14using namespace KPublicTransport;
15using namespace Qt::Literals;
16
17namespace KPublicTransport {
18
19class EquipmentPrivate : public QSharedData
20{
21public:
22 Equipment::Type type = Equipment::Unknown;
23 Disruption::Effect disruptionEffect = Disruption::NormalService;
24 QStringList notes;
25};
26
27}
28
29KPUBLICTRANSPORT_MAKE_GADGET(Equipment)
30KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, Equipment::Type, type, setType)
31KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, Disruption::Effect, disruptionEffect, setDisruptionEffect)
32KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, QStringList, notes, setNotes)
33
34void Equipment::addNote(const QString& note)
35{
36 const auto n = NotesUtil::normalizeNote(note);
37 const auto idx = NotesUtil::needsAdding(d->notes, n);
38 if (idx >= 0) {
39 d.detach();
40 NotesUtil::performAdd(d->notes, n, idx);
41 }
42}
43
45{
46 switch (d->type) {
47 case Elevator:
49 case Escalator:
51 case Unknown:
52 break;
53 }
54
55 return u"map-symbolic"_s;
56}
57
59{
60 return Json::toJson(equipment);
61}
62
64{
65 return Json::fromJson<Equipment>(obj);
66}
67
68#include "moc_equipment.cpp"
Status information about equipment such as elevators or escalators.
Definition equipment.h:25
QString iconName
An icon representing the equipment type.
Definition equipment.h:45
static QJsonObject toJson(const Equipment &equipment)
Serializes one object to JSON.
Definition equipment.cpp:58
Type
Type of equipment.
Definition equipment.h:29
static Equipment fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
Definition equipment.cpp:63
static Q_INVOKABLE QString maneuverIconName(KPublicTransport::PathSection::Maneuver maneuver)
An icon representing maneuver.
Definition path.cpp:77
@ Elevator
Take an elevator.
Definition path.h:59
@ Escalator
Take an escalator.
Definition path.h:60
Effect
Disruption effects, numerical sorted so that higher values imply more severe disruptions.
Definition disruption.h:25
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.