blob: 85d20a397b5fb84a8a0481ded2c5d9159bf0f471 [file] [log] [blame]
swissChili4b3105a2022-02-22 16:34:39 -08001#include "Cell.h"
2
swissChilid85daa92022-02-24 15:29:02 -08003QHash<QUuid, Cell *> Cell::_cellUuids = QHash<QUuid, Cell*>();
4
5Cell::~Cell()
6{
7 _cellUuids.remove(_uuid);
8}
9
swissChili4b3105a2022-02-22 16:34:39 -080010Cell::Cell(QObject *parent) : QObject(parent)
11{
swissChilid85daa92022-02-24 15:29:02 -080012 _cellUuids[_uuid] = this;
swissChili4b3105a2022-02-22 16:34:39 -080013}
14
15Cell::Cell(const Cell &copy, QObject *parent)
16 : Cell(parent)
17{
18 *this = copy;
19}
20
21Cell::Cell(QString code, QString result, QObject *parent)
22 : Cell(parent)
23{
24 setCode(code);
25 setResult(result);
26}
27
28Cell &Cell::operator =(const Cell &copy)
29{
30 setCode(copy.code());
31 setResult(copy.result());
32
33 return *this;
34}
35
36QString Cell::code() const
37{
38 return _code;
39}
40
41QString Cell::result() const
42{
43 return _result;
44}
45
swissChilid85daa92022-02-24 15:29:02 -080046QUuid Cell::uuid() const
47{
48 return _uuid;
49}
50
51int Cell::status() const
52{
53 return _status;
54}
55
swissChiliece1ac82022-02-25 11:20:42 -080056int Cell::resultType() const
57{
58 return _resultType;
59}
60
swissChili4b3105a2022-02-22 16:34:39 -080061void Cell::setCode(QString code)
62{
63 _code = code;
64 emit codeChanged(code);
65}
66
67void Cell::setResult(QString result)
68{
69 _result = result;
70 emit resultChanged(result);
71}
swissChilid85daa92022-02-24 15:29:02 -080072
73void Cell::setStatus(int status)
74{
75 _status = status;
76 emit statusChanged(status);
77}
78
swissChiliece1ac82022-02-25 11:20:42 -080079void Cell::setResultType(int resultType)
80{
81 _resultType = resultType;
82 emit resultTypeChanged(resultType);
83}
84
swissChilid85daa92022-02-24 15:29:02 -080085Cell *Cell::cellFromUuid(QUuid uuid)
86{
87 if (_cellUuids.contains(uuid))
88 return _cellUuids[uuid];
89 else
90 return nullptr;
91}
swissChili505de412022-03-24 12:35:08 -070092
swissChilid2af6ad2022-04-16 14:42:17 -070093void Cell::fromJson(QJsonObject json)
94{
95 setCode(json["code"].toString());
96 setResult(json["result"].toString());
97 setStatus(json["status"].toInt());
98 setResultType(json["resultType"].toInt());
99}
100
swissChili505de412022-03-24 12:35:08 -0700101QJsonObject Cell::toJson() const
102{
103 QJsonObject object;
104
105 object["code"] = code();
106 object["result"] = result();
107 object["status"] = status();
108 object["resultType"] = resultType();
109
110 return object;
111}