45 #include <QTextLayout> 48 #include "private/qdeclarativestyledtext_p.h" 136 if (rangeStart != drawText.
length() && formatStack.
count()) {
139 formatRange.
start = rangeStart;
141 ranges.
append(formatRange);
143 rangeStart = drawText.
length();
147 if (parseCloseTag(ch,
text)) {
148 if (formatStack.
count())
153 if (formatStack.
count())
154 format = formatStack.
top();
155 if (parseTag(ch,
text, drawText, format))
156 formatStack.
push(format);
158 textStart = ch -
text.constData() + 1;
160 }
else if (*ch == ampersand) {
163 parseEntity(ch,
text, drawText);
164 textStart = ch -
text.constData() + 1;
174 if (rangeStart != drawText.
length() && formatStack.
count()) {
177 formatRange.
start = rangeStart;
179 ranges.
append(formatRange);
183 layout.setAdditionalFormats(ranges);
212 return parseFontAttributes(ch, textIn, format);
215 }
else if (*ch != slash){
257 int entityStart = ch - textIn.
constData();
258 int entityLength = 0;
261 QStringRef entity(&textIn, entityStart, entityLength);
263 textOut +=
QChar(62);
265 textOut +=
QChar(60);
267 textOut +=
QChar(38);
280 attr = parseAttribute(ch, textIn);
289 if (size >= 1 && size <= 7) {
290 static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
308 }
else if (*ch == equals) {
310 if (*ch != singleQuote && *ch != doubleQuote) {
318 QStringRef attr(&textIn, attrStart, attrLength);
336 while (*ch != singleQuote && *ch != doubleQuote && !ch->
isNull()) {
344 return QStringRef(&textIn, valStart, valLength);
static const QChar greaterThan
The QColor class provides colors based on RGB, HSV or CMYK values.
static const QChar doubleQuote
QString toString() const
Returns a copy of the string reference as a QString object.
The QTextLayout::FormatRange structure is used to apply extra formatting information for a specified ...
void setFontItalic(bool italic)
If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic...
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
#define QT_END_NAMESPACE
This macro expands to.
static void parse(const QString &string, QTextLayout &layout)
static bool greaterThan(const QString &s1, const QString &s2)
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool isNull() const
Returns true if the character is the Unicode character 0x0000 ('\0'); otherwise returns false...
int count(const T &t) const
Returns the number of occurrences of value in the vector.
int length() const
Returns the number of characters in this string.
void skipSpace(const QChar *&ch)
QPair< QStringRef, QStringRef > parseAttribute(const QChar *&ch, const QString &textIn)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QStack class is a template class that provides a stack.
int start
Specifies the beginning of the format range within the text layout's text.
QDeclarativeStyledTextPrivate(const QString &t, QTextLayout &l)
The QString class provides a Unicode character string.
static const QChar equals
bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
The QChar class provides a 16-bit Unicode character.
bool parseCloseTag(const QChar *&ch, const QString &textIn)
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
void setFontWeight(int weight)
Sets the text format's font weight to weight.
T pop()
Removes the top item from the stack and returns it.
void reserve(int size)
Attempts to allocate memory for at least size characters.
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool isEmpty(const char *str)
static bool lessThan(const QChar *a, int l, const char *c)
void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut)
bool isEmpty() const
Returns true if the string reference has no characters; otherwise returns false.
void setFontPointSize(qreal size)
Sets the text format's font size.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void push(const T &t)
Adds element t to the top of the stack.
static const QChar singleQuote
The QStringRef class provides a thin wrapper around QString substrings.
The QTextLayout class is used to lay out and render text.
QString & append(QChar c)
The QFont class specifies a font used for drawing text.
QDeclarativeStyledTextPrivate * d
QDeclarativeStyledText(const QString &string, QTextLayout &layout)
bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
~QDeclarativeStyledText()
int length
Specifies the numer of characters the format range spans.
QTextCharFormat format
Specifies the format to apply.
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
static const QChar lessThan
QStringRef parseValue(const QChar *&ch, const QString &textIn)
static const QChar ampersand
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
const QChar at(int i) const
Returns the character at the given index position in the string reference.
T & top()
Returns a reference to the stack's top item.