From 91988c912e1c1f0b90d8f2006107302b58417a75 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sat, 13 Aug 2016 13:40:05 +0200 Subject: [PATCH] fix order audit display --- src/dialogs/orderauditdlg_p.h | 37 +++++++++++++++++++++++++++++++++++-- 1 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/dialogs/orderauditdlg_p.h b/src/dialogs/orderauditdlg_p.h index 9c7cc17..050e338 100644 --- a/src/dialogs/orderauditdlg_p.h +++ b/src/dialogs/orderauditdlg_p.h @@ -62,8 +62,41 @@ static QVariant getMetaValue(T*obj,QString n) class MOADynamicObject:public QObject { public: - virtual bool hasValue(QString n){return hasMetaValue(this,n);} - virtual QVariant getValue(QString n){return getMetaValue(this,n);} + virtual bool hasValue(QString n)//{return hasMetaValue(this,n);} + { + const QMetaObject*mobj=metaObject(); + //look for property + int id=mobj->indexOfProperty(n.toLatin1().data()); + if(id>=0)return true; + //look for method + id=mobj->indexOfMethod(n.toLatin1().data()); + if(id<0)return false; + QMetaMethod mm=mobj->method(id); + if(mm.parameterNames().size()!=0)return false; + if(QString(mm.typeName()).isEmpty())return false; + return true; + } + virtual QVariant getValue(QString n)//{return getMetaValue(this,n);} + { + const QMetaObject*mobj=metaObject(); + //look for property + int id=mobj->indexOfProperty(n.toLatin1().data()); + if(id>=0)return mobj->property(id).read(this); + //look for method + id=mobj->indexOfMethod(n.toLatin1().data()); + if(id<0)return QVariant(); + QMetaMethod mm=mobj->method(id); + if(mm.parameterNames().size()!=0)return QVariant(); + if(QString(mm.typeName()).isEmpty())return QVariant(); + //try to invoke + int dataid=QMetaType::type(mm.typeName()); + void *data=QMetaType::create(dataid); + QVariant ret; + if(mm.invoke(this, Qt::DirectConnection, QGenericReturnArgument(mm.typeName(),data))) + ret=QVariant(dataid,data); + QMetaType::destroy(dataid,data); + return ret; + } }; class MOAItem:public MOADynamicObject -- 1.7.2.5