#include "modelinfo.h"

ModelInfo::ModelInfo()
{

}

//QJsonObject BoxModel::toObject()
//{
//    QJsonObject obj;
//    QJsonObject line1;//文本和下拉框的第一排
//    QJsonObject line2;//文本和下拉框的第二排

//    obj.insert("ModelName",ModelName);

//    line1.insert("text1_1",text1_1);
//    line1.insert("text2_1",text2_1);
//    line1.insert("text3_1",text3_1);
//    line1.insert("text4_1",text4_1);
//    line1.insert("text5_1",text5_1);

//    line2.insert("text1_2",text1_2);
//    line2.insert("text2_2",text2_2);
//    line2.insert("text3_2",text3_2);
//    line2.insert("text4_2",text4_2);
//    line2.insert("text5_2",text5_2);

//    line1.insert("data1_1",data1_1);
//    line1.insert("data2_1",data2_1);
//    line1.insert("data3_1",data3_1);
//    line1.insert("data4_1",data4_1);
//    line1.insert("data5_1",data5_1);

//    line2.insert("data1_2",data1_2);
//    line2.insert("data2_2",data2_2);
//    line2.insert("data3_2",data3_2);
//    line2.insert("data4_2",data4_2);
//    line2.insert("data5_2",data5_2);

//    obj.insert("line1",line1);
//    obj.insert("line2",line2);

//    return obj;
//}

//QSharedPointer<BoxModel> BoxModel::fromObject(QJsonObject &obj)
//{
//    QString model_name = obj.value("ModelName").toString();
//    if(model_name.isEmpty()) return QSharedPointer<BoxModel>();
//    QSharedPointer<BoxModel> ret(new BoxModel);

//    QJsonObject line1 = obj.value("line1").toObject();
//    QJsonObject line2 = obj.value("line2").toObject();

//    ret->ModelName = obj.value("ModelName").toString();

//    ret->text1_1 = line1.value("text1_1").toString();
//    ret->text2_1 = line1.value("text2_1").toString();
//    ret->text3_1 = line1.value("text3_1").toString();
//    ret->text4_1 = line1.value("text4_1").toString();
//    ret->text5_1 = line1.value("text5_1").toString();
//    ret->text1_2 = line2.value("text1_2").toString();
//    ret->text2_2 = line2.value("text2_2").toString();
//    ret->text3_2 = line2.value("text3_2").toString();
//    ret->text4_2 = line2.value("text4_2").toString();
//    ret->text5_2 = line2.value("text5_2").toString();

//    ret->data1_1 = line1.value("data1_1").toString();
//    ret->data2_1 = line1.value("data2_1").toString();
//    ret->data3_1 = line1.value("data3_1").toString();
//    ret->data4_1 = line1.value("data4_1").toString();
//    ret->data5_1 = line1.value("data5_1").toString();
//    ret->data1_2 = line2.value("data1_2").toString();
//    ret->data2_2 = line2.value("data2_2").toString();
//    ret->data3_2 = line2.value("data3_2").toString();
//    ret->data4_2 = line2.value("data4_2").toString();
//    ret->data5_2 = line2.value("data5_2").toString();

//    return ret;
//}

QJsonObject BoxModel::toObject()
{
    QJsonObject obj;
    obj.insert("baseModel_Name",baseModel_Name);
    obj.insert("Model_Name",Model_Name);
    obj.insert("Type_Name",Type_Name);
    obj.insert("Type_Data",Type_Data);

    return obj;
}

QSharedPointer<BoxModel> BoxModel::fromObject(QJsonObject &obj)
{
    QSharedPointer<BoxModel> ret(new BoxModel);

    ret->baseModel_Name = obj.value("baseModel_Name").toString();
    ret->Model_Name = obj.value("Model_Name").toString();

    ret->Type_Name = obj.value("Type_Name").toArray();
    ret->Type_Data = obj.value("Type_Data").toArray();

    return ret;
}

QJsonObject PackModel::toObject()
{
    QJsonObject obj;

    obj.insert("BaseModel_Name",BaseModel_Name);
    obj.insert("Model_Name",Model_Name);
    obj.insert("Type_Name",Type_Name);
    obj.insert("Type_Data",Type_Data);

    return obj;
}

QSharedPointer<PackModel> PackModel::fromObject(QJsonObject &obj)
{
    QSharedPointer<PackModel> ret(new PackModel);

    ret->BaseModel_Name = obj.value("BaseModel_Name").toString();
    ret->Model_Name = obj.value("Model_Name").toString();

    ret->Type_Name = obj.value("Type_Name").toArray();
    ret->Type_Data = obj.value("Type_Data").toArray();

    return ret;
}
