diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index b3f9fb604c3..042b93cc74d 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -683,7 +683,7 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc) sel.cursor = c; selections.append(sel); } - ed->setExtraExtraSelections(selections); + ed->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection, selections); break; } } diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index ea9da5cb6bd..49d29b75c93 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2477,6 +2477,9 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e) void BaseTextEditor::slotCursorPositionChanged() { QList extraSelections; + setExtraSelections(ParenthesesMatchingSelection, extraSelections); // clear + if (d->m_parenthesesMatchingEnabled) + d->m_parenthesesMatchingTimer->start(50); if (d->m_highlightCurrentLine) { QTextEdit::ExtraSelection sel; @@ -2487,11 +2490,7 @@ void BaseTextEditor::slotCursorPositionChanged() extraSelections.append(sel); } - if (d->m_parenthesesMatchingEnabled) - d->m_parenthesesMatchingTimer->start(50); - - d->m_extraSelections = extraSelections; - setExtraSelections(d->m_extraSelections + d->m_extraExtraSelections); + setExtraSelections(CurrentLineSelection, extraSelections); } QTextBlock TextBlockUserData::testCollapse(const QTextBlock& block) @@ -3133,7 +3132,7 @@ void BaseTextEditor::_q_matchParentheses() if (backwardMatchType == TextBlockUserData::NoMatch && forwardMatchType == TextBlockUserData::NoMatch) return; - QList extraSelections = d->m_extraSelections; + QList extraSelections; if (backwardMatch.hasSelection()) { QTextEdit::ExtraSelection sel; @@ -3186,8 +3185,7 @@ void BaseTextEditor::_q_matchParentheses() } extraSelections.append(sel); } - d->m_extraSelections = extraSelections; - setExtraSelections(d->m_extraSelections + d->m_extraExtraSelections); + setExtraSelections(ParenthesesMatchingSelection, extraSelections); } void BaseTextEditor::setActionHack(QObject *hack) @@ -3234,15 +3232,21 @@ void BaseTextEditor::deleteLine() cut(); } -void BaseTextEditor::setExtraExtraSelections(const QList &selections) +void BaseTextEditor::setExtraSelections(ExtraSelectionKind kind, const QList &selections) { - d->m_extraExtraSelections = selections; - setExtraSelections(d->m_extraSelections + d->m_extraExtraSelections); + if (selections.isEmpty() && d->m_extraSelections[kind].isEmpty()) + return; + d->m_extraSelections[kind] = selections; + + QList all; + for (int i = 0; i < NExtraSelectionKinds; ++i) + all += d->m_extraSelections[i]; + QPlainTextEdit::setExtraSelections(all); } -QList BaseTextEditor::extraExtraSelections() const +QList BaseTextEditor::extraSelections(ExtraSelectionKind kind) const { - return d->m_extraExtraSelections; + return d->m_extraSelections[kind]; } diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 714b1a507c8..40454a9c7d4 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -369,7 +369,6 @@ private: Internal::BaseTextEditorPrivate *d; friend class Internal::BaseTextEditorPrivate; - public: QWidget *extraArea() const; virtual int extraAreaWidth(int *markWidthPtr = 0) const; @@ -385,8 +384,16 @@ public: void ensureCursorVisible(); - void setExtraExtraSelections(const QList &selections); - QList extraExtraSelections() const; + enum ExtraSelectionKind { + CurrentLineSelection, + ParenthesesMatchingSelection, + CodeWarningsSelection, + CodeSemanticsSelection, + OtherSelection, + NExtraSelectionKinds + }; + void setExtraSelections(ExtraSelectionKind kind, const QList &selections); + QList extraSelections(ExtraSelectionKind kind) const; struct BlockRange { BlockRange():first(0), last(-1){} diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index 56b1071e1c6..9f1e5a7eb67 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -204,8 +204,7 @@ public: QObject *m_actionHack; - QList m_extraSelections; - QList m_extraExtraSelections; + QList m_extraSelections[BaseTextEditor::NExtraSelectionKinds]; // block selection mode bool m_inBlockSelectionMode; diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index dcfe55d195b..eb65457c109 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -225,23 +225,12 @@ void VCSBaseEditor::mouseMoveEvent(QMouseEvent *e) sel.format.setFontUnderline(true); change = changeUnderCursor(cursor); sel.format.setProperty(QTextFormat::UserProperty, change); - bool found = false; - foreach (QTextEdit::ExtraSelection es, extraSelections()) { - if (es.format.stringProperty(QTextFormat::UserProperty) == sel.format.stringProperty(QTextFormat::UserProperty)) { - found = true; - break; - } - } - if (!found) { - setExtraSelections(QList() << sel); - viewport()->setCursor(Qt::PointingHandCursor); - } - } else { - if (!extraSelections().isEmpty()) { - setExtraSelections(QList()); - viewport()->setCursor(Qt::IBeamCursor); - } + setExtraSelections(OtherSelection, QList() << sel); + viewport()->setCursor(Qt::PointingHandCursor); } + } else { + setExtraSelections(OtherSelection, QList()); + viewport()->setCursor(Qt::IBeamCursor); } TextEditor::BaseTextEditor::mouseMoveEvent(e); }