swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 1 | #include "Cell.h" |
| 2 | |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 3 | QHash<QUuid, Cell *> Cell::_cellUuids = QHash<QUuid, Cell*>(); |
| 4 | |
| 5 | Cell::~Cell() |
| 6 | { |
| 7 | _cellUuids.remove(_uuid); |
| 8 | } |
| 9 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 10 | Cell::Cell(QObject *parent) : QObject(parent) |
| 11 | { |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 12 | _cellUuids[_uuid] = this; |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | Cell::Cell(const Cell ©, QObject *parent) |
| 16 | : Cell(parent) |
| 17 | { |
| 18 | *this = copy; |
| 19 | } |
| 20 | |
| 21 | Cell::Cell(QString code, QString result, QObject *parent) |
| 22 | : Cell(parent) |
| 23 | { |
| 24 | setCode(code); |
| 25 | setResult(result); |
| 26 | } |
| 27 | |
| 28 | Cell &Cell::operator =(const Cell ©) |
| 29 | { |
| 30 | setCode(copy.code()); |
| 31 | setResult(copy.result()); |
| 32 | |
| 33 | return *this; |
| 34 | } |
| 35 | |
| 36 | QString Cell::code() const |
| 37 | { |
| 38 | return _code; |
| 39 | } |
| 40 | |
| 41 | QString Cell::result() const |
| 42 | { |
| 43 | return _result; |
| 44 | } |
| 45 | |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 46 | QUuid Cell::uuid() const |
| 47 | { |
| 48 | return _uuid; |
| 49 | } |
| 50 | |
| 51 | int Cell::status() const |
| 52 | { |
| 53 | return _status; |
| 54 | } |
| 55 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 56 | void Cell::setCode(QString code) |
| 57 | { |
| 58 | _code = code; |
| 59 | emit codeChanged(code); |
| 60 | } |
| 61 | |
| 62 | void Cell::setResult(QString result) |
| 63 | { |
| 64 | _result = result; |
| 65 | emit resultChanged(result); |
| 66 | } |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 67 | |
| 68 | void Cell::setStatus(int status) |
| 69 | { |
| 70 | _status = status; |
| 71 | emit statusChanged(status); |
| 72 | } |
| 73 | |
| 74 | Cell *Cell::cellFromUuid(QUuid uuid) |
| 75 | { |
| 76 | if (_cellUuids.contains(uuid)) |
| 77 | return _cellUuids[uuid]; |
| 78 | else |
| 79 | return nullptr; |
| 80 | } |