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:
@@ -229,7 +229,7 @@ void CppEditorWidget::finalizeInitializationAfterDuplication(TextEditorWidget *o
|
|||||||
if (cppEditorWidget->isSemanticInfoValidExceptLocalUses())
|
if (cppEditorWidget->isSemanticInfoValidExceptLocalUses())
|
||||||
updateSemanticInfo(cppEditorWidget->semanticInfo());
|
updateSemanticInfo(cppEditorWidget->semanticInfo());
|
||||||
d->m_cppEditorOutline->update();
|
d->m_cppEditorOutline->update();
|
||||||
const ExtraSelectionKind selectionKind = CodeWarningsSelection;
|
const Id selectionKind = CodeWarningsSelection;
|
||||||
setExtraSelections(selectionKind, cppEditorWidget->extraSelections(selectionKind));
|
setExtraSelections(selectionKind, cppEditorWidget->extraSelections(selectionKind));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ using namespace Utils;
|
|||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
enum { NExtraSelectionKinds = 12 };
|
||||||
|
|
||||||
typedef QString (TransformationMethod)(const QString &);
|
typedef QString (TransformationMethod)(const QString &);
|
||||||
|
|
||||||
static QString QString_toUpper(const QString &str)
|
static QString QString_toUpper(const QString &str)
|
||||||
@@ -414,8 +416,8 @@ public:
|
|||||||
void highlightSearchResults(const QTextBlock &block, TextEditorOverlay *overlay);
|
void highlightSearchResults(const QTextBlock &block, TextEditorOverlay *overlay);
|
||||||
QTimer m_delayedUpdateTimer;
|
QTimer m_delayedUpdateTimer;
|
||||||
|
|
||||||
void setExtraSelections(int kind, const QList<QTextEdit::ExtraSelection> &selections);
|
void setExtraSelections(Core::Id kind, const QList<QTextEdit::ExtraSelection> &selections);
|
||||||
QHash<int, QList<QTextEdit::ExtraSelection>> m_extraSelections;
|
QHash<Core::Id, QList<QTextEdit::ExtraSelection>> m_extraSelections;
|
||||||
|
|
||||||
// block selection mode
|
// block selection mode
|
||||||
bool m_inBlockSelectionMode;
|
bool m_inBlockSelectionMode;
|
||||||
@@ -555,8 +557,7 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent)
|
|||||||
|
|
||||||
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
||||||
m_fileEncodingLabelAction = m_toolBar->addWidget(m_fileEncodingLabel);
|
m_fileEncodingLabelAction = m_toolBar->addWidget(m_fileEncodingLabel);
|
||||||
|
m_extraSelections.reserve(NExtraSelectionKinds);
|
||||||
m_extraSelections.reserve(TextEditorWidget::NExtraSelectionKinds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -619,6 +620,18 @@ QString TextEditorWidget::convertToPlainText(const QString &txt)
|
|||||||
|
|
||||||
static const char kTextBlockMimeType[] = "application/vnd.qtcreator.blocktext";
|
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)
|
TextEditorWidget::TextEditorWidget(QWidget *parent)
|
||||||
: QPlainTextEdit(parent)
|
: QPlainTextEdit(parent)
|
||||||
{
|
{
|
||||||
@@ -2615,7 +2628,7 @@ void TextEditorWidgetPrivate::documentAboutToBeReloaded()
|
|||||||
// remove extra selections (loads of QTextCursor objects)
|
// remove extra selections (loads of QTextCursor objects)
|
||||||
|
|
||||||
m_extraSelections.clear();
|
m_extraSelections.clear();
|
||||||
m_extraSelections.reserve(TextEditorWidget::NExtraSelectionKinds);
|
m_extraSelections.reserve(NExtraSelectionKinds);
|
||||||
q->QPlainTextEdit::setExtraSelections(QList<QTextEdit::ExtraSelection>());
|
q->QPlainTextEdit::setExtraSelections(QList<QTextEdit::ExtraSelection>());
|
||||||
|
|
||||||
// clear all overlays
|
// clear all overlays
|
||||||
@@ -6085,8 +6098,7 @@ void TextEditorWidget::deleteStartOfWordCamelCase()
|
|||||||
setTextCursor(c);
|
setTextCursor(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// kind can be either a value from the ExtraSelectionKind enum, or an unique Core::Id identifier.
|
void TextEditorWidgetPrivate::setExtraSelections(Id kind, const QList<QTextEdit::ExtraSelection> &selections)
|
||||||
void TextEditorWidgetPrivate::setExtraSelections(int kind, const QList<QTextEdit::ExtraSelection> &selections)
|
|
||||||
{
|
{
|
||||||
if (selections.isEmpty() && m_extraSelections[kind].isEmpty())
|
if (selections.isEmpty() && m_extraSelections[kind].isEmpty())
|
||||||
return;
|
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);
|
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
|
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
|
return d->m_extraSelections.value(kind);
|
||||||
QTC_ASSERT(kind.uniqueIdentifier() >= NExtraSelectionKinds, return QList<QTextEdit::ExtraSelection>());
|
|
||||||
return d->m_extraSelections[kind.uniqueIdentifier()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextEditorWidget::extraSelectionTooltip(int pos) const
|
QString TextEditorWidget::extraSelectionTooltip(int pos) const
|
||||||
|
|||||||
@@ -328,22 +328,18 @@ public:
|
|||||||
|
|
||||||
void ensureCursorVisible();
|
void ensureCursorVisible();
|
||||||
|
|
||||||
enum ExtraSelectionKind {
|
static Core::Id FakeVimSelection;
|
||||||
CurrentLineSelection,
|
static Core::Id SnippetPlaceholderSelection;
|
||||||
ParenthesesMatchingSelection,
|
static Core::Id CurrentLineSelection;
|
||||||
CodeWarningsSelection,
|
static Core::Id ParenthesesMatchingSelection;
|
||||||
CodeSemanticsSelection,
|
static Core::Id CodeWarningsSelection;
|
||||||
UndefinedSymbolSelection,
|
static Core::Id CodeSemanticsSelection;
|
||||||
UnusedSymbolSelection,
|
static Core::Id UndefinedSymbolSelection;
|
||||||
FakeVimSelection,
|
static Core::Id UnusedSymbolSelection;
|
||||||
OtherSelection,
|
static Core::Id OtherSelection;
|
||||||
SnippetPlaceholderSelection,
|
static Core::Id ObjCSelection;
|
||||||
ObjCSelection,
|
static Core::Id DebuggerExceptionSelection;
|
||||||
DebuggerExceptionSelection,
|
|
||||||
NExtraSelectionKinds
|
|
||||||
};
|
|
||||||
void setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections);
|
|
||||||
QList<QTextEdit::ExtraSelection> extraSelections(ExtraSelectionKind kind) const;
|
|
||||||
void setExtraSelections(Core::Id kind, const QList<QTextEdit::ExtraSelection> &selections);
|
void setExtraSelections(Core::Id kind, const QList<QTextEdit::ExtraSelection> &selections);
|
||||||
QList<QTextEdit::ExtraSelection> extraSelections(Core::Id kind) const;
|
QList<QTextEdit::ExtraSelection> extraSelections(Core::Id kind) const;
|
||||||
QString extraSelectionTooltip(int pos) const;
|
QString extraSelectionTooltip(int pos) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user