From 649559ade315a0d9992e9218fd0902a67a1d724f Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Mon, 9 Aug 2010 10:34:31 +0200 Subject: [PATCH] Store the QTextCharFormat used to mark virtual methods. --- src/plugins/cppeditor/cppeditor.cpp | 7 +++---- src/plugins/cppeditor/cppeditor.h | 1 + src/plugins/texteditor/syntaxhighlighter.cpp | 17 +---------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 723c97f677a..ad37b0146af 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -988,9 +988,6 @@ void CPPEditor::highlightTypeUsages(int from, int to) Q_ASSERT(!chunks.isEmpty()); QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber); - QTextCharFormat virtualMethodFormat; // ### hardcoded; - virtualMethodFormat.setFontItalic(true); - QMapIterator<int, QVector<SemanticInfo::Use> > it(chunks); while (b.isValid() && it.hasNext()) { it.next(); @@ -1021,7 +1018,7 @@ void CPPEditor::highlightTypeUsages(int from, int to) break; case SemanticInfo::Use::VirtualMethod: - formatRange.format = virtualMethodFormat; + formatRange.format = m_virtualMethodFormat; break; default: @@ -1746,6 +1743,8 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs) m_fieldFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_FIELD)); m_keywordFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_KEYWORD)); + m_virtualMethodFormat.setFontItalic(true); // ### hardcoded + // only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link m_occurrencesFormat.clearForeground(); m_occurrenceRenameFormat.clearForeground(); diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 7519c4ceed5..f043c264a42 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -291,6 +291,7 @@ private: QTextCharFormat m_localFormat; QTextCharFormat m_fieldFormat; QTextCharFormat m_keywordFormat; + QTextCharFormat m_virtualMethodFormat; QList<QTextEdit::ExtraSelection> m_renameSelections; int m_currentRenameSelection; diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index 35329447f37..c5eaf2c640f 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -665,21 +665,6 @@ QTextBlock SyntaxHighlighter::currentBlock() const return d->currentBlock; } -static bool isSimilarCharFormat(const QTextCharFormat &format, const QTextCharFormat &other) -{ - if (format.foreground() != other.foreground()) - return false; - else if (format.background() != other.background()) - return false; - else if (format.underlineStyle() != other.underlineStyle()) - return false; - else if (format.underlineColor() != other.underlineColor()) - return false; - else if (format.font() != other.font()) - return false; - return true; -} - void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block, const QList<QTextLayout::FormatRange> &formats) { @@ -706,7 +691,7 @@ void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block, if (skip < formats.size() && it->start == formats.at(skip).start && it->length == formats.at(skip).length - && isSimilarCharFormat(it->format, formats.at(skip).format)) { + && it->format == formats.at(skip).format) { ++skip; ++it; } else { -- GitLab