From: Konrad Rosenbaum Date: Sat, 13 Aug 2016 11:40:05 +0000 (+0200) Subject: fix order audit display X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=91988c912e1c1f0b90d8f2006107302b58417a75;p=web%2Fkonrad%2Fsmoke.git fix order audit display --- 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