mirror of
https://github.com/status-im/dotherside.git
synced 2025-02-12 12:46:24 +00:00
Started adding support for RoleNames
This commit is contained in:
parent
df498cb64c
commit
95aeef5db0
@ -31,3 +31,10 @@ void* BaseQAbstractListModel::modelObject()
|
||||
{
|
||||
return m_modelObject;
|
||||
}
|
||||
|
||||
QHash<int,QByteArray> BaseQAbstractListModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,9 @@ class BaseQAbstractListModel : public QAbstractListModel
|
||||
/// Return the dModelPointer
|
||||
void* modelObject();
|
||||
|
||||
/// Return the roleNames
|
||||
virtual QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
void* m_modelObject;
|
||||
RowCountCallback m_rowCountCallback;
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "DOtherSide.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <QtQml/QQmlContext>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <QtCore/QModelIndex>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtQml/QQmlContext>
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
#include "DynamicQObject.h"
|
||||
#include "BaseQAbstractListModel.h"
|
||||
@ -446,3 +446,21 @@ void dos_qabstractlistmodel_delete(void* vptr)
|
||||
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
||||
delete model;
|
||||
}
|
||||
|
||||
void dos_qhash_int_qbytearray_create(QHashIntQByteArrayVoidPtr* vptr)
|
||||
{
|
||||
*vptr = new QHash<int, QByteArray>();
|
||||
}
|
||||
|
||||
void dos_qhash_int_qbytearray_delete(QHashIntQByteArrayVoidPtr vptr)
|
||||
{
|
||||
auto qHash = reinterpret_cast<QHash<int,QByteArray>*>(vptr);
|
||||
delete qHash;
|
||||
}
|
||||
|
||||
void dos_qhash_int_qbytearray_insert(QHashIntQByteArrayVoidPtr vptr, int key, ConstCharPtr value)
|
||||
{
|
||||
auto qHash = reinterpret_cast<QHash<int, QByteArray>*>(vptr);
|
||||
qHash->insert(key, QByteArray(value));
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,11 @@ extern "C"
|
||||
void dos_qmodelindex_child(void* vptr, int row, int column, void* child);
|
||||
void dos_qmodelindex_sibling(void* vptr, int row, int column, void* sibling);
|
||||
|
||||
// QHash<int, QByteArray>
|
||||
void dos_qhash_int_qbytearray_create(QHashIntQByteArrayVoidPtr* vptr);
|
||||
void dos_qhash_int_qbytearray_delete(QHashIntQByteArrayVoidPtr vptr);
|
||||
void dos_qhash_int_qbytearray_insert(QHashIntQByteArrayVoidPtr vptr, int key, ConstCharPtr value);
|
||||
|
||||
// QAbstractListModel
|
||||
void dos_qabstractlistmodel_create(void** vptr,
|
||||
void* callbackObject,
|
||||
|
@ -3,7 +3,6 @@ import macros
|
||||
import typeinfo
|
||||
|
||||
type MyQAbstractListModel = ref object of QAbstractListModel
|
||||
m_name: string
|
||||
|
||||
proc create(self: MyQAbstractListModel) =
|
||||
var qAbstractListModel = self.QAbstractListModel
|
||||
@ -22,6 +21,7 @@ method rowCount(self: MyQAbstractListModel, index: QModelIndex): cint =
|
||||
return 3
|
||||
|
||||
method data(self: MyQAbstractListModel, index: QModelIndex, role: cint): QVariant =
|
||||
echo "index valid: " & $index.isValid & " row: " & $index.row & " column: " & $index.column
|
||||
return nil
|
||||
|
||||
proc mainProc() =
|
||||
|
@ -630,3 +630,24 @@ proc newQAbstractListModel*(): QAbstractListModel =
|
||||
## Return a new QAbstractListModel
|
||||
newWithCondFinalizer(result, delete)
|
||||
result.create()
|
||||
|
||||
# RoleNames QHash
|
||||
proc dos_qhash_int_qbytearray_create(qHash: RawQHashIntByteArray) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
proc dos_qhash_int_qbytearray_delete(qHash: RawQHashIntByteArray) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
proc dos_qhash_int_qbytearray_insert(qHash: RawQHashIntByteArray, key: int, value: cstring) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
|
||||
proc create(qHash: var QHashIntByteArray) =
|
||||
debugMsg("QHashIntByteArray", "create")
|
||||
dos_qhash_int_qbytearray_create(qHash.data)
|
||||
qHash.deleted = false
|
||||
|
||||
proc delete(qHash: QHashIntByteArray) =
|
||||
dos_qhash_int_qbytearray_delete(qHash.data)
|
||||
qHash.deleted = true
|
||||
|
||||
proc insert(qHash: QHashIntByteArray, key: int, value: cstring) =
|
||||
dos_qhash_int_qbytearray_insert(qHash.data, key, value)
|
||||
|
||||
proc newQHashIntQByteArray(): QHashIntByteArray =
|
||||
newWithCondFinalizer(result, delete)
|
||||
result.create()
|
||||
|
@ -43,3 +43,9 @@ type
|
||||
data: RawQAbstractListModel
|
||||
deleted: bool
|
||||
QAbstractListModel* = ref QAbstractListModelObj ## A QAbstractListModel
|
||||
|
||||
RawQHashIntByteArray = distinct pointer
|
||||
QHashIntByteArrayObj = object of RootObj
|
||||
data: RawQHashIntByteArray
|
||||
deleted: bool
|
||||
QHashIntByteArray = ref QHashIntByteArrayObj ## A QHash<int,QByteArray>
|
||||
|
Loading…
x
Reference in New Issue
Block a user