//NB: Icons liscenced under the LGPL

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>
#include <QFileSystemModel>

#include "scriptlistmodel.h"
#include "variableswidgetdialog.h"
#include "consoleoutmodel.h"
#include "variablestablemodel.h"
#include "drawpointsdialog.h"
#include "configdialog.h"
#include "mainimagegraphicsview.h"

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::MainWindow *ui;
    /*Useful Variables*/
    QString currentImagePath;
    QString currentVariablesPath;
    QString externalTextEditor;
    QString externalMidiPlayer;
    QString scriptsDirectory;

    /*File List Widget */
    QFileSystemModel *imageFileModel;
    //TODO:  This needs to have a default value
    QString rootPath;
    QString rootIndex;

    /*Main Image Display Widget */

    /*Variables Widget*/
    VariablesTableModel *variablesModel;
    QMenu *variablesWidgetMenu;
    QMenu *retMenu;
    QList<QAction*> retMenuAction;
    QMenu *addMenu;
    QProcess *extMidiPlayer;

    /*Scripts Widget*/
    ScriptListModel *scriptsModel;

    /*ConsoleOutModel*/
    ConsoleOutModel *consoleOutModel;

signals:
    //To help  connect script list widget to run script widget,
    //   this is tied to scriptListView_activated
    void scriptChanged(QString scriptName, QString scriptPath, QString scriptDescription,
        QString scriptRequire, QString scriptOptional, QString scriptReturn);
    void sendConsoleOut(QString text, ConsoleOut::OutputType);

public slots:
    //To help  connect script list wiget to run script widget
    void scriptListView_activated(const QModelIndex &index);
    void extMidiPlayer_finished(int exitCode);

private slots:
    void on_actionHelp_Contents_triggered();
    void on_actionAdd_Blank_Variable_triggered();
    void on_action_Insert_Variable_File_Path_s_triggered();
    void on_actionRefresh_Image_triggered();
    void on_actionImport_Variables_triggered();
    void on_actionPreferences_triggered();
    void on_actionOpen_Image_triggered();
    void on_actionSet_Current_Image_from_Variable_triggered();
    void on_actionKill_External_Midi_Player_triggered();
    void on_actionPlay_Variable_in_External_Midi_Player_triggered();
    void on_variablesViewDownB_clicked();
    void on_variablesViewUpB_clicked();
    void on_actionRefresh_Scripts_triggered();
    void on_actionEdit_Script_triggered();
    void on_actionAddVarImagePath_triggered();
    void on_actionAddVarPoints_triggered();
    void on_actionSplash_Screen_triggered();
    void on_actionSave_Variables_As_triggered();
    void on_actionOpen_Variables_triggered();
    void on_actionSave_Variables_triggered();
    void on_actionAbout_triggered();
    void on_scriptListWidget_visibilityChanged(bool visible);
    void on_variablesWidget_visibilityChanged(bool visible);
    void on_consoleWidget_visibilityChanged(bool visible);
    void on_fileListWidget_visibilityChanged(bool visible);
    void on_mainImageDisplayWidget_visibilityChanged(bool visible);
    void on_actionScripts_triggered(bool checked);
    void on_actionConsole_triggered(bool checked);
    void on_actionVariables_triggered(bool checked);
    void on_actionCurrent_Image_Path_triggered(bool checked);
    void on_actionCurrent_Image_triggered(bool checked);
    void on_variablesViewEditB_clicked();
    void on_variablesViewDelB_clicked();
    void on_imageFileView_activated(QModelIndex index);

    //For variables view  (the menu of return values)
    void loadReturnValues(QStringList returnNames, QStringList returnValues);
    void retMenu_clicked();
};

#endif // MAINWINDOW_H
