#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPalette>
#include <QFile>
#include <QTextStream>
#include <QScrollBar>
#include <QColorDialog>
#include "ui_mainwindow.h"
#include "pievaluator.h"
#include "session_manager.h"


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

protected:
	void changeEvent(QEvent * e);

private:
	void updateGraphics();
	void redrawGraphics();

	PIEvaluator evaluator;
	QPalette npal, epal;
	SessionManager session;
	int ans;
	bool active_;

private slots:
	void loading(QPIConfig & conf);
	void saving(QPIConfig & conf);
	void on_lineInput_textChanged(QString s);
	void on_lineInput_returnPressed();
	void on_treeHistory_itemDoubleClicked(QTreeWidgetItem * item, int column) {lineInput->setText(item->text(0));}
	void on_treeVariables_itemSelectionChanged() {buttonVarDel->setDisabled(treeVariables->selectedItems().isEmpty());}
	void on_treeGraphics_itemSelectionChanged();
	void on_treeGraphics_itemChanged(QTreeWidgetItem * , int col) { if (active_) redrawGraphics();}
	void on_treeGraphics_itemDoubleClicked(QTreeWidgetItem * item, int column);
	void on_buttonVarAdd_clicked();
	void on_buttonVarDel_clicked();
	void on_buttonVarClear_clicked() {treeVariables->clear(); buttonVarClear->setEnabled(false);}
	void on_buttonGraphicAdd_clicked();
	void on_buttonGraphicDel_clicked();
	void on_buttonGraphicClear_clicked();
	void on_tabWidget_currentChanged(int index);
	void on_graphic_visualRectChanged() {redrawGraphics();}

};

#endif // MAINWINDOW_H
