#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(QObject *parent)
    : QObject(parent)
    , _cellModel(new CellModel(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.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);
}
