diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 723c97f677a0a69581a34daa9566ec99f682a189..ad37b0146afdc277029a08a2f18ae721a075a078 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 7519c4ceed56a142afc758f1a98d189e237ac9da..f043c264a42090e71c24020e118742e3b3f79325 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 35329447f3705918a0a5658c7224424c9c76c167..c5eaf2c640f40737b7fa0db83b0c529f1480118b 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 {