Commit edce84c5 authored by Volker Krause's avatar Volker Krause
Browse files

Make UIC 918 DB vendor blocks usable from JS

Will be needed to extract the Bahncard information.
parent ba2330e4
Pipeline #71917 passed with stage
in 13 minutes and 16 seconds
......@@ -63,6 +63,12 @@ QVariant Uic9183Parser::block(const QString &name) const
return {};
}
if (name == QLatin1String("0080BL")) {
return QVariant::fromValue(findBlock<Vendor0080BLBlock>());
}
if (name == QLatin1String("0080VU")) {
return QVariant::fromValue(findBlock<Vendor0080VUBlock>());
}
return QVariant::fromValue(findBlock(name.toUtf8().constData()));
}
......
......@@ -27,6 +27,30 @@ enum {
// 4x field value length
// nx field value
// S001: price model (textual)
// S002: product class (numeric: 0 = C, 1 = B, 2 = A)
// S003: product class outbound (A, B, or C)
// S004: produce class return
// S009: [num adults]-[num adults with Bahncard]-[Bahncard type] (49 = BC25, 19,78 = BC50)
// S012: number of children
// S014: S[class of travel]
// S015: departure station name (outbound)
// S016: arrival station name (outbound)
// S017: departure station name (return)
// S018: arrival station name (return)
// S019, S020: Rail&Fly specific
// S021: via
// S023: traveler name
// S026: price type (numeric) (12 = Normalpreis, 13 = Sparpreis, 3 = Rail&Fly)
// S027: id number (no longer used)
// S028: [given name]#[family name]
// S031: first day of validity, dd.MM.yyyy
// S032: last day of validity, dd.MM.yyyy
// S035: departure station IBNR without country prefix (outbound)
// S036: arrival station IBNR without country prefix (outbound)
// S040: number of persons?
// S041: number of tickets?
Vendor0080BLSubBlock::Vendor0080BLSubBlock() = default;
Vendor0080BLSubBlock::Vendor0080BLSubBlock(const Uic9183Block &block, int offset)
......@@ -207,6 +231,14 @@ Vendor0080BLSubBlock Vendor0080BLBlock::findSubBlock(const char id[3]) const
return {};
}
QVariant Vendor0080BLBlock::findSubBlock(const QString &str) const
{
if (str.size() != 3) {
return {};
}
return QVariant::fromValue(findSubBlock(str.toUtf8().constData()));
}
int Vendor0080BLBlock::subblockOffset(const Uic9183Block& block)
{
const auto certCount = *(block.content() + 2) - '0';
......
......@@ -38,6 +38,8 @@ private:
/** UIC 918.3 0080BL vendor data block sub-block. */
class KITINERARY_EXPORT Vendor0080BLSubBlock
{
Q_GADGET
Q_PROPERTY(QString content READ toString)
public:
Vendor0080BLSubBlock();
Vendor0080BLSubBlock(const Uic9183Block &block, int offset);
......@@ -72,7 +74,7 @@ class KITINERARY_EXPORT Vendor0080BLBlock
Q_PROPERTY(int orderBlockCount READ orderBlockCount)
public:
Vendor0080BLBlock(const Uic9183Block &block);
Vendor0080BLBlock(const Uic9183Block &block = Uic9183Block());
bool isValid() const;
int orderBlockCount() const;
......@@ -84,6 +86,7 @@ public:
Vendor0080BLSubBlock firstBlock() const;
/** Finds a S-block by type. */
Vendor0080BLSubBlock findSubBlock(const char id[3]) const;
Q_INVOKABLE QVariant findSubBlock(const QString &str) const;
static constexpr const char RecordId[] = "0080BL";
private:
......@@ -101,7 +104,7 @@ class Vendor0080VUTicketData;
class KITINERARY_EXPORT Vendor0080VUBlock
{
public:
Vendor0080VUBlock(const Uic9183Block &block);
Vendor0080VUBlock(const Uic9183Block &block = Uic9183Block());
bool isValid() const;
const Vendor0080VUCommonData* commonData() const;
......@@ -114,3 +117,6 @@ private:
}
Q_DECLARE_METATYPE(KItinerary::Vendor0080BLBlock)
Q_DECLARE_METATYPE(KItinerary::Vendor0080BLSubBlock)
Q_DECLARE_METATYPE(KItinerary::Vendor0080VUBlock)
Supports Markdown
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