File indexing completed on 2024-05-12 04:42:42
0001 /* 0002 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "equipment.h" 0008 0009 #include "datatypes_p.h" 0010 #include "json_p.h" 0011 #include "notesutil_p.h" 0012 0013 using namespace KPublicTransport; 0014 0015 namespace KPublicTransport { 0016 0017 class EquipmentPrivate : public QSharedData 0018 { 0019 public: 0020 Equipment::Type type = Equipment::Unknown; 0021 Disruption::Effect disruptionEffect = Disruption::NormalService; 0022 QStringList notes; 0023 }; 0024 0025 } 0026 0027 KPUBLICTRANSPORT_MAKE_GADGET(Equipment) 0028 KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, Equipment::Type, type, setType) 0029 KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, Disruption::Effect, disruptionEffect, setDisruptionEffect) 0030 KPUBLICTRANSPORT_MAKE_PROPERTY(Equipment, QStringList, notes, setNotes) 0031 0032 void Equipment::addNote(const QString& note) 0033 { 0034 const auto n = NotesUtil::normalizeNote(note); 0035 const auto idx = NotesUtil::needsAdding(d->notes, n); 0036 if (idx >= 0) { 0037 d.detach(); 0038 NotesUtil::performAdd(d->notes, n, idx); 0039 } 0040 } 0041 0042 QJsonObject Equipment::toJson(const Equipment &equipment) 0043 { 0044 return Json::toJson(equipment); 0045 } 0046 0047 Equipment Equipment::fromJson(const QJsonObject &obj) 0048 { 0049 return Json::fromJson<Equipment>(obj); 0050 } 0051 0052 #include "moc_equipment.cpp"