mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
215 lines
7.0 KiB
C++
215 lines
7.0 KiB
C++
#include <QByteArray>
|
|
#include <QList>
|
|
#include <QMetaObject>
|
|
#include <QMimeData>
|
|
#include <QString>
|
|
#include <QByteArray>
|
|
#include <cstring>
|
|
#include <QUrl>
|
|
#include <QVariant>
|
|
#include "qmimedata.h"
|
|
|
|
#include "gen_qmimedata.h"
|
|
|
|
extern "C" {
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
}
|
|
|
|
QMimeData* QMimeData_new() {
|
|
return new QMimeData();
|
|
}
|
|
|
|
QMetaObject* QMimeData_MetaObject(const QMimeData* self) {
|
|
return (QMetaObject*) self->metaObject();
|
|
}
|
|
|
|
void QMimeData_Tr(const char* s, char** _out, int* _out_Strlen) {
|
|
QString ret = QMimeData::tr(s);
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_TrUtf8(const char* s, char** _out, int* _out_Strlen) {
|
|
QString ret = QMimeData::trUtf8(s);
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_Urls(const QMimeData* self, QUrl*** _out, size_t* _out_len) {
|
|
QList<QUrl> ret = self->urls();
|
|
// Convert QList<> from C++ memory to manually-managed C memory of copy-constructed pointers
|
|
QUrl** __out = static_cast<QUrl**>(malloc(sizeof(QUrl**) * ret.length()));
|
|
for (size_t i = 0, e = ret.length(); i < e; ++i) {
|
|
__out[i] = new QUrl(ret[i]);
|
|
}
|
|
*_out = __out;
|
|
*_out_len = ret.length();
|
|
}
|
|
|
|
void QMimeData_SetUrls(QMimeData* self, QUrl** urls, size_t urls_len) {
|
|
QList<QUrl> urls_QList;
|
|
urls_QList.reserve(urls_len);
|
|
for(size_t i = 0; i < urls_len; ++i) {
|
|
urls_QList.push_back(*(urls[i]));
|
|
}
|
|
self->setUrls(urls_QList);
|
|
}
|
|
|
|
bool QMimeData_HasUrls(const QMimeData* self) {
|
|
return self->hasUrls();
|
|
}
|
|
|
|
void QMimeData_Text(const QMimeData* self, char** _out, int* _out_Strlen) {
|
|
QString ret = self->text();
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_SetText(QMimeData* self, const char* text, size_t text_Strlen) {
|
|
QString text_QString = QString::fromUtf8(text, text_Strlen);
|
|
self->setText(text_QString);
|
|
}
|
|
|
|
bool QMimeData_HasText(const QMimeData* self) {
|
|
return self->hasText();
|
|
}
|
|
|
|
void QMimeData_Html(const QMimeData* self, char** _out, int* _out_Strlen) {
|
|
QString ret = self->html();
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_SetHtml(QMimeData* self, const char* html, size_t html_Strlen) {
|
|
QString html_QString = QString::fromUtf8(html, html_Strlen);
|
|
self->setHtml(html_QString);
|
|
}
|
|
|
|
bool QMimeData_HasHtml(const QMimeData* self) {
|
|
return self->hasHtml();
|
|
}
|
|
|
|
QVariant* QMimeData_ImageData(const QMimeData* self) {
|
|
QVariant ret = self->imageData();
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
return static_cast<QVariant*>(new QVariant(ret));
|
|
}
|
|
|
|
void QMimeData_SetImageData(QMimeData* self, QVariant* image) {
|
|
self->setImageData(*image);
|
|
}
|
|
|
|
bool QMimeData_HasImage(const QMimeData* self) {
|
|
return self->hasImage();
|
|
}
|
|
|
|
QVariant* QMimeData_ColorData(const QMimeData* self) {
|
|
QVariant ret = self->colorData();
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
return static_cast<QVariant*>(new QVariant(ret));
|
|
}
|
|
|
|
void QMimeData_SetColorData(QMimeData* self, QVariant* color) {
|
|
self->setColorData(*color);
|
|
}
|
|
|
|
bool QMimeData_HasColor(const QMimeData* self) {
|
|
return self->hasColor();
|
|
}
|
|
|
|
QByteArray* QMimeData_Data(const QMimeData* self, const char* mimetype, size_t mimetype_Strlen) {
|
|
QString mimetype_QString = QString::fromUtf8(mimetype, mimetype_Strlen);
|
|
QByteArray ret = self->data(mimetype_QString);
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
return static_cast<QByteArray*>(new QByteArray(ret));
|
|
}
|
|
|
|
void QMimeData_SetData(QMimeData* self, const char* mimetype, size_t mimetype_Strlen, QByteArray* data) {
|
|
QString mimetype_QString = QString::fromUtf8(mimetype, mimetype_Strlen);
|
|
self->setData(mimetype_QString, *data);
|
|
}
|
|
|
|
void QMimeData_RemoveFormat(QMimeData* self, const char* mimetype, size_t mimetype_Strlen) {
|
|
QString mimetype_QString = QString::fromUtf8(mimetype, mimetype_Strlen);
|
|
self->removeFormat(mimetype_QString);
|
|
}
|
|
|
|
bool QMimeData_HasFormat(const QMimeData* self, const char* mimetype, size_t mimetype_Strlen) {
|
|
QString mimetype_QString = QString::fromUtf8(mimetype, mimetype_Strlen);
|
|
return self->hasFormat(mimetype_QString);
|
|
}
|
|
|
|
void QMimeData_Formats(const QMimeData* self, char*** _out, int** _out_Lengths, size_t* _out_len) {
|
|
QStringList ret = self->formats();
|
|
// Convert QStringList from C++ memory to manually-managed C memory
|
|
char** __out = static_cast<char**>(malloc(sizeof(char*) * ret.length()));
|
|
int* __out_Lengths = static_cast<int*>(malloc(sizeof(int) * ret.length()));
|
|
for (size_t i = 0, e = ret.length(); i < e; ++i) {
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret[i].toUtf8();
|
|
__out[i] = static_cast<char*>(malloc(b.length()));
|
|
memcpy(__out[i], b.data(), b.length());
|
|
__out_Lengths[i] = b.length();
|
|
}
|
|
*_out = __out;
|
|
*_out_Lengths = __out_Lengths;
|
|
*_out_len = ret.length();
|
|
}
|
|
|
|
void QMimeData_Clear(QMimeData* self) {
|
|
self->clear();
|
|
}
|
|
|
|
void QMimeData_Tr2(const char* s, const char* c, char** _out, int* _out_Strlen) {
|
|
QString ret = QMimeData::tr(s, c);
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_Tr3(const char* s, const char* c, int n, char** _out, int* _out_Strlen) {
|
|
QString ret = QMimeData::tr(s, c, static_cast<int>(n));
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_TrUtf82(const char* s, const char* c, char** _out, int* _out_Strlen) {
|
|
QString ret = QMimeData::trUtf8(s, c);
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_TrUtf83(const char* s, const char* c, int n, char** _out, int* _out_Strlen) {
|
|
QString ret = QMimeData::trUtf8(s, c, static_cast<int>(n));
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
QByteArray b = ret.toUtf8();
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
memcpy(*_out, b.data(), b.length());
|
|
*_out_Strlen = b.length();
|
|
}
|
|
|
|
void QMimeData_Delete(QMimeData* self) {
|
|
delete self;
|
|
}
|
|
|