diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2014-12-28 10:09:57 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2015-02-04 13:22:17 +0000 |
commit | 6bbee89653f442550ad2e20f25b4fb5b89b07e34 (patch) | |
tree | 62a4d2657943a6c02033d6e5bfcc5392d1e7b6f3 /src/plugins/qtsupport | |
parent | 3f1fd49c71ebb3bcfa4914d35d801ebd98eb72cd (diff) | |
download | qt-creator-6bbee89653f442550ad2e20f25b4fb5b89b07e34.tar.gz |
QtSupport: Deduplicate code in QtOutputFormatter
Change-Id: I79a1c51fb52c66561d44acfb9c26c5ec24ca6e52
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/qtsupport')
-rw-r--r-- | src/plugins/qtsupport/qtoutputformatter.cpp | 77 |
1 files changed, 18 insertions, 59 deletions
diff --git a/src/plugins/qtsupport/qtoutputformatter.cpp b/src/plugins/qtsupport/qtoutputformatter.cpp index acf7729ed4..2e16d334d9 100644 --- a/src/plugins/qtsupport/qtoutputformatter.cpp +++ b/src/plugins/qtsupport/qtoutputformatter.cpp @@ -109,71 +109,30 @@ void QtOutputFormatter::appendMessagePart(QTextCursor &cursor, const QString &tx { QString deferredText; - int start = 0; - int pos = txt.indexOf(QLatin1Char('\n')); - while (pos != -1) { - // Line identified - if (!m_lastLine.isEmpty()) { - // Line continuation - const QString newPart = txt.mid(start, pos - start + 1); - const QString line = m_lastLine + newPart; - LinkResult lr = matchLine(line); - if (!lr.href.isEmpty()) { - // Found something && line continuation - cursor.insertText(deferredText, format); - deferredText.clear(); + const int length = txt.length(); + for (int start = 0, pos = -1; start < length; start = pos + 1) { + pos = txt.indexOf(QLatin1Char('\n'), start); + const QString newPart = txt.mid(start, (pos == -1) ? -1 : pos - start + 1); + const QString line = m_lastLine + newPart; + + LinkResult lr = matchLine(line); + if (!lr.href.isEmpty()) { + // Found something && line continuation + cursor.insertText(deferredText, format); + deferredText.clear(); + if (!m_lastLine.isEmpty()) clearLastLine(); - appendLine(cursor, lr, line, format); - } else { - // Found nothing, just emit the new part - deferredText += newPart; - } - // Handled line continuation - m_lastLine.clear(); + appendLine(cursor, lr, line, format); } else { - const QString line = txt.mid(start, pos - start + 1); - LinkResult lr = matchLine(line); - if (!lr.href.isEmpty()) { - cursor.insertText(deferredText, format); - deferredText.clear(); - appendLine(cursor, lr, line, format); - } else { - deferredText += line; - } + // Found nothing, just emit the new part + deferredText += newPart; } - start = pos + 1; - pos = txt.indexOf(QLatin1Char('\n'), start); - } - // Handle left over stuff - if (start < txt.length()) { - if (!m_lastLine.isEmpty()) { - // Line continuation - const QString newPart = txt.mid(start); - const QString line = m_lastLine + newPart; - LinkResult lr = matchLine(line); - if (!lr.href.isEmpty()) { - // Found something && line continuation - cursor.insertText(deferredText, format); - deferredText.clear(); - clearLastLine(); - appendLine(cursor, lr, line, format); - } else { - // Found nothing, just emit the new part - deferredText += newPart; - } + if (pos == -1) { m_lastLine = line; - } else { - m_lastLine = txt.mid(start); - LinkResult lr = matchLine(m_lastLine); - if (!lr.href.isEmpty()) { - cursor.insertText(deferredText, format); - deferredText.clear(); - appendLine(cursor, lr, m_lastLine, format); - } else { - deferredText += m_lastLine; - } + break; } + m_lastLine.clear(); // Handled line continuation } cursor.insertText(deferredText, format); } |