#include "PosMateDataObject.h"

PosMateDataObject::PosMateDataObject(const PosMateDataObject &posMateDataObj, QObject *parent):QObject(parent)
{
    const QMetaObject *m = posMateDataObj.metaObject();
    for( int i=m->propertyOffset(); i<m->propertyCount(); i++)
    {
        QMetaProperty qmp = m->property(i);
        QString key = QString::fromLatin1(qmp.name());
        QVariant value = posMateDataObj.property(key.toUtf8());
        this->setProperty(key.toUtf8(), value);
    }
}


PosMateDataObject& PosMateDataObject::operator =(const PosMateDataObject& posMateDataObj)
{
    const QMetaObject *m = posMateDataObj.metaObject();
    for( int i=m->propertyOffset(); i<m->propertyCount(); i++)
    {
        QMetaProperty qmp = m->property(i);
        QString key = QString::fromLatin1(qmp.name());
        QVariant value = posMateDataObj.property(key.toUtf8());
        this->setProperty(key.toUtf8(), value);
    }
    return *this;
}


/*
void PosMateDataObject::FetchDataFromJson(const QJsonObject &json)
{
    foreach(QString key,  json.keys())
    {
        setProperty(key.toUtf8(), json[key].toVariant());
    }
    return;
}
*/
