#ifndef MDI_WINDOW_H
#define MDI_WINDOW_H


#include <QMainWindow>
#include <QTextEdit>
#include "Objects.h"
#include "MdiChild.h"


class QAction;
class QMenu;
class QMdiArea;
class QMdiSubWindow;
class QSignalMapper;
class QTcpServer;
class Ui_MainWindow;


/*
class MdiOptions
{
public:
    void serialize();
    void deserialize();
};
*/


class MdiWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MdiWindow(QWidget *parent = 0);
    void init(Ui_MainWindow* ui);

    bool openFile(const QString &fileName);
signals:

protected:
    void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;

public slots:

private slots:

    // File menu actions
    void newFile();
    void open();
    void save();
    void saveAs();

    void handleRequest();
    void updatePreview();

    void setWebPreviewURL();
    void refreshWebPreview();

    // Edit menu actions
#ifndef QT_NO_CLIPBOARD
    void cut();
    void copy();
    void paste();
#endif

    void bold();
    void italic();
    void quote();
    void code();
    void heading1();
    void heading2();
    void heading3();
    void heading4();
    void hyperlink();
    void image();
    void unorderedList();
    void orderedList();
    void horizontalRule();
    void timestamp();
    void pageNumber();
    void pageCount();
    void options();
    void saveAll();
    void selectAll();
    void del();
    void undo();
    void redo();
    void find();
    void findNext();
    void findPrevious();
    void goToLine();

    // Help
    void support();
    void website();

    // Window menu actions
    void cascadeSubWindows();
    void tileSubWindows();
    void tabSubWindows();

    void updateActions();
    MdiChild *createMdiChild();
    void switchLayoutDirection();
    void setActiveSubWindow(QWidget *window);

    void changeRootObject(const QModelIndex &index);
    void changePropertiesObject(const QModelIndex &index);

    // Dialog events
    void upgradeClicked();

private:
    void changeProjectTree(QObject *rootObject);
    void updateObjectTree(QObject *rootObject);
    void updatePropertiesView(QObject *object);
    void setupServer();
    void readSettings();
    void readLicense();
    void writeSettings();
    MdiChild *activeMdiChild();
    QMdiSubWindow *findMdiChild(const QString &fileName);

    //Solution solution;
    QByteArray pdfContents;
    QTcpServer *server;
    QMdiArea *mdiArea;
    QSignalMapper *windowMapper;
    Ui_MainWindow *appWindow;
};


#endif // MDI_WINDOW_H
