diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 034e17831237f8cac77b40c1d60cab01279b7a0a..663bc73f6226fa8eabf6edd122bb5b6c10368b52 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -898,12 +898,6 @@ void CPPEditor::highlightTypeUsages(int from, int to) Q_ASSERT(!chunks.isEmpty()); QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber); - QTextCharFormat localUseFormat; - localUseFormat.setForeground(Qt::darkBlue); // ### hardcoded - - QTextCharFormat memberUseFormat; - memberUseFormat.setForeground(Qt::darkRed); // ### hardcoded - QMapIterator<int, QVector<SemanticInfo::Use> > it(chunks); while (b.isValid() && it.hasNext()) { it.next(); @@ -926,11 +920,11 @@ void CPPEditor::highlightTypeUsages(int from, int to) break; case SemanticInfo::Use::Field: - formatRange.format = memberUseFormat; + formatRange.format = m_fieldFormat; break; case SemanticInfo::Use::Local: - formatRange.format = localUseFormat; + formatRange.format = m_localFormat; break; default: @@ -1641,7 +1635,6 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs) const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories); highlighter->setFormats(formats.constBegin(), formats.constEnd()); - highlighter->rehighlight(); m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES)); m_occurrencesUnusedFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_UNUSED)); @@ -1651,11 +1644,23 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs) m_occurrencesUnusedFormat.setToolTip(tr("Unused variable")); m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME)); m_typeFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_TYPE)); + m_localFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LOCAL)); + m_fieldFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_FIELD)); m_keywordFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_KEYWORD)); // 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(); + + // Clear all additional formats since they may have changed + QTextBlock b = document()->firstBlock(); + while (b.isValid()) { + highlighter->setExtraAdditionalFormats(b, QList<QTextLayout::FormatRange>()); + b = b.next(); + } + + // This also triggers an update of the additional formats + highlighter->rehighlight(); } void CPPEditor::setTabSettings(const TextEditor::TabSettings &ts) diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 738a97758666f1d332d2d484e9c8f1c95a38c692..cf07b3d51db69b5d60e23b3becbc96df80c16136 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -285,6 +285,8 @@ private: QTextCharFormat m_occurrencesUnusedFormat; QTextCharFormat m_occurrenceRenameFormat; QTextCharFormat m_typeFormat; + QTextCharFormat m_localFormat; + QTextCharFormat m_fieldFormat; QTextCharFormat m_keywordFormat; QList<QTextEdit::ExtraSelection> m_renameSelections; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 1dc5d365d413fdbd4521990cb644d2d0fa002bbe..e1c6b12debe23462075a01f706d0893bbaf69e37 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -108,6 +108,8 @@ const char * const C_OCCURRENCES_RENAME = "Occurrences.Rename"; const char * const C_NUMBER = "Number"; const char * const C_STRING = "String"; const char * const C_TYPE = "Type"; +const char * const C_LOCAL = "Local"; +const char * const C_FIELD = "Field"; const char * const C_KEYWORD = "Keyword"; const char * const C_OPERATOR = "Operator"; const char * const C_PREPROCESSOR = "Preprocessor"; diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 48d01931381f6a0ef82e623187e07ce117dea139..96dc201fbd433cf8ed25abc9143c23fd3c3cb6fa 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -126,6 +126,8 @@ TextEditorSettings::TextEditorSettings(QObject *parent) formatDescriptions.append(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_STRING), tr("String"), Qt::darkGreen)); formatDescriptions.append(FormatDescription(QLatin1String(C_TYPE), tr("Type"), Qt::darkMagenta)); + formatDescriptions.append(FormatDescription(QLatin1String(C_LOCAL), tr("Local"), Qt::darkBlue)); + formatDescriptions.append(FormatDescription(QLatin1String(C_FIELD), tr("Field"), Qt::darkRed)); formatDescriptions.append(FormatDescription(QLatin1String(C_KEYWORD), tr("Keyword"), Qt::darkYellow)); formatDescriptions.append(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator"))); formatDescriptions.append(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue));