forked from qt-creator/qt-creator
Outline: Double click should jump to text even in non-sync mode
This commit is contained in:
@@ -89,6 +89,8 @@ CppOutlineWidget::CppOutlineWidget(CPPEditor *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)));
|
||||
}
|
||||
|
||||
QList<QAction*> CppOutlineWidget::filterMenuActions() const
|
||||
@@ -131,6 +133,12 @@ void CppOutlineWidget::updateSelectionInText(const QItemSelection &selection)
|
||||
|
||||
if (!selection.indexes().isEmpty()) {
|
||||
QModelIndex proxyIndex = selection.indexes().first();
|
||||
updateTextCursor(proxyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void CppOutlineWidget::updateTextCursor(const QModelIndex &proxyIndex)
|
||||
{
|
||||
QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
||||
CPlusPlus::Symbol *symbol = m_model->symbolFromIndex(index);
|
||||
if (symbol) {
|
||||
@@ -147,7 +155,6 @@ void CppOutlineWidget::updateSelectionInText(const QItemSelection &selection)
|
||||
m_editor->gotoLine(symbol->line(), symbol->column() - 1);
|
||||
m_blockCursorSync = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CppOutlineWidget::syncCursor()
|
||||
|
||||
@@ -47,6 +47,7 @@ private slots:
|
||||
void modelUpdated();
|
||||
void updateSelectionInTree(const QModelIndex &index);
|
||||
void updateSelectionInText(const QItemSelection &selection);
|
||||
void updateTextCursor(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
bool syncCursor();
|
||||
|
||||
@@ -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,8 +170,14 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection)
|
||||
|
||||
if (!selection.indexes().isEmpty()) {
|
||||
QModelIndex index = selection.indexes().first();
|
||||
QModelIndex sourceIndex = m_filterModel->mapToSource(index);
|
||||
|
||||
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())
|
||||
@@ -189,7 +198,6 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection)
|
||||
m_editor->setTextCursor(textCursor);
|
||||
m_editor->centerCursor();
|
||||
m_blockCursorSync = false;
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSOutlineWidget::setShowBindings(bool showBindings)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user