#include "NoticeObject.h"

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

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

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