blob: fb5bc42b71463acdbf689c71673591ba8b3c2bad [file] [log] [blame]
swissChili4b3105a2022-02-22 16:34:39 -08001#pragma once
2
3#include <QObject>
4#include <qqml.h>
swissChilid85daa92022-02-24 15:29:02 -08005#include <QUuid>
6#include <QHash>
swissChili4b3105a2022-02-22 16:34:39 -08007
8class Cell : public QObject
9{
10 Q_OBJECT
11 QML_ELEMENT
12
13 Q_PROPERTY(QString code READ code WRITE setCode NOTIFY codeChanged)
14 Q_PROPERTY(QString result READ result WRITE setResult NOTIFY resultChanged)
swissChilid85daa92022-02-24 15:29:02 -080015 Q_PROPERTY(QUuid uuid READ uuid NOTIFY uuidChanged)
16 Q_PROPERTY(int status READ status WRITE setStatus NOTIFY statusChanged)
swissChili4b3105a2022-02-22 16:34:39 -080017
18public:
swissChilid85daa92022-02-24 15:29:02 -080019 ~Cell();
swissChili4b3105a2022-02-22 16:34:39 -080020 explicit Cell(QObject *parent = nullptr);
21 Cell(const Cell &copy, QObject *parent = nullptr);
22 Cell(QString code, QString result, QObject *parent = nullptr);
23
24 Cell &operator =(const Cell &copy);
25
26 QString code() const;
27 QString result() const;
swissChilid85daa92022-02-24 15:29:02 -080028 QUuid uuid() const;
29 int status() const;
swissChili4b3105a2022-02-22 16:34:39 -080030
31 void setCode(QString code);
32 void setResult(QString result);
swissChilid85daa92022-02-24 15:29:02 -080033 void setStatus(int status);
34
35 Q_INVOKABLE static Cell *cellFromUuid(QUuid uuid);
36
37 enum Status
38 {
39 RUNNING,
40 IDLE,
41 WAITING,
42 };
43
44 Q_ENUM(Status);
swissChili4b3105a2022-02-22 16:34:39 -080045
46signals:
47 void codeChanged(QString code);
48 void resultChanged(QString result);
swissChilid85daa92022-02-24 15:29:02 -080049 void uuidChanged(QUuid uuid);
50 void statusChanged(int status);
swissChili4b3105a2022-02-22 16:34:39 -080051
52private:
swissChilid85daa92022-02-24 15:29:02 -080053 int _status = IDLE;
swissChili4b3105a2022-02-22 16:34:39 -080054 QString _code, _result;
swissChilid85daa92022-02-24 15:29:02 -080055 QUuid _uuid = QUuid::createUuid();
56
57 static QHash<QUuid, Cell *> _cellUuids;
swissChili4b3105a2022-02-22 16:34:39 -080058};
59
60Q_DECLARE_METATYPE(Cell)