KItinerary
file.cpp
102 const auto resDir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("reservations"_L1));
123 const auto resDir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("reservations"_L1));
157 d->zipFile->writeFile("reservations/"_L1 + id + ".json"_L1, QJsonDocument(JsonLdDocument::toJson(res)).toJson());
170 // serialNumber can contain percent-encoding or slashes, ie stuff we don't want to have in file names
171 return passTypeIdenfier + '/'_L1 + QString::fromUtf8(serialNumber.toUtf8().toBase64(QByteArray::Base64UrlEncoding));
181 return { passId.left(idx).toString(), QString::fromUtf8(QByteArray::fromBase64(passId.mid(idx + 1).toUtf8(), QByteArray::Base64UrlEncoding)) };
214 const auto passDir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("passes"_L1));
240 const auto docDir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("documents"_L1));
260 const auto dir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("documents/"_L1 + id));
294 const auto dir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("documents/"_L1 + id));
334 const auto fileName = normalizeDocumentFileName(JsonLdDocument::readProperty(docInfo, "name").toString());
338 d->zipFile->writeFile("documents/"_L1 + id + "/meta.json"_L1, QJsonDocument(JsonLdDocument::toJson(normalizedDocInfo)).toJson());
345 const auto dir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("custom/"_L1 + scope));
360 const auto dir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("custom/"_L1 + scope));
371 const auto dir = dynamic_cast<const KArchiveDirectory *>(d->zipFile->directory()->entry("custom/"_L1 + scope));
QStringList entries() const
const KArchiveFile * file(const QString &name) const
virtual QByteArray data() const
A file containing a bundle of reservations and associated documents.
Definition file.h:38
void addDocument(const QString &id, const QVariant &docInfo, const QByteArray &docData)
Adds a document and associated meta data to the file.
Definition file.cpp:322
QByteArray passData(const QString &passId) const
Pass data for the given pass id.
Definition file.cpp:211
static QString passId(const KPkPass::Pass *pass)
Returns the pass identifier used in here for pass.
Definition file.cpp:160
static QString normalizeDocumentFileName(const QString &name)
Makes sure the resulting file name is something that can safely be used without messing up the file s...
Definition file.cpp:304
QList< QString > reservations() const
Lists the identifiers of all reservations in this file.
Definition file.cpp:100
QVariant reservation(const QString &resId) const
Loads the reservation with the given identifier.
Definition file.cpp:120
void addPass(KPkPass::Pass *pass, const QByteArray &rawData)
Add a pkpass file to this file.
Definition file.cpp:227
bool hasCustomData(QStringView scope, const QString &id) const
Returns true if custom data with the given id exists in scope.
Definition file.cpp:357
QByteArray customData(QStringView scope, const QString &id) const
Returns the custom data in the given namespace and with the given id.
Definition file.cpp:368
QVariant documentInfo(const QString &id) const
Loads the document meta data of document id.
Definition file.cpp:257
QByteArray documentData(const QString &id) const
Loads the content of document id.
Definition file.cpp:286
QList< QString > listCustomData(QStringView scope) const
List custom data in the given namespace.
Definition file.cpp:342
void addCustomData(QStringView scope, const QString &id, const QByteArray &data)
Adds a custom data element with identifier id in to namespace scope.
Definition file.cpp:384
static void writeProperty(QVariant &obj, const char *name, const QVariant &value)
Set property name on object obj to value value.
Definition jsonlddocument.cpp:538
static QVariant readProperty(const QVariant &obj, const char *name)
Read property name on object obj.
Definition jsonlddocument.cpp:522
static QJsonArray toJson(const QList< QVariant > &data)
Serialize instantiated data types to JSON-LD.
Definition jsonlddocument.cpp:497
static QList< QVariant > fromJson(const QJsonArray &array)
Convert JSON-LD array into instantiated data types.
Definition jsonlddocument.cpp:339
static QVariant fromJsonSingular(const QJsonObject &obj)
Convert a single JSON-LD object into an instantiated data type.
Definition jsonlddocument.cpp:361
bool canConvert(const QVariant &value)
Checks if the given value can be up-cast to T.
Definition datatypes.h:31
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
Base64UrlEncoding
QByteArray fromBase64(const QByteArray &base64, Base64Options options)
QByteArray toBase64(Base64Options options) const const
WriteOnly
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
void push_back(parameter_type value)
void reserve(qsizetype size)
QChar * data()
QString fromUtf8(QByteArrayView str)
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
qsizetype size() const const
QByteArray toUtf8() const const
QTextStream & left(QTextStream &stream)
WithoutBraces
QUuid createUuid()
Decodes an identifier returned by passId() again.
Definition file.h:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:52:35 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:52:35 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.