2015-11-23 21:33:17 +01:00
|
|
|
#include "DOtherSide/DOtherSide.h"
|
2014-07-19 18:26:08 +02:00
|
|
|
|
2015-02-04 23:02:26 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
2014-07-19 18:26:08 +02:00
|
|
|
#include <QtCore/QDir>
|
|
|
|
#include <QtCore/QDebug>
|
2015-01-18 12:26:51 +01:00
|
|
|
#include <QtCore/QModelIndex>
|
2015-03-11 21:32:45 +01:00
|
|
|
#include <QtCore/QHash>
|
2015-01-31 12:50:14 +01:00
|
|
|
#include <QtGui/QGuiApplication>
|
|
|
|
#include <QtQml/QQmlContext>
|
|
|
|
#include <QtQml/QQmlApplicationEngine>
|
|
|
|
#include <QtQuick/QQuickView>
|
|
|
|
#include <QtWidgets/QApplication>
|
2015-12-05 17:33:54 +01:00
|
|
|
#include <QResource>
|
2014-07-19 18:26:08 +02:00
|
|
|
|
2015-11-23 21:33:17 +01:00
|
|
|
#include "DOtherSide/DynamicQObject.h"
|
|
|
|
#include "DOtherSide/BaseQAbstractListModel.h"
|
|
|
|
#include "DOtherSide/BaseQObject.h"
|
|
|
|
#include "DOtherSide/OnSlotExecutedHandler.h"
|
2014-07-19 18:26:08 +02:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
void convert_to_cstring(const QString& source, char** destination)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QByteArray array = source.toUtf8();
|
2015-01-31 14:20:36 +01:00
|
|
|
*destination = qstrdup(array.data());
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qguiapplication_create()
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
static int argc = 1;
|
|
|
|
static char empty[1] = {0};
|
|
|
|
static char* argv[] = {empty};
|
|
|
|
new QGuiApplication(argc, argv);
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qguiapplication_delete()
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
delete qApp;
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qguiapplication_exec()
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
qApp->exec();
|
|
|
|
}
|
|
|
|
|
2015-01-11 13:05:50 +01:00
|
|
|
void dos_qguiapplication_quit()
|
|
|
|
{
|
|
|
|
qApp->quit();
|
|
|
|
}
|
|
|
|
|
2015-01-11 13:29:44 +01:00
|
|
|
void dos_qapplication_create()
|
|
|
|
{
|
|
|
|
static int argc = 1;
|
|
|
|
static char empty[1] = {0};
|
|
|
|
static char* argv[] = {empty};
|
|
|
|
new QApplication(argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qapplication_delete()
|
|
|
|
{
|
|
|
|
delete qApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qapplication_exec()
|
|
|
|
{
|
|
|
|
qApp->exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qapplication_quit()
|
|
|
|
{
|
|
|
|
qApp->quit();
|
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qqmlapplicationengine_create(void** vptr)
|
2014-12-01 21:02:18 +01:00
|
|
|
{
|
|
|
|
*vptr = new QQmlApplicationEngine();
|
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qqmlapplicationengine_load(void* vptr, const char* filename)
|
2014-12-01 21:02:18 +01:00
|
|
|
{
|
|
|
|
QQmlApplicationEngine* engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
|
|
|
engine->load(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QDir::separator() + QString(filename)));
|
|
|
|
}
|
|
|
|
|
2015-12-05 17:33:54 +01:00
|
|
|
void dos_qqmlapplicationengine_load_url(void* vptr, void* url)
|
|
|
|
{
|
|
|
|
QQmlApplicationEngine* engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
|
|
|
QUrl* qurl = reinterpret_cast<QUrl*>(url);
|
|
|
|
engine -> load(*qurl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qqmlapplicationengine_add_import_path(void* vptr, const char* path)
|
|
|
|
{
|
|
|
|
QQmlApplicationEngine* engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
|
|
|
engine -> addImportPath(QString(path));
|
|
|
|
}
|
|
|
|
|
2014-12-08 12:55:09 +01:00
|
|
|
void dos_qqmlapplicationengine_context(void* vptr, void** context)
|
|
|
|
{
|
|
|
|
QQmlApplicationEngine* engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
|
|
|
engine->rootContext();
|
|
|
|
*context = engine->rootContext();
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:02:18 +01:00
|
|
|
void dos_qqmlapplicationengine_delete(void* vptr)
|
|
|
|
{
|
|
|
|
QQmlApplicationEngine* engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
|
|
|
delete engine;
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qquickview_create(void** vptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
*vptr = new QQuickView();
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qquickview_show(void* vptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QQuickView* view = reinterpret_cast<QQuickView*>(vptr);
|
|
|
|
view->show();
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qquickview_delete(void* vptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QQuickView* view = reinterpret_cast<QQuickView*>(vptr);
|
|
|
|
delete view;
|
|
|
|
}
|
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
void dos_qquickview_source(void* vptr, char** result)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QQuickView* view = reinterpret_cast<QQuickView*>(vptr);
|
|
|
|
QUrl url = view->source();
|
2015-04-27 19:58:18 +02:00
|
|
|
convert_to_cstring(url.toString(), result);
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qquickview_set_source(void* vptr, const char* filename)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QQuickView* view = reinterpret_cast<QQuickView*>(vptr);
|
|
|
|
view->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QDir::separator() + QString(filename)));
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qquickview_rootContext(void* vptr, void** context)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QQuickView* view = reinterpret_cast<QQuickView*>(vptr);
|
|
|
|
*context = view->rootContext();
|
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_chararray_delete(char* ptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
if (ptr) delete[] ptr;
|
|
|
|
}
|
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
void dos_qqmlcontext_baseUrl(void* vptr, char** result)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QQmlContext* context = reinterpret_cast<QQmlContext*>(vptr);
|
|
|
|
QUrl url = context->baseUrl();
|
2015-04-27 19:58:18 +02:00
|
|
|
convert_to_cstring(url.toString(), result);
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qqmlcontext_setcontextproperty(void* vptr, const char* name, void* value)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
QQmlContext* context = reinterpret_cast<QQmlContext*>(vptr);
|
2014-08-30 18:46:34 +02:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(value);
|
2014-07-19 18:26:08 +02:00
|
|
|
context->setContextProperty(QString::fromUtf8(name), *variant);
|
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qvariant_create(void** vptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
*vptr = new QVariant();
|
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qvariant_create_int(void** vptr, int value)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
*vptr = new QVariant(value);
|
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qvariant_create_bool(void** vptr, bool value)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
*vptr = new QVariant(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qvariant_create_string(void** vptr, const char* value)
|
|
|
|
{
|
|
|
|
*vptr = new QVariant(value);
|
|
|
|
}
|
|
|
|
|
2015-01-10 11:26:23 +01:00
|
|
|
void dos_qvariant_create_qvariant(void** vptr, void* other)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto newQVariant = new QVariant();
|
|
|
|
auto otherQVariant = reinterpret_cast<QVariant*>(other);
|
|
|
|
*newQVariant = *otherQVariant;
|
|
|
|
*vptr = newQVariant;
|
2015-01-10 11:26:23 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qvariant_create_qobject(void** vptr, void* value)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-08-30 18:46:34 +02:00
|
|
|
auto qobject = reinterpret_cast<QObject*>(value);
|
|
|
|
auto variant = new QVariant();
|
2014-07-19 18:26:08 +02:00
|
|
|
variant->setValue<QObject*>(qobject);
|
|
|
|
*vptr = variant;
|
|
|
|
}
|
|
|
|
|
2015-01-11 13:05:50 +01:00
|
|
|
void dos_qvariant_create_float(void** vptr, float value)
|
|
|
|
{
|
|
|
|
*vptr = new QVariant(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qvariant_create_double(void** vptr, double value)
|
|
|
|
{
|
|
|
|
*vptr = new QVariant(value);
|
|
|
|
}
|
|
|
|
|
2015-01-26 19:11:50 +01:00
|
|
|
void dos_qvariant_create_qabstractlistmodel(void** vptr, void* value)
|
|
|
|
{
|
|
|
|
auto qobject = reinterpret_cast<QObject*>(value);
|
|
|
|
auto variant = new QVariant();
|
|
|
|
variant->setValue<QObject*>(qobject);
|
|
|
|
*vptr = variant;
|
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qvariant_isnull(void* vptr, bool* isNull)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-08-30 18:46:34 +02:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
2015-01-31 14:20:36 +01:00
|
|
|
*isNull = variant->isNull();
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qvariant_delete(void* vptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-08-30 18:46:34 +02:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
delete variant;
|
|
|
|
}
|
|
|
|
|
2015-01-10 11:26:23 +01:00
|
|
|
void dos_qvariant_assign(void* vptr, void* other)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto leftQVariant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
auto rightQVariant = reinterpret_cast<QVariant*>(other);
|
|
|
|
*leftQVariant = *rightQVariant;
|
2015-01-10 11:26:23 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qvariant_toInt(void* vptr, int* value)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-08-30 18:46:34 +02:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
2015-01-31 14:20:36 +01:00
|
|
|
*value = variant->toInt();
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qvariant_toBool(void* vptr, bool* value)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-08-30 18:46:34 +02:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
2015-01-31 14:20:36 +01:00
|
|
|
*value = variant->toBool();
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qvariant_toFloat(void* vptr, float* value)
|
2015-01-11 13:05:50 +01:00
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*value = variant->toFloat();
|
2015-01-11 13:05:50 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qvariant_toDouble(void* vptr, double* value)
|
2015-01-11 13:05:50 +01:00
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*value = variant->toDouble();
|
2015-01-11 13:05:50 +01:00
|
|
|
}
|
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
void dos_qvariant_toString(void* vptr, char** ptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-08-30 18:46:34 +02:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
2015-04-27 19:58:18 +02:00
|
|
|
convert_to_cstring(variant->toString(), ptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2014-08-30 18:46:34 +02:00
|
|
|
void dos_qvariant_setInt(void* vptr, int value)
|
|
|
|
{
|
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*variant = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qvariant_setBool(void* vptr, bool value)
|
|
|
|
{
|
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*variant = value;
|
|
|
|
}
|
|
|
|
|
2015-01-11 13:05:50 +01:00
|
|
|
void dos_qvariant_setFloat(void* vptr, float value)
|
|
|
|
{
|
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*variant = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qvariant_setDouble(void* vptr, double value)
|
|
|
|
{
|
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*variant = value;
|
|
|
|
}
|
|
|
|
|
2014-08-30 18:46:34 +02:00
|
|
|
void dos_qvariant_setString(void* vptr, const char* value)
|
|
|
|
{
|
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*variant = value;
|
|
|
|
}
|
|
|
|
|
2015-01-12 21:21:46 +01:00
|
|
|
void dos_qvariant_setQObject(void* vptr, void* value)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
auto qobject = reinterpret_cast<QObject*>(value);
|
|
|
|
variant->setValue<QObject*>(qobject);
|
2015-01-12 21:21:46 +01:00
|
|
|
}
|
|
|
|
|
2015-01-26 19:11:50 +01:00
|
|
|
void dos_qvariant_setQAbstractListModel(void* vptr, void* value)
|
|
|
|
{
|
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
auto qobject = reinterpret_cast<QObject*>(value);
|
|
|
|
variant->setValue<QObject*>(qobject);
|
|
|
|
}
|
|
|
|
|
2014-08-30 18:46:34 +02:00
|
|
|
void dos_qobject_create(void** vptr, void* dObjectPointer, DObjectCallback dObjectCallback)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2015-02-05 23:04:59 +01:00
|
|
|
auto dynamicQObject = new BaseQObject();
|
2014-12-08 12:55:09 +01:00
|
|
|
QQmlEngine::setObjectOwnership(dynamicQObject, QQmlEngine::CppOwnership);
|
2015-09-20 11:39:25 +02:00
|
|
|
dynamicQObject->setOnSlotExecutedHandler(OnSlotExecutedHandler(dObjectPointer, dObjectCallback));
|
2014-07-19 18:26:08 +02:00
|
|
|
*vptr = dynamicQObject;
|
|
|
|
}
|
|
|
|
|
2015-01-31 17:01:03 +01:00
|
|
|
void dos_qobject_delete(void* vptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2015-02-05 23:04:59 +01:00
|
|
|
auto dynamicQObject = reinterpret_cast<BaseQObject*>(vptr);
|
2014-12-08 12:55:09 +01:00
|
|
|
dynamicQObject->disconnect();
|
2014-07-19 18:26:08 +02:00
|
|
|
delete dynamicQObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qobject_slot_create(void* vptr, const char* name, int parametersCount, int* parametersMetaTypes, int* slotIndex)
|
|
|
|
{
|
|
|
|
if (parametersCount <= 0)
|
|
|
|
return;
|
|
|
|
|
2015-02-05 23:04:59 +01:00
|
|
|
auto qobject = reinterpret_cast<QObject*>(vptr);
|
|
|
|
auto dynamicQObject = dynamic_cast<IDynamicQObject*>(qobject);
|
2014-07-19 18:26:08 +02:00
|
|
|
|
|
|
|
QMetaType::Type returnType = static_cast<QMetaType::Type>(parametersMetaTypes[0]);
|
|
|
|
QList<QMetaType::Type> argumentsTypes;
|
|
|
|
for (int i = 1; i < parametersCount; ++i)
|
|
|
|
argumentsTypes << static_cast<QMetaType::Type>(parametersMetaTypes[i]);
|
|
|
|
|
|
|
|
dynamicQObject->registerSlot(QString::fromStdString(name), returnType, argumentsTypes, *slotIndex);
|
|
|
|
}
|
|
|
|
|
2014-08-30 18:46:34 +02:00
|
|
|
void dos_qobject_signal_create(void* vptr, const char* name, int parametersCount, int* parametersMetaTypes, int* signalIndex)
|
|
|
|
{
|
|
|
|
if (parametersCount <= 0)
|
|
|
|
return;
|
|
|
|
|
2015-02-05 23:04:59 +01:00
|
|
|
auto qobject = reinterpret_cast<QObject*>(vptr);
|
|
|
|
auto dynamicQObject = dynamic_cast<IDynamicQObject*>(qobject);
|
2014-08-30 18:46:34 +02:00
|
|
|
|
|
|
|
QList<QMetaType::Type> argumentsTypes;
|
|
|
|
for (int i = 0; i < parametersCount; ++i)
|
|
|
|
argumentsTypes << static_cast<QMetaType::Type>(parametersMetaTypes[i]);
|
|
|
|
|
|
|
|
dynamicQObject->registerSignal(QString::fromStdString(name), argumentsTypes, *signalIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qobject_signal_emit(void* vptr, const char* name, int parametersCount, void** parameters)
|
|
|
|
{
|
2015-02-05 23:04:59 +01:00
|
|
|
auto qobject = reinterpret_cast<QObject*>(vptr);
|
|
|
|
auto dynamicQObject = dynamic_cast<IDynamicQObject*>(qobject);
|
|
|
|
|
2014-08-30 18:46:34 +02:00
|
|
|
QVariantList arguments;
|
|
|
|
for (int i = 0; i < parametersCount; ++i)
|
|
|
|
arguments << *(reinterpret_cast<QVariant*>(parameters[i]));
|
2015-02-05 23:04:59 +01:00
|
|
|
|
2014-08-30 18:46:34 +02:00
|
|
|
dynamicQObject->emitSignal(QString::fromStdString(name), arguments);
|
|
|
|
}
|
2014-12-24 14:30:41 +01:00
|
|
|
|
|
|
|
void dos_qobject_property_create(void* vptr,
|
|
|
|
const char* name,
|
|
|
|
int type,
|
|
|
|
const char* readSlot,
|
|
|
|
const char* writeSlot,
|
|
|
|
const char* notifySignal)
|
|
|
|
{
|
2015-02-05 23:04:59 +01:00
|
|
|
auto qobject = reinterpret_cast<QObject*>(vptr);
|
|
|
|
auto dynamicQObject = dynamic_cast<IDynamicQObject*>(qobject);
|
2014-12-24 14:30:41 +01:00
|
|
|
dynamicQObject->registerProperty(QString(name),
|
|
|
|
QMetaType::Type(type),
|
|
|
|
QString(readSlot),
|
|
|
|
QString(writeSlot),
|
|
|
|
QString(notifySignal));
|
|
|
|
}
|
2015-01-18 12:26:51 +01:00
|
|
|
|
|
|
|
void dos_qmodelindex_create(void** vptr)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = new QModelIndex();
|
|
|
|
*vptr = index;
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qmodelindex_delete(void* vptr)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
delete index;
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qmodelindex_row(void* vptr, int* row)
|
2015-01-18 12:26:51 +01:00
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
*row = index->row();
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qmodelindex_column(void* vptr, int* column)
|
2015-01-18 12:26:51 +01:00
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
*column = index->column();
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qmodelindex_isValid(void* vptr, bool* isValid)
|
2015-01-18 12:26:51 +01:00
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
*isValid = index->isValid();
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qmodelindex_data(void* vptr, int role, void* data)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
auto result = reinterpret_cast<QVariant*>(data);
|
|
|
|
*result = index->data(role);
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qmodelindex_parent(void* vptr, void* parent)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
auto parentIndex = reinterpret_cast<QModelIndex*>(parent);
|
|
|
|
*parentIndex = index->parent();
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qmodelindex_child(void* vptr, int row, int column, void* child)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
auto childIndex = reinterpret_cast<QModelIndex*>(child);
|
|
|
|
*childIndex = index->child(row, column);
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qmodelindex_sibling(void* vptr, int row, int column, void* sibling)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
|
|
|
auto siblingIndex = reinterpret_cast<QModelIndex*>(sibling);
|
|
|
|
*siblingIndex = index->sibling(row, column);
|
2015-01-18 12:26:51 +01:00
|
|
|
}
|
2015-01-19 22:23:18 +01:00
|
|
|
|
2015-01-20 21:18:58 +01:00
|
|
|
void dos_qabstractlistmodel_create(void** vptr,
|
2015-09-20 11:39:25 +02:00
|
|
|
void* dObjectPointer,
|
2015-02-10 00:40:20 +01:00
|
|
|
DObjectCallback dObjectCallback,
|
2015-01-26 21:26:21 +01:00
|
|
|
RowCountCallback rowCountCallback,
|
2015-02-15 12:59:42 +01:00
|
|
|
ColumnCountCallback columnCountCallback,
|
2015-01-31 16:30:12 +01:00
|
|
|
DataCallback dataCallback,
|
2015-02-14 15:45:04 +01:00
|
|
|
SetDataCallback setDataCallback,
|
|
|
|
RoleNamesCallback roleNamesCallaback,
|
2015-02-15 12:59:42 +01:00
|
|
|
FlagsCallback flagsCallback,
|
|
|
|
HeaderDataCallback headerDataCallback)
|
2015-01-19 22:23:18 +01:00
|
|
|
{
|
2015-09-20 11:39:25 +02:00
|
|
|
auto model = new BaseQAbstractListModel(dObjectPointer,
|
2015-01-31 17:01:03 +01:00
|
|
|
rowCountCallback,
|
2015-02-15 12:59:42 +01:00
|
|
|
columnCountCallback,
|
2015-01-31 17:01:03 +01:00
|
|
|
dataCallback,
|
2015-02-14 15:45:04 +01:00
|
|
|
setDataCallback,
|
|
|
|
roleNamesCallaback,
|
2015-02-15 12:59:42 +01:00
|
|
|
flagsCallback,
|
|
|
|
headerDataCallback);
|
2015-09-20 11:39:25 +02:00
|
|
|
model->setOnSlotExecutedHandler(OnSlotExecutedHandler(dObjectPointer, dObjectCallback));
|
2015-01-31 14:20:36 +01:00
|
|
|
*vptr = model;
|
2015-01-19 22:23:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qabstractlistmodel_delete(void* vptr)
|
|
|
|
{
|
2015-01-31 14:20:36 +01:00
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
delete model;
|
2015-01-19 22:23:18 +01:00
|
|
|
}
|
2015-01-31 12:50:14 +01:00
|
|
|
|
2015-01-31 17:55:14 +01:00
|
|
|
void dos_qabstractlistmodel_beginInsertRows(void* vptr, QModelIndexVoidPtr parentIndex, int first, int last)
|
|
|
|
{
|
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
auto index = reinterpret_cast<QModelIndex*>(parentIndex);
|
|
|
|
model->publicBeginInsertRows(*index, first, last);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qabstractlistmodel_endInsertRows(void* vptr)
|
|
|
|
{
|
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
model->publicEndInsertRows();
|
|
|
|
}
|
|
|
|
|
2015-02-02 21:59:29 +01:00
|
|
|
void dos_qabstractlistmodel_beginRemoveRows(void* vptr, QModelIndexVoidPtr parentIndex, int first, int last)
|
|
|
|
{
|
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
auto index = reinterpret_cast<QModelIndex*>(parentIndex);
|
|
|
|
model->publicBeginRemoveRows(*index, first, last);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qabstractlistmodel_endRemoveRows(void* vptr)
|
|
|
|
{
|
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
model->publicEndRemoveRows();
|
|
|
|
}
|
|
|
|
|
2015-02-01 12:50:31 +01:00
|
|
|
void dos_qabstractlistmodel_beginResetModel(void* vptr)
|
|
|
|
{
|
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
model->publicBeginResetModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qabstractlistmodel_endResetModel(void* vptr)
|
|
|
|
{
|
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
model->publicEndResetModel();
|
|
|
|
}
|
|
|
|
|
2015-02-04 23:02:26 +01:00
|
|
|
void dos_qabstractlistmodel_dataChanged(void* vptr,
|
|
|
|
QModelIndexVoidPtr topLeftIndex,
|
2015-02-01 12:50:31 +01:00
|
|
|
QModelIndexVoidPtr bottomRightIndex,
|
|
|
|
int* rolesArrayPtr,
|
|
|
|
int rolesArrayLength)
|
|
|
|
{
|
|
|
|
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
|
|
|
auto topLeft = reinterpret_cast<QModelIndex*>(topLeftIndex);
|
|
|
|
auto bottomRight = reinterpret_cast<QModelIndex*>(bottomRightIndex);
|
|
|
|
auto roles = QVector<int>::fromStdVector(std::vector<int>(rolesArrayPtr, rolesArrayPtr + rolesArrayLength));
|
|
|
|
model->publicDataChanged(*topLeft, *bottomRight, roles);
|
|
|
|
}
|
|
|
|
|
2015-01-31 12:50:14 +01:00
|
|
|
void dos_qhash_int_qbytearray_create(QHashIntQByteArrayVoidPtr* vptr)
|
|
|
|
{
|
|
|
|
*vptr = new QHash<int, QByteArray>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qhash_int_qbytearray_delete(QHashIntQByteArrayVoidPtr vptr)
|
|
|
|
{
|
2015-01-31 17:01:03 +01:00
|
|
|
auto qHash = reinterpret_cast<QHash<int, QByteArray>*>(vptr);
|
2015-01-31 12:50:14 +01:00
|
|
|
delete qHash;
|
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qhash_int_qbytearray_insert(QHashIntQByteArrayVoidPtr vptr, int key, const char* value)
|
2015-01-31 12:50:14 +01:00
|
|
|
{
|
|
|
|
auto qHash = reinterpret_cast<QHash<int, QByteArray>*>(vptr);
|
|
|
|
qHash->insert(key, QByteArray(value));
|
|
|
|
}
|
|
|
|
|
2015-01-31 14:20:36 +01:00
|
|
|
void dos_qhash_int_qbytearray_value(QHashIntQByteArrayVoidPtr vptr, int key, char** result)
|
|
|
|
{
|
|
|
|
auto qHash = reinterpret_cast<QHash<int, QByteArray>*>(vptr);
|
|
|
|
QByteArray value = qHash->value(key);
|
|
|
|
*result = qstrdup(value.data());
|
|
|
|
}
|
|
|
|
|
2015-12-05 17:33:54 +01:00
|
|
|
void dos_qresource_register(const char* filename)
|
|
|
|
{
|
|
|
|
QResource::registerResource(QString(filename));
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qurl_create(void** vptr, const char* url, int parsingMode)
|
|
|
|
{
|
|
|
|
*vptr = new QUrl(QString(url), (QUrl::ParsingMode) parsingMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qurl_delete(void* vptr)
|
|
|
|
{
|
|
|
|
QUrl* url = reinterpret_cast<QUrl*>(vptr);
|
|
|
|
delete url;
|
|
|
|
}
|
|
|
|
|