Logo Search packages:      
Sourcecode: ktikz version File versions  Download package

void LogHighlighter::highlightBlock ( const QString &  text ) [protected]

Implements QSyntaxHighlighter::highlightBlock()

See also:
QSyntaxHighlighter::highlightBlock()

Definition at line 59 of file loghighlighter.cpp.

References LogHighlighter::HighlightingRule::format, m_highlightingRules, m_statisticsFormat, and m_statisticsStartExpression.

{
      // Try each highlighting pattern and apply formatting if it matches
      foreach (const HighlightingRule &rule, m_highlightingRules)
      {
//          const QRegExp expression(rule.pattern);
//          int index = text.indexOf(expression);
            QRegExp expression(rule.pattern);
            int index = expression.indexIn(text);
            while (index >= 0)
            {
                  const int length = expression.matchedLength();
                  setFormat(index, length, rule.format);
//                index = text.indexOf(expression, index + length);
                  index = expression.indexIn(text, index + length);
            }
      }
      // The current block state tracks multiline formatting
      setCurrentBlockState(0);
      int startIndex = text.indexOf(m_statisticsStartExpression); // Index to start highlighting statistics (if any)
      if (previousBlockState() == 1) // The previous block ended within statistics
            startIndex = 0;

      if (startIndex >= 0)
      {
            const int endIndex = text.size() - 1;
            const int statisticsLength = endIndex - startIndex + 1;
            setFormat(startIndex, statisticsLength, m_statisticsFormat);
            // Make the next invocation of this routine aware that it should continue highlighting in statistics format
            setCurrentBlockState(1);
      }
}

Generated by  Doxygen 1.6.0   Back to index