Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _MTEXTEDIT_H_
- #define _MTEXTEDIT_H_
- #include <QTextBrowser>
- #include <QPointer>
- #include <QWidget>
- #include <QTextCursor>
- #include <QSet>
- class QAbstractItemModel;
- class QTextDocument;
- class QTextCharFormat;
- class QMimeData;
- class QImage;
- class MTextEdit : public QTextBrowser
- {
- Q_OBJECT
- public:
- MTextEdit(QWidget *parent=nullptr);
- virtual ~MTextEdit() = default;
- QByteArray save() const;
- void load(const QByteArray& source);
- const unsigned int& fontSize() const;
- void setFontSize(const unsigned int& val);
- const QColor& fgColor() const;
- const QColor& bgColor() const;
- void setFgColor(const QColor& val);
- void setBgColor(const QColor& val);
- public slots:
- void setText(const QString &text);
- QString toHtml() const;
- QAction* undoAction();
- QAction* redoAction();
- QAction* cutAction();
- QAction* copyAction();
- QAction* pasteAction();
- QAction* boldAction();
- QAction* italicAction();
- QAction* underlineAction();
- QAction* strikeoutAction();
- QAction* orderedListAction();
- QAction* unorderedListAction();
- QAction* increaseIndentAction();
- QAction* decreaseIndentAction();
- QAction* imageAction();
- signals:
- void fontSizeChanged(unsigned int sz);
- void fgColorChanged(const QColor &c);
- void bgColorChanged(const QColor &c);
- protected:
- virtual void focusInEvent(QFocusEvent *e) override;
- void dropImage(const QImage& image);
- void dropDocument(const QUrl& origFilePath);
- void createActions();
- virtual bool canInsertFromMimeData(const QMimeData *source) const override;
- virtual void insertFromMimeData(const QMimeData *source) override;
- virtual QMimeData *createMimeDataFromSelection() const override;
- void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
- void fontChanged(const QFont &f);
- void list(bool checked, QTextListFormat::Style style);
- void indent(int delta);
- protected slots:
- void textBold();
- void textUnderline();
- void textStrikeout();
- void textItalic();
- void textSize();
- void textFgColor(const QColor& col);
- void textBgColor(const QColor& col);
- void listBullet(bool checked);
- void listOrdered(bool checked);
- void slotCurrentCharFormatChanged(const QTextCharFormat &format);
- void slotCursorPositionChanged();
- void slotClipboardDataChanged();
- void urlActivated(const QUrl &link);
- void increaseIndentation();
- void decreaseIndentation();
- void insertImage();
- private:
- quint32 m_imageCounter;
- QPointer<QTextList> m_lastBlockList;
- QAction* m_undoAction;
- QAction* m_redoAction;
- QAction* m_cutAction;
- QAction* m_copyAction;
- QAction* m_pasteAction;
- QAction* m_boldAction;
- QAction* m_italicAction;
- QAction* m_underlineAction;
- QAction* m_strikeoutAction;
- QAction *m_orderedListAction;
- QAction *m_unorderedListAction;
- QAction *m_increaseIndentAction;
- QAction *m_decreaseIndentAction;
- QAction *m_imageAction;
- QAbstractItemModel* m_fontsModel;
- unsigned int m_fontSize;
- QColor m_fgColor;
- QColor m_bgColor;
- QSet<QString> m_imageList;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement