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