CppEditor: Add context object into connections

Change-Id: I1a74f62b0a42ea4971b14fb82213f662b5fe4736
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2023-08-01 19:49:35 +02:00
parent a6df8ebb53
commit 1ceea7a91f
8 changed files with 19 additions and 20 deletions

View File

@@ -82,7 +82,7 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(CppCodeModelSettings *s)
m_ignorePatternTextEdit->setToolTip(m_ignoreFilesCheckBox->toolTip());
m_ignorePatternTextEdit->setEnabled(m_ignoreFilesCheckBox->isChecked());
connect(m_ignoreFilesCheckBox, &QCheckBox::stateChanged, [this] {
connect(m_ignoreFilesCheckBox, &QCheckBox::stateChanged, this, [this] {
m_ignorePatternTextEdit->setEnabled(m_ignoreFilesCheckBox->isChecked());
});

View File

@@ -388,8 +388,7 @@ BaseEditorDocumentProcessor *CppEditorDocument::processor()
{
if (!m_processor) {
m_processor.reset(CppModelManager::createEditorDocumentProcessor(this));
connect(m_processor.data(),
&BaseEditorDocumentProcessor::projectPartInfoUpdated,
connect(m_processor.data(), &BaseEditorDocumentProcessor::projectPartInfoUpdated, this,
[this](const ProjectPartInfo &info) {
const bool hasProjectPart = !(info.hints & ProjectPartInfo::IsFallbackMatch);
minimizableInfoBars()->setInfoVisible(NO_PROJECT_CONFIGURATION, !hasProjectPart);
@@ -398,7 +397,7 @@ BaseEditorDocumentProcessor *CppEditorDocument::processor()
const bool isProjectFile = info.hints & ProjectPartInfo::IsFromProjectMatch;
showHideInfoBarAboutMultipleParseContexts(isAmbiguous && isProjectFile);
});
connect(m_processor.data(), &BaseEditorDocumentProcessor::codeWarningsUpdated,
connect(m_processor.data(), &BaseEditorDocumentProcessor::codeWarningsUpdated, this,
[this](unsigned revision,
const QList<QTextEdit::ExtraSelection> selections,
const TextEditor::RefactorMarkers &refactorMarkers) {
@@ -406,7 +405,7 @@ BaseEditorDocumentProcessor *CppEditorDocument::processor()
});
connect(m_processor.data(), &BaseEditorDocumentProcessor::ifdefedOutBlocksUpdated,
this, &CppEditorDocument::ifdefedOutBlocksUpdated);
connect(m_processor.data(), &BaseEditorDocumentProcessor::cppDocumentUpdated,
connect(m_processor.data(), &BaseEditorDocumentProcessor::cppDocumentUpdated, this,
[this](const CPlusPlus::Document::Ptr document) {
// Update syntax highlighter
auto *highlighter = qobject_cast<CppHighlighter *>(syntaxHighlighter());

View File

@@ -454,7 +454,7 @@ void CppEditorWidget::finalizeInitialization()
connect(document(), &QTextDocument::contentsChange,
&d->m_localRenaming, &CppLocalRenaming::onContentsChangeOfEditorWidgetDocument);
connect(&d->m_localRenaming, &CppLocalRenaming::finished, [this] {
connect(&d->m_localRenaming, &CppLocalRenaming::finished, this, [this] {
cppEditorDocument()->recalculateSemanticInfoDetached();
});
connect(&d->m_localRenaming, &CppLocalRenaming::processKeyPressNormally,

View File

@@ -1048,7 +1048,7 @@ void InsertVirtualMethodsDialog::initGui()
auto clearUserAddedReplacements = new QAction(this);
clearUserAddedReplacements->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
clearUserAddedReplacements->setText(Tr::tr("Clear Added \"override\" Equivalents"));
connect(clearUserAddedReplacements, &QAction::triggered, [this] {
connect(clearUserAddedReplacements, &QAction::triggered, this, [this] {
m_availableOverrideReplacements = defaultOverrideReplacements();
updateOverrideReplacementsComboBox();
m_clearUserAddedReplacementsButton->setEnabled(false);

View File

@@ -8907,9 +8907,8 @@ public:
QSizePolicy labelSizePolicy = errorLabel->sizePolicy();
labelSizePolicy.setRetainSizeWhenHidden(true);
errorLabel->setSizePolicy(labelSizePolicy);
connect(constructorParamsModel,
&ConstructorParams::validOrder,
[=, button = buttonBox->button(QDialogButtonBox::Ok)](bool valid) {
connect(constructorParamsModel, &ConstructorParams::validOrder, this,
[errorLabel, button = buttonBox->button(QDialogButtonBox::Ok)](bool valid) {
button->setEnabled(valid);
errorLabel->setVisible(!valid);
});
@@ -8917,7 +8916,8 @@ public:
// setup select all/none checkbox
QCheckBox *const checkBox = new QCheckBox(Tr::tr("Initialize all members"));
checkBox->setChecked(true);
connect(checkBox, &QCheckBox::stateChanged, [model = constructorParamsModel](int state) {
connect(checkBox, &QCheckBox::stateChanged, this,
[model = constructorParamsModel](int state) {
if (state != Qt::PartiallyChecked) {
for (int i = 0; i < model->rowCount(); ++i)
model->setData(model->index(i, ConstructorParams::ShouldInitColumn),

View File

@@ -36,7 +36,7 @@ CppQuickFixProjectsSettings::CppQuickFixProjectsSettings(ProjectExplorer::Projec
m_useGlobalSettings = true;
}
}
connect(project, &ProjectExplorer::Project::aboutToSaveSettings, [this] {
connect(project, &ProjectExplorer::Project::aboutToSaveSettings, this, [this] {
auto settings = m_project->namedSettings(QUICK_FIX_SETTINGS_ID).toMap();
settings.insert(USE_GLOBAL_SETTINGS, m_useGlobalSettings);
m_project->setNamedSettings(QUICK_FIX_SETTINGS_ID, settings);

View File

@@ -190,24 +190,24 @@ e.g. name = "m_test_foo_":
connect(m_listWidget_customTemplates, &QListWidget::currentItemChanged,
this, &CppQuickFixSettingsWidget::currentCustomItemChanged);
connect(pushButton_addValueType, &QPushButton::clicked, [this] {
connect(pushButton_addValueType, &QPushButton::clicked, this, [this] {
auto item = new QListWidgetItem("<type>", m_valueTypes);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled
| Qt::ItemNeverHasChildren);
m_valueTypes->scrollToItem(item);
item->setSelected(true);
});
connect(pushButton_addCustomTemplate, &QPushButton::clicked, [this] {
connect(pushButton_addCustomTemplate, &QPushButton::clicked, this, [this] {
auto item = new QListWidgetItem("<type>", m_listWidget_customTemplates);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
m_listWidget_customTemplates->scrollToItem(item);
m_listWidget_customTemplates->setCurrentItem(item);
m_lineEdit_customTemplateTypes->setText("<type>");
});
connect(m_pushButton_removeCustomTemplate, &QPushButton::clicked, [this] {
connect(m_pushButton_removeCustomTemplate, &QPushButton::clicked, this, [this] {
delete m_listWidget_customTemplates->currentItem();
});
connect(pushButton_removeValueType, &QPushButton::clicked, [this] {
connect(pushButton_removeValueType, &QPushButton::clicked, this, [this] {
delete m_valueTypes->currentItem();
});

View File

@@ -381,7 +381,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
QObject::connect(&t, &QTimer::timeout, &l, &QEventLoop::quit);
const IAssistProposal *immediateProposal = nullptr;
const IAssistProposal *finalProposal = nullptr;
QObject::connect(initialTestFile->m_editorWidget, &CppEditorWidget::proposalsReady,
QObject::connect(initialTestFile->m_editorWidget, &CppEditorWidget::proposalsReady, &l,
[&](const IAssistProposal *i, const IAssistProposal *f) {
immediateProposal = i;
finalProposal = f;