40 QSyntaxHighlighter(parent)
47 QTextCharFormat format;
51 format = QTextCharFormat();
52 format.setForeground(QColor(
"black"));
53 format.setFontWeight(75);
54 pattern =
"\\([^\\)]*\\)";
55 applyFormat(text, format, pattern);
58 format = QTextCharFormat();
59 format.setForeground(QColor(
"blue"));
60 pattern =
"\"[^\"]*\"";
61 applyFormat(text, format, pattern);
64 format = QTextCharFormat();
65 format.setForeground(QColor(
"red"));
66 pattern =
"\\d[\\d|\\.]*";
67 applyFormat(text, format, pattern);
70 format = QTextCharFormat();
71 format.setForeground(QColor(63, 127, 95));
74 applyFormat(text, format, pattern);
77 format = QTextCharFormat();
78 format.setForeground(QColor(
"green"));
79 pattern =
"\\<[^!]\\S*[\\>]?";
80 applyFormat(text, format, pattern);
83 format = QTextCharFormat();
84 format.setForeground(QColor(
"gray"));
85 pattern =
"\\<!--.*--\\>";
86 applyFormat(text, format, pattern);
90 void ElastixSyntaxHighlighter::highlightTimestamp(
const QString &text)
92 QTextCharFormat format;
96 QString stampPattern =
"^\\[?[0-9]{2}:[0-9]{2}:[0-9]{2}( :[0-9]{3})?\\]?";
98 QString headingPattern = stampPattern +
"\\s\\w*\\s--\\s";
99 headingPattern = headingPattern +
"|------->.*";
102 format.setFontWeight(QFont::Bold);
103 format.setForeground(Qt::black);
104 applyFormat(text, format, headingPattern);
107 format.setFontWeight(QFont::Bold);
108 format.setForeground(Qt::darkMagenta);
109 applyFormat(text, format, stampPattern);
112 void ElastixSyntaxHighlighter::applyFormat(
const QString &text,
const QTextCharFormat& format,
const QString pattern)
114 QRegExp expression(pattern);
115 int index = text.indexOf(expression);
118 int length = expression.matchedLength();
120 setFormat(index, length, format);
121 index = text.indexOf(expression, index + length);
ElastixSyntaxHighlighter(QTextDocument *parent)
virtual void highlightBlock(const QString &text)
RealScalar length() const