| #pragma once |
| |
| #include <QObject> |
| #include <qqml.h> |
| #include <QUuid> |
| #include <QHash> |
| #include <QJsonObject> |
| |
| class Cell : public QObject |
| { |
| Q_OBJECT |
| QML_ELEMENT |
| |
| Q_PROPERTY(QString code READ code WRITE setCode NOTIFY codeChanged) |
| Q_PROPERTY(QString result READ result WRITE setResult NOTIFY resultChanged) |
| Q_PROPERTY(QUuid uuid READ uuid NOTIFY uuidChanged) |
| Q_PROPERTY(int status READ status WRITE setStatus NOTIFY statusChanged) |
| Q_PROPERTY(int resultType READ resultType WRITE setResultType NOTIFY resultTypeChanged) |
| |
| public: |
| ~Cell(); |
| explicit Cell(QObject *parent = nullptr); |
| Cell(const Cell ©, QObject *parent = nullptr); |
| Cell(QString code, QString result, QObject *parent = nullptr); |
| |
| Cell &operator =(const Cell ©); |
| |
| QString code() const; |
| QString result() const; |
| QUuid uuid() const; |
| int status() const; |
| int resultType() const; |
| |
| void setCode(QString code); |
| void setResult(QString result); |
| void setStatus(int status); |
| void setResultType(int resultType); |
| |
| Q_INVOKABLE static Cell *cellFromUuid(QUuid uuid); |
| |
| Q_INVOKABLE void fromJson(QJsonObject json); |
| Q_INVOKABLE QJsonObject toJson() const; |
| |
| enum Status |
| { |
| RUNNING, |
| IDLE, |
| WAITING, |
| }; |
| |
| Q_ENUM(Status); |
| |
| enum ResultType |
| { |
| EXPRESSION, |
| DIAGNOSTIC |
| }; |
| |
| Q_ENUM(ResultType) |
| |
| signals: |
| void codeChanged(QString code); |
| void resultChanged(QString result); |
| void uuidChanged(QUuid uuid); |
| void statusChanged(int status); |
| void resultTypeChanged(int resultType); |
| |
| private: |
| int _status = IDLE, _resultType = EXPRESSION; |
| QString _code, _result; |
| QUuid _uuid = QUuid::createUuid(); |
| |
| static QHash<QUuid, Cell *> _cellUuids; |
| }; |
| |
| Q_DECLARE_METATYPE(Cell) |