forked from vedderb/bldc-tool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mrichtextedit.h
94 lines (83 loc) · 3.04 KB
/
mrichtextedit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
** Copyright (C) 2013 Jiří Procházka (Hobrasoft)
** Contact: http://www.hobrasoft.cz/
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file is under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation and appearing
** in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the
** GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
*/
#ifndef _MRICHTEXTEDIT_H_
#define _MRICHTEXTEDIT_H_
#include <QPointer>
#include "ui_mrichtextedit.h"
/**
* @Brief A simple rich-text editor
*/
class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit {
Q_OBJECT
public:
MRichTextEdit(QWidget *parent = 0);
QString toPlainText() const { return f_textedit->toPlainText(); }
QString toHtml() const;
QTextDocument *document() { return f_textedit->document(); }
QTextCursor textCursor() const { return f_textedit->textCursor(); }
void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); }
public slots:
void setText(const QString &text);
protected slots:
void setPlainText(const QString &text) { f_textedit->setPlainText(text); }
void setHtml(const QString &text) { f_textedit->setHtml(text); }
void textRemoveFormat();
void textRemoveAllFormat();
void textBold();
void textUnderline();
void textStrikeout();
void textItalic();
void textSize(const QString &p);
void textLink(bool checked);
void textStyle(int index);
void textBgColor();
void listBullet(bool checked);
void listOrdered(bool checked);
void slotCurrentCharFormatChanged(const QTextCharFormat &format);
void slotCursorPositionChanged();
void slotClipboardDataChanged();
void increaseIndentation();
void decreaseIndentation();
void insertImage();
void textSource();
protected:
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
void fontChanged(const QFont &f);
void bgColorChanged(const QColor &c);
void list(bool checked, QTextListFormat::Style style);
void indent(int delta);
void focusInEvent(QFocusEvent *event);
QStringList m_paragraphItems;
int m_fontsize_h1;
int m_fontsize_h2;
int m_fontsize_h3;
int m_fontsize_h4;
enum ParagraphItems { ParagraphStandard = 0,
ParagraphHeading1,
ParagraphHeading2,
ParagraphHeading3,
ParagraphHeading4,
ParagraphMonospace };
QPointer<QTextList> m_lastBlockList;
};
#endif