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-12-06 00:23:25 +01:00
|
|
|
#include <QtCore/QResource>
|
2015-01-31 12:50:14 +01:00
|
|
|
#include <QtGui/QGuiApplication>
|
|
|
|
#include <QtQml/QQmlContext>
|
|
|
|
#include <QtQml/QQmlApplicationEngine>
|
|
|
|
#include <QtQuick/QQuickView>
|
|
|
|
#include <QtWidgets/QApplication>
|
2014-07-19 18:26:08 +02:00
|
|
|
|
2015-12-27 17:58:49 +01:00
|
|
|
#include "DOtherSide/DOtherSideTypesCpp.h"
|
2015-11-23 21:33:17 +01:00
|
|
|
#include "DOtherSide/OnSlotExecutedHandler.h"
|
2016-01-07 12:04:40 +01:00
|
|
|
#include "DOtherSide/DosQMetaObject.h"
|
|
|
|
#include "DOtherSide/DosQObject.h"
|
|
|
|
#include "DOtherSide/DosQObjectImpl.h"
|
|
|
|
|
|
|
|
using namespace DOS;
|
2015-12-27 17:58:49 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-12-05 18:15:01 +01:00
|
|
|
void dos_qcoreapplication_application_dir_path(char** result)
|
|
|
|
{
|
|
|
|
convert_to_cstring(QCoreApplication::applicationDirPath(), result);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
2014-12-01 21:02:18 +01:00
|
|
|
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)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
|
|
|
auto qurl = reinterpret_cast<QUrl*>(url);
|
2015-12-06 00:23:25 +01:00
|
|
|
engine->load(*qurl);
|
2015-12-05 17:33:54 +01:00
|
|
|
}
|
|
|
|
|
2015-12-29 12:11:52 +01:00
|
|
|
void dos_qqmlapplicationengine_load_data(void *vptr, const char *data)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
2015-12-29 12:11:52 +01:00
|
|
|
engine->loadData(data);
|
|
|
|
}
|
|
|
|
|
2015-12-05 17:33:54 +01:00
|
|
|
void dos_qqmlapplicationengine_add_import_path(void* vptr, const char* path)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
2015-12-06 00:23:25 +01:00
|
|
|
engine->addImportPath(QString(path));
|
2015-12-05 17:33:54 +01:00
|
|
|
}
|
|
|
|
|
2014-12-08 12:55:09 +01:00
|
|
|
void dos_qqmlapplicationengine_context(void* vptr, void** context)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
2014-12-08 12:55:09 +01:00
|
|
|
engine->rootContext();
|
|
|
|
*context = engine->rootContext();
|
|
|
|
}
|
|
|
|
|
2015-12-23 19:58:12 +01:00
|
|
|
void dos_qqmlapplicationengine_rootObjects(void* vptr, void*** array, int* array_length)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
2015-12-24 12:04:31 +01:00
|
|
|
QList<QObject*> list = engine->rootObjects();
|
2015-12-24 12:16:37 +01:00
|
|
|
auto objects = new QObject*[list.size()];
|
2015-12-24 12:04:31 +01:00
|
|
|
if (objects == nullptr) return;
|
2015-12-23 19:58:12 +01:00
|
|
|
for (int i = 0; i < list.length(); i += 1) objects[i] = list.at(i);
|
|
|
|
*array = reinterpret_cast<void**>(objects);
|
|
|
|
*array_length = list.length();
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:02:18 +01:00
|
|
|
void dos_qqmlapplicationengine_delete(void* vptr)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
|
2014-12-01 21:02:18 +01:00
|
|
|
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
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto view = reinterpret_cast<QQuickView*>(vptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
view->show();
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qquickview_delete(void* vptr)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto view = reinterpret_cast<QQuickView*>(vptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
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
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto view = reinterpret_cast<QQuickView*>(vptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
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
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto view = reinterpret_cast<QQuickView*>(vptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
view->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QDir::separator() + QString(filename)));
|
|
|
|
}
|
|
|
|
|
2015-12-22 18:21:52 +01:00
|
|
|
void dos_qquickview_set_source_url(void* vptr, void* url)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto view = reinterpret_cast<QQuickView*>(vptr);
|
|
|
|
auto _url = reinterpret_cast<QUrl*>(url);
|
2015-12-22 18:21:52 +01:00
|
|
|
view->setSource(*_url);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qquickview_set_resize_mode(void* vptr, int resizeMode)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto view = reinterpret_cast<QQuickView*>(vptr);
|
2015-12-22 18:21:52 +01:00
|
|
|
view->setResizeMode((QQuickView::ResizeMode) resizeMode);
|
|
|
|
}
|
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
void dos_qquickview_rootContext(void* vptr, void** context)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto view = reinterpret_cast<QQuickView*>(vptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
*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-12-24 12:16:37 +01:00
|
|
|
void dos_qobjectptr_array_delete(void** ptr)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto context = reinterpret_cast<QQmlContext*>(vptr);
|
2014-07-19 18:26:08 +02:00
|
|
|
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
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto 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
|
|
|
}
|
|
|
|
|
2015-12-23 19:46:21 +01:00
|
|
|
void dos_qvariant_toQObject(void* vptr, void** value)
|
|
|
|
{
|
|
|
|
auto variant = reinterpret_cast<QVariant*>(vptr);
|
|
|
|
*value = variant->value<QObject*>();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-01-03 14:02:28 +01:00
|
|
|
void dos_qobject_create(void** vptr, void* dObjectPointer,
|
|
|
|
MetaObjectCallback dMetaObjectCallback,
|
|
|
|
DObjectCallback dObjectCallback)
|
|
|
|
{
|
2016-01-04 23:03:57 +01:00
|
|
|
|
2016-01-07 12:04:40 +01:00
|
|
|
auto dynamicQObject = new DosQObject();
|
|
|
|
auto impl = std::make_unique<DynamicQObjectImpl>(dynamicQObject,
|
|
|
|
OnMetaObjectHandler(dObjectPointer, dMetaObjectCallback),
|
|
|
|
OnSlotExecutedHandler(dObjectPointer, dObjectCallback));
|
2016-01-04 23:03:57 +01:00
|
|
|
dynamicQObject->setImpl(std::move(impl));
|
2016-01-03 14:02:28 +01:00
|
|
|
QQmlEngine::setObjectOwnership(dynamicQObject, QQmlEngine::CppOwnership);
|
|
|
|
*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 qobject = reinterpret_cast<QObject*>(vptr);
|
2015-12-28 13:21:02 +01:00
|
|
|
qobject->disconnect();
|
|
|
|
delete qobject;
|
2014-08-30 18:46:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2016-01-07 12:04:40 +01:00
|
|
|
auto dynamicQObject = dynamic_cast<IDosQObject*>(qobject);
|
2015-02-05 23:04:59 +01:00
|
|
|
|
2015-12-28 13:21:02 +01:00
|
|
|
auto transformation = [](void* vptr)->QVariant{return *(reinterpret_cast<QVariant*>(vptr));};
|
2016-01-07 12:04:40 +01:00
|
|
|
const std::vector<QVariant> variants = toVector(parameters, parametersCount, transformation);
|
2015-12-28 13:21:02 +01:00
|
|
|
dynamicQObject->emitSignal(QString::fromStdString(name), variants);
|
2014-08-30 18:46:34 +02:00
|
|
|
}
|
2014-12-24 14:30:41 +01:00
|
|
|
|
2015-12-23 19:46:21 +01:00
|
|
|
void dos_qobject_signal_connect(void* senderVPtr,
|
|
|
|
const char* signal,
|
|
|
|
void* receiverVPtr,
|
|
|
|
const char* method,
|
|
|
|
int type,
|
|
|
|
bool* result)
|
|
|
|
{
|
|
|
|
auto sender = reinterpret_cast<QObject*>(senderVPtr);
|
|
|
|
auto receiver = reinterpret_cast<QObject*>(receiverVPtr);
|
2015-12-28 13:21:02 +01:00
|
|
|
*result = QObject::connect(sender, signal, receiver, method, (Qt::ConnectionType) type);
|
2015-12-23 19:46:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qobject_signal_disconnect(void* senderVPtr,
|
|
|
|
const char* signal,
|
|
|
|
void* receiverVPtr,
|
|
|
|
const char* method,
|
|
|
|
bool* result)
|
|
|
|
{
|
|
|
|
auto sender = reinterpret_cast<QObject*>(senderVPtr);
|
|
|
|
auto receiver = reinterpret_cast<QObject*>(receiverVPtr);
|
2015-12-28 13:21:02 +01:00
|
|
|
*result = QObject::disconnect(sender, signal, receiver, method);
|
2014-12-24 14:30:41 +01:00
|
|
|
}
|
2015-01-18 12:26:51 +01:00
|
|
|
|
2015-12-23 19:58:12 +01:00
|
|
|
void dos_qobject_objectName(void* vptr, char** result)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto object = reinterpret_cast<QObject*>(vptr);
|
2015-12-23 19:58:12 +01:00
|
|
|
convert_to_cstring(object->objectName(), result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qobject_findChild(void* vptr, const char* name, int options, void** child)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto object = reinterpret_cast<QObject*>(vptr);
|
2015-12-23 19:58:12 +01:00
|
|
|
*child = object->findChild<QObject*>(QString::fromUtf8(name), (Qt::FindChildOptions) options);
|
|
|
|
}
|
|
|
|
|
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-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)
|
|
|
|
{
|
2015-12-06 00:23:25 +01:00
|
|
|
QResource::registerResource(QString::fromUtf8(filename));
|
2015-12-05 17:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qurl_create(void** vptr, const char* url, int parsingMode)
|
|
|
|
{
|
2015-12-06 00:23:25 +01:00
|
|
|
*vptr = new QUrl(QString::fromUtf8(url), (QUrl::ParsingMode) parsingMode);
|
2015-12-05 17:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qurl_delete(void* vptr)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto url = reinterpret_cast<QUrl*>(vptr);
|
2015-12-05 17:33:54 +01:00
|
|
|
delete url;
|
|
|
|
}
|
|
|
|
|
2015-12-22 17:53:29 +01:00
|
|
|
void dos_qurl_to_string(void* vptr, char** result)
|
|
|
|
{
|
2015-12-29 15:50:43 +01:00
|
|
|
auto url = reinterpret_cast<QUrl*>(vptr);
|
2015-12-22 17:53:29 +01:00
|
|
|
convert_to_cstring(url->toString(), result);
|
|
|
|
}
|
|
|
|
|
2016-01-06 15:42:21 +01:00
|
|
|
void dos_qmetaobject_create(void **vptr,
|
2016-01-07 12:04:40 +01:00
|
|
|
void* superClassVPtr,
|
|
|
|
const char* className,
|
|
|
|
::SignalDefinitions signalDefinitions,
|
|
|
|
::SlotDefinitions slotDefinitions,
|
|
|
|
::PropertyDefinitions propertyDefinitions)
|
2015-12-27 17:58:49 +01:00
|
|
|
{
|
2016-01-07 12:04:40 +01:00
|
|
|
auto superClassHolder = static_cast<DosIQMetaObjectHolder*>(superClassVPtr);
|
|
|
|
|
|
|
|
auto metaObject = std::make_shared<DosQMetaObject>(*superClassHolder->data(),
|
|
|
|
QString::fromUtf8(className),
|
|
|
|
toVector(signalDefinitions),
|
|
|
|
toVector(slotDefinitions),
|
|
|
|
toVector(propertyDefinitions));
|
|
|
|
*vptr = new DosIQMetaObjectHolder(std::move(metaObject));
|
2015-12-27 17:58:49 +01:00
|
|
|
}
|
|
|
|
|
2016-01-06 15:42:21 +01:00
|
|
|
void dos_qmetaobject_delete(void *vptr)
|
2015-12-27 17:58:49 +01:00
|
|
|
{
|
2016-01-07 12:04:40 +01:00
|
|
|
auto factory = reinterpret_cast<DosIQMetaObjectHolder*>(vptr);
|
2015-12-27 17:58:49 +01:00
|
|
|
delete factory;
|
|
|
|
}
|
2016-01-07 12:04:40 +01:00
|
|
|
|
|
|
|
void dos_qobject_qmetaobject(void **vptr)
|
|
|
|
{
|
|
|
|
*vptr = new DosIQMetaObjectHolder(std::make_shared<DosQObjectMetaObject>());
|
|
|
|
}
|
|
|
|
|
|
|
|
void dos_qabstractlistmodel_qmetaobject(void **vptr)
|
|
|
|
{
|
|
|
|
*vptr = new DosIQMetaObjectHolder(std::make_shared<DosQAbstractListModelMetaObject>());
|
|
|
|
}
|