forked from qt-creator/qt-creator
TextEditor: Avoid using Core::Id::uniqueIdentifier
... by using Core::Ids instead of ExtraSelectionKind enum. Change-Id: I664ff2a4a03eddd8fe1150929203a1727c12dc84 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -150,6 +150,8 @@ using namespace Utils;
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
|
||||
enum { NExtraSelectionKinds = 12 };
|
||||
|
||||
typedef QString (TransformationMethod)(const QString &);
|
||||
|
||||
static QString QString_toUpper(const QString &str)
|
||||
@@ -414,8 +416,8 @@ public:
|
||||
void highlightSearchResults(const QTextBlock &block, TextEditorOverlay *overlay);
|
||||
QTimer m_delayedUpdateTimer;
|
||||
|
||||
void setExtraSelections(int kind, const QList<QTextEdit::ExtraSelection> &selections);
|
||||
QHash<int, QList<QTextEdit::ExtraSelection>> m_extraSelections;
|
||||
void setExtraSelections(Core::Id kind, const QList<QTextEdit::ExtraSelection> &selections);
|
||||
QHash<Core::Id, QList<QTextEdit::ExtraSelection>> m_extraSelections;
|
||||
|
||||
// block selection mode
|
||||
bool m_inBlockSelectionMode;
|
||||
@@ -555,8 +557,7 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent)
|
||||
|
||||
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
||||
m_fileEncodingLabelAction = m_toolBar->addWidget(m_fileEncodingLabel);
|
||||
|
||||
m_extraSelections.reserve(TextEditorWidget::NExtraSelectionKinds);
|
||||
m_extraSelections.reserve(NExtraSelectionKinds);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
@@ -619,6 +620,18 @@ QString TextEditorWidget::convertToPlainText(const QString &txt)
|
||||
|
||||
static const char kTextBlockMimeType[] = "application/vnd.qtcreator.blocktext";
|
||||
|
||||
Id TextEditorWidget::SnippetPlaceholderSelection("TextEdit.SnippetPlaceHolderSelection");
|
||||
Id TextEditorWidget::CurrentLineSelection("TextEdit.CurrentLineSelection");
|
||||
Id TextEditorWidget::ParenthesesMatchingSelection("TextEdit.ParenthesesMatchingSelection");
|
||||
Id TextEditorWidget::CodeWarningsSelection("TextEdit.CodeWarningsSelection");
|
||||
Id TextEditorWidget::CodeSemanticsSelection("TextEdit.CodeSemanticsSelection");
|
||||
Id TextEditorWidget::UndefinedSymbolSelection("TextEdit.UndefinedSymbolSelection");
|
||||
Id TextEditorWidget::UnusedSymbolSelection("TextEdit.UnusedSymbolSelection");
|
||||
Id TextEditorWidget::OtherSelection("TextEdit.OtherSelection");
|
||||
Id TextEditorWidget::ObjCSelection("TextEdit.ObjCSelection");
|
||||
Id TextEditorWidget::DebuggerExceptionSelection("TextEdit.DebuggerExceptionSelection");
|
||||
Id TextEditorWidget::FakeVimSelection("TextEdit.FakeVimSelection");
|
||||
|
||||
TextEditorWidget::TextEditorWidget(QWidget *parent)
|
||||
: QPlainTextEdit(parent)
|
||||
{
|
||||
@@ -2615,7 +2628,7 @@ void TextEditorWidgetPrivate::documentAboutToBeReloaded()
|
||||
// remove extra selections (loads of QTextCursor objects)
|
||||
|
||||
m_extraSelections.clear();
|
||||
m_extraSelections.reserve(TextEditorWidget::NExtraSelectionKinds);
|
||||
m_extraSelections.reserve(NExtraSelectionKinds);
|
||||
q->QPlainTextEdit::setExtraSelections(QList<QTextEdit::ExtraSelection>());
|
||||
|
||||
// clear all overlays
|
||||
@@ -6085,8 +6098,7 @@ void TextEditorWidget::deleteStartOfWordCamelCase()
|
||||
setTextCursor(c);
|
||||
}
|
||||
|
||||
// kind can be either a value from the ExtraSelectionKind enum, or an unique Core::Id identifier.
|
||||
void TextEditorWidgetPrivate::setExtraSelections(int kind, const QList<QTextEdit::ExtraSelection> &selections)
|
||||
void TextEditorWidgetPrivate::setExtraSelections(Id kind, const QList<QTextEdit::ExtraSelection> &selections)
|
||||
{
|
||||
if (selections.isEmpty() && m_extraSelections[kind].isEmpty())
|
||||
return;
|
||||
@@ -6124,28 +6136,14 @@ void TextEditorWidgetPrivate::setExtraSelections(int kind, const QList<QTextEdit
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditorWidget::setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections)
|
||||
void TextEditorWidget::setExtraSelections(Id kind, const QList<QTextEdit::ExtraSelection> &selections)
|
||||
{
|
||||
d->setExtraSelections(kind, selections);
|
||||
}
|
||||
|
||||
QList<QTextEdit::ExtraSelection> TextEditorWidget::extraSelections(ExtraSelectionKind kind) const
|
||||
{
|
||||
return d->m_extraSelections[kind];
|
||||
}
|
||||
|
||||
void TextEditorWidget::setExtraSelections(Id kind, const QList<QTextEdit::ExtraSelection> &selections)
|
||||
{
|
||||
// Private Core:Id identifiers from the 0-1000 range cannot be used here, they conflict with ExtraSelectionKind
|
||||
QTC_ASSERT(kind.uniqueIdentifier() >= NExtraSelectionKinds, return);
|
||||
d->setExtraSelections(kind.uniqueIdentifier(), selections);
|
||||
}
|
||||
|
||||
QList<QTextEdit::ExtraSelection> TextEditorWidget::extraSelections(Id kind) const
|
||||
{
|
||||
// Private Core:Id identifiers from the 0-1000 range cannot be used here, they conflict with ExtraSelectionKind
|
||||
QTC_ASSERT(kind.uniqueIdentifier() >= NExtraSelectionKinds, return QList<QTextEdit::ExtraSelection>());
|
||||
return d->m_extraSelections[kind.uniqueIdentifier()];
|
||||
return d->m_extraSelections.value(kind);
|
||||
}
|
||||
|
||||
QString TextEditorWidget::extraSelectionTooltip(int pos) const
|
||||
|
||||
Reference in New Issue
Block a user