forked from qt-creator/qt-creator
Store the QTextCharFormat used to mark virtual methods.
This commit is contained in:
@@ -988,9 +988,6 @@ void CPPEditor::highlightTypeUsages(int from, int to)
|
|||||||
Q_ASSERT(!chunks.isEmpty());
|
Q_ASSERT(!chunks.isEmpty());
|
||||||
QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber);
|
QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber);
|
||||||
|
|
||||||
QTextCharFormat virtualMethodFormat; // ### hardcoded;
|
|
||||||
virtualMethodFormat.setFontItalic(true);
|
|
||||||
|
|
||||||
QMapIterator<int, QVector<SemanticInfo::Use> > it(chunks);
|
QMapIterator<int, QVector<SemanticInfo::Use> > it(chunks);
|
||||||
while (b.isValid() && it.hasNext()) {
|
while (b.isValid() && it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
@@ -1021,7 +1018,7 @@ void CPPEditor::highlightTypeUsages(int from, int to)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SemanticInfo::Use::VirtualMethod:
|
case SemanticInfo::Use::VirtualMethod:
|
||||||
formatRange.format = virtualMethodFormat;
|
formatRange.format = m_virtualMethodFormat;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1746,6 +1743,8 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
|
|||||||
m_fieldFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_FIELD));
|
m_fieldFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_FIELD));
|
||||||
m_keywordFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_KEYWORD));
|
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
|
// only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link
|
||||||
m_occurrencesFormat.clearForeground();
|
m_occurrencesFormat.clearForeground();
|
||||||
m_occurrenceRenameFormat.clearForeground();
|
m_occurrenceRenameFormat.clearForeground();
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ private:
|
|||||||
QTextCharFormat m_localFormat;
|
QTextCharFormat m_localFormat;
|
||||||
QTextCharFormat m_fieldFormat;
|
QTextCharFormat m_fieldFormat;
|
||||||
QTextCharFormat m_keywordFormat;
|
QTextCharFormat m_keywordFormat;
|
||||||
|
QTextCharFormat m_virtualMethodFormat;
|
||||||
|
|
||||||
QList<QTextEdit::ExtraSelection> m_renameSelections;
|
QList<QTextEdit::ExtraSelection> m_renameSelections;
|
||||||
int m_currentRenameSelection;
|
int m_currentRenameSelection;
|
||||||
|
|||||||
@@ -665,21 +665,6 @@ QTextBlock SyntaxHighlighter::currentBlock() const
|
|||||||
return d->currentBlock;
|
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,
|
void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block,
|
||||||
const QList<QTextLayout::FormatRange> &formats)
|
const QList<QTextLayout::FormatRange> &formats)
|
||||||
{
|
{
|
||||||
@@ -706,7 +691,7 @@ void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block,
|
|||||||
if (skip < formats.size()
|
if (skip < formats.size()
|
||||||
&& it->start == formats.at(skip).start
|
&& it->start == formats.at(skip).start
|
||||||
&& it->length == formats.at(skip).length
|
&& it->length == formats.at(skip).length
|
||||||
&& isSimilarCharFormat(it->format, formats.at(skip).format)) {
|
&& it->format == formats.at(skip).format) {
|
||||||
++skip;
|
++skip;
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user