2024-08-25 04:08:24 +00:00
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QItemDelegate>
|
|
|
|
#include <QItemEditorFactory>
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QModelIndex>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QStyleOptionViewItem>
|
|
|
|
#include <QWidget>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "qitemdelegate.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qitemdelegate.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
QItemDelegate* QItemDelegate_new() {
|
|
|
|
return new QItemDelegate();
|
|
|
|
}
|
|
|
|
|
|
|
|
QItemDelegate* QItemDelegate_new2(QObject* parent) {
|
|
|
|
return new QItemDelegate(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
QMetaObject* QItemDelegate_MetaObject(QItemDelegate* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return (QMetaObject*) const_cast<const QItemDelegate*>(self)->metaObject();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QItemDelegate_Tr(const char* s, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QItemDelegate::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();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QItemDelegate_TrUtf8(const char* s, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QItemDelegate::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();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QItemDelegate_HasClipping(QItemDelegate* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QItemDelegate*>(self)->hasClipping();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QItemDelegate_SetClipping(QItemDelegate* self, bool clip) {
|
|
|
|
self->setClipping(clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QItemDelegate_Paint(QItemDelegate* self, QPainter* painter, QStyleOptionViewItem* option, QModelIndex* index) {
|
2024-08-29 07:01:51 +00:00
|
|
|
const_cast<const QItemDelegate*>(self)->paint(painter, *option, *index);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QSize* QItemDelegate_SizeHint(QItemDelegate* self, QStyleOptionViewItem* option, QModelIndex* index) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QSize ret = const_cast<const QItemDelegate*>(self)->sizeHint(*option, *index);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QSize*>(new QSize(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget* QItemDelegate_CreateEditor(QItemDelegate* self, QWidget* parent, QStyleOptionViewItem* option, QModelIndex* index) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QItemDelegate*>(self)->createEditor(parent, *option, *index);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QItemDelegate_SetEditorData(QItemDelegate* self, QWidget* editor, QModelIndex* index) {
|
2024-08-29 07:01:51 +00:00
|
|
|
const_cast<const QItemDelegate*>(self)->setEditorData(editor, *index);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QItemDelegate_SetModelData(QItemDelegate* self, QWidget* editor, QAbstractItemModel* model, QModelIndex* index) {
|
2024-08-29 07:01:51 +00:00
|
|
|
const_cast<const QItemDelegate*>(self)->setModelData(editor, model, *index);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QItemDelegate_UpdateEditorGeometry(QItemDelegate* self, QWidget* editor, QStyleOptionViewItem* option, QModelIndex* index) {
|
2024-08-29 07:01:51 +00:00
|
|
|
const_cast<const QItemDelegate*>(self)->updateEditorGeometry(editor, *option, *index);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QItemEditorFactory* QItemDelegate_ItemEditorFactory(QItemDelegate* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QItemDelegate*>(self)->itemEditorFactory();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QItemDelegate_SetItemEditorFactory(QItemDelegate* self, QItemEditorFactory* factory) {
|
|
|
|
self->setItemEditorFactory(factory);
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QItemDelegate_Tr2(const char* s, const char* c, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QItemDelegate::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();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QItemDelegate_Tr3(const char* s, const char* c, int n, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QItemDelegate::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();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QItemDelegate_TrUtf82(const char* s, const char* c, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QItemDelegate::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();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QItemDelegate_TrUtf83(const char* s, const char* c, int n, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QItemDelegate::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 QItemDelegate_Delete(QItemDelegate* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|