MDIApplication Example

#ifndef TEXTEDITCHILD_H
#define TEXTEDITCHILD_H

#include <QTextEdit>
#include "childinterface.h"

class TextEditChildPrivate;
class QFontComboBox;
class QComboBox;

/* TextEditChild */
class TextEditChild : public QTextEdit,
                      public ChildInterface
{
    Q_OBJECT
    Q_INTERFACES(ChildInterface)
public:
    TextEditChild();
    virtual ~TextEditChild();
public:
    virtual TypeDocument typeDocument() const { return td_Text; }
    virtual void buildUserInterface(RibbonBar* pRib, QStatusBar* pStatusBar, RibbonPage* pageHome);
    virtual void removeUserInterface(RibbonBar* pRib, QStatusBar* pStatusBar, RibbonPage* pageHome);
public:
    void newFile();
    bool loadFile(const QString& fileName);
    virtual bool save();
    virtual bool saveAs();
    bool saveFile(const QString& fileName);
    virtual QString userFriendlyCurrentFile();
    virtual QString currentFile() const { return m_curFile; }
    virtual bool hasSelection() const;
protected:
    void createActions();
    void createGroupClipboard(RibbonPage* page);
    void createGroupFont(RibbonPage* page);
    void createGroupParagraph(RibbonPage* page);
    //    void createGroupEditing(RibbonPage* page);
protected:
    void closeEvent(QCloseEvent* event);
private Q_SLOTS:
    void textBold();
    void textUnderline();
    void textItalic();
    void textFamily(const QString& f);
    void textSize(const QString& p);
    void textStyle(int styleIndex);
    void textColor(const QColor& col);
    void setColorText();
    void textAlign(QAction* a);
    void selectAll();

    void currentCharFormatChanged(const QTextCharFormat& format);
    void cursorPositionChanged();

    void documentWasModified();
    void clipboardDataChanged();
private:
    void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
    void fontChanged(const QFont& f);
    void colorChanged(const QColor& c);
    void alignmentChanged(Qt::Alignment a);

    bool maybeSave();
    void setCurrentFile(const QString& fileName);
    QString strippedName(const QString& fullFileName);
protected:
    QString m_curFile;
    bool m_isUntitled;

    QAction* m_actionTextBold;
    QAction* m_actionTextUnderline;
    QAction* m_actionTextItalic;
    QAction* m_actionTextColor;
    QAction* m_actionAlignLeft;
    QAction* m_actionAlignCenter;
    QAction* m_actionAlignRight;
    QAction* m_actionAlignJustify;
    QAction* m_actionUndo;
    QAction* m_actionRedo;

    QAction* m_actionPaste;
    QAction* m_actionCut;
    QAction* m_actionCopy;
    QAction* m_actionFormatPointer;

    PopupColorButton* m_colorButton;
    QFontComboBox*  m_comboFont;
    QComboBox*      m_comboSize;

private:
    friend class TextEditChildPrivate;
    TextEditChildPrivate* m_pimpl;
};

#endif // TEXTEDITCHILD_H