7#include "datatypes_p.h"
9#include "mergeutil_p.h"
11#include <KLocalizedString>
21 Feature::Type type = Feature::NoFeature;
22 Feature::Availability availability = Feature::Unknown;
28KPUBLICTRANSPORT_MAKE_GADGET(
Feature)
30KPUBLICTRANSPORT_MAKE_PROPERTY(
Feature,
QString, description, setDescription)
31KPUBLICTRANSPORT_MAKE_PROPERTY(
Feature, Feature::Type, type, setType)
32KPUBLICTRANSPORT_MAKE_PROPERTY(
Feature, Feature::Availability, availability, setAvailability)
34KPUBLICTRANSPORT_MAKE_PROPERTY(
Feature,
int, quantity, setQuantity)
40 d->availability = availability;
51 case Feature::AirConditioning:
52 return i18nc(
"train coach feature",
"Air conditioning");
53 case Feature::Restaurant:
54 return i18nc(
"train coach feature",
"Bistro or restaurant");
55 case Feature::ToddlerArea:
56 return i18nc(
"train coach feature",
"Toddler area");
57 case Feature::FamilyArea:
58 return i18nc(
"train coach feature",
"Family area");
59 case Feature::WheelchairAccessible:
60 return i18nc(
"train coach feature",
"Wheelchair accessible");
61 case Feature::SilentArea:
62 return i18nc(
"train coach feature",
"Quiet area");
63 case Feature::BusinessArea:
64 return i18nc(
"train coach feature",
"Business area");
65 case Feature::BikeStorage:
66 return i18nc(
"train coach feature",
"Bike storage");
68 return i18nc(
"train coach feature",
"Toilet");
69 case Feature::WheelchairAccessibleToilet:
70 return i18nc(
"train coach feature",
"Wheelchair accessible toilet");
71 case Feature::InformationPoint:
72 return i18nc(
"train coach feature",
"Information point");
74 return i18nc(
"train coach feature",
"Wi-Fi");
75 case Feature::PowerSockets:
76 return i18nc(
"train coach feature",
"Power sockets");
79 case Feature::NoFeature:
94 case Feature::NoFeature:
96 case Feature::AirConditioning:
97 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-airconditioning.svg"_s;
98 case Feature::Restaurant:
99 return u
"qrc:///org.kde.kpublictransport/assets/images/train-coach-restaurant.svg"_s;
100 case Feature::ToddlerArea:
101 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-toddlerarea.svg"_s;
102 case Feature::FamilyArea:
103 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-family.svg"_s;
104 case Feature::WheelchairAccessible:
105 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-wheelchair-accessible.svg"_s;
106 case Feature::SilentArea:
107 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-silentarea.svg"_s;
108 case Feature::BusinessArea:
109 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-businessarea.svg"_s;
110 case Feature::BikeStorage:
111 return u
"qrc:///org.kde.kpublictransport/assets/images/transport-mode-bike.svg"_s;
112 case Feature::Toilet:
113 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-toilet.svg"_s;
114 case Feature::WheelchairAccessibleToilet:
115 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-wheelchair-toilet.svg"_s;
116 case Feature::InformationPoint:
117 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-information.svg"_s;
119 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-wifi.svg"_s;
120 case Feature::PowerSockets:
121 return u
"qrc:///org.kde.kpublictransport/assets/images/vehicle-feature-powersocket.svg"_s;
126 return u
"documentinfo"_s;
131 auto obj = Json::toJson(feature);
132 if (!feature.d->quantity) {
133 obj.remove(
"quantity"_L1);
140 return Json::toJson(features);
145 return Json::fromJson<Feature>(obj);
150 return Json::fromJson<Feature>(array);
155 if (lhs.type() != rhs.type()) {
159 if (lhs.type() == Feature::Other) {
166[[nodiscard]]
static Feature::Availability mergeAvailability(Feature::Availability lhs, Feature::Availability rhs)
168 if (lhs == Feature::Unknown) {
171 if (rhs == Feature::Unknown) {
175 return lhs == Feature::Available ? rhs : lhs;
181 res.setName(MergeUtil::mergeString(lhs.
name(), rhs.
name()));
183 res.setAvailability(mergeAvailability(lhs.availability(), rhs.availability()));
189#include "moc_feature.cpp"
An amenity, facility or other relevant property of a vehicle (train, bus, etc), vehicle part (e....
static Feature merge(const Feature &lhs, const Feature &rhs)
Merge two features referring to the same thing.
static QString typeDisplayName(KPublicTransport::Feature::Type type)
Generic display name for feature of type.
QString description
An optional longer human-readable description.
QString name
A short human-readable label of this feature.
static bool isSame(const Feature &lhs, const Feature &rhs)
Returns true if both features refer to the same thing.
static Feature fromJson(const QJsonObject &obj)
Deserialize an object from JSON.
static QJsonObject toJson(const Feature &feature)
Serializes one object to JSON.
KPublicTransport::Disruption::Effect disruptionEffect
Distruption effects on the feature.
QString displayName
A short humand-readable label for this feature.
int quantity
Amount of instances of this feature.
QString typeIconName
Icon representing the given feature type type.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
Effect
Disruption effects, numerical sorted so that higher values imply more severe disruptions.
Query operations and data types for accessing realtime public transport information from online servi...
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
bool isEmpty() const const