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/cppeditor/cppoutline.cpp | |
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/cppeditor/cppoutline.cpp')
-rw-r--r-- | src/plugins/cppeditor/cppoutline.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/cppeditor/cppoutline.cpp b/src/plugins/cppeditor/cppoutline.cpp index 2bc7916e9f..641e577995 100644 --- a/src/plugins/cppeditor/cppoutline.cpp +++ b/src/plugins/cppeditor/cppoutline.cpp @@ -46,8 +46,6 @@ enum { CppOutlineTreeView::CppOutlineTreeView(QWidget *parent) : Utils::NavigationTreeView(parent) { - // see also QmlJSOutlineTreeView - setFocusPolicy(Qt::NoFocus); setExpandsOnDoubleClick(false); } @@ -105,6 +103,7 @@ CppOutlineWidget::CppOutlineWidget(CPPEditorWidget *editor) : setLayout(layout); m_treeView->setModel(m_proxyModel); + setFocusProxy(m_treeView); connect(m_model, SIGNAL(modelReset()), this, SLOT(modelUpdated())); modelUpdated(); @@ -113,8 +112,8 @@ CppOutlineWidget::CppOutlineWidget(CPPEditorWidget *editor) : this, SLOT(updateSelectionInTree(QModelIndex))); 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())); } QList<QAction*> CppOutlineWidget::filterMenuActions() const @@ -145,7 +144,7 @@ void CppOutlineWidget::updateSelectionInTree(const QModelIndex &index) if (debug) qDebug() << "CppOutline - updating selection due to cursor move"; - m_treeView->selectionModel()->select(proxyIndex, QItemSelectionModel::ClearAndSelect); + m_treeView->setCurrentIndex(proxyIndex); m_treeView->scrollTo(proxyIndex); m_blockCursorSync = false; } @@ -176,11 +175,15 @@ void CppOutlineWidget::updateTextCursor(const QModelIndex &proxyIndex) // line has to be 1 based, column 0 based! m_editor->gotoLine(symbol->line(), symbol->column() - 1); - m_editor->setFocus(); m_blockCursorSync = false; } } +void CppOutlineWidget::focusEditor() +{ + m_editor->setFocus(); +} + bool CppOutlineWidget::syncCursor() { return m_enableCursorSync && !m_blockCursorSync; |