21 HighlightingRule rule;
26 keywordPatterns <<
"\\bCASE\\b" <<
"\\bWHEN\\b" <<
"\\bTHEN\\b" 27 <<
"\\bELSE\\b" <<
"\\bEND\\b";
29 Q_FOREACH (
const QString &pattern, keywordPatterns )
31 rule.pattern =
QRegExp( pattern, Qt::CaseInsensitive );
32 rule.format = keywordFormat;
33 highlightingRules.
append( rule );
37 rule.pattern =
QRegExp(
"\'[^\'\r\n]*\'" );
38 rule.format = quotationFormat;
39 highlightingRules.
append( rule );
42 rule.pattern =
QRegExp(
"\"[^\"\r\n]*\"" );
43 rule.format = columnNameFormat;
44 highlightingRules.
append( rule );
50 HighlightingRule rule;
51 Q_FOREACH (
const QString& field, fieldList )
55 rule.pattern =
QRegExp(
"\\b" + field +
"\\b" );
56 rule.format = columnNameFormat;
57 highlightingRules.
append( rule );
63 Q_FOREACH (
const HighlightingRule &rule, highlightingRules )
65 QRegExp expression( rule.pattern );
73 index = expression.
indexIn( text, index + length );
void append(const T &value)
void highlightBlock(const QString &text) override
int matchedLength() const
void setForeground(const QBrush &brush)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
QgsExpressionHighlighter(QTextDocument *parent=nullptr)
void setFontWeight(int weight)
void addFields(const QStringList &fieldList)