ClangCodeModel: Support setting additional preprocessor directives

... for a document.
This was only ever implemented for the built-in code model.

Fixes: QTCREATORBUG-20423
Change-Id: Ia99d0136e9995a5626058ad06173ea077be024d8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-09-08 15:27:55 +02:00
parent fbd4775f89
commit f7efefb6d4
7 changed files with 54 additions and 35 deletions

View File

@@ -507,19 +507,15 @@ void CppEditorWidget::finalizeInitialization()
// clang-format on
// Toolbar: '#' Button
// TODO: Make "Additional Preprocessor Directives" also useful with Clang Code Model.
if (!d->m_modelManager->isClangCodeModelActive()) {
d->m_preprocessorButton = new QToolButton(this);
d->m_preprocessorButton->setText(QLatin1String("#"));
Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG);
connect(cmd, &Command::keySequenceChanged,
this, &CppEditorWidget::updatePreprocessorButtonTooltip);
updatePreprocessorButtonTooltip();
connect(d->m_preprocessorButton, &QAbstractButton::clicked,
this, &CppEditorWidget::showPreProcessorWidget);
insertExtraToolBarWidget(TextEditorWidget::Left, d->m_preprocessorButton);
}
d->m_preprocessorButton = new QToolButton(this);
d->m_preprocessorButton->setText(QLatin1String("#"));
Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG);
connect(cmd, &Command::keySequenceChanged,
this, &CppEditorWidget::updatePreprocessorButtonTooltip);
updatePreprocessorButtonTooltip();
connect(d->m_preprocessorButton, &QAbstractButton::clicked,
this, &CppEditorWidget::showPreProcessorWidget);
insertExtraToolBarWidget(TextEditorWidget::Left, d->m_preprocessorButton);
connect(this, &TextEditor::TextEditorWidget::toolbarOutlineChanged,
this, &CppEditorWidget::handleOutlineChanged);