KPublicTransport

equipment.cpp
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
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 
13 using namespace KPublicTransport;
14 
15 namespace KPublicTransport {
16 
17 class EquipmentPrivate : public QSharedData
18 {
19 public:
20  Equipment::Type type = Equipment::Unknown;
21  Disruption::Effect disruptionEffect = Disruption::NormalService;
22  QStringList notes;
23 };
24 
25 }
26 
27 KPUBLICTRANSPORT_MAKE_GADGET(Equipment)
28 KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, Equipment::Type, type, setType)
29 KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, Disruption::Effect, disruptionEffect, setDisruptionEffect)
30 KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, QStringList, notes, setNotes)
31 
32 void Equipment::addNote(const QString& note)
33 {
34  const auto n = NotesUtil::normalizeNote(note);
35  const auto idx = NotesUtil::needsAdding(d->notes, n);
36  if (idx >= 0) {
37  d.detach();
38  NotesUtil::performAdd(d->notes, n, idx);
39  }
40 }
41 
43 {
44  return Json::toJson(equipment);
45 }
46 
48 {
49  return Json::fromJson<Equipment>(obj);
50 }
51 
52 #include "moc_equipment.cpp"
Status information about equipment such as elevators or escalators.
Definition: equipment.h:24
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
Effect
Disruption effects, numerical sorted so that higher values imply more severe disruptions.
Definition: disruption.h:25
Type
Type of equipment.
Definition: equipment.h:29
static QJsonObject toJson(const Equipment &equipment)
Serializes one object to JSON.
Definition: equipment.cpp:42
static Equipment fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
Definition: equipment.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:05:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.