191 lines
4.1 KiB
C++
191 lines
4.1 KiB
C++
#include "devicemodel.h"
|
|
|
|
DeviceModel::DeviceModel()
|
|
{}
|
|
|
|
DeviceModel::~DeviceModel()
|
|
{}
|
|
|
|
QString DeviceModel::name() const
|
|
{
|
|
return _name;
|
|
}
|
|
|
|
void DeviceModel::setName(const QString &newName)
|
|
{
|
|
_name = newName;
|
|
}
|
|
|
|
QString DeviceModel::description() const
|
|
{
|
|
return _description;
|
|
}
|
|
|
|
void DeviceModel::setDescription(const QString &newDescription)
|
|
{
|
|
_description = newDescription;
|
|
}
|
|
|
|
int DeviceModel::workEfficiency() const
|
|
{
|
|
return _workEfficiency;
|
|
}
|
|
|
|
void DeviceModel::setWorkEfficiency(int newWorkEfficiency)
|
|
{
|
|
_workEfficiency = newWorkEfficiency;
|
|
}
|
|
|
|
int DeviceModel::reliability() const
|
|
{
|
|
return _reliability;
|
|
}
|
|
|
|
void DeviceModel::setReliability(int newReliability)
|
|
{
|
|
_reliability = newReliability;
|
|
}
|
|
|
|
int DeviceModel::energyEfficiency() const
|
|
{
|
|
return _energyEfficiency;
|
|
}
|
|
|
|
void DeviceModel::setEnergyEfficiency(int newEnergyEfficiency)
|
|
{
|
|
_energyEfficiency = newEnergyEfficiency;
|
|
}
|
|
|
|
int DeviceModel::userFriendliness() const
|
|
{
|
|
return _userFriendliness;
|
|
}
|
|
|
|
void DeviceModel::setUserFriendliness(int newUserFriendliness)
|
|
{
|
|
_userFriendliness = newUserFriendliness;
|
|
}
|
|
|
|
int DeviceModel::durability() const
|
|
{
|
|
return _durability;
|
|
}
|
|
|
|
void DeviceModel::setDurability(int newDurability)
|
|
{
|
|
_durability = newDurability;
|
|
}
|
|
|
|
int DeviceModel::aestheticQualities() const
|
|
{
|
|
return _aestheticQualities;
|
|
}
|
|
|
|
void DeviceModel::setAestheticQualities(int newAestheticQualities)
|
|
{
|
|
_aestheticQualities = newAestheticQualities;
|
|
}
|
|
|
|
int DeviceModel::idType() const
|
|
{
|
|
return _idType;
|
|
}
|
|
|
|
void DeviceModel::setIdType(int newIdType)
|
|
{
|
|
_idType = newIdType;
|
|
}
|
|
|
|
QString DeviceModel::nameType() const
|
|
{
|
|
return _nameType;
|
|
}
|
|
|
|
void DeviceModel::setNameType(const QString &newNameType)
|
|
{
|
|
_nameType = newNameType;
|
|
}
|
|
|
|
int DeviceModel::idManuf() const
|
|
{
|
|
return _idManuf;
|
|
}
|
|
|
|
void DeviceModel::setIdManuf(int newIdManuf)
|
|
{
|
|
_idManuf = newIdManuf;
|
|
}
|
|
|
|
QString DeviceModel::nameManuf() const
|
|
{
|
|
return _nameManuf;
|
|
}
|
|
|
|
void DeviceModel::setNameManuf(const QString &newNameManuf)
|
|
{
|
|
_nameManuf = newNameManuf;
|
|
}
|
|
|
|
QList<DeviceStructureElement> DeviceModel::structureElements() const
|
|
{
|
|
return _structureElements;
|
|
}
|
|
|
|
void DeviceModel::setStructureElements(const QList<DeviceStructureElement> &newStructureElements)
|
|
{
|
|
_structureElements = newStructureElements;
|
|
}
|
|
|
|
void DeviceModel::fromJson(const QJsonObject &json)
|
|
{
|
|
setId(json["id"].toInt());
|
|
setName(json["name"].toString());
|
|
setDescription(json["description"].toString());
|
|
setWorkEfficiency(json["workEfficiency"].toInt());
|
|
setReliability(json["reliability"].toInt());
|
|
setEnergyEfficiency(json["energyEfficiency"].toInt());
|
|
setUserFriendliness(json["userFriendliness"].toInt());
|
|
setDurability(json["durability"].toInt());
|
|
setAestheticQualities(json["aestheticQualities"].toInt());
|
|
setIdType(json["idType"].toInt());
|
|
setNameType(json["nameType"].toString());
|
|
setIdManuf(json["idManuf"].toInt());
|
|
setNameManuf(json["nameManuf"].toString());
|
|
|
|
QJsonArray structureElementsArray = json["structureElements"].toArray();
|
|
QList<DeviceStructureElement> elements;
|
|
for (const QJsonValue &value : structureElementsArray) {
|
|
DeviceStructureElement element;
|
|
element.fromJson(value.toObject());
|
|
elements.append(element);
|
|
}
|
|
setStructureElements(elements);
|
|
}
|
|
|
|
QJsonObject DeviceModel::toJson() const
|
|
{
|
|
QJsonObject obj;
|
|
|
|
obj["id"] = id();
|
|
obj["name"] = name();
|
|
obj["description"] = description();
|
|
obj["workEfficiency"] = workEfficiency();
|
|
obj["reliability"] = reliability();
|
|
obj["energyEfficiency"] = energyEfficiency();
|
|
obj["userFriendliness"] = userFriendliness();
|
|
obj["durability"] = durability();
|
|
obj["aestheticQualities"] = aestheticQualities();
|
|
obj["idType"] = idType();
|
|
obj["nameType"] = nameType();
|
|
obj["idManuf"] = idManuf();
|
|
obj["nameManuf"] = nameManuf();
|
|
|
|
QJsonArray structureElementsArray;
|
|
for (const DeviceStructureElement &element : structureElements()) {
|
|
structureElementsArray.append(element.toJson());
|
|
}
|
|
obj["structureElements"] = structureElementsArray;
|
|
|
|
return obj;
|
|
}
|