swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <QObject> |
| 4 | |
| 5 | #include "Cell.h" |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 6 | #include "NbRuntime.h" |
swissChili | e386bc7 | 2022-02-24 21:31:31 -0800 | [diff] [blame] | 7 | #include "CellModel.h" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 8 | |
| 9 | class Notebook : public QObject |
| 10 | { |
| 11 | Q_OBJECT |
| 12 | QML_ELEMENT |
| 13 | |
| 14 | Q_PROPERTY(CellModel *cellModel READ cellModel NOTIFY cellModelChanged) |
| 15 | |
| 16 | public: |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 17 | ~Notebook(); |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 18 | explicit Notebook(QObject *parent = nullptr); |
| 19 | Notebook(const Notebook &other, QObject *parent = nullptr); |
| 20 | |
| 21 | CellModel *cellModel(); |
| 22 | |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 23 | Q_INVOKABLE void runCell(QUuid uuid); |
| 24 | Q_INVOKABLE void quitCell(QUuid uuid); |
| 25 | |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 26 | signals: |
| 27 | void cellModelChanged(); |
| 28 | |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 29 | protected slots: |
| 30 | void cellFinishedRunning(Cell *cell, RuntimeResult result); |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame] | 31 | void cellFailedToParse(Cell *cell, ParseResult result, Parser parser); |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 32 | void cellWaiting(Cell *cell); |
| 33 | void cellRunning(Cell *cell); |
| 34 | void cellQuit(Cell *cell); |
| 35 | |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 36 | protected: |
| 37 | friend class CellModel; |
| 38 | |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 39 | QList<Cell *> _cells; |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 40 | CellModel *_cellModel; |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 41 | QThread *_rtThread; |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame] | 42 | NbRuntime *_rt; |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | Q_DECLARE_METATYPE(Notebook) |