Commit 0ae527ce authored by Volker Krause's avatar Volker Krause
Browse files

Also move the bit array factory function to ByteArray

parent 47a28576
......@@ -5,7 +5,6 @@
*/
#include "barcode.h"
#include "bitarray.h"
#include <era/ssbticketreader.h>
#include <pdf/pdfbarcodeutil_p.h>
......@@ -82,9 +81,4 @@ QVariant JsApi::Barcode::decodeEraSsbTicket(const QVariant &s, int versionOverri
return SSBTicketReader::read(s.toByteArray(), versionOverride);
}
QVariant JsApi::Barcode::toBitArray(const QVariant &b) const
{
return QVariant::fromValue(JsApi::BitArray(b.toByteArray()));
}
#include "moc_barcode.cpp"
......@@ -58,9 +58,6 @@ public:
*/
Q_INVOKABLE QVariant decodeEraSsbTicket(const QVariant &s, int versionOverride = 0) const;
/** Converts the given QByteArray into a BitArray. */
Q_INVOKABLE QVariant toBitArray(const QVariant &b) const;
///@cond internal
void setDecoder(BarcodeDecoder *decoder);
///@endcond
......
......@@ -5,6 +5,7 @@
*/
#include "bytearray.h"
#include "bitarray.h"
#include "logging.h"
#include <QQmlEngine>
......@@ -64,6 +65,11 @@ QString JsApi::ByteArray::decodeLatin1(const QByteArray &input) const
return QString::fromLatin1(input.constData(), input.size());
}
QVariant JsApi::ByteArray::toBitArray(const QByteArray &input) const
{
return QVariant::fromValue(JsApi::BitArray(input));
}
QJSValue JsApi::ByteArray::toArrayBuffer(const QByteArray &input) const
{
const auto engine = qjsEngine(this);
......
......@@ -9,6 +9,7 @@
#include <QObject>
#include <QJSValue>
#include <QVariant>
class QByteArray;
......@@ -35,6 +36,9 @@ public:
/** Convert a QByteArray/ArrayBuffer to a string, assuming Latin1 encoding. */
Q_INVOKABLE QString decodeLatin1(const QByteArray &input) const;
/** Converts the given QByteArray or JS ArrayBuffer into a BitArray. */
Q_INVOKABLE QVariant toBitArray(const QByteArray &input) const;
/** Convert a QByteArray to a JS ArrayBuffer.
* This is mainly a migration aid until we return ArrayBuffers everywhere.
*/
......
......@@ -64,7 +64,7 @@ function parsePdf(pdf) {
personalRes.programMembershipUsed.programName = "CartaFRECCIA";
}
var bitArray = Barcode.toBitArray(barcode);
var bitArray = ByteArray.toBitArray(barcode);
var seatNum = bitArray.readNumberMSB(31*8 + 2, 7);
if (seatNum > 0) {
personalRes.reservedTicket.ticketedSeat.seatNumber = "" + seatNum;
......
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