mirror of
https://github.com/status-im/dotherside.git
synced 2025-02-12 04:26:43 +00:00
Finish DQml-QAbstractItemModel
This commit is contained in:
commit
5038d6d5e4
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,4 +5,5 @@ build
|
||||
.directory
|
||||
#*#
|
||||
nimcache
|
||||
*.kdev4
|
||||
*.kdev4
|
||||
*.user
|
@ -8,8 +8,9 @@ add_library(${PROJECT_NAME} STATIC
|
||||
qquickview.d
|
||||
qqmlapplicationengine.d
|
||||
qqmlcontext.d
|
||||
chararray.d
|
||||
qguiapplication.d
|
||||
qapplication.d
|
||||
qmodelindex.d
|
||||
qabstractlistmodel.d
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
@ -1,56 +0,0 @@
|
||||
import dothersideinterface;
|
||||
import std.string;
|
||||
|
||||
class CharArray
|
||||
{
|
||||
this()
|
||||
{
|
||||
_size = 0;
|
||||
dos_chararray_create(_data, _size);
|
||||
}
|
||||
|
||||
this(int size)
|
||||
{
|
||||
_size = size;
|
||||
dos_chararray_create(_data, _size);
|
||||
}
|
||||
|
||||
this(char* data, int size)
|
||||
{
|
||||
_data = data;
|
||||
_size = size;
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_chararray_delete(_data);
|
||||
}
|
||||
|
||||
char* data()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
int size()
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
ref char* dataRef()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
ref int sizeRef()
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
override string toString()
|
||||
{
|
||||
return fromStringz(_data).dup;
|
||||
}
|
||||
|
||||
private char* _data;
|
||||
private int _size;
|
||||
}
|
@ -1,90 +1,126 @@
|
||||
extern(C)
|
||||
{
|
||||
// QApplication
|
||||
void dos_qapplication_create();
|
||||
void dos_qapplication_exec();
|
||||
void dos_qapplication_delete();
|
||||
void dos_qapplication_quit();
|
||||
// QApplication
|
||||
void dos_qapplication_create();
|
||||
void dos_qapplication_exec();
|
||||
void dos_qapplication_delete();
|
||||
void dos_qapplication_quit();
|
||||
|
||||
// QGuiApplication
|
||||
void dos_qguiapplication_create();
|
||||
void dos_qguiapplication_exec();
|
||||
void dos_qguiapplication_delete();
|
||||
void dos_qguiapplication_quit();
|
||||
// QGuiApplication
|
||||
void dos_qguiapplication_create();
|
||||
void dos_qguiapplication_exec();
|
||||
void dos_qguiapplication_delete();
|
||||
void dos_qguiapplication_quit();
|
||||
|
||||
// QQmlApplicationEngine
|
||||
void dos_qqmlapplicationengine_create(ref void*);
|
||||
void dos_qqmlapplicationengine_load(void*, immutable (char)* filename);
|
||||
void dos_qqmlapplicationengine_context(void*, ref void*);
|
||||
void dos_qqmlapplicationengine_delete(void*);
|
||||
// QQmlApplicationEngine
|
||||
void dos_qqmlapplicationengine_create(ref void*);
|
||||
void dos_qqmlapplicationengine_load(void*, immutable (char)* filename);
|
||||
void dos_qqmlapplicationengine_context(void*, ref void*);
|
||||
void dos_qqmlapplicationengine_delete(void*);
|
||||
|
||||
// QQuickView
|
||||
void dos_qquickview_create(ref void*);
|
||||
void dos_qquickview_show(void*);
|
||||
void dos_qquickview_source(void*, ref char *, ref int);
|
||||
void dos_qquickview_set_source(void*, immutable (char)* filename);
|
||||
void dos_qquickview_rootContext(void*, ref void*);
|
||||
void dos_qquickview_delete(void*);
|
||||
// QQuickView
|
||||
void dos_qquickview_create(ref void*);
|
||||
void dos_qquickview_show(void*);
|
||||
void dos_qquickview_source(void*, ref char *);
|
||||
void dos_qquickview_set_source(void*, immutable (char)* filename);
|
||||
void dos_qquickview_rootContext(void*, ref void*);
|
||||
void dos_qquickview_delete(void*);
|
||||
|
||||
// CharArray
|
||||
void dos_chararray_create(ref char*);
|
||||
void dos_chararray_create(ref char*, int size);
|
||||
void dos_chararray_delete(char*);
|
||||
// CharArray
|
||||
void dos_chararray_delete(char*);
|
||||
|
||||
// QQmlContext
|
||||
void dos_qqmlcontext_baseUrl(void*, ref char*, ref int);
|
||||
void dos_qqmlcontext_setcontextproperty(void*, immutable (char)*, void*);
|
||||
// QQmlContext
|
||||
void dos_qqmlcontext_baseUrl(void*, ref char*);
|
||||
void dos_qqmlcontext_setcontextproperty(void*, immutable (char)*, void*);
|
||||
|
||||
// QVariant
|
||||
void dos_qvariant_create(ref void*);
|
||||
void dos_qvariant_create_int(ref void*, int);
|
||||
void dos_qvariant_create_bool(ref void*, bool);
|
||||
void dos_qvariant_create_string(ref void*, immutable(char)*);
|
||||
void dos_qvariant_create_qobject(ref void*, void*);
|
||||
void dos_qvariant_create_float(ref void*, float);
|
||||
void dos_qvariant_create_double(ref void*, double);
|
||||
void dos_qvariant_toInt(void*, ref int);
|
||||
void dos_qvariant_setInt(void*, int);
|
||||
void dos_qvariant_toBool(void*, ref bool);
|
||||
void dos_qvariant_setBool(void*, bool);
|
||||
void dos_qvariant_toString(void*, ref char*, ref int);
|
||||
void dos_qvariant_setString(void*, immutable(char)*);
|
||||
void dos_qvariant_toFloat(void*, ref float);
|
||||
void dos_qvariant_setFloat(void*, float);
|
||||
void dos_qvariant_toDouble(void*, ref double);
|
||||
void dos_qvariant_setDouble(void*, double);
|
||||
void dos_qvariant_isnull(void*, ref bool);
|
||||
void dos_qvariant_delete(void*);
|
||||
void dos_qvariant_assign(void*, void*);
|
||||
void dos_qvariant_setQObject(void*, void*);
|
||||
// QVariant
|
||||
void dos_qvariant_create(ref void*);
|
||||
void dos_qvariant_create_int(ref void*, int);
|
||||
void dos_qvariant_create_bool(ref void*, bool);
|
||||
void dos_qvariant_create_string(ref void*, immutable(char)*);
|
||||
void dos_qvariant_create_qobject(ref void*, void*);
|
||||
void dos_qvariant_create_float(ref void*, float);
|
||||
void dos_qvariant_create_double(ref void*, double);
|
||||
void dos_qvariant_toInt(void*, ref int);
|
||||
void dos_qvariant_setInt(void*, int);
|
||||
void dos_qvariant_toBool(void*, ref bool);
|
||||
void dos_qvariant_setBool(void*, bool);
|
||||
void dos_qvariant_toString(void*, ref char*);
|
||||
void dos_qvariant_setString(void*, immutable(char)*);
|
||||
void dos_qvariant_toFloat(void*, ref float);
|
||||
void dos_qvariant_setFloat(void*, float);
|
||||
void dos_qvariant_toDouble(void*, ref double);
|
||||
void dos_qvariant_setDouble(void*, double);
|
||||
void dos_qvariant_isnull(void*, ref bool);
|
||||
void dos_qvariant_delete(void*);
|
||||
void dos_qvariant_assign(void*, void*);
|
||||
void dos_qvariant_setQObject(void*, void*);
|
||||
|
||||
// QObject
|
||||
void dos_qobject_create(ref void*,
|
||||
void* dobject,
|
||||
void function (void*, void*, int , void**));
|
||||
// QObject
|
||||
void dos_qobject_create(ref void*,
|
||||
void* dobject,
|
||||
void function (void*, void*, int , void**));
|
||||
|
||||
void dos_qobject_slot_create(void*,
|
||||
immutable (char)* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
ref int slotIndex);
|
||||
void dos_qobject_slot_create(void*,
|
||||
immutable (char)* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
ref int slotIndex);
|
||||
|
||||
void dos_qobject_signal_create(void*,
|
||||
immutable(char)* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
ref int signalIndex);
|
||||
void dos_qobject_signal_create(void*,
|
||||
immutable(char)* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
ref int signalIndex);
|
||||
|
||||
void dos_qobject_signal_emit(void*, immutable(char)* name,
|
||||
int parametersCount,
|
||||
void** parameters);
|
||||
void dos_qobject_signal_emit(void*, immutable(char)* name,
|
||||
int parametersCount,
|
||||
void** parameters);
|
||||
|
||||
void dos_qobject_property_create(void*,
|
||||
immutable(char)* name,
|
||||
int propertyMetaType,
|
||||
immutable(char)* readSlot,
|
||||
immutable(char)* writeSlot,
|
||||
immutable(char)* notifySignal);
|
||||
void dos_qobject_property_create(void*,
|
||||
immutable(char)* name,
|
||||
int propertyMetaType,
|
||||
immutable(char)* readSlot,
|
||||
immutable(char)* writeSlot,
|
||||
immutable(char)* notifySignal);
|
||||
|
||||
void dos_qobject_delete(void*);
|
||||
void dos_qobject_delete(void*);
|
||||
|
||||
// QModelIndex
|
||||
void dos_qmodelindex_create(ref void* index);
|
||||
void dos_qmodelindex_delete(void* index);
|
||||
void dos_qmodelindex_row(void*, ref int result);
|
||||
void dos_qmodelindex_column(void*, ref int result);
|
||||
void dos_qmodelindex_isValid(void* index, ref bool result);
|
||||
void dos_qmodelindex_data(void* index, int role, void* variant);
|
||||
void dos_qmodelindex_parent(void* index, void* parent);
|
||||
void dos_qmodelindex_child(void* index, int r, int c, void* child);
|
||||
void dos_qmodelindex_sibling(void* index, int r, int c, void* sibling);
|
||||
|
||||
// QHashIntByteArray
|
||||
void dos_qhash_int_qbytearray_create(ref void*);
|
||||
void dos_qhash_int_qbytearray_delete(void*);
|
||||
void dos_qhash_int_qbytearray_insert(void*, int, immutable(char)*);
|
||||
void dos_qhash_int_qbytearray_value(void*, int, ref char*);
|
||||
|
||||
// QAbstractListModel
|
||||
void dos_qabstractlistmodel_create(ref void*,
|
||||
void*,
|
||||
void function (void*, void*, int, void**),
|
||||
void function (void*, void*, ref int),
|
||||
void function (void*, void*, ref int),
|
||||
void function (void*, void*, int, void*),
|
||||
void function (void*, void*, void*, int, ref bool),
|
||||
void function (void*, void*),
|
||||
void function (void*, void*, ref int),
|
||||
void function (void*, int, int, int, void*));
|
||||
void dos_qabstractlistmodel_beginInsertRows(void* vptr, void* parent, int first, int last);
|
||||
void dos_qabstractlistmodel_endInsertRows(void* vptr);
|
||||
void dos_qabstractlistmodel_beginRemoveRows(void* vptr, void* parent, int first, int last);
|
||||
void dos_qabstractlistmodel_endRemoveRows(void* vptr);
|
||||
void dos_qabstractlistmodel_beginResetModel(void* vptr);
|
||||
void dos_qabstractlistmodel_endResetModel(void* vptr);
|
||||
void dos_qabstractlistmodel_dataChanged(void* vptr, void* topLeft, void* bottomRight, int* rolesPtr, int rolesLength);
|
||||
void dos_qabstractlistmodel_delete(void*);
|
||||
}
|
||||
|
||||
|
@ -6,3 +6,5 @@ public import qobject;
|
||||
public import qqmlapplicationengine;
|
||||
public import qquickview;
|
||||
public import qmetatype;
|
||||
public import qmodelindex;
|
||||
public import qabstractlistmodel;
|
||||
|
@ -1,67 +0,0 @@
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
import std.traits;
|
||||
import std.conv;
|
||||
import std.functional;
|
||||
import core.memory;
|
||||
import dotherside;
|
||||
|
||||
class MyObject : QObject
|
||||
{
|
||||
this()
|
||||
{
|
||||
foo = registerSlot("foo", &_foo);
|
||||
bar = registerSlot("bar", &_bar);
|
||||
nameChanged = registerSignal!(string)("nameChanged");
|
||||
tor = registerSlot("tor", &_tor);
|
||||
}
|
||||
|
||||
public QSlot!(void delegate(int)) foo;
|
||||
private void _foo(int fooValue)
|
||||
{
|
||||
writeln("D: Called foo slot with argument ", fooValue , "!!");
|
||||
}
|
||||
|
||||
public QSlot!(int delegate(int)) bar;
|
||||
private int _bar(int barValue)
|
||||
{
|
||||
writeln("D: Called bar slot with argument " , barValue, "!!");
|
||||
return 666;
|
||||
}
|
||||
|
||||
public QSlot!(string delegate(string)) tor;
|
||||
private string _tor (string torValue)
|
||||
{
|
||||
writeln("D: Called tor slot with argument ", torValue, "!!");
|
||||
return "2343";
|
||||
}
|
||||
|
||||
public QSignal!(string) nameChanged;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
try
|
||||
{
|
||||
auto app = new QGuiApplication;
|
||||
scope(exit) destroy(app);
|
||||
|
||||
auto view = new QQuickView;
|
||||
scope(exit) destroy(view);
|
||||
|
||||
auto myObject = new MyObject();
|
||||
scope(exit) destroy(myObject);
|
||||
|
||||
auto context = view.rootContext();
|
||||
context.setContextProperty("myObject", new QVariant(myObject));
|
||||
|
||||
view.setSource("Test.qml");
|
||||
view.show();
|
||||
|
||||
myObject.nameChanged("prova");
|
||||
|
||||
app.exec();
|
||||
}
|
||||
catch
|
||||
{}
|
||||
}
|
183
D/DQml/qabstractlistmodel.d
Normal file
183
D/DQml/qabstractlistmodel.d
Normal file
@ -0,0 +1,183 @@
|
||||
import dothersideinterface;
|
||||
import qobject;
|
||||
import qmodelindex;
|
||||
import qvariant;
|
||||
import std.string;
|
||||
|
||||
class QAbstractListModel : QObject
|
||||
{
|
||||
this()
|
||||
{
|
||||
super(true);
|
||||
dos_qabstractlistmodel_create(this.vptr,
|
||||
cast(void*)this,
|
||||
&staticSlotCallback,
|
||||
&rowCountCallback,
|
||||
&columnCountCallback,
|
||||
&dataCallback,
|
||||
&setDataCallback,
|
||||
&roleNamesCallback,
|
||||
&flagsCallback,
|
||||
&headerDataCallback);
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_qabstractlistmodel_delete(this.vptr);
|
||||
}
|
||||
|
||||
public int rowCount(QModelIndex parentIndex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int columnCount(QModelIndex parentIndex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public QVariant data(QModelIndex index, int role)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool setData(QModelIndex index, QVariant value, int role)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public string[int] roleNames()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public int flags(QModelIndex index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public QVariant headerData(int section, int orienation, int role)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected final void beginInsertRows(QModelIndex parent, int first, int last)
|
||||
{
|
||||
dos_qabstractlistmodel_beginInsertRows(this.vptr,
|
||||
parent.voidPointer(),
|
||||
first,
|
||||
last);
|
||||
}
|
||||
|
||||
protected final void endInsertRows()
|
||||
{
|
||||
dos_qabstractlistmodel_endInsertRows(this.vptr);
|
||||
}
|
||||
|
||||
protected final void beginRemoveRows(QModelIndex parent, int first, int last)
|
||||
{
|
||||
dos_qabstractlistmodel_beginRemoveRows(this.vptr,
|
||||
parent.voidPointer(),
|
||||
first,
|
||||
last);
|
||||
}
|
||||
|
||||
protected final void endRemoveRows()
|
||||
{
|
||||
dos_qabstractlistmodel_endRemoveRows(this.vptr);
|
||||
}
|
||||
|
||||
protected final void beginResetModel()
|
||||
{
|
||||
dos_qabstractlistmodel_beginResetModel(this.vptr);
|
||||
}
|
||||
|
||||
protected final void endResetModel()
|
||||
{
|
||||
dos_qabstractlistmodel_endResetModel(this.vptr);
|
||||
}
|
||||
|
||||
protected final void dataChanged(QModelIndex topLeft, QModelIndex bottomRight, int[] roles)
|
||||
{
|
||||
dos_qabstractlistmodel_dataChanged(this.vptr,
|
||||
topLeft.voidPointer(),
|
||||
bottomRight.voidPointer(),
|
||||
roles.ptr,
|
||||
cast(int)(roles.length));
|
||||
}
|
||||
|
||||
private extern (C) static void rowCountCallback(void* modelPtr,
|
||||
void* indexPtr,
|
||||
ref int result)
|
||||
{
|
||||
auto model = cast(QAbstractListModel)(modelPtr);
|
||||
auto index = new QModelIndex(indexPtr);
|
||||
result = model.rowCount(index);
|
||||
}
|
||||
|
||||
private extern (C) static void columnCountCallback(void* modelPtr,
|
||||
void* indexPtr,
|
||||
ref int result)
|
||||
{
|
||||
auto model = cast(QAbstractListModel)(modelPtr);
|
||||
auto index = new QModelIndex(indexPtr);
|
||||
result = model.columnCount(index);
|
||||
}
|
||||
|
||||
private extern (C) static void dataCallback(void* modelPtr,
|
||||
void* indexPtr,
|
||||
int role,
|
||||
void* result)
|
||||
{
|
||||
auto model = cast(QAbstractListModel)(modelPtr);
|
||||
auto index = new QModelIndex(indexPtr);
|
||||
auto value = model.data(index, role);
|
||||
if (value is null)
|
||||
return;
|
||||
dos_qvariant_assign(result, value.voidPointer());
|
||||
}
|
||||
|
||||
private extern (C) static void setDataCallback(void* modelPtr,
|
||||
void* indexPtr,
|
||||
void* valuePtr,
|
||||
int role,
|
||||
ref bool result)
|
||||
{
|
||||
auto model = cast(QAbstractListModel)(modelPtr);
|
||||
auto index = new QModelIndex(indexPtr);
|
||||
auto value = new QVariant(valuePtr);
|
||||
result = model.setData(index, value, role);
|
||||
}
|
||||
|
||||
private extern (C) static void roleNamesCallback(void* modelPtr,
|
||||
void* result)
|
||||
{
|
||||
auto model = cast(QAbstractListModel)(modelPtr);
|
||||
auto roles = model.roleNames();
|
||||
foreach(int key; roles.keys) {
|
||||
dos_qhash_int_qbytearray_insert(result, key, roles[key].toStringz());
|
||||
}
|
||||
}
|
||||
|
||||
private extern (C) static void flagsCallback(void* modelPtr,
|
||||
void* indexPtr,
|
||||
ref int result)
|
||||
{
|
||||
auto model = cast(QAbstractListModel)(modelPtr);
|
||||
auto index = new QModelIndex(indexPtr);
|
||||
result = model.flags(index);
|
||||
}
|
||||
|
||||
private extern (C) static void headerDataCallback(void* modelPtr,
|
||||
int section,
|
||||
int orientation,
|
||||
int role,
|
||||
void* result)
|
||||
{
|
||||
auto model = cast(QAbstractListModel)(modelPtr);
|
||||
QVariant value = model.headerData(section, orientation, role);
|
||||
if (value is null)
|
||||
return;
|
||||
dos_qvariant_assign(result, value.voidPointer());
|
||||
}
|
||||
}
|
@ -2,23 +2,23 @@ import dothersideinterface;
|
||||
|
||||
class QApplication
|
||||
{
|
||||
this()
|
||||
{
|
||||
dos_qapplication_create();
|
||||
}
|
||||
this()
|
||||
{
|
||||
dos_qapplication_create();
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_qapplication_delete();
|
||||
}
|
||||
~this()
|
||||
{
|
||||
dos_qapplication_delete();
|
||||
}
|
||||
|
||||
void exec()
|
||||
{
|
||||
dos_qapplication_exec();
|
||||
}
|
||||
void exec()
|
||||
{
|
||||
dos_qapplication_exec();
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
dos_qapplication_quit();
|
||||
}
|
||||
void quit()
|
||||
{
|
||||
dos_qapplication_quit();
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,23 @@ import dothersideinterface;
|
||||
|
||||
class QGuiApplication
|
||||
{
|
||||
this()
|
||||
{
|
||||
dos_qguiapplication_create();
|
||||
}
|
||||
this()
|
||||
{
|
||||
dos_qguiapplication_create();
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_qguiapplication_delete();
|
||||
}
|
||||
~this()
|
||||
{
|
||||
dos_qguiapplication_delete();
|
||||
}
|
||||
|
||||
void exec()
|
||||
{
|
||||
dos_qguiapplication_exec();
|
||||
}
|
||||
void exec()
|
||||
{
|
||||
dos_qguiapplication_exec();
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
dos_qguiapplication_quit();
|
||||
}
|
||||
void quit()
|
||||
{
|
||||
dos_qguiapplication_quit();
|
||||
}
|
||||
}
|
||||
|
42
D/DQml/qhashintbytearray.d
Normal file
42
D/DQml/qhashintbytearray.d
Normal file
@ -0,0 +1,42 @@
|
||||
import dothersideinterface;
|
||||
import qvariant;
|
||||
import std.string;
|
||||
|
||||
class QHashIntByteArray
|
||||
{
|
||||
this()
|
||||
{
|
||||
dos_qhash_int_qbytearray_create(this.vptr);
|
||||
}
|
||||
|
||||
this(void* vptr)
|
||||
{
|
||||
this.vptr = vptr;
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_qhash_int_qbytearray_delete(this.vptr);
|
||||
}
|
||||
|
||||
public void* voidPointer()
|
||||
{
|
||||
return vptr;
|
||||
}
|
||||
|
||||
public void insert(int key, string value)
|
||||
{
|
||||
dos_qhash_int_qbytearray_insert(this.vptr, key, value.toStringz());
|
||||
}
|
||||
|
||||
public string value(int key)
|
||||
{
|
||||
char* array;
|
||||
dos_qhash_int_qbytearray_value(this.vptr, key, array);
|
||||
string result = fromStringz(array).dup;
|
||||
dos_chararray_delete(array);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void* vptr;
|
||||
}
|
@ -2,66 +2,66 @@ import qobject;
|
||||
import qvariant;
|
||||
|
||||
/*
|
||||
enum Type {
|
||||
UnknownType = 0, Bool = 1, Int = 2, UInt = 3, LongLong = 4, ULongLong = 5,
|
||||
Double = 6, Long = 32, Short = 33, Char = 34, ULong = 35, UShort = 36,
|
||||
UChar = 37, Float = 38,
|
||||
VoidStar = 31,
|
||||
QChar = 7, QString = 10, QStringList = 11, QByteArray = 12,
|
||||
QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
|
||||
QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
|
||||
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
|
||||
QEasingCurve = 29, QUuid = 30, QVariant = 41, QModelIndex = 42,
|
||||
QRegularExpression = 44,
|
||||
QJsonValue = 45, QJsonObject = 46, QJsonArray = 47, QJsonDocument = 48,
|
||||
QObjectStar = 39, SChar = 40,
|
||||
Void = 43,
|
||||
QVariantMap = 8, QVariantList = 9, QVariantHash = 28,
|
||||
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
|
||||
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
|
||||
QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78,
|
||||
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82,
|
||||
QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86,
|
||||
QSizePolicy = 121,
|
||||
User = 1024
|
||||
};
|
||||
enum Type {
|
||||
UnknownType = 0, Bool = 1, Int = 2, UInt = 3, LongLong = 4, ULongLong = 5,
|
||||
Double = 6, Long = 32, Short = 33, Char = 34, ULong = 35, UShort = 36,
|
||||
UChar = 37, Float = 38,
|
||||
VoidStar = 31,
|
||||
QChar = 7, QString = 10, QStringList = 11, QByteArray = 12,
|
||||
QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
|
||||
QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
|
||||
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
|
||||
QEasingCurve = 29, QUuid = 30, QVariant = 41, QModelIndex = 42,
|
||||
QRegularExpression = 44,
|
||||
QJsonValue = 45, QJsonObject = 46, QJsonArray = 47, QJsonDocument = 48,
|
||||
QObjectStar = 39, SChar = 40,
|
||||
Void = 43,
|
||||
QVariantMap = 8, QVariantList = 9, QVariantHash = 28,
|
||||
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
|
||||
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
|
||||
QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78,
|
||||
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82,
|
||||
QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86,
|
||||
QSizePolicy = 121,
|
||||
User = 1024
|
||||
};
|
||||
*/
|
||||
|
||||
public enum QMetaType
|
||||
{
|
||||
Unknown = 0,
|
||||
Bool = 1,
|
||||
Int = 2,
|
||||
String = 10,
|
||||
VoidStr = 31,
|
||||
QObject = 39,
|
||||
QVariant = 41,
|
||||
Void = 43
|
||||
Unknown = 0,
|
||||
Bool = 1,
|
||||
Int = 2,
|
||||
String = 10,
|
||||
VoidStr = 31,
|
||||
QObject = 39,
|
||||
QVariant = 41,
|
||||
Void = 43
|
||||
}
|
||||
|
||||
public QMetaType GetMetaType(T)()
|
||||
if (is (T == int)
|
||||
|| is (T == bool)
|
||||
|| is (T == string)
|
||||
|| is (T == void)
|
||||
|| is (T == QObject)
|
||||
|| is (T == QVariant)
|
||||
|| is (T == void*))
|
||||
{
|
||||
static if (is (T == bool))
|
||||
return QMetaType.Bool;
|
||||
else if (is (T == int))
|
||||
return QMetaType.Int;
|
||||
else if (is( T == void))
|
||||
return QMetaType.Void;
|
||||
else if (is (T == string))
|
||||
return QMetaType.String;
|
||||
else if (is (T == QObject))
|
||||
return QMetaType.QObject;
|
||||
else if (is (T == QVariant))
|
||||
return QMetaType.QVariant;
|
||||
else if (is (T == void*))
|
||||
return QMetaType.VoidStar;
|
||||
else
|
||||
return QMetaType.Unknown;
|
||||
}
|
||||
if (is (T == int)
|
||||
|| is (T == bool)
|
||||
|| is (T == string)
|
||||
|| is (T == void)
|
||||
|| is (T == QObject)
|
||||
|| is (T == QVariant)
|
||||
|| is (T == void*))
|
||||
{
|
||||
static if (is (T == bool))
|
||||
return QMetaType.Bool;
|
||||
else if (is (T == int))
|
||||
return QMetaType.Int;
|
||||
else if (is( T == void))
|
||||
return QMetaType.Void;
|
||||
else if (is (T == string))
|
||||
return QMetaType.String;
|
||||
else if (is (T == QObject))
|
||||
return QMetaType.QObject;
|
||||
else if (is (T == QVariant))
|
||||
return QMetaType.QVariant;
|
||||
else if (is (T == void*))
|
||||
return QMetaType.VoidStar;
|
||||
else
|
||||
return QMetaType.Unknown;
|
||||
}
|
||||
|
77
D/DQml/qmodelindex.d
Normal file
77
D/DQml/qmodelindex.d
Normal file
@ -0,0 +1,77 @@
|
||||
import dothersideinterface;
|
||||
import qvariant;
|
||||
|
||||
class QModelIndex
|
||||
{
|
||||
this()
|
||||
{
|
||||
dos_qmodelindex_create(this.ptr);
|
||||
}
|
||||
|
||||
this(void* ptr)
|
||||
{
|
||||
this.ptr = ptr;
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_qmodelindex_delete(this.ptr);
|
||||
ptr = null;
|
||||
}
|
||||
|
||||
public void* voidPointer()
|
||||
{
|
||||
return this.ptr;
|
||||
}
|
||||
|
||||
public int row()
|
||||
{
|
||||
int result = -1;
|
||||
dos_qmodelindex_row(this.ptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int column()
|
||||
{
|
||||
int result = -1;
|
||||
dos_qmodelindex_column(this.ptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool isValid()
|
||||
{
|
||||
bool result = false;
|
||||
dos_qmodelindex_isValid(this.ptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public QVariant data(int role)
|
||||
{
|
||||
auto result = new QVariant();
|
||||
dos_qmodelindex_data(this.ptr, role, result.voidPointer());
|
||||
return result;
|
||||
}
|
||||
|
||||
public QModelIndex parent()
|
||||
{
|
||||
auto result = new QModelIndex();
|
||||
dos_qmodelindex_parent(this.ptr, result.ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
public QModelIndex child(int row, int column)
|
||||
{
|
||||
auto result = new QModelIndex();
|
||||
dos_qmodelindex_child(this.ptr, row, column, result.ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
public QModelIndex sibling(int row, int column)
|
||||
{
|
||||
auto result = new QModelIndex();
|
||||
dos_qmodelindex_sibling(this.ptr, row, column, result.ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void* ptr;
|
||||
}
|
202
D/DQml/qobject.d
202
D/DQml/qobject.d
@ -11,101 +11,113 @@ import qvariant;
|
||||
|
||||
public class QObject
|
||||
{
|
||||
this()
|
||||
{
|
||||
dos_qobject_create(this.data, cast (void*) this, &staticSlotCallback);
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_qobject_delete(this.data);
|
||||
}
|
||||
|
||||
public void* rawData()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
private extern (C) static void staticSlotCallback(void* qObjectPtr,
|
||||
void* rawSlotName,
|
||||
int numParameters,
|
||||
void** parametersArray)
|
||||
{
|
||||
QVariant[] parameters = new QVariant[numParameters];
|
||||
for (int i = 0; i < numParameters; ++i)
|
||||
parameters[i] = new QVariant(parametersArray[i]);
|
||||
QObject qObject = cast(QObject) qObjectPtr;
|
||||
QVariant slotName = new QVariant(rawSlotName);
|
||||
qObject.onSlotCalled(slotName, parameters);
|
||||
}
|
||||
|
||||
protected void onSlotCalled(QVariant slotName, QVariant[] parameters)
|
||||
{
|
||||
}
|
||||
|
||||
protected void registerSlot(string name, QMetaType[] types)
|
||||
{
|
||||
int index = -1;
|
||||
int length = cast(int)types.length;
|
||||
int[] array = to!(int[])(types);
|
||||
dos_qobject_slot_create(this.data,
|
||||
name.toStringz(),
|
||||
length,
|
||||
array.ptr,
|
||||
index);
|
||||
}
|
||||
|
||||
protected void registerSignal(string name, QMetaType[] types)
|
||||
{
|
||||
int index = -1;
|
||||
int length = cast(int)types.length;
|
||||
int[] array = length > 0 ? to!(int[])(types) : null;
|
||||
dos_qobject_signal_create(this.data,
|
||||
name.toStringz(),
|
||||
length,
|
||||
array.ptr,
|
||||
index);
|
||||
}
|
||||
|
||||
protected void registerProperty(string name,
|
||||
QMetaType type,
|
||||
string readSlotName,
|
||||
string writeSlotName,
|
||||
string notifySignalName)
|
||||
{
|
||||
dos_qobject_property_create(this.data,
|
||||
name.toStringz(),
|
||||
type,
|
||||
readSlotName.toStringz(),
|
||||
writeSlotName.toStringz(),
|
||||
notifySignalName.toStringz());
|
||||
}
|
||||
|
||||
protected void emit(T)(string signalName, T t)
|
||||
{
|
||||
emit(signalName, new QVariant(t));
|
||||
}
|
||||
|
||||
protected void emit(string signalName, QVariant value)
|
||||
{
|
||||
QVariant[] array = [value];
|
||||
emit(signalName, array);
|
||||
}
|
||||
|
||||
protected void emit(string signalName, QVariant[] arguments = null)
|
||||
{
|
||||
int length = cast(int)arguments.length;
|
||||
void*[] array = null;
|
||||
if (length > 0) {
|
||||
array = new void*[length];
|
||||
foreach (int i, QVariant v; arguments)
|
||||
array[i] = v.rawData();
|
||||
public this()
|
||||
{
|
||||
this(false);
|
||||
}
|
||||
dos_qobject_signal_emit(this.data,
|
||||
signalName.toStringz(),
|
||||
length,
|
||||
array.ptr);
|
||||
}
|
||||
|
||||
private void* data;
|
||||
protected this(bool disableDosCalls)
|
||||
{
|
||||
this.disableDosCalls = disableDosCalls;
|
||||
if (!this.disableDosCalls)
|
||||
dos_qobject_create(this.vptr, cast(void*)this, &staticSlotCallback);
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
if (!this.disableDosCalls)
|
||||
{
|
||||
dos_qobject_delete(this.vptr);
|
||||
this.vptr = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void* voidPointer()
|
||||
{
|
||||
return this.vptr;
|
||||
}
|
||||
|
||||
protected void onSlotCalled(QVariant slotName, QVariant[] parameters)
|
||||
{
|
||||
}
|
||||
|
||||
protected void registerSlot(string name, QMetaType[] types)
|
||||
{
|
||||
int index = -1;
|
||||
int length = cast(int)types.length;
|
||||
int[] array = to!(int[])(types);
|
||||
dos_qobject_slot_create(this.vptr,
|
||||
name.toStringz(),
|
||||
length,
|
||||
array.ptr,
|
||||
index);
|
||||
}
|
||||
|
||||
protected void registerSignal(string name, QMetaType[] types)
|
||||
{
|
||||
int index = -1;
|
||||
int length = cast(int)types.length;
|
||||
int[] array = length > 0 ? to!(int[])(types) : null;
|
||||
dos_qobject_signal_create(this.vptr,
|
||||
name.toStringz(),
|
||||
length,
|
||||
array.ptr,
|
||||
index);
|
||||
}
|
||||
|
||||
protected void registerProperty(string name,
|
||||
QMetaType type,
|
||||
string readSlotName,
|
||||
string writeSlotName,
|
||||
string notifySignalName)
|
||||
{
|
||||
dos_qobject_property_create(this.vptr,
|
||||
name.toStringz(),
|
||||
type,
|
||||
readSlotName.toStringz(),
|
||||
writeSlotName.toStringz(),
|
||||
notifySignalName.toStringz());
|
||||
}
|
||||
|
||||
protected void emit(T)(string signalName, T t)
|
||||
{
|
||||
emit(signalName, new QVariant(t));
|
||||
}
|
||||
|
||||
protected void emit(string signalName, QVariant value)
|
||||
{
|
||||
QVariant[] array = [value];
|
||||
emit(signalName, array);
|
||||
}
|
||||
|
||||
protected void emit(string signalName, QVariant[] arguments = null)
|
||||
{
|
||||
int length = cast(int)arguments.length;
|
||||
void*[] array = null;
|
||||
if (length > 0) {
|
||||
array = new void*[length];
|
||||
foreach (int i, QVariant v; arguments)
|
||||
array[i] = v.voidPointer();
|
||||
}
|
||||
dos_qobject_signal_emit(this.vptr,
|
||||
signalName.toStringz(),
|
||||
length,
|
||||
array.ptr);
|
||||
}
|
||||
|
||||
protected extern (C) static void staticSlotCallback(void* qObjectPtr,
|
||||
void* rawSlotName,
|
||||
int numParameters,
|
||||
void** parametersArray)
|
||||
{
|
||||
QVariant[] parameters = new QVariant[numParameters];
|
||||
for (int i = 0; i < numParameters; ++i)
|
||||
parameters[i] = new QVariant(parametersArray[i]);
|
||||
QObject qObject = cast(QObject) qObjectPtr;
|
||||
QVariant slotName = new QVariant(rawSlotName);
|
||||
qObject.onSlotCalled(slotName, parameters);
|
||||
}
|
||||
|
||||
protected void* vptr;
|
||||
private bool disableDosCalls;
|
||||
}
|
||||
|
@ -4,27 +4,32 @@ import std.string;
|
||||
|
||||
class QQmlApplicationEngine
|
||||
{
|
||||
public this()
|
||||
{
|
||||
dos_qqmlapplicationengine_create(data);
|
||||
}
|
||||
this()
|
||||
{
|
||||
dos_qqmlapplicationengine_create(this.vptr);
|
||||
}
|
||||
|
||||
public ~this()
|
||||
{
|
||||
dos_qqmlapplicationengine_delete(data);
|
||||
}
|
||||
~this()
|
||||
{
|
||||
dos_qqmlapplicationengine_delete(this.vptr);
|
||||
}
|
||||
|
||||
public QQmlContext rootContext()
|
||||
{
|
||||
void* contextData;
|
||||
dos_qqmlapplicationengine_context(data, contextData);
|
||||
return new QQmlContext(contextData);
|
||||
}
|
||||
public void* voidPointer()
|
||||
{
|
||||
return this.vptr;
|
||||
}
|
||||
|
||||
public QQmlContext rootContext()
|
||||
{
|
||||
void* contextVPtr;
|
||||
dos_qqmlapplicationengine_context(this.vptr, contextVPtr);
|
||||
return new QQmlContext(contextVPtr);
|
||||
}
|
||||
|
||||
public void load(string filename)
|
||||
{
|
||||
dos_qqmlapplicationengine_load(data, filename.toStringz());
|
||||
}
|
||||
public void load(string filename)
|
||||
{
|
||||
dos_qqmlapplicationengine_load(this.vptr, filename.toStringz());
|
||||
}
|
||||
|
||||
private void* data;
|
||||
private void* vptr;
|
||||
}
|
||||
|
@ -1,31 +1,32 @@
|
||||
import dothersideinterface;
|
||||
import qvariant;
|
||||
import chararray;
|
||||
import std.string;
|
||||
|
||||
class QQmlContext
|
||||
{
|
||||
public this(void* data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
this(void* vptr)
|
||||
{
|
||||
this.vptr = vptr;
|
||||
}
|
||||
|
||||
public void* rawData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
public void* voidPointer()
|
||||
{
|
||||
return vptr;
|
||||
}
|
||||
|
||||
public string baseUrl()
|
||||
{
|
||||
auto array = new CharArray();
|
||||
scope(exit) destroy(array);
|
||||
dos_qqmlcontext_baseUrl(data, array.dataRef(), array.sizeRef());
|
||||
return array.toString();
|
||||
}
|
||||
public string baseUrl()
|
||||
{
|
||||
char* array;
|
||||
dos_qqmlcontext_baseUrl(this.vptr, array);
|
||||
string result = fromStringz(array).dup;
|
||||
dos_chararray_delete(array);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setContextProperty(string name, QVariant value)
|
||||
{
|
||||
dos_qqmlcontext_setcontextproperty(data, name.ptr, value.rawData());
|
||||
}
|
||||
public void setContextProperty(string name, QVariant value)
|
||||
{
|
||||
dos_qqmlcontext_setcontextproperty(this.vptr, name.ptr, value.voidPointer());
|
||||
}
|
||||
|
||||
private void* data;
|
||||
private void* vptr;
|
||||
}
|
||||
|
@ -1,45 +1,50 @@
|
||||
import dothersideinterface;
|
||||
import qqmlcontext;
|
||||
import chararray;
|
||||
import std.string;
|
||||
|
||||
class QQuickView
|
||||
{
|
||||
this()
|
||||
{
|
||||
dos_qquickview_create(data);
|
||||
}
|
||||
this()
|
||||
{
|
||||
dos_qquickview_create(this.vptr);
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
dos_qquickview_delete(data);
|
||||
}
|
||||
|
||||
void show()
|
||||
{
|
||||
dos_qquickview_show(data);
|
||||
}
|
||||
|
||||
QQmlContext rootContext()
|
||||
{
|
||||
void* contextData;
|
||||
dos_qquickview_rootContext(data, contextData);
|
||||
return new QQmlContext(contextData);
|
||||
}
|
||||
|
||||
string source()
|
||||
{
|
||||
auto array = new CharArray();
|
||||
scope(exit) destroy(array);
|
||||
dos_qquickview_source(data, array.dataRef(), array.sizeRef());
|
||||
return array.toString();
|
||||
}
|
||||
|
||||
void setSource(string filename)
|
||||
{
|
||||
immutable(char)* filenameAsCString = filename.toStringz();
|
||||
dos_qquickview_set_source(data, filenameAsCString);
|
||||
}
|
||||
~this()
|
||||
{
|
||||
dos_qquickview_delete(this.vptr);
|
||||
}
|
||||
|
||||
private void* data;
|
||||
public void* voidPointer()
|
||||
{
|
||||
return this.vptr;
|
||||
}
|
||||
|
||||
public void show()
|
||||
{
|
||||
dos_qquickview_show(this.vptr);
|
||||
}
|
||||
|
||||
public QQmlContext rootContext()
|
||||
{
|
||||
void* contextData;
|
||||
dos_qquickview_rootContext(this.vptr, contextData);
|
||||
return new QQmlContext(contextData);
|
||||
}
|
||||
|
||||
public string source()
|
||||
{
|
||||
char* array;
|
||||
dos_qquickview_source(this.vptr, array);
|
||||
string result = fromStringz(array).dup;
|
||||
dos_chararray_delete(array);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setSource(string filename)
|
||||
{
|
||||
immutable(char)* filenameAsCString = filename.toStringz();
|
||||
dos_qquickview_set_source(this.vptr, filenameAsCString);
|
||||
}
|
||||
|
||||
private void* vptr;
|
||||
}
|
||||
|
@ -1,160 +1,160 @@
|
||||
import dothersideinterface;
|
||||
import qobject;
|
||||
import std.string;
|
||||
import chararray;
|
||||
|
||||
class QVariant
|
||||
{
|
||||
public this()
|
||||
{
|
||||
dos_qvariant_create(this.data);
|
||||
}
|
||||
public this()
|
||||
{
|
||||
dos_qvariant_create(this.vptr);
|
||||
}
|
||||
|
||||
public this(int value)
|
||||
{
|
||||
dos_qvariant_create_int(this.data, value);
|
||||
}
|
||||
public this(int value)
|
||||
{
|
||||
dos_qvariant_create_int(this.vptr, value);
|
||||
}
|
||||
|
||||
public this(bool value)
|
||||
{
|
||||
dos_qvariant_create_bool(this.data, value);
|
||||
}
|
||||
public this(bool value)
|
||||
{
|
||||
dos_qvariant_create_bool(this.vptr, value);
|
||||
}
|
||||
|
||||
public this(string value)
|
||||
{
|
||||
dos_qvariant_create_string(this.data, value.toStringz());
|
||||
}
|
||||
public this(string value)
|
||||
{
|
||||
dos_qvariant_create_string(this.vptr, value.toStringz());
|
||||
}
|
||||
|
||||
public this(float value)
|
||||
{
|
||||
dos_qvariant_create_float(this.data, value);
|
||||
}
|
||||
public this(float value)
|
||||
{
|
||||
dos_qvariant_create_float(this.vptr, value);
|
||||
}
|
||||
|
||||
public this(double value)
|
||||
{
|
||||
dos_qvariant_create_double(this.data, value);
|
||||
}
|
||||
public this(double value)
|
||||
{
|
||||
dos_qvariant_create_double(this.vptr, value);
|
||||
}
|
||||
|
||||
public this(QObject value)
|
||||
{
|
||||
dos_qvariant_create_qobject(this.data, value.rawData());
|
||||
}
|
||||
public this(QObject value)
|
||||
{
|
||||
dos_qvariant_create_qobject(this.vptr, value.voidPointer());
|
||||
}
|
||||
|
||||
public this(void* data, bool hasOwnership = false)
|
||||
{
|
||||
this.data = data;
|
||||
this.hasOwnership = hasOwnership;
|
||||
}
|
||||
public this(void* vptr, bool hasOwnership = false)
|
||||
{
|
||||
this.vptr = vptr;
|
||||
this.hasOwnership = hasOwnership;
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
if (this.hasOwnership)
|
||||
dos_qvariant_delete(this.data);
|
||||
}
|
||||
~this()
|
||||
{
|
||||
if (this.hasOwnership)
|
||||
dos_qvariant_delete(this.vptr);
|
||||
}
|
||||
|
||||
public void* rawData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
public void* voidPointer()
|
||||
{
|
||||
return this.vptr;
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
dos_qvariant_setInt(this.data, value);
|
||||
}
|
||||
public void setValue(int value)
|
||||
{
|
||||
dos_qvariant_setInt(this.vptr, value);
|
||||
}
|
||||
|
||||
public void setValue(bool value)
|
||||
{
|
||||
dos_qvariant_setBool(this.data, value);
|
||||
}
|
||||
public void setValue(bool value)
|
||||
{
|
||||
dos_qvariant_setBool(this.vptr, value);
|
||||
}
|
||||
|
||||
public void setValue(string value)
|
||||
{
|
||||
dos_qvariant_setString(this.data, value.toStringz());
|
||||
}
|
||||
public void setValue(string value)
|
||||
{
|
||||
dos_qvariant_setString(this.vptr, value.toStringz());
|
||||
}
|
||||
|
||||
public void setValue(QObject value)
|
||||
{
|
||||
dos_qvariant_setQObject(this.data, value.rawData());
|
||||
}
|
||||
public void setValue(QObject value)
|
||||
{
|
||||
dos_qvariant_setQObject(this.vptr, value.voidPointer());
|
||||
}
|
||||
|
||||
public void setValue(float value)
|
||||
{
|
||||
dos_qvariant_setFloat(this.data, value);
|
||||
}
|
||||
public void setValue(float value)
|
||||
{
|
||||
dos_qvariant_setFloat(this.vptr, value);
|
||||
}
|
||||
|
||||
public void setValue(double value)
|
||||
{
|
||||
dos_qvariant_setDouble(this.data, value);
|
||||
}
|
||||
public void setValue(double value)
|
||||
{
|
||||
dos_qvariant_setDouble(this.vptr, value);
|
||||
}
|
||||
|
||||
public void getValue(ref int value)
|
||||
{
|
||||
value = toInt();
|
||||
}
|
||||
public void getValue(ref int value)
|
||||
{
|
||||
value = toInt();
|
||||
}
|
||||
|
||||
public void getValue(ref bool value)
|
||||
{
|
||||
value = toBool();
|
||||
}
|
||||
public void getValue(ref bool value)
|
||||
{
|
||||
value = toBool();
|
||||
}
|
||||
|
||||
public void getValue(ref string value)
|
||||
{
|
||||
value = toString();
|
||||
}
|
||||
public void getValue(ref string value)
|
||||
{
|
||||
value = toString();
|
||||
}
|
||||
|
||||
public void getValue(ref float value)
|
||||
{
|
||||
value = toFloat();
|
||||
}
|
||||
public void getValue(ref float value)
|
||||
{
|
||||
value = toFloat();
|
||||
}
|
||||
|
||||
public void getValue(ref double value)
|
||||
{
|
||||
value = toDouble();
|
||||
}
|
||||
public void getValue(ref double value)
|
||||
{
|
||||
value = toDouble();
|
||||
}
|
||||
|
||||
public bool isNull()
|
||||
{
|
||||
bool result;
|
||||
dos_qvariant_isnull(this.data, result);
|
||||
return result;
|
||||
}
|
||||
public bool isNull()
|
||||
{
|
||||
bool result;
|
||||
dos_qvariant_isnull(this.vptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool toBool()
|
||||
{
|
||||
bool result;
|
||||
dos_qvariant_toBool(this.data, result);
|
||||
return result;
|
||||
}
|
||||
public bool toBool()
|
||||
{
|
||||
bool result;
|
||||
dos_qvariant_toBool(this.vptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int toInt()
|
||||
{
|
||||
int result;
|
||||
dos_qvariant_toInt(this.data, result);
|
||||
return result;
|
||||
}
|
||||
public int toInt()
|
||||
{
|
||||
int result;
|
||||
dos_qvariant_toInt(this.vptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public float toFloat()
|
||||
{
|
||||
float result;
|
||||
dos_qvariant_toFloat(this.data, result);
|
||||
return result;
|
||||
}
|
||||
public float toFloat()
|
||||
{
|
||||
float result;
|
||||
dos_qvariant_toFloat(this.vptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public double toDouble()
|
||||
{
|
||||
double result;
|
||||
dos_qvariant_toDouble(this.data, result);
|
||||
return result;
|
||||
}
|
||||
public double toDouble()
|
||||
{
|
||||
double result;
|
||||
dos_qvariant_toDouble(this.vptr, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string toString()
|
||||
{
|
||||
auto result = new CharArray();
|
||||
scope(exit) destroy(result);
|
||||
dos_qvariant_toString(this.data, result.dataRef(), result.sizeRef());
|
||||
return result.toString();
|
||||
}
|
||||
public override string toString()
|
||||
{
|
||||
char* array;
|
||||
dos_qvariant_toString(this.vptr, array);
|
||||
string result = fromStringz(array).dup;
|
||||
dos_chararray_delete(array);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void* data = null;
|
||||
private bool hasOwnership = true;
|
||||
private void* vptr = null;
|
||||
private bool hasOwnership = true;
|
||||
}
|
||||
|
11
D/Examples/AbstractItemModel/CMakeLists.txt
Normal file
11
D/Examples/AbstractItemModel/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project (DQmlAbstractItemModel C D )
|
||||
add_executable(${PROJECT_NAME} main.d model.d)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../DQml"
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../../../DOtherSide/DOtherSide/libDOtherSide.so"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../../DQml/libDQml.a"
|
||||
)
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/main.qml DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
26
D/Examples/AbstractItemModel/main.d
Normal file
26
D/Examples/AbstractItemModel/main.d
Normal file
@ -0,0 +1,26 @@
|
||||
import dqml;
|
||||
import model;
|
||||
|
||||
void main()
|
||||
{
|
||||
try
|
||||
{
|
||||
auto app = new QGuiApplication();
|
||||
scope(exit) destroy(app);
|
||||
|
||||
auto model = new ListModel();
|
||||
scope(exit) destroy(model);
|
||||
|
||||
auto variant = new QVariant();
|
||||
variant.setValue(model);
|
||||
|
||||
auto engine = new QQmlApplicationEngine();
|
||||
scope(exit) destroy(engine);
|
||||
|
||||
engine.rootContext().setContextProperty("myListModel", variant);
|
||||
engine.load("main.qml");
|
||||
app.exec();
|
||||
}
|
||||
catch
|
||||
{}
|
||||
}
|
25
D/Examples/AbstractItemModel/main.qml
Normal file
25
D/Examples/AbstractItemModel/main.qml
Normal file
@ -0,0 +1,25 @@
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Window 2.1
|
||||
|
||||
ApplicationWindow
|
||||
{
|
||||
width: 400
|
||||
height: 300
|
||||
title: "AbstractItemModel"
|
||||
Component.onCompleted: visible = true
|
||||
|
||||
Component
|
||||
{
|
||||
id: myListModelDelegate
|
||||
Label { text: "Name:" + name }
|
||||
}
|
||||
|
||||
ListView
|
||||
{
|
||||
anchors.fill: parent
|
||||
model: myListModel
|
||||
delegate: myListModelDelegate
|
||||
}
|
||||
}
|
48
D/Examples/AbstractItemModel/model.d
Normal file
48
D/Examples/AbstractItemModel/model.d
Normal file
@ -0,0 +1,48 @@
|
||||
import dqml;
|
||||
import std.stdio;
|
||||
|
||||
|
||||
class ListModel : QAbstractListModel
|
||||
{
|
||||
this()
|
||||
{
|
||||
this.names = ["John", "Max", "Paul", "Anna"];
|
||||
this.roles[Roles.Name] = "name";
|
||||
}
|
||||
|
||||
public override int rowCount(QModelIndex parent = null)
|
||||
{
|
||||
if (parent && parent.isValid())
|
||||
return 0;
|
||||
return cast(int)(names.length);
|
||||
}
|
||||
|
||||
public override QVariant data(QModelIndex index, int role)
|
||||
{
|
||||
if (index is null)
|
||||
return null;
|
||||
|
||||
if (!index.isValid())
|
||||
return null;
|
||||
|
||||
if (index.row() < 0 || index.row() >= rowCount())
|
||||
return null;
|
||||
|
||||
switch(role)
|
||||
{
|
||||
case Roles.Name:
|
||||
return new QVariant(names[index.row]);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string[int] roleNames()
|
||||
{
|
||||
return roles;
|
||||
}
|
||||
|
||||
private string[] names;
|
||||
private string[int] roles;
|
||||
private enum Roles : int { Name = 0 };
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
add_subdirectory(HelloWorld)
|
||||
add_subdirectory(SimpleData)
|
||||
add_subdirectory(SlotsAndProperties)
|
||||
add_subdirectory(SlotsAndProperties)
|
||||
add_subdirectory(AbstractItemModel)
|
||||
add_subdirectory(ContactApp)
|
11
D/Examples/ContactApp/CMakeLists.txt
Normal file
11
D/Examples/ContactApp/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project (DQmlContactApp C D )
|
||||
add_executable(${PROJECT_NAME} main.d applicationlogic.d contact.d contactlist.d)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../DQml"
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../../../DOtherSide/DOtherSide/libDOtherSide.so"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../../DQml/libDQml.a"
|
||||
)
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/main.qml DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
60
D/Examples/ContactApp/applicationlogic.d
Normal file
60
D/Examples/ContactApp/applicationlogic.d
Normal file
@ -0,0 +1,60 @@
|
||||
import dqml;
|
||||
import contactlist;
|
||||
import std.stdio;
|
||||
|
||||
class ApplicationLogic : QObject
|
||||
{
|
||||
this(QApplication app)
|
||||
{
|
||||
this.m_app = app;
|
||||
this.m_contactList = new ContactList();
|
||||
this.registerSlot("contactList", [QMetaType.QObject]);
|
||||
this.registerSlot("onLoadTriggered", [QMetaType.Void]);
|
||||
this.registerSlot("onSaveTriggered", [QMetaType.Void]);
|
||||
this.registerSlot("onExitTriggered", [QMetaType.Void]);
|
||||
this.registerProperty("contactList", QMetaType.QObject, "contactList", null, null);
|
||||
}
|
||||
|
||||
public ContactList contactList()
|
||||
{
|
||||
return this.m_contactList;
|
||||
}
|
||||
|
||||
public void onLoadTriggered()
|
||||
{
|
||||
writefln("Load Triggered");
|
||||
}
|
||||
|
||||
public void onSaveTriggered()
|
||||
{
|
||||
writefln("Save Triggered");
|
||||
}
|
||||
|
||||
public void onExitTriggered()
|
||||
{
|
||||
this.m_app.quit();
|
||||
}
|
||||
|
||||
protected override void onSlotCalled(QVariant slotName, QVariant[] arguments)
|
||||
{
|
||||
switch(slotName.toString())
|
||||
{
|
||||
case "contactList":
|
||||
return arguments[0].setValue(contactList());
|
||||
case "onExitTriggered":
|
||||
onExitTriggered();
|
||||
break;
|
||||
case "onSaveTriggered":
|
||||
onSaveTriggered();
|
||||
break;
|
||||
case "onLoadTriggered":
|
||||
onLoadTriggered();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private QApplication m_app;
|
||||
private ContactList m_contactList;
|
||||
}
|
70
D/Examples/ContactApp/contact.d
Normal file
70
D/Examples/ContactApp/contact.d
Normal file
@ -0,0 +1,70 @@
|
||||
import dqml;
|
||||
|
||||
class Contact : QObject
|
||||
{
|
||||
this(string firstName = "", string lastName = "")
|
||||
{
|
||||
this.m_firstName = firstName;
|
||||
this.m_lastName = lastName;
|
||||
this.registerSlot("firstName", [QMetaType.String]);
|
||||
this.registerSlot("setFirstName", [QMetaType.Void, QMetaType.String]);
|
||||
this.registerSignal("firstNameChanged", [QMetaType.String]);
|
||||
this.registerSlot("lastName", [QMetaType.String]);
|
||||
this.registerSlot("setLastName", [QMetaType.Void, QMetaType.String]);
|
||||
this.registerSignal("lastNameChanged", [QMetaType.String]);
|
||||
this.registerProperty("firstName", QMetaType.String, "firstName", "setFirstName", "firstNameChanged");
|
||||
this.registerProperty("lastName", QMetaType.String, "lastName", "setLastName", "lastNameChanged");
|
||||
}
|
||||
|
||||
public string firstName()
|
||||
{
|
||||
return this.m_firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(string firstName)
|
||||
{
|
||||
if (this.m_firstName != firstName)
|
||||
{
|
||||
this.m_firstName = firstName;
|
||||
emit("firstNameChanged", firstName);
|
||||
}
|
||||
}
|
||||
|
||||
public string lastName()
|
||||
{
|
||||
return this.m_lastName;
|
||||
}
|
||||
|
||||
public void setLastName(string lastName)
|
||||
{
|
||||
if (this.m_lastName != lastName)
|
||||
{
|
||||
this.m_lastName = lastName;
|
||||
emit ("lastNameChanged", lastName);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void onSlotCalled(QVariant slotName, QVariant[] arguments)
|
||||
{
|
||||
switch (slotName.toString())
|
||||
{
|
||||
case "firstName":
|
||||
arguments[0].setValue(firstName());
|
||||
break;
|
||||
case "setFirstName":
|
||||
setFirstName(arguments[1].toString());
|
||||
break;
|
||||
case "lastName":
|
||||
arguments[0].setValue(lastName());
|
||||
break;
|
||||
case "setLastName":
|
||||
setLastName(arguments[1].toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private string m_firstName;
|
||||
private string m_lastName;
|
||||
}
|
92
D/Examples/ContactApp/contactlist.d
Normal file
92
D/Examples/ContactApp/contactlist.d
Normal file
@ -0,0 +1,92 @@
|
||||
import dqml;
|
||||
import contact;
|
||||
import std.stdio;
|
||||
import std.algorithm;
|
||||
|
||||
class ContactList : QAbstractListModel
|
||||
{
|
||||
this()
|
||||
{
|
||||
this.m_contacts = [];
|
||||
this.m_roleNames[Roles.FirstName] = "firstName";
|
||||
this.m_roleNames[Roles.LastName] = "lastName";
|
||||
this.registerSlot("add", [QMetaType.Void, QMetaType.String, QMetaType.String]);
|
||||
this.registerSlot("del", [QMetaType.Void, QMetaType.Int]);
|
||||
}
|
||||
|
||||
public override int rowCount(QModelIndex parent = null)
|
||||
{
|
||||
if (parent && parent.isValid())
|
||||
return 0;
|
||||
return cast(int)(this.m_contacts.length);
|
||||
}
|
||||
|
||||
public override QVariant data(QModelIndex index, int role)
|
||||
{
|
||||
if (index is null)
|
||||
return null;
|
||||
|
||||
if (!index.isValid())
|
||||
return null;
|
||||
|
||||
if (index.row() < 0 || index.row() >= rowCount())
|
||||
return null;
|
||||
|
||||
auto contact = this.m_contacts[index.row];
|
||||
|
||||
switch(role)
|
||||
{
|
||||
case Roles.FirstName:
|
||||
return new QVariant(contact.firstName());
|
||||
case Roles.LastName:
|
||||
return new QVariant(contact.lastName());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string[int] roleNames()
|
||||
{
|
||||
return this.m_roleNames;
|
||||
}
|
||||
|
||||
public void add(string firstName, string lastName)
|
||||
{
|
||||
auto index = new QModelIndex();
|
||||
auto pos = rowCount();
|
||||
writefln("Adding %s %s in pos %d", firstName, lastName, pos);
|
||||
beginInsertRows(index, pos, pos);
|
||||
this.m_contacts ~= new Contact(firstName, lastName);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
public void del(int pos)
|
||||
{
|
||||
if (pos < 0 || pos >= rowCount())
|
||||
return;
|
||||
auto index = new QModelIndex();
|
||||
writefln("Removing at pos %d", pos);
|
||||
beginRemoveRows(index, pos, pos);
|
||||
this.m_contacts = remove(this.m_contacts, pos);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
protected override void onSlotCalled(QVariant slotName, QVariant[] arguments)
|
||||
{
|
||||
switch (slotName.toString())
|
||||
{
|
||||
case "add":
|
||||
add(arguments[1].toString(), arguments[2].toString());
|
||||
break;
|
||||
case "del":
|
||||
del(arguments[1].toInt());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Contact[] m_contacts;
|
||||
private string[int] m_roleNames;
|
||||
private enum Roles : int { FirstName = 0, LastName};
|
||||
}
|
26
D/Examples/ContactApp/main.d
Normal file
26
D/Examples/ContactApp/main.d
Normal file
@ -0,0 +1,26 @@
|
||||
import dqml;
|
||||
import applicationlogic;
|
||||
|
||||
void main()
|
||||
{
|
||||
try
|
||||
{
|
||||
auto app = new QApplication();
|
||||
scope(exit) destroy(app);
|
||||
|
||||
auto logic = new ApplicationLogic(app);
|
||||
scope(exit) destroy(logic);
|
||||
|
||||
auto variant = new QVariant();
|
||||
variant.setValue(logic);
|
||||
|
||||
auto engine = new QQmlApplicationEngine();
|
||||
scope(exit) destroy(engine);
|
||||
|
||||
engine.rootContext().setContextProperty("logic", variant);
|
||||
engine.load("main.qml");
|
||||
app.exec();
|
||||
}
|
||||
catch
|
||||
{}
|
||||
}
|
93
D/Examples/ContactApp/main.qml
Normal file
93
D/Examples/ContactApp/main.qml
Normal file
@ -0,0 +1,93 @@
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Window 2.1
|
||||
|
||||
ApplicationWindow {
|
||||
|
||||
width: 500
|
||||
height: 300
|
||||
title: "ContactApp"
|
||||
visible: true
|
||||
|
||||
menuBar: MenuBar {
|
||||
Menu {
|
||||
title: "&File"
|
||||
MenuItem { text: "&Load"; onTriggered: logic.onLoadTriggered() }
|
||||
MenuItem { text: "&Save"; onTriggered: logic.onSaveTriggered() }
|
||||
MenuItem { text: "&Exit"; onTriggered: logic.onExitTriggered() }
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
Component {
|
||||
id: tableTextDelegate
|
||||
Label {
|
||||
id: tableTextDelegateInstance
|
||||
property var styleData: undefined
|
||||
states: State {
|
||||
when: styleData !== undefined
|
||||
PropertyChanges {
|
||||
target: tableTextDelegateInstance;
|
||||
text: styleData.value;
|
||||
color: styleData.textColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: tableButtonDelegate
|
||||
Button {
|
||||
id: tableButtonDelegateInstance
|
||||
property var styleData: undefined
|
||||
text: "Delete"
|
||||
onClicked: logic.contactList.del(styleData.row)
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: tableItemDelegate
|
||||
Loader {
|
||||
id: tableItemDelegateInstance
|
||||
sourceComponent: {
|
||||
if (styleData.column === 0 || styleData.column === 1)
|
||||
return tableTextDelegate
|
||||
else if (styleData.column === 2)
|
||||
return tableButtonDelegate
|
||||
else
|
||||
return tableTextDelegate
|
||||
}
|
||||
Binding {
|
||||
target: tableItemDelegateInstance.item
|
||||
property: "styleData"
|
||||
value: styleData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TableView {
|
||||
model: logic.contactList
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
TableViewColumn { role: "firstName"; title: "FirstName"; width: 200 }
|
||||
TableViewColumn { role: "lastName"; title: "LastName"; width: 200}
|
||||
TableViewColumn { width: 100; }
|
||||
itemDelegate: tableItemDelegate
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Label { text: "FirstName" }
|
||||
TextField { id: nameTextField; Layout.fillWidth: true; text: "" }
|
||||
Label { text: "LastName" }
|
||||
TextField { id: surnameTextField; Layout.fillWidth: true; text: "" }
|
||||
Button {
|
||||
text: "Add"
|
||||
onClicked: logic.contactList.add(nameTextField.text, surnameTextField.text)
|
||||
enabled: nameTextField.text !== "" && surnameTextField.text !== ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ class Contact : QObject
|
||||
}
|
||||
}
|
||||
|
||||
override protected void onSlotCalled(QVariant slotName, QVariant[] arguments)
|
||||
protected override void onSlotCalled(QVariant slotName, QVariant[] arguments)
|
||||
{
|
||||
switch (slotName.toString())
|
||||
{
|
||||
|
@ -16,11 +16,10 @@
|
||||
#include "BaseQAbstractListModel.h"
|
||||
#include "BaseQObject.h"
|
||||
|
||||
void convert_to_cstring(const QString& source, char** destination, int* length)
|
||||
void convert_to_cstring(const QString& source, char** destination)
|
||||
{
|
||||
QByteArray array = source.toUtf8();
|
||||
*destination = qstrdup(array.data());
|
||||
*length = qstrlen(array.data());
|
||||
}
|
||||
|
||||
void dos_qguiapplication_create()
|
||||
@ -110,11 +109,11 @@ void dos_qquickview_delete(void* vptr)
|
||||
delete view;
|
||||
}
|
||||
|
||||
void dos_qquickview_source(void* vptr, char** result, int* length)
|
||||
void dos_qquickview_source(void* vptr, char** result)
|
||||
{
|
||||
QQuickView* view = reinterpret_cast<QQuickView*>(vptr);
|
||||
QUrl url = view->source();
|
||||
convert_to_cstring(url.toString(), result, length);
|
||||
convert_to_cstring(url.toString(), result);
|
||||
}
|
||||
|
||||
void dos_qquickview_set_source(void* vptr, const char* filename)
|
||||
@ -129,29 +128,16 @@ void dos_qquickview_rootContext(void* vptr, void** context)
|
||||
*context = view->rootContext();
|
||||
}
|
||||
|
||||
void dos_chararray_create(char** ptr)
|
||||
{
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
void dos_chararray_create(char** ptr, int size)
|
||||
{
|
||||
if (size > 0)
|
||||
*ptr = new char[size];
|
||||
else
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
void dos_chararray_delete(char* ptr)
|
||||
{
|
||||
if (ptr) delete[] ptr;
|
||||
}
|
||||
|
||||
void dos_qqmlcontext_baseUrl(void* vptr, char** result, int* length)
|
||||
void dos_qqmlcontext_baseUrl(void* vptr, char** result)
|
||||
{
|
||||
QQmlContext* context = reinterpret_cast<QQmlContext*>(vptr);
|
||||
QUrl url = context->baseUrl();
|
||||
convert_to_cstring(url.toString(), result, length);
|
||||
convert_to_cstring(url.toString(), result);
|
||||
}
|
||||
|
||||
void dos_qqmlcontext_setcontextproperty(void* vptr, const char* name, void* value)
|
||||
@ -258,10 +244,10 @@ void dos_qvariant_toDouble(void* vptr, double* value)
|
||||
*value = variant->toDouble();
|
||||
}
|
||||
|
||||
void dos_qvariant_toString(void* vptr, char** ptr, int* size)
|
||||
void dos_qvariant_toString(void* vptr, char** ptr)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
convert_to_cstring(variant->toString(), ptr, size);
|
||||
convert_to_cstring(variant->toString(), ptr);
|
||||
}
|
||||
|
||||
void dos_qvariant_setInt(void* vptr, int value)
|
||||
|
@ -39,17 +39,16 @@ DOS_API void dos_qqmlapplicationengine_delete(void* vptr);
|
||||
// QQuickView
|
||||
DOS_API void dos_qquickview_create(void** vptr);
|
||||
DOS_API void dos_qquickview_show(void* vptr);
|
||||
DOS_API void dos_qquickview_source(void* vptr, char** result, int* length);
|
||||
DOS_API void dos_qquickview_source(void* vptr, char** result);
|
||||
DOS_API void dos_qquickview_set_source(void* vptr, const char* filename);
|
||||
DOS_API void dos_qquickview_delete(void* vptr);
|
||||
DOS_API void dos_qquickview_rootContext(void* vptr, void** context);
|
||||
DOS_API void dos_qquickview_rootContext(void* vptr, void** result);
|
||||
|
||||
// QQmlContext
|
||||
DOS_API void dos_qqmlcontext_baseUrl(void* vptr, char** result, int* length);
|
||||
DOS_API void dos_qqmlcontext_baseUrl(void* vptr, char** result);
|
||||
DOS_API void dos_qqmlcontext_setcontextproperty(void* vptr, const char* name, void* value);
|
||||
|
||||
// CharArray
|
||||
DOS_API void dos_chararray_create(char** ptr, int size);
|
||||
DOS_API void dos_chararray_delete(char* ptr);
|
||||
|
||||
// QVariant
|
||||
@ -62,19 +61,19 @@ DOS_API void dos_qvariant_create_qvariant(void** vptr, void* value);
|
||||
DOS_API void dos_qvariant_create_float(void** vptr, float value);
|
||||
DOS_API void dos_qvariant_create_double(void** vptr, double value);
|
||||
DOS_API void dos_qvariant_create_qabstractlistmodel(void** vptr, void* value);
|
||||
DOS_API void dos_qvariant_toInt(void* vptr, int* value);
|
||||
DOS_API void dos_qvariant_toInt(void* vptr, int* result);
|
||||
DOS_API void dos_qvariant_setInt(void* vptr, int value);
|
||||
DOS_API void dos_qvariant_toBool(void* vptr, bool* value);
|
||||
DOS_API void dos_qvariant_toBool(void* vptr, bool* result);
|
||||
DOS_API void dos_qvariant_setBool(void* vptr, bool value);
|
||||
DOS_API void dos_qvariant_toFloat(void* vptr, float* value);
|
||||
DOS_API void dos_qvariant_toFloat(void* vptr, float* result);
|
||||
DOS_API void dos_qvariant_setFloat(void* vptr, float value);
|
||||
DOS_API void dos_qvariant_toDouble(void* vptr, double* value);
|
||||
DOS_API void dos_qvariant_toDouble(void* vptr, double* result);
|
||||
DOS_API void dos_qvariant_setDouble(void* vptr, double value);
|
||||
DOS_API void dos_qvariant_toString(void* vptr, char** ptr, int* size);
|
||||
DOS_API void dos_qvariant_toString(void* vptr, char** result);
|
||||
DOS_API void dos_qvariant_setString(void* vptr, const char* value);
|
||||
DOS_API void dos_qvariant_setQObject(void* vptr, void* value);
|
||||
DOS_API void dos_qvariant_setQAbstractListModel(void* vptr, void* value);
|
||||
DOS_API void dos_qvariant_isnull(void* vptr, bool* isNull);
|
||||
DOS_API void dos_qvariant_isnull(void* vptr, bool* result);
|
||||
DOS_API void dos_qvariant_delete(void* vptr);
|
||||
DOS_API void dos_qvariant_assign(void* vptr, void* other);
|
||||
|
||||
@ -82,24 +81,20 @@ DOS_API void dos_qvariant_assign(void* vptr, void* other);
|
||||
DOS_API void dos_qobject_create(void** vptr,
|
||||
void* dObjectPointer,
|
||||
DObjectCallback dObjectCallback);
|
||||
|
||||
DOS_API void dos_qobject_slot_create(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
int* slotIndex);
|
||||
|
||||
DOS_API void dos_qobject_signal_create(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
int* signalIndex);
|
||||
|
||||
DOS_API void dos_qobject_signal_emit(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
void** parameters);
|
||||
|
||||
DOS_API void dos_qobject_property_create(void* vptr,
|
||||
const char* name,
|
||||
int propertyMetaType,
|
||||
@ -136,24 +131,13 @@ DOS_API void dos_qabstractlistmodel_create(void** vptr,
|
||||
RoleNamesCallback roleNamesCallback,
|
||||
FlagsCallback flagsCallback,
|
||||
HeaderDataCallback headerDataCallback);
|
||||
DOS_API void dos_qabstractlistmodel_beginInsertRows(void* vptr,
|
||||
QModelIndexVoidPtr parentIndex,
|
||||
int first,
|
||||
int last);
|
||||
DOS_API void dos_qabstractlistmodel_beginInsertRows(void* vptr, void* parent, int first, int last);
|
||||
DOS_API void dos_qabstractlistmodel_endInsertRows(void* vptr);
|
||||
DOS_API void dos_qabstractlistmodel_beginRemoveRows(void* vptr,
|
||||
QModelIndexVoidPtr parentIndex,
|
||||
int first,
|
||||
int last);
|
||||
DOS_API void dos_qabstractlistmodel_beginRemoveRows(void* vptr, void* parent, int first, int last);
|
||||
DOS_API void dos_qabstractlistmodel_endRemoveRows(void* vptr);
|
||||
DOS_API void dos_qabstractlistmodel_beginResetModel(void* vptr);
|
||||
DOS_API void dos_qabstractlistmodel_endResetModel(void* vptr);
|
||||
DOS_API void dos_qabstractlistmodel_dataChanged(void* vptr,
|
||||
QModelIndexVoidPtr topLeftIndex,
|
||||
QModelIndexVoidPtr bottomRightIndex,
|
||||
int* rolesArrayPtr,
|
||||
int rolesArrayLength);
|
||||
|
||||
DOS_API void dos_qabstractlistmodel_dataChanged(void* vptr, void* topLeft, void* bottomRight, int* rolesPtr, int rolesLength);
|
||||
DOS_API void dos_qabstractlistmodel_delete(void* vptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user