Editor: add and use editor toolbar outline setter

Simplifies switching between c++ builtin code model and clangd since we
can now react on new outlines in the c++ editor widget.

Fixes: QTCREATORBUG-27594
Change-Id: I76bdc301d78572cbdf4196658f751b5204743fbb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2022-08-17 13:27:33 +02:00
parent 10c7b810b2
commit 0bc3d74ea4
8 changed files with 76 additions and 34 deletions

View File

@@ -228,7 +228,7 @@ public:
QPointer<QAction> m_popupAction;
QPointer<Client> m_client;
QPointer<QAction> m_outlineAction;
QPointer<QWidget> m_outline;
};
void updateEditorToolBar(Core::IEditor *editor)
@@ -292,19 +292,16 @@ void updateEditorToolBar(Core::IEditor *editor)
if (!extras->m_client || !client || extras->m_client != client
|| !client->supportsDocumentSymbols(document)) {
if (extras->m_outlineAction) {
widget->toolBar()->removeAction(extras->m_outlineAction);
delete extras->m_outlineAction;
}
if (extras->m_outline && widget->toolbarOutlineWidget() == extras->m_outline)
widget->setToolbarOutline(nullptr);
extras->m_client.clear();
}
if (!extras->m_client) {
QWidget *comboBox = LanguageClientOutlineWidgetFactory::createComboBox(client, textEditor);
if (comboBox) {
extras->m_outline = LanguageClientOutlineWidgetFactory::createComboBox(client, textEditor);
if (extras->m_outline) {
widget->setToolbarOutline(extras->m_outline);
extras->m_client = client;
extras->m_outlineAction = widget->insertExtraToolBarWidget(TextEditorWidget::Left,
comboBox);
}
}
}