diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2010-12-20 09:44:54 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2010-12-20 09:45:29 +0100 |
commit | 94fc750a45a9973f2f3551f4b9fad2c4df595446 (patch) | |
tree | 08822721fd13fa0872d91474306164f629a9c40b /src/plugins/qmljseditor | |
parent | 32f69b9b7790a71f182e4676337f98b0c1f181b0 (diff) | |
download | qt-creator-94fc750a45a9973f2f3551f4b9fad2c4df595446.tar.gz |
Outline: Double click should jump to text even in non-sync mode
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r-- | src/plugins/qmljseditor/qmljsoutline.cpp | 44 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsoutline.h | 1 |
2 files changed, 27 insertions, 18 deletions
diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index fcfdb885fc..6c3910e590 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -102,6 +102,9 @@ void QmlJSOutlineWidget::setEditor(QmlJSTextEditor *editor) connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateSelectionInText(QItemSelection))); + connect(m_treeView, SIGNAL(doubleClicked(QModelIndex)), + this, SLOT(updateTextCursor(QModelIndex))); + connect(m_editor, SIGNAL(outlineModelIndexChanged(QModelIndex)), this, SLOT(updateSelectionInTree(QModelIndex))); connect(m_editor->outlineModel(), SIGNAL(updated()), @@ -167,29 +170,34 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection) if (!selection.indexes().isEmpty()) { QModelIndex index = selection.indexes().first(); - QModelIndex sourceIndex = m_filterModel->mapToSource(index); - AST::SourceLocation location = m_editor->outlineModel()->sourceLocation(sourceIndex); + updateTextCursor(index); + } +} + +void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index) +{ + QModelIndex sourceIndex = m_filterModel->mapToSource(index); + AST::SourceLocation location = m_editor->outlineModel()->sourceLocation(sourceIndex); - if (!location.isValid()) - return; + if (!location.isValid()) + return; - const QTextBlock lastBlock = m_editor->document()->lastBlock(); - const uint textLength = lastBlock.position() + lastBlock.length(); - if (location.offset >= textLength) - return; + const QTextBlock lastBlock = m_editor->document()->lastBlock(); + const uint textLength = lastBlock.position() + lastBlock.length(); + if (location.offset >= textLength) + return; - Core::EditorManager *editorManager = Core::EditorManager::instance(); - editorManager->cutForwardNavigationHistory(); - editorManager->addCurrentPositionToNavigationHistory(); + Core::EditorManager *editorManager = Core::EditorManager::instance(); + editorManager->cutForwardNavigationHistory(); + editorManager->addCurrentPositionToNavigationHistory(); - QTextCursor textCursor = m_editor->textCursor(); - m_blockCursorSync = true; - textCursor.setPosition(location.offset); - m_editor->setTextCursor(textCursor); - m_editor->centerCursor(); - m_blockCursorSync = false; - } + QTextCursor textCursor = m_editor->textCursor(); + m_blockCursorSync = true; + textCursor.setPosition(location.offset); + m_editor->setTextCursor(textCursor); + m_editor->centerCursor(); + m_blockCursorSync = false; } void QmlJSOutlineWidget::setShowBindings(bool showBindings) diff --git a/src/plugins/qmljseditor/qmljsoutline.h b/src/plugins/qmljseditor/qmljsoutline.h index 87430cb4dc..000bb1a5e5 100644 --- a/src/plugins/qmljseditor/qmljsoutline.h +++ b/src/plugins/qmljseditor/qmljsoutline.h @@ -54,6 +54,7 @@ private slots: void modelUpdated(); void updateSelectionInTree(const QModelIndex &index); void updateSelectionInText(const QItemSelection &selection); + void updateTextCursor(const QModelIndex &index); void setShowBindings(bool showBindings); private: |