forked from ondra/colnod-connector
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#include <QJsonObject>
|
|
#include "entity.h"
|
|
|
|
const QUuid &Entity::getId() const {
|
|
return id;
|
|
}
|
|
|
|
void Entity::setId(const QUuid &id) {
|
|
Entity::id = id;
|
|
}
|
|
|
|
const QString &Entity::getName() const {
|
|
return name;
|
|
}
|
|
|
|
void Entity::setName(const QString &name) {
|
|
Entity::name = name;
|
|
}
|
|
|
|
const QString &Entity::getDescription() const {
|
|
return description;
|
|
}
|
|
|
|
void Entity::setDescription(const QString &description) {
|
|
Entity::description = description;
|
|
}
|
|
|
|
quint64 Entity::getLastUpdate() const {
|
|
return lastUpdate;
|
|
}
|
|
|
|
void Entity::setLastUpdate(quint64 lastUpdate) {
|
|
this->lastUpdate = lastUpdate;
|
|
}
|
|
|
|
QString Entity::idToStringWithoutBraces() const
|
|
{
|
|
const qint8 lengthOfUuid = 36;
|
|
return id.toString().mid(1, lengthOfUuid);
|
|
}
|
|
|
|
void Entity::fromJSON(const QJsonObject &json) {
|
|
id = json.value("id").toString();
|
|
name = json.value("name").toString();
|
|
description = json.value("description").toString();
|
|
lastUpdate = json.value("lastUpdate").toDouble();
|
|
}
|
|
|
|
QJsonObject Entity::toJSON() const {
|
|
QJsonObject json;
|
|
|
|
json.value("id") = this->idToStringWithoutBraces();
|
|
json.value("name") = name;
|
|
json.value("description") = description;
|
|
json.value("lastUpdate") = lastUpdate;
|
|
|
|
return json;
|
|
}
|