Commit 649559ad authored by Roberto Raggi's avatar Roberto Raggi

Store the QTextCharFormat used to mark virtual methods.

parent cdf9d03e
......@@ -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();
......
......@@ -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;
......
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment