wip
This commit is contained in:
parent
39c0c94a24
commit
28f9898573
|
@ -17,8 +17,11 @@ namespace DOS
|
||||||
class DosQObjectImpl : public QAbstractDynamicMetaObject, public IDosQObject
|
class DosQObjectImpl : public QAbstractDynamicMetaObject, public IDosQObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using ParentMetaCall = std::function<int(QMetaObject::Call, int, void **)>;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
DosQObjectImpl(QObject* parent,
|
DosQObjectImpl(QObject* parent,
|
||||||
|
ParentMetaCall parentMetaCall,
|
||||||
OnMetaObject onMetaObject,
|
OnMetaObject onMetaObject,
|
||||||
OnSlotExecuted onSlotExecuted);
|
OnSlotExecuted onSlotExecuted);
|
||||||
|
|
||||||
|
@ -37,6 +40,7 @@ private:
|
||||||
bool writeProperty(int index, void** args);
|
bool writeProperty(int index, void** args);
|
||||||
|
|
||||||
QObject* m_parent;
|
QObject* m_parent;
|
||||||
|
const ParentMetaCall m_parentMetaCall;
|
||||||
const OnMetaObject m_onMetaObject;
|
const OnMetaObject m_onMetaObject;
|
||||||
const OnSlotExecuted m_onSlotExecuted;
|
const OnSlotExecuted m_onSlotExecuted;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
#include "DOtherSide/DosQAbstractListModel.h"
|
#include "DOtherSide/DosQAbstractListModel.h"
|
||||||
#include "DOtherSide/DosQObjectImpl.h"
|
#include "DOtherSide/DosQObjectImpl.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
DOS::DosQObjectImpl::ParentMetaCall createParentMetaCall(QAbstractListModel* parent)
|
||||||
|
{
|
||||||
|
return [parent](QMetaObject::Call callType, int index, void** args)->int {
|
||||||
|
return parent->QAbstractListModel::qt_metacall(callType, index, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace DOS
|
namespace DOS
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -14,7 +24,7 @@ DosQAbstractListModel::DosQAbstractListModel(void *modelObject,
|
||||||
RoleNamesCallback roleNamesCallback,
|
RoleNamesCallback roleNamesCallback,
|
||||||
FlagsCallback flagsCallback,
|
FlagsCallback flagsCallback,
|
||||||
HeaderDataCallback headerDataCallback)
|
HeaderDataCallback headerDataCallback)
|
||||||
: m_impl(new DosQObjectImpl(this, std::move(onMetaObject), std::move(onSlotExecuted)))
|
: m_impl(new DosQObjectImpl(this, ::createParentMetaCall(this), std::move(onMetaObject), std::move(onSlotExecuted)))
|
||||||
, m_modelObject(std::move(modelObject))
|
, m_modelObject(std::move(modelObject))
|
||||||
, m_rowCountCallback(std::move(rowCountCallback))
|
, m_rowCountCallback(std::move(rowCountCallback))
|
||||||
, m_columnCountCallback(std::move(columnCountCallback))
|
, m_columnCountCallback(std::move(columnCountCallback))
|
||||||
|
|
|
@ -5,11 +5,21 @@
|
||||||
#include <QtCore/QMetaMethod>
|
#include <QtCore/QMetaMethod>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
DOS::DosQObjectImpl::ParentMetaCall createParentMetaCall(QObject* parent)
|
||||||
|
{
|
||||||
|
return [parent](QMetaObject::Call callType, int index, void** args) -> int {
|
||||||
|
return parent->QObject::qt_metacall(callType, index, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace DOS
|
namespace DOS
|
||||||
{
|
{
|
||||||
|
|
||||||
DosQObject::DosQObject(OnMetaObject onMetaObject, OnSlotExecuted onSlotExecuted)
|
DosQObject::DosQObject(OnMetaObject onMetaObject, OnSlotExecuted onSlotExecuted)
|
||||||
: m_impl(new DosQObjectImpl(this, std::move(onMetaObject), std::move(onSlotExecuted)))
|
: m_impl(new DosQObjectImpl(this, ::createParentMetaCall(this), std::move(onMetaObject), std::move(onSlotExecuted)))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool DosQObject::emitSignal(const QString &name, const std::vector<QVariant> &args)
|
bool DosQObject::emitSignal(const QString &name, const std::vector<QVariant> &args)
|
||||||
|
|
|
@ -8,9 +8,11 @@ namespace DOS
|
||||||
{
|
{
|
||||||
|
|
||||||
DosQObjectImpl::DosQObjectImpl(QObject* parent,
|
DosQObjectImpl::DosQObjectImpl(QObject* parent,
|
||||||
|
ParentMetaCall parentMetaCall,
|
||||||
OnMetaObject onMetaObject,
|
OnMetaObject onMetaObject,
|
||||||
OnSlotExecuted onSlotExecuted)
|
OnSlotExecuted onSlotExecuted)
|
||||||
: m_parent(std::move(parent))
|
: m_parent(std::move(parent))
|
||||||
|
, m_parentMetaCall(std::move(parentMetaCall))
|
||||||
, m_onMetaObject(std::move(onMetaObject))
|
, m_onMetaObject(std::move(onMetaObject))
|
||||||
, m_onSlotExecuted(std::move(onSlotExecuted))
|
, m_onSlotExecuted(std::move(onSlotExecuted))
|
||||||
{
|
{
|
||||||
|
@ -35,8 +37,8 @@ bool DosQObjectImpl::emitSignal(const QString &name, const std::vector<QVariant>
|
||||||
}
|
}
|
||||||
|
|
||||||
int DosQObjectImpl::metaCall(QMetaObject::Call callType, int index, void **args)
|
int DosQObjectImpl::metaCall(QMetaObject::Call callType, int index, void **args)
|
||||||
{
|
{
|
||||||
index = m_parent->QObject::qt_metacall(callType, index, args);
|
index = m_parentMetaCall(callType, index, args);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return index;
|
return index;
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,9 @@ ApplicationWindow {
|
||||||
width: 100
|
width: 100
|
||||||
height: 100
|
height: 100
|
||||||
objectName: "testWindow"
|
objectName: "testWindow"
|
||||||
Component.onCompleted: visible = true
|
Component.onCompleted: {
|
||||||
|
visible = true
|
||||||
|
console.log(testObject)
|
||||||
|
console.log(testObject.name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
#include <QQmlContext>
|
||||||
// DOtherSide
|
// DOtherSide
|
||||||
#include "DOtherSide/DOtherSide.h"
|
#include "DOtherSide/DOtherSide.h"
|
||||||
#include "DOtherSide/DosQObject.h"
|
#include "DOtherSide/DosQObject.h"
|
||||||
|
@ -212,8 +212,6 @@ int main(int argc, char* argv[])
|
||||||
slotDefinitions,
|
slotDefinitions,
|
||||||
propertyDefinitions);
|
propertyDefinitions);
|
||||||
|
|
||||||
// auto mo = std::make_shared<DosQObjectMetaObject>();
|
|
||||||
|
|
||||||
auto moh = std::make_unique<DosIQMetaObjectHolder>(mo);
|
auto moh = std::make_unique<DosIQMetaObjectHolder>(mo);
|
||||||
|
|
||||||
auto omo = [&]() -> DosIQMetaObjectHolder* { return moh.get(); };
|
auto omo = [&]() -> DosIQMetaObjectHolder* { return moh.get(); };
|
||||||
|
@ -241,7 +239,14 @@ int main(int argc, char* argv[])
|
||||||
<< testObject.property("name").toString().toStdString() << std::endl
|
<< testObject.property("name").toString().toStdString() << std::endl
|
||||||
<< value.toStdString() << std::endl;
|
<< value.toStdString() << std::endl;
|
||||||
|
|
||||||
return success ? 0 : 1;
|
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
QQmlApplicationEngine engine;
|
||||||
|
engine.rootContext()->setContextProperty("testObject", QVariant::fromValue<QObject*>(&testObject));
|
||||||
|
engine.load(QUrl("qrc:///main.qml"));
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "test_dotherside.moc"
|
#include "test_dotherside.moc"
|
||||||
|
|
Loading…
Reference in New Issue