diff options
author | Daniel Teske <daniel.teske@digia.com> | 2014-04-09 17:04:50 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@digia.com> | 2014-04-16 13:52:41 +0200 |
commit | aeabe1a727af3ebc0e05570da20f3d0a0a427f3b (patch) | |
tree | a1d04fedb07354bca4723b53150744c8394d7b0d /src/plugins/qmljseditor | |
parent | 18f8486b05a48f072cf0b0170b8854a25bb9d372 (diff) | |
download | qt-creator-aeabe1a727af3ebc0e05570da20f3d0a0a427f3b.tar.gz |
OutlineViews: Make behavior consistent with other views
Allow them to be focused, activate also on return/enter. Also fix focus
handling so that assigning a shortcut to "Activate Outline View"
actually
works.
Change-Id: I878777ae0dad493af1715b36ee264a4f0c12443e
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r-- | src/plugins/qmljseditor/qmljsoutline.cpp | 13 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsoutline.h | 1 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsoutlinetreeview.cpp | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index e42a617d78..fe6953ae7b 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -104,6 +104,7 @@ QmlJSOutlineWidget::QmlJSOutlineWidget(QWidget *parent) : m_filterModel->setFilterBindings(false); m_treeView->setModel(m_filterModel); + setFocusProxy(m_treeView); QVBoxLayout *layout = new QVBoxLayout; @@ -130,8 +131,8 @@ void QmlJSOutlineWidget::setEditor(QmlJSTextEditorWidget *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_treeView, SIGNAL(activated(QModelIndex)), + this, SLOT(focusEditor())); connect(m_editor, SIGNAL(outlineModelIndexChanged(QModelIndex)), this, SLOT(updateSelectionInTree(QModelIndex))); @@ -187,7 +188,7 @@ void QmlJSOutlineWidget::updateSelectionInTree(const QModelIndex &index) filterIndex = m_filterModel->mapFromSource(baseIndex); } - m_treeView->selectionModel()->select(filterIndex, QItemSelectionModel::ClearAndSelect); + m_treeView->setCurrentIndex(filterIndex); m_treeView->scrollTo(filterIndex); m_blockCursorSync = false; } @@ -226,10 +227,14 @@ void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index) textCursor.setPosition(location.offset); m_editor->setTextCursor(textCursor); m_editor->centerCursor(); - m_editor->setFocus(); m_blockCursorSync = false; } +void QmlJSOutlineWidget::focusEditor() +{ + m_editor->setFocus(); +} + void QmlJSOutlineWidget::setShowBindings(bool showBindings) { m_filterModel->setFilterBindings(!showBindings); diff --git a/src/plugins/qmljseditor/qmljsoutline.h b/src/plugins/qmljseditor/qmljsoutline.h index 668b697c72..39cf78be98 100644 --- a/src/plugins/qmljseditor/qmljsoutline.h +++ b/src/plugins/qmljseditor/qmljsoutline.h @@ -80,6 +80,7 @@ private slots: void updateSelectionInTree(const QModelIndex &index); void updateSelectionInText(const QItemSelection &selection); void updateTextCursor(const QModelIndex &index); + void focusEditor(); void setShowBindings(bool showBindings); private: diff --git a/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp b/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp index 808726bffe..6a883155c5 100644 --- a/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp +++ b/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp @@ -39,8 +39,6 @@ namespace Internal { QmlJSOutlineTreeView::QmlJSOutlineTreeView(QWidget *parent) : Utils::NavigationTreeView(parent) { - // see also CppOutlineTreeView - setFocusPolicy(Qt::NoFocus); setExpandsOnDoubleClick(false); setDragEnabled(true); |