Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 91cc016a authored by Volker Krause's avatar Volker Krause

Add data types for train bookings

parent 43fc9f15
......@@ -32,6 +32,11 @@ bool Airline::operator!=(const Airline &other) const
return m_iataCode != other.m_iataCode || m_name != other.m_name;
}
bool TrainStation::operator!=(const TrainStation &other) const
{
return m_name != other.m_name;
}
static QString localizedDateTime(const QDateTime &dt)
{
auto s = QLocale().toString(dt, QLocale::ShortFormat);
......@@ -60,3 +65,13 @@ QString LodgingReservation::checkoutDateLocalized() const
{
return QLocale().toString(m_checkoutDate.date(), QLocale::ShortFormat);
}
QString TrainTrip::departureTimeLocalized() const
{
return QLocale().toString(m_departureTime, QLocale::ShortFormat);
}
QString TrainTrip::arrivalTimeLocalized() const
{
return QLocale().toString(m_arrivalTime, QLocale::ShortFormat);
}
......@@ -54,6 +54,13 @@ public:
bool operator!=(const Airline &other) const;
};
class TrainStation {
SEMANTIC_GADGET
SEMANTIC_PROPERTY(QString, name)
public:
bool operator!=(const TrainStation &other) const;
};
class Flight
{
SEMANTIC_GADGET
......@@ -87,6 +94,25 @@ class LodgingBusiness
SEMANTIC_PROPERTY(QVariant, address)
};
class TrainTrip
{
SEMANTIC_GADGET
SEMANTIC_PROPERTY(QString, arrivalPlatform)
SEMANTIC_PROPERTY(TrainStation, arrivalStation)
SEMANTIC_PROPERTY(QDateTime, arrivalTime)
SEMANTIC_PROPERTY(QString, departurePlatform)
SEMANTIC_PROPERTY(TrainStation, departureStation)
SEMANTIC_PROPERTY(QDateTime, departureTime)
SEMANTIC_PROPERTY(QString, trainNumber)
Q_PROPERTY(QString departureTimeLocalized READ departureTimeLocalized CONSTANT)
Q_PROPERTY(QString arrivalTimeLocalized READ arrivalTimeLocalized CONSTANT)
private:
QString departureTimeLocalized() const;
QString arrivalTimeLocalized() const;
};
class Reservation
{
Q_GADGET
......@@ -112,13 +138,20 @@ class FlightReservation : protected Reservation
SEMANTIC_GADGET
};
class TrainReservation : protected Reservation
{
SEMANTIC_GADGET
};
Q_DECLARE_METATYPE(Airport)
Q_DECLARE_METATYPE(Airline)
Q_DECLARE_METATYPE(Flight)
Q_DECLARE_METATYPE(FlightReservation)
Q_DECLARE_METATYPE(LodgingBusiness)
Q_DECLARE_METATYPE(LodgingReservation)
Q_DECLARE_METATYPE(FlightReservation)
Q_DECLARE_METATYPE(PostalAddress)
Q_DECLARE_METATYPE(TrainStation)
Q_DECLARE_METATYPE(TrainTrip)
#undef SEMANTIC_GADGET
......
......@@ -94,6 +94,9 @@ static QVariant createInstance(const QJsonObject &obj)
MAKE_FACTORY(LodgingBusiness);
MAKE_FACTORY(LodgingReservation);
MAKE_FACTORY(PostalAddress);
MAKE_FACTORY(TrainStation);
MAKE_FACTORY(TrainTrip);
MAKE_FACTORY(TrainReservation);
return {};
}
......
......@@ -50,6 +50,9 @@ GRANTLEE_MAKE_GADGET(FlightReservation)
GRANTLEE_MAKE_GADGET(LodgingBusiness)
GRANTLEE_MAKE_GADGET(LodgingReservation)
GRANTLEE_MAKE_GADGET(PostalAddress)
GRANTLEE_MAKE_GADGET(TrainStation)
GRANTLEE_MAKE_GADGET(TrainTrip)
GRANTLEE_MAKE_GADGET(TrainReservation)
SemanticRenderer::SemanticRenderer()
{
......@@ -60,6 +63,9 @@ SemanticRenderer::SemanticRenderer()
Grantlee::registerMetaType<LodgingBusiness>();
Grantlee::registerMetaType<LodgingReservation>();
Grantlee::registerMetaType<PostalAddress>();
Grantlee::registerMetaType<TrainStation>();
Grantlee::registerMetaType<TrainTrip>();
Grantlee::registerMetaType<TrainReservation>();
}
bool SemanticRenderer::render(const MimeTreeParser::MessagePartPtr &msgPart, MessageViewer::HtmlWriter *htmlWriter, MessageViewer::RenderContext *context) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment