#ifndef RUNSCRIPTWIDGET_H
#define RUNSCRIPTWIDGET_H

#include <QtGui>
#include "ui_runscriptwidget.h"
#include "consoleoutmodel.h"  //For ConsoleOut namespace
#include "Python.h"

namespace Ui{
    class RunScriptWidget;
}

class RunScriptWidget : public QWidget{
    Q_OBJECT
public:
    RunScriptWidget(QWidget *parent);
    ~RunScriptWidget();

private:
    //This is the argv that will be passed to the script to be executed..
    char **argv;

    Ui::RunScriptWidget *ui;

    void runScript();

    QString scriptName, scriptPath, scriptDescription;
    QStringList scriptRequire, scriptOptional, scriptReturn;

    QStandardItemModel *argTableModel;
    QStandardItemModel *returnTableModel;

    QMenu *argMenu;

    QList<QAction*> argMenuAction;

signals:
    void sendConsoleOut(QString text, ConsoleOut::OutputType);
    void returnsChanged(QStringList returnNames, QStringList returnValues);

public slots:
    void loadScript(QString _scriptName, QString _scriptPath, QString _scriptDescription,
               QString _scriptRequire, QString _scriptOptional, QString _scriptReturn);

    void loadVariables(QStringList names, QStringList values);

    void argMenu_clicked();

    void clear();  //This happens when scripts are refreshed

private slots:
    void on_runScriptButton_clicked();

    //This is a 'helper', connects to datachanged, and calls returnsChanged
    void returnsChanged_helper();
};

#endif // RUNSCRIPTWIDGET_H
