#include "Notebook.h"
#include "CellModel.h"
#include "../PPrint.h"

// TODO: avoid potential race condition if Cell is deleted, pass by value with same UUID instead

Notebook::~Notebook()
{
    _rtThread->quit();
    _rtThread->wait();
}

Notebook::Notebook(QObject *parent)
    : QObject(parent)
    , _cellModel(new CellModel(this))
    , _rt(new NbRuntime(this))
    , _rtThread(new QThread(this))
{
    connect(_rt, &NbRuntime::cellFailedToParse, this, &Notebook::cellFailedToParse);
    connect(_rt, &NbRuntime::cellFinishedRunning, this, &Notebook::cellFinishedRunning);
    connect(_rt, &NbRuntime::cellQuit, this, &Notebook::cellQuit);
    connect(_rt, &NbRuntime::cellRunning, this, &Notebook::cellRunning);
    connect(_rt, &NbRuntime::cellWaiting, this, &Notebook::cellWaiting);

    _rt->moveToThread(_rtThread);
    _rtThread->start();
}

Notebook::Notebook(const Notebook &other, QObject *parent)
    : Notebook(parent)
{
    for (const Cell *cell : other._cells)
    {
        _cells.append(new Cell(*cell, this));
    }
}

CellModel *Notebook::cellModel()
{
    return _cellModel;
}

void Notebook::runCell(QUuid uuid)
{
    qInfo() << "Running cell" << uuid;
    _rt->queueCell(Cell::cellFromUuid(uuid));
}

void Notebook::quitCell(QUuid uuid)
{
    _rt->unqueueCell(Cell::cellFromUuid(uuid));
}

void Notebook::cellFinishedRunning(Cell *cell, RuntimeResult result)
{
    qInfo() << "cellFinishedRunning" << cell->uuid() << pprint(result);
    cell->setResult(pprint(result));
    cell->setStatus(Cell::IDLE);
}

void Notebook::cellFailedToParse(Cell *cell, ParseResult result)
{
    qInfo() << "cellFailedToParse" << cell->uuid() << pprint(result);
    cell->setResult(pprint(result));
    cell->setStatus(Cell::IDLE);
}

void Notebook::cellWaiting(Cell *cell)
{
    qInfo() << "cellWaiting" << cell->uuid();
    cell->setStatus(Cell::WAITING);
}

void Notebook::cellRunning(Cell *cell)
{
    qInfo() << "cellRunning" << cell->uuid();
    cell->setStatus(Cell::RUNNING);
}

void Notebook::cellQuit(Cell *cell)
{
    qInfo() << "cellQuit" << cell->uuid();
    cell->setResult("");
    cell->setStatus(Cell::IDLE);
}
