From edebca70ed12ef259367222cc456f7bf007b2001 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann <Thomas.Hartmann@nokia.com> Date: Wed, 8 Sep 2010 16:34:49 +0200 Subject: [PATCH] QmlJSEditor: changing behaivour of text markers The delay was increased to 500 ms and the marker only appears now, if the cursor is directly on the type name. This way the text marker creates less visual noise. --- src/plugins/qmljseditor/qmljseditor.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index a3d7fbdddb4..7cedf1806a1 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -725,7 +725,7 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) : connect(m_updateOutlineIndexTimer, SIGNAL(timeout()), this, SLOT(updateOutlineIndexNow())); m_cursorPositionTimer = new QTimer(this); - m_cursorPositionTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL); + m_cursorPositionTimer->setInterval(UPDATE_OUTLINE_INTERVAL); m_cursorPositionTimer->setSingleShot(true); connect(m_cursorPositionTimer, SIGNAL(timeout()), this, SLOT(updateCursorPositionNow())); @@ -984,20 +984,25 @@ void QmlJSTextEditor::updateCursorPositionNow() Node *newNode = m_semanticInfo.declaringMemberNoProperties(position()); if (oldNode != newNode && m_oldCursorPosition != -1) m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, false); - if (oldNode != newNode && - m_contextPane->isAvailable(editableInterface(), m_semanticInfo.lookupContext(), newNode) && + if (m_contextPane->isAvailable(editableInterface(), m_semanticInfo.lookupContext(), newNode) && !m_contextPane->widget()->isVisible()) { QList<TextEditor::Internal::RefactorMarker> markers; if (UiObjectMember *m = newNode->uiObjectMemberCast()) { + const int start = qualifiedTypeNameId(m)->identifierToken.begin(); for (UiQualifiedId *q = qualifiedTypeNameId(m); q; q = q->next) { if (! q->next) { const int end = q->identifierToken.end(); - TextEditor::Internal::RefactorMarker marker; - QTextCursor tc(document()); - tc.setPosition(end); - marker.cursor = tc; - marker.tooltip = tr("Show Qt Quick ToolBar"); - markers.append(marker); + if (position() >= start && position() <= end) { + TextEditor::Internal::RefactorMarker marker; + QTextCursor tc(document()); + tc.setPosition(end); + marker.cursor = tc; + marker.tooltip = tr("Show Qt Quick ToolBar"); + markers.append(marker); + } else { + QList<TextEditor::Internal::RefactorMarker> markers; + setRefactorMarkers(markers); + } } } } @@ -1748,7 +1753,7 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) Node *newNode = m_semanticInfo.declaringMemberNoProperties(position()); if (newNode) { m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, true); - showTextMarker(); + m_cursorPositionTimer->start(); //update text marker } } -- GitLab