fix order audit display
authorKonrad Rosenbaum <konrad@silmor.de>
Sat, 13 Aug 2016 11:40:05 +0000 (13:40 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Sat, 13 Aug 2016 11:40:05 +0000 (13:40 +0200)
src/dialogs/orderauditdlg_p.h

index 9c7cc17..050e338 100644 (file)
@@ -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