Commit 5567f6f0 authored by Volker Krause's avatar Volker Krause
Browse files

Port QByteArray -> JS ArrayBuffer conversion to Qt6

This now works with public API even.
parent 06722516
Pipeline #182271 passed with stage
in 3 minutes and 7 seconds
......@@ -175,18 +175,18 @@ target_link_libraries(KPimItinerary
KF5::Mime
PRIVATE
Qt${QT_MAJOR_VERSION}::Qml
Qt${QT_MAJOR_VERSION}::QmlPrivate
KF5::Archive
KF5::I18n
KF5::I18nLocaleData
KF5::Codecs
KF5::Contacts
KPim::PkPass
Poppler::Core
OpenSSL::Crypto
ZLIB::ZLIB
)
target_link_libraries(KPimItinerary PRIVATE Poppler::Core)
if (TARGET KF5::I18nLocaleData)
target_link_libraries(KPimItinerary PRIVATE KF5::I18nLocaleData)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(KPimItinerary PRIVATE Qt5::QmlPrivate) # for QByteArray -> ArrayBuffer conversion
endif()
if (TARGET ZXing::ZXing)
......
......@@ -13,8 +13,10 @@
#include <QImage>
#include <QQmlEngine>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <private/qv4arraybuffer_p.h>
#include <private/qv4engine_p.h>
#endif
using namespace KItinerary;
......@@ -45,7 +47,11 @@ QJSValue JsApi::Barcode::decodeAztecBinary(const QVariant &img) const
return {};
}
const auto engine = qjsEngine(this);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return QJSValue(engine->handle(), engine->handle()->newArrayBuffer(content)->asReturnedValue());
#else
return QJSValue(QJSManagedValue(QVariant(content), engine));
#endif
}
return {};
}
......
......@@ -10,8 +10,10 @@
#include <QQmlEngine>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <private/qv4arraybuffer_p.h>
#include <private/qv4engine_p.h>
#endif
#include <zlib.h>
......@@ -73,5 +75,9 @@ QVariant JsApi::ByteArray::toBitArray(const QByteArray &input) const
QJSValue JsApi::ByteArray::toArrayBuffer(const QByteArray &input) const
{
const auto engine = qjsEngine(this);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return QJSValue(engine->handle(), engine->handle()->newArrayBuffer(input)->asReturnedValue());
#else
return QJSValue(QJSManagedValue(QVariant(input), engine));
#endif
}
......@@ -10,8 +10,10 @@
#include <QQmlEngine>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <private/qv4arraybuffer_p.h>
#include <private/qv4engine_p.h>
#endif
using namespace KItinerary;
......@@ -29,5 +31,9 @@ bool BinaryDocumentProcessor::matches(const ExtractorFilter &filter, const Extra
QJSValue BinaryDocumentProcessor::contentToScriptValue(const ExtractorDocumentNode &node, QJSEngine *engine) const
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return QJSValue(engine->handle(), engine->handle()->newArrayBuffer(node.content<QByteArray>())->asReturnedValue());
#else
return QJSValue(QJSManagedValue(QVariant(node.content<QByteArray>()), engine));
#endif
}
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