forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.3' into 4.4
Change-Id: I624040b7910d4025208709b22157869c6085df2f
This commit is contained in:
@@ -221,7 +221,7 @@ void QmlJSEditorWidget::modificationChanged(bool changed)
|
|||||||
|
|
||||||
bool QmlJSEditorWidget::isOutlineCursorChangesBlocked()
|
bool QmlJSEditorWidget::isOutlineCursorChangesBlocked()
|
||||||
{
|
{
|
||||||
return hasFocus() || m_blockOutLineCursorChanges;
|
return hasFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorWidget::jumpToOutlineElement(int /*index*/)
|
void QmlJSEditorWidget::jumpToOutlineElement(int /*index*/)
|
||||||
@@ -814,7 +814,6 @@ void QmlJSEditorWidget::showContextPane()
|
|||||||
|
|
||||||
void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||||
{
|
{
|
||||||
m_blockOutLineCursorChanges = true;
|
|
||||||
QPointer<QMenu> menu(new QMenu(this));
|
QPointer<QMenu> menu(new QMenu(this));
|
||||||
|
|
||||||
QMenu *refactoringMenu = new QMenu(tr("Refactoring"), menu);
|
QMenu *refactoringMenu = new QMenu(tr("Refactoring"), menu);
|
||||||
@@ -859,7 +858,6 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
|
|
||||||
menu->exec(e->globalPos());
|
menu->exec(e->globalPos());
|
||||||
delete menu;
|
delete menu;
|
||||||
m_blockOutLineCursorChanges = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlJSEditorWidget::event(QEvent *e)
|
bool QmlJSEditorWidget::event(QEvent *e)
|
||||||
|
@@ -122,7 +122,6 @@ private:
|
|||||||
QTimer m_contextPaneTimer;
|
QTimer m_contextPaneTimer;
|
||||||
QComboBox *m_outlineCombo;
|
QComboBox *m_outlineCombo;
|
||||||
QModelIndex m_outlineModelIndex;
|
QModelIndex m_outlineModelIndex;
|
||||||
bool m_blockOutLineCursorChanges = false;
|
|
||||||
QmlJS::ModelManagerInterface *m_modelManager = nullptr;
|
QmlJS::ModelManagerInterface *m_modelManager = nullptr;
|
||||||
|
|
||||||
QmlJS::IContextPane *m_contextPane = nullptr;
|
QmlJS::IContextPane *m_contextPane = nullptr;
|
||||||
|
@@ -125,6 +125,14 @@ void QmlJSOutlineWidget::setEditor(QmlJSEditorWidget *editor)
|
|||||||
|
|
||||||
m_filterModel->setSourceModel(m_editor->qmlJsEditorDocument()->outlineModel());
|
m_filterModel->setSourceModel(m_editor->qmlJsEditorDocument()->outlineModel());
|
||||||
m_treeView->expandAll();
|
m_treeView->expandAll();
|
||||||
|
connect(m_editor->qmlJsEditorDocument()->outlineModel(), &QAbstractItemModel::modelAboutToBeReset, [this]() {
|
||||||
|
if (m_treeView && m_treeView->selectionModel())
|
||||||
|
m_treeView->selectionModel()->blockSignals(true);
|
||||||
|
});
|
||||||
|
connect(m_editor->qmlJsEditorDocument()->outlineModel(), &QAbstractItemModel::modelReset, [this]() {
|
||||||
|
if (m_treeView && m_treeView->selectionModel())
|
||||||
|
m_treeView->selectionModel()->blockSignals(false);
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_treeView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect(m_treeView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
this, &QmlJSOutlineWidget::updateSelectionInText);
|
this, &QmlJSOutlineWidget::updateSelectionInText);
|
||||||
@@ -195,8 +203,10 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection)
|
|||||||
|
|
||||||
void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index)
|
void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
|
const auto update = [this](const QModelIndex &index) {
|
||||||
if (!m_editor->isOutlineCursorChangesBlocked()) {
|
if (!m_editor->isOutlineCursorChangesBlocked()) {
|
||||||
QModelIndex sourceIndex = m_filterModel->mapToSource(index);
|
QModelIndex sourceIndex = m_filterModel->mapToSource(index);
|
||||||
|
|
||||||
AST::SourceLocation location
|
AST::SourceLocation location
|
||||||
= m_editor->qmlJsEditorDocument()->outlineModel()->sourceLocation(sourceIndex);
|
= m_editor->qmlJsEditorDocument()->outlineModel()->sourceLocation(sourceIndex);
|
||||||
|
|
||||||
@@ -212,12 +222,15 @@ void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index)
|
|||||||
Core::EditorManager::addCurrentPositionToNavigationHistory();
|
Core::EditorManager::addCurrentPositionToNavigationHistory();
|
||||||
|
|
||||||
QTextCursor textCursor = m_editor->textCursor();
|
QTextCursor textCursor = m_editor->textCursor();
|
||||||
m_blockCursorSync = true;
|
|
||||||
textCursor.setPosition(location.offset);
|
textCursor.setPosition(location.offset);
|
||||||
m_editor->setTextCursor(textCursor);
|
m_editor->setTextCursor(textCursor);
|
||||||
m_editor->centerCursor();
|
m_editor->centerCursor();
|
||||||
m_blockCursorSync = false;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
m_blockCursorSync = true;
|
||||||
|
update(index);
|
||||||
|
m_blockCursorSync = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSOutlineWidget::focusEditor()
|
void QmlJSOutlineWidget::focusEditor()
|
||||||
|
Reference in New Issue
Block a user