swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <QObject> |
| 4 | #include <qqml.h> |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 5 | #include <QUuid> |
| 6 | #include <QHash> |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 7 | |
| 8 | class 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) |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 15 | Q_PROPERTY(QUuid uuid READ uuid NOTIFY uuidChanged) |
| 16 | Q_PROPERTY(int status READ status WRITE setStatus NOTIFY statusChanged) |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame^] | 17 | Q_PROPERTY(int resultType READ resultType WRITE setResultType NOTIFY resultTypeChanged) |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 18 | |
| 19 | public: |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 20 | ~Cell(); |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 21 | explicit Cell(QObject *parent = nullptr); |
| 22 | Cell(const Cell ©, QObject *parent = nullptr); |
| 23 | Cell(QString code, QString result, QObject *parent = nullptr); |
| 24 | |
| 25 | Cell &operator =(const Cell ©); |
| 26 | |
| 27 | QString code() const; |
| 28 | QString result() const; |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 29 | QUuid uuid() const; |
| 30 | int status() const; |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame^] | 31 | int resultType() const; |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 32 | |
| 33 | void setCode(QString code); |
| 34 | void setResult(QString result); |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 35 | void setStatus(int status); |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame^] | 36 | void setResultType(int resultType); |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 37 | |
| 38 | Q_INVOKABLE static Cell *cellFromUuid(QUuid uuid); |
| 39 | |
| 40 | enum Status |
| 41 | { |
| 42 | RUNNING, |
| 43 | IDLE, |
| 44 | WAITING, |
| 45 | }; |
| 46 | |
| 47 | Q_ENUM(Status); |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 48 | |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame^] | 49 | enum ResultType |
| 50 | { |
| 51 | EXPRESSION, |
| 52 | DIAGNOSTIC |
| 53 | }; |
| 54 | |
| 55 | Q_ENUM(ResultType) |
| 56 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 57 | signals: |
| 58 | void codeChanged(QString code); |
| 59 | void resultChanged(QString result); |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 60 | void uuidChanged(QUuid uuid); |
| 61 | void statusChanged(int status); |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame^] | 62 | void resultTypeChanged(int resultType); |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 63 | |
| 64 | private: |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame^] | 65 | int _status = IDLE, _resultType = EXPRESSION; |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 66 | QString _code, _result; |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 67 | QUuid _uuid = QUuid::createUuid(); |
| 68 | |
| 69 | static QHash<QUuid, Cell *> _cellUuids; |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | Q_DECLARE_METATYPE(Cell) |