#ifndef MDI_CHILD_H
#define MDI_CHILD_H


#include <QTextEdit>


class MdiChild : public QTextEdit
{
    Q_OBJECT
public:
    MdiChild();
    ~MdiChild();

    void newFile();
    bool loadFile(const QString &fileName);
    bool save();
    bool saveAs();
    bool saveFile(const QString &fileName);
    QString userFriendlyCurrentFile();
    QString currentFile() { return curFile; }

    void markdownSelection(const char* preText, const char* postText);
    void insertText(const char* text);

    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 del();
    void undo();
    void redo();
    void find();
    void findNext();
    void findPrevious();
    void goToLine();

signals:
    void closing();
    void documentContentsChanged();

private slots:
    void documentWasModified();

protected:
    void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;

private:
    bool maybeSave();
    void setCurrentFile(const QString &fileName);
    QString strippedName(const QString &fullFileName);

    QString curFile;
    bool isUntitled;
};


#endif // MDI_CHILD_H
