From 8daa208f6c2992f7fb25b0535f9be085976a4c05 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 20 Sep 2012 18:50:47 +0200 Subject: [PATCH] Handle mouse wheel on cpp editor's overview combo box Mind that the mouse wheel doesn't really work on the combo box as expected, because it only cycles through toplevel items. Task-number: QTCREATORBUG-7894 Change-Id: I6e22b6c7d7256c16c81280e80652cf1350166f83 Reviewed-by: Kai Koehne --- src/plugins/cppeditor/cppeditor.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 85ef02020fb..fd30be4b383 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -903,10 +903,22 @@ void CPPEditorWidget::onContentsChanged(int position, int charsRemoved, int char void CPPEditorWidget::updateFileName() {} -void CPPEditorWidget::jumpToOutlineElement(int) +void CPPEditorWidget::jumpToOutlineElement(int index) { - QModelIndex index = m_proxyModel->mapToSource(m_outlineCombo->view()->currentIndex()); - Symbol *symbol = m_outlineModel->symbolFromIndex(index); + QModelIndex modelIndex = m_outlineCombo->view()->currentIndex(); + // When the user clicks on an item in the combo box, + // the view's currentIndex is updated, so we want to use that. + // When the scroll wheel was used on the combo box, + // the view's currentIndex is not updated, + // but the passed index to this method is correct. + // So, if the view has a current index, we reset it, to be able + // to distinguish wheel events later + if (modelIndex.isValid()) + m_outlineCombo->view()->setCurrentIndex(QModelIndex()); + else + modelIndex = m_proxyModel->index(index, 0); // toplevel index + QModelIndex sourceIndex = m_proxyModel->mapToSource(modelIndex); + Symbol *symbol = m_outlineModel->symbolFromIndex(sourceIndex); if (! symbol) return;