37 #include <QQuickTextDocument> 39 #include <QtGui/QTextCharFormat> 40 #include <QtCore/QTextCodec> 48 class QmlRichText :
public QObject
54 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged)
55 Q_PROPERTY(
int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
56 Q_PROPERTY(
int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
57 Q_PROPERTY(
int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
58 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
59 Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)
60 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
61 Q_PROPERTY(
bool bold READ bold WRITE setBold NOTIFY boldChanged)
62 Q_PROPERTY(
bool italic READ italic WRITE setItalic NOTIFY italicChanged)
63 Q_PROPERTY(
bool underline READ underline WRITE setUnderline NOTIFY underlineChanged)
64 Q_PROPERTY(
int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
65 Q_PROPERTY(QUrl fileUrl READ fileUrl WRITE setFileUrl NOTIFY fileUrlChanged)
66 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
67 Q_PROPERTY(QSizeF size READ size NOTIFY sizeChanged)
72 QQuickItem *target() {
return m_target; }
73 void setTarget(QQuickItem *target);
74 void setCursorPosition(
int position);
75 void setSelectionStart(
int position);
76 void setSelectionEnd(
int position);
77 int cursorPosition()
const {
return m_cursorPosition; }
78 int selectionStart()
const {
return m_selectionStart; }
79 int selectionEnd()
const {
return m_selectionEnd; }
80 QString fontFamily()
const;
81 QColor textColor()
const;
82 Qt::Alignment alignment()
const;
83 void setAlignment(Qt::Alignment a);
86 bool underline()
const;
90 QSizeF size()
const {
return m_doc->size(); }
93 void setBold(
bool arg);
94 void setItalic(
bool arg);
95 void setUnderline(
bool arg);
96 void setFontSize(
int arg);
97 void setTextColor(
const QColor &arg);
98 void setFontFamily(
const QString &arg);
99 void setFileUrl(
const QUrl &arg);
100 void setText(
const QString &arg);
101 void saveAs(
const QUrl &arg,
const QString &fileType);
102 void insertTable(
int rows = 1,
int columns = 2,
int border = 0);
108 void targetChanged();
109 void cursorPositionChanged();
110 void selectionStartChanged();
111 void selectionEndChanged();
112 void fontFamilyChanged();
113 void textColorChanged();
114 void alignmentChanged();
116 void italicChanged();
117 void underlineChanged();
118 void fontSizeChanged();
119 void fileUrlChanged();
121 void error(QString message);
126 QTextCursor textCursor()
const;
127 void mergeFormatOnWordOrSelection(
const QTextCharFormat &format);
128 QQuickItem *m_target;
129 QTextDocument *m_doc;
130 int m_cursorPosition;
131 int m_selectionStart;
137 QString m_documentTitle;
140 #endif // QMLRICHTEXT_H