blob: 1a0206e5c45c5c22eddb8db801e9c11570d5afbe [file] [log] [blame]
swissChili25620b02022-02-23 17:15:16 -08001#pragma once
2
3#include <QObject>
4
5#include "Cell.h"
swissChilid85daa92022-02-24 15:29:02 -08006#include "NbRuntime.h"
swissChilie386bc72022-02-24 21:31:31 -08007#include "CellModel.h"
swissChili25620b02022-02-23 17:15:16 -08008
9class Notebook : public QObject
10{
11 Q_OBJECT
12 QML_ELEMENT
13
14 Q_PROPERTY(CellModel *cellModel READ cellModel NOTIFY cellModelChanged)
15
16public:
swissChili732628e2022-02-25 10:35:56 -080017 ~Notebook();
swissChili25620b02022-02-23 17:15:16 -080018 explicit Notebook(QObject *parent = nullptr);
19 Notebook(const Notebook &other, QObject *parent = nullptr);
20
21 CellModel *cellModel();
22
swissChilid85daa92022-02-24 15:29:02 -080023 Q_INVOKABLE void runCell(QUuid uuid);
24 Q_INVOKABLE void quitCell(QUuid uuid);
25
swissChili25620b02022-02-23 17:15:16 -080026signals:
27 void cellModelChanged();
28
swissChilid85daa92022-02-24 15:29:02 -080029protected slots:
30 void cellFinishedRunning(Cell *cell, RuntimeResult result);
swissChiliece1ac82022-02-25 11:20:42 -080031 void cellFailedToParse(Cell *cell, ParseResult result, Parser parser);
swissChilid85daa92022-02-24 15:29:02 -080032 void cellWaiting(Cell *cell);
33 void cellRunning(Cell *cell);
34 void cellQuit(Cell *cell);
35
swissChili25620b02022-02-23 17:15:16 -080036protected:
37 friend class CellModel;
38
swissChilid85daa92022-02-24 15:29:02 -080039 QList<Cell *> _cells;
swissChili25620b02022-02-23 17:15:16 -080040 CellModel *_cellModel;
swissChili732628e2022-02-25 10:35:56 -080041 QThread *_rtThread;
swissChiliece1ac82022-02-25 11:20:42 -080042 NbRuntime *_rt;
swissChili25620b02022-02-23 17:15:16 -080043};
44
45Q_DECLARE_METATYPE(Notebook)