Added categories for occurrences and for renaming occurrences

So they can be adapted in the color schemes.
This commit is contained in:
Thorbjørn Lindeijer
2009-07-14 10:34:17 +02:00
parent 12911cda5c
commit 8cc916a0ca
5 changed files with 15 additions and 5 deletions

View File

@@ -841,7 +841,7 @@ void CPPEditor::renameInPlace()
if (c.position() >= s.cursor.anchor() if (c.position() >= s.cursor.anchor()
&& c.position() <= s.cursor.position()) { && c.position() <= s.cursor.position()) {
m_currentRenameSelection = i; m_currentRenameSelection = i;
m_renameSelections[i].format.setBackground(QColor(255, 200, 200)); m_renameSelections[i].format = m_occurrenceRenameFormat;
setExtraSelections(CodeSemanticsSelection, m_renameSelections); setExtraSelections(CodeSemanticsSelection, m_renameSelections);
break; break;
} }
@@ -1566,6 +1566,8 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
highlighter->rehighlight(); highlighter->rehighlight();
m_linkFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LINK)); m_linkFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LINK));
m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES));
m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME));
} }
void CPPEditor::setDisplaySettings(const TextEditor::DisplaySettings &ds) void CPPEditor::setDisplaySettings(const TextEditor::DisplaySettings &ds)
@@ -1632,9 +1634,6 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
int line = 0, column = 0; int line = 0, column = 0;
convertPosition(position(), &line, &column); convertPosition(position(), &line, &column);
QTextCharFormat format;
format.setBackground(QColor(220, 220, 220));
QList<QTextEdit::ExtraSelection> selections; QList<QTextEdit::ExtraSelection> selections;
SemanticInfo::LocalUseIterator it(semanticInfo.localUses); SemanticInfo::LocalUseIterator it(semanticInfo.localUses);
@@ -1655,7 +1654,7 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
if (! good) if (! good)
continue; continue;
highlightUses(document(), format, uses, &selections); highlightUses(document(), m_occurrencesFormat, uses, &selections);
break; // done break; // done
} }

View File

@@ -301,6 +301,8 @@ private:
QAction *m_sortAction; QAction *m_sortAction;
QTimer *m_updateMethodBoxTimer; QTimer *m_updateMethodBoxTimer;
QTimer *m_updateUsesTimer; QTimer *m_updateUsesTimer;
QTextCharFormat m_occurrencesFormat;
QTextCharFormat m_occurrenceRenameFormat;
QList<QTextEdit::ExtraSelection> m_renameSelections; QList<QTextEdit::ExtraSelection> m_renameSelections;
int m_currentRenameSelection; int m_currentRenameSelection;

View File

@@ -190,6 +190,10 @@ QColor FormatDescription::background() const
} else if (m_name == QLatin1String(Constants::C_SELECTION)) { } else if (m_name == QLatin1String(Constants::C_SELECTION)) {
const QPalette palette = QApplication::palette(); const QPalette palette = QApplication::palette();
return palette.color(QPalette::Highlight); return palette.color(QPalette::Highlight);
} else if (m_name == QLatin1String(Constants::C_OCCURRENCES)) {
return QColor(220, 220, 220);
} else if (m_name == QLatin1String(Constants::C_OCCURRENCES_RENAME)) {
return QColor(255, 200, 200);
} }
return QColor(); // invalid color return QColor(); // invalid color
} }

View File

@@ -77,6 +77,8 @@ const char * const C_SEARCH_SCOPE = "SearchScope";
const char * const C_PARENTHESES = "Parentheses"; const char * const C_PARENTHESES = "Parentheses";
const char * const C_CURRENT_LINE = "CurrentLine"; const char * const C_CURRENT_LINE = "CurrentLine";
const char * const C_CURRENT_LINE_NUMBER = "CurrentLineNumber"; const char * const C_CURRENT_LINE_NUMBER = "CurrentLineNumber";
const char * const C_OCCURRENCES = "Occurrences";
const char * const C_OCCURRENCES_RENAME = "Occurrences.Rename";
const char * const C_NUMBER = "Number"; const char * const C_NUMBER = "Number";
const char * const C_STRING = "String"; const char * const C_STRING = "String";

View File

@@ -77,6 +77,9 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
currentLineNumber.format().setBold(true); currentLineNumber.format().setBold(true);
formatDescriptions.append(currentLineNumber); formatDescriptions.append(currentLineNumber);
formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES), tr("Occurrences")));
formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_RENAME), tr("Renaming Occurrence")));
// Standard categories // Standard categories
formatDescriptions.append(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue)); 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_STRING), tr("String"), Qt::darkGreen));