/****************************************************************************
**
** Modifications by Romain Gaucher for Modelib
**   >> http://neuroo.kouette.com/modelib
**
** One line to give the program's name and a brief idea of what it does.
** Copyright (C) 2005      Romain Gaucher, Modelib::Project port
** Copyright (C) 2004-2005 Trolltech AS.
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 2 of the License, or (at your option)
** any later version.
**
** This program is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along with
** this program; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
****************************************************************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "highlighter.h"
#include "options.h"

class QAction;
class QMenu;
class QTextEdit;
class QStringList;
class Modele;

/**
	Main application window
*/
class MainWindow : public QMainWindow
{
    Q_OBJECT

private:
	//! Option widget
	Options *options;

public:
	//! main constructor
    MainWindow();
    MainWindow(const QString &fileName);

protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void newFile();
    void open();
    bool save();
    bool saveAs();
    void about();
	void print();
	void aboutAuthors();
    void documentWasModified();

	void setLPFile(Modele *);

	void solve();
	void utils();
	void redraw();
	void addToMenu(QObject *, const QStringList &,QMenu *, const char *,QActionGroup *);

private:
    void init();
	void setupHighlight();
    void createActions();
    void createMenus();
    void createToolBars();
    void createStatusBar();
    void readSettings();
	void readPlugins();
    void writeSettings();
    bool maybeSave();
    void loadFile(const QString &fileName);
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fileName);
    QString strippedName(const QString &fullFileName);
    MainWindow *findMainWindow(const QString &fileName);


    QTextEdit   *textEdit;      //!< The text area
	Highlighter *highlighter;   //!< Instance of the highlighter

    QString curFile;            //!< Name of the current file
    bool isUntitled;            //!< Know if it's untitiled or not

	// Menus
    QMenu *fileMenu;
    QMenu *editMenu;
    QMenu *helpMenu;
	QMenu *toolMenu;
	QMenu *optionMenu;

	// Toolbars
    QToolBar *fileToolBar;
    QToolBar *editToolBar;
	QToolBar *otherBar;

	// All actions
    QAction *newAct;
    QAction *openAct;
	QAction *printAct;
    QAction *saveAct;
    QAction *saveAsAct;
    QAction *closeAct;
    QAction *exitAct;
    QAction *cutAct;
    QAction *copyAct;
    QAction *pasteAct;
	QAction *undoAct;
	QAction *redoAct;
    QAction *aboutAct;
	QAction *aboutQtAct;
	QAction *aboutPluginsAct;
    QAction *solveAct;
    QAction *utilsAct;
	QAction *pickerAct;
	QAction *selectAct;

	// Plugins' relatives
	QStringList pluginFileNames;
	QAction *pluginAct;
	QMenu   *pluginMenu;
};

#endif
