191 lines
3.9 KiB
C++
191 lines
3.9 KiB
C++
#include "device.h"
|
|
|
|
Device::Device()
|
|
{}
|
|
|
|
Device::~Device()
|
|
{}
|
|
|
|
QString Device::serialNumber() const
|
|
{
|
|
return _serialNumber;
|
|
}
|
|
|
|
void Device::setSerialNumber(const QString &newSerialNumber)
|
|
{
|
|
_serialNumber = newSerialNumber;
|
|
}
|
|
|
|
QDateTime Device::purchaseDate() const
|
|
{
|
|
return _purchaseDate;
|
|
}
|
|
|
|
void Device::setPurchaseDate(const QDateTime &newPurchaseDate)
|
|
{
|
|
_purchaseDate = newPurchaseDate;
|
|
}
|
|
|
|
double Device::price() const
|
|
{
|
|
return _price;
|
|
}
|
|
|
|
void Device::setPrice(double newPrice)
|
|
{
|
|
_price = newPrice;
|
|
}
|
|
|
|
QDateTime Device::warrantyExpireDate() const
|
|
{
|
|
return _warrantyExpireDate;
|
|
}
|
|
|
|
void Device::setWarrantyExpireDate(const QDateTime &newWarrantyExpireDate)
|
|
{
|
|
_warrantyExpireDate = newWarrantyExpireDate;
|
|
}
|
|
|
|
bool Device::isWorking() const
|
|
{
|
|
return _isWorking;
|
|
}
|
|
|
|
void Device::setIsWorking(bool newIsWorking)
|
|
{
|
|
_isWorking = newIsWorking;
|
|
}
|
|
|
|
QString Device::furtherInformation() const
|
|
{
|
|
return _furtherInformation;
|
|
}
|
|
|
|
void Device::setFurtherInformation(const QString &newFurtherInformation)
|
|
{
|
|
_furtherInformation = newFurtherInformation;
|
|
}
|
|
|
|
int Device::idLocation() const
|
|
{
|
|
return _idLocation;
|
|
}
|
|
|
|
void Device::setIdLocation(int newIdLocation)
|
|
{
|
|
_idLocation = newIdLocation;
|
|
}
|
|
|
|
QString Device::nameLocation() const
|
|
{
|
|
return _nameLocation;
|
|
}
|
|
|
|
void Device::setNameLocation(const QString &newNameLocation)
|
|
{
|
|
_nameLocation = newNameLocation;
|
|
}
|
|
|
|
int Device::idEmployee() const
|
|
{
|
|
return _idEmployee;
|
|
}
|
|
|
|
void Device::setIdEmployee(int newIdEmployee)
|
|
{
|
|
_idEmployee = newIdEmployee;
|
|
}
|
|
|
|
QString Device::nameEmployee() const
|
|
{
|
|
return _nameEmployee;
|
|
}
|
|
|
|
void Device::setNameEmployee(const QString &newNameEmployee)
|
|
{
|
|
_nameEmployee = newNameEmployee;
|
|
}
|
|
|
|
int Device::idDepartment() const
|
|
{
|
|
return _idDepartment;
|
|
}
|
|
|
|
void Device::setIdDepartment(int newIdDepartment)
|
|
{
|
|
_idDepartment = newIdDepartment;
|
|
}
|
|
|
|
QString Device::nameDepartment() const
|
|
{
|
|
return _nameDepartment;
|
|
}
|
|
|
|
void Device::setNameDepartment(const QString &newNameDepartment)
|
|
{
|
|
_nameDepartment = newNameDepartment;
|
|
}
|
|
|
|
DeviceModel Device::deviceModel() const
|
|
{
|
|
return _deviceModel;
|
|
}
|
|
|
|
void Device::setDeviceModel(const DeviceModel &newDeviceModel)
|
|
{
|
|
_deviceModel = newDeviceModel;
|
|
}
|
|
|
|
bool Device::isLiked() const
|
|
{
|
|
return _isLiked;
|
|
}
|
|
|
|
void Device::setIsLiked(bool newIsLiked)
|
|
{
|
|
_isLiked = newIsLiked;
|
|
}
|
|
|
|
void Device::fromJson(const QJsonObject &json)
|
|
{
|
|
setId(json["id"].toInt());
|
|
setSerialNumber(json["serialNumber"].toString());
|
|
setPurchaseDate(QDateTime::fromString(json["purchaseDate"].toString(), Qt::ISODate));
|
|
setPrice(json["price"].toDouble());
|
|
setWarrantyExpireDate(QDateTime::fromString(json["warrantyExpireDate"].toString(), Qt::ISODate));
|
|
setIsWorking(json["isWorking"].toBool());
|
|
setFurtherInformation(json["furtherInformation"].toString());
|
|
setIdLocation(json["idLocation"].toInt());
|
|
setNameLocation(json["nameLocation"].toString());
|
|
setIdEmployee(json["idEmployee"].toInt());
|
|
setNameEmployee(json["nameEmployee"].toString());
|
|
setIdDepartment(json["idDepartment"].toInt());
|
|
setNameDepartment(json["nameDepartment"].toString());
|
|
setIsLiked(json["isLiked"].toBool());
|
|
|
|
DeviceModel model;
|
|
model.fromJson(json["deviceModel"].toObject());
|
|
setDeviceModel(model);
|
|
}
|
|
|
|
QJsonObject Device::toJson() const
|
|
{
|
|
QJsonObject obj;
|
|
obj["id"] = id();
|
|
obj["serialNumber"] = serialNumber();
|
|
obj["purchaseDate"] = purchaseDate().toString(Qt::ISODate);
|
|
obj["price"] = price();
|
|
obj["warrantyExpireDate"] = warrantyExpireDate().toString(Qt::ISODate);
|
|
obj["isWorking"] = isWorking();
|
|
obj["furtherInformation"] = furtherInformation();
|
|
obj["idLocation"] = idLocation();
|
|
obj["nameLocation"] = nameLocation();
|
|
obj["idEmployee"] = idEmployee();
|
|
obj["nameEmployee"] = nameEmployee();
|
|
obj["idDepartment"] = idDepartment();
|
|
obj["nameDepartment"] = nameDepartment();
|
|
obj["deviceModel"] = deviceModel().toJson();
|
|
obj["isLiked"] = isLiked();
|
|
return obj;
|
|
}
|