CMakeProjectManager: Pass context object to lambda connections

Remove some unneeded lambda () brackets.
Remove some unneeded lambda return type specifiers.

Change-Id: I9695367d66a151f2611554b9fe5897c1bac7ef5c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-12-07 15:37:42 +01:00
parent 9e7743494c
commit d0e24654f6
8 changed files with 29 additions and 29 deletions

View File

@@ -184,7 +184,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
auto buildDirAspect = bc->buildDirectoryAspect(); auto buildDirAspect = bc->buildDirectoryAspect();
buildDirAspect->setAutoApplyOnEditingFinished(true); buildDirAspect->setAutoApplyOnEditingFinished(true);
connect(buildDirAspect, &BaseAspect::changed, this, [this]() { connect(buildDirAspect, &BaseAspect::changed, this, [this] {
m_configModel->flush(); // clear out config cache...; m_configModel->flush(); // clear out config cache...;
}); });
@@ -199,7 +199,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
}); });
auto qmlDebugAspect = bc->aspect<QtSupport::QmlDebuggingAspect>(); auto qmlDebugAspect = bc->aspect<QtSupport::QmlDebuggingAspect>();
connect(qmlDebugAspect, &QtSupport::QmlDebuggingAspect::changed, this, [this]() { connect(qmlDebugAspect, &QtSupport::QmlDebuggingAspect::changed, this, [this] {
updateButtonState(); updateButtonState();
}); });
@@ -216,7 +216,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
m_kitConfiguration = new QPushButton(Tr::tr("Kit Configuration")); m_kitConfiguration = new QPushButton(Tr::tr("Kit Configuration"));
m_kitConfiguration->setToolTip(Tr::tr("Edit the current kit's CMake configuration.")); m_kitConfiguration->setToolTip(Tr::tr("Edit the current kit's CMake configuration."));
m_kitConfiguration->setFixedWidth(m_kitConfiguration->sizeHint().width()); m_kitConfiguration->setFixedWidth(m_kitConfiguration->sizeHint().width());
connect(m_kitConfiguration, &QPushButton::clicked, this, [this]() { kitCMakeConfiguration(); }); connect(m_kitConfiguration, &QPushButton::clicked, this, [this] { kitCMakeConfiguration(); });
m_filterEdit = new FancyLineEdit; m_filterEdit = new FancyLineEdit;
m_filterEdit->setPlaceholderText(Tr::tr("Filter")); m_filterEdit->setPlaceholderText(Tr::tr("Filter"));
@@ -238,7 +238,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
m_configTextFilterModel->setFilterKeyColumn(-1); m_configTextFilterModel->setFilterKeyColumn(-1);
m_configTextFilterModel->setNewItemRole(ConfigModel::ItemIsUserNew); m_configTextFilterModel->setNewItemRole(ConfigModel::ItemIsUserNew);
connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() { connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this] {
QModelIndex selectedIdx = m_configView->currentIndex(); QModelIndex selectedIdx = m_configView->currentIndex();
if (selectedIdx.isValid()) if (selectedIdx.isValid())
m_configView->scrollTo(selectedIdx); m_configView->scrollTo(selectedIdx);
@@ -266,7 +266,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
m_progressIndicator->hide(); m_progressIndicator->hide();
m_showProgressTimer.setSingleShot(true); m_showProgressTimer.setSingleShot(true);
m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator->show(); }); connect(&m_showProgressTimer, &QTimer::timeout, this, [this] { m_progressIndicator->show(); });
m_addButton = new QPushButton(Tr::tr("&Add")); m_addButton = new QPushButton(Tr::tr("&Add"));
m_addButton->setToolTip(Tr::tr("Add a new configuration value.")); m_addButton->setToolTip(Tr::tr("Add a new configuration value."));
@@ -453,7 +453,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
QRegularExpression::CaseInsensitiveOption)); QRegularExpression::CaseInsensitiveOption));
}); });
connect(m_resetButton, &QPushButton::clicked, this, [this](){ connect(m_resetButton, &QPushButton::clicked, this, [this] {
m_configModel->resetAllChanges(isInitialConfiguration()); m_configModel->resetAllChanges(isInitialConfiguration());
}); });
connect(m_reconfigureButton, &QPushButton::clicked, this, [this] { connect(m_reconfigureButton, &QPushButton::clicked, this, [this] {
@@ -468,11 +468,11 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
m_reconfigureButton->setEnabled(false); m_reconfigureButton->setEnabled(false);
} }
}); });
connect(m_setButton, &QPushButton::clicked, this, [this]() { setVariableUnsetFlag(false); }); connect(m_setButton, &QPushButton::clicked, this, [this] { setVariableUnsetFlag(false); });
connect(m_unsetButton, &QPushButton::clicked, this, [this]() { connect(m_unsetButton, &QPushButton::clicked, this, [this] {
setVariableUnsetFlag(true); setVariableUnsetFlag(true);
}); });
connect(m_editButton, &QPushButton::clicked, this, [this]() { connect(m_editButton, &QPushButton::clicked, this, [this] {
QModelIndex idx = m_configView->currentIndex(); QModelIndex idx = m_configView->currentIndex();
if (idx.column() != 1) if (idx.column() != 1)
idx = idx.sibling(idx.row(), 1); idx = idx.sibling(idx.row(), 1);
@@ -1023,7 +1023,7 @@ QAction *CMakeBuildSettingsWidget::createForceAction(int type, const QModelIndex
QAction *forceAction = new QAction(Tr::tr("Force to %1").arg(typeString), nullptr); QAction *forceAction = new QAction(Tr::tr("Force to %1").arg(typeString), nullptr);
forceAction->setEnabled(m_configModel->canForceTo(idx, t)); forceAction->setEnabled(m_configModel->canForceTo(idx, t));
connect(forceAction, &QAction::triggered, connect(forceAction, &QAction::triggered,
this, [this, idx, t]() { m_configModel->forceTo(idx, t); }); this, [this, idx, t] { m_configModel->forceTo(idx, t); });
return forceAction; return forceAction;
} }
@@ -1603,7 +1603,7 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
[](const CMakeConfigItem &c) { return !c.isNull(); }); [](const CMakeConfigItem &c) { return !c.isNull(); });
// TODO: Upgrade from Qt Creator < 4.13: Remove when no longer supported! // TODO: Upgrade from Qt Creator < 4.13: Remove when no longer supported!
const QString buildTypeName = [this]() { const QString buildTypeName = [this] {
switch (buildType()) { switch (buildType()) {
case Debug: case Debug:
return QString("Debug"); return QString("Debug");

View File

@@ -790,12 +790,12 @@ void CMakeBuildSystem::wireUpConnections()
// trigger an initial parser run // trigger an initial parser run
// Became active/inactive: // Became active/inactive:
connect(target(), &Target::activeBuildConfigurationChanged, this, [this]() { connect(target(), &Target::activeBuildConfigurationChanged, this, [this] {
// Build configuration has changed: // Build configuration has changed:
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to active BC changed"; qCDebug(cmakeBuildSystemLog) << "Requesting parse due to active BC changed";
reparse(CMakeBuildSystem::REPARSE_DEFAULT); reparse(CMakeBuildSystem::REPARSE_DEFAULT);
}); });
connect(project(), &Project::activeTargetChanged, this, [this]() { connect(project(), &Project::activeTargetChanged, this, [this] {
// Build configuration has changed: // Build configuration has changed:
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to active target changed"; qCDebug(cmakeBuildSystemLog) << "Requesting parse due to active target changed";
reparse(CMakeBuildSystem::REPARSE_DEFAULT); reparse(CMakeBuildSystem::REPARSE_DEFAULT);

View File

@@ -223,8 +223,8 @@ CMakeEditorFactory::CMakeEditorFactory()
addMimeType(Constants::CMAKE_MIMETYPE); addMimeType(Constants::CMAKE_MIMETYPE);
addMimeType(Constants::CMAKE_PROJECT_MIMETYPE); addMimeType(Constants::CMAKE_PROJECT_MIMETYPE);
setEditorCreator([]() { return new CMakeEditor; }); setEditorCreator([] { return new CMakeEditor; });
setEditorWidgetCreator([]() { return new CMakeEditorWidget; }); setEditorWidgetCreator([] { return new CMakeEditorWidget; });
setDocumentCreator(createCMakeDocument); setDocumentCreator(createCMakeDocument);
setIndenterCreator([](QTextDocument *doc) { return new CMakeIndenter(doc); }); setIndenterCreator([](QTextDocument *doc) { return new CMakeIndenter(doc); });
setUseGenericHighlighter(true); setUseGenericHighlighter(true);
@@ -232,7 +232,7 @@ CMakeEditorFactory::CMakeEditorFactory()
setCodeFoldingSupported(true); setCodeFoldingSupported(true);
setCompletionAssistProvider(new CMakeFileCompletionAssistProvider); setCompletionAssistProvider(new CMakeFileCompletionAssistProvider);
setAutoCompleterCreator([]() { return new CMakeAutoCompleter; }); setAutoCompleterCreator([] { return new CMakeAutoCompleter; });
setEditorActionHandlers(TextEditorActionHandler::UnCommentSelection setEditorActionHandlers(TextEditorActionHandler::UnCommentSelection
| TextEditorActionHandler::JumpToFileUnderCursor | TextEditorActionHandler::JumpToFileUnderCursor

View File

@@ -203,11 +203,11 @@ CMakeKitAspect::CMakeKitAspect()
//make sure the default value is set if a selected CMake is removed //make sure the default value is set if a selected CMake is removed
connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeRemoved, connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeRemoved,
[this] { for (Kit *k : KitManager::kits()) fix(k); }); this, [this] { for (Kit *k : KitManager::kits()) fix(k); });
//make sure the default value is set if a new default CMake is set //make sure the default value is set if a new default CMake is set
connect(CMakeToolManager::instance(), &CMakeToolManager::defaultCMakeChanged, connect(CMakeToolManager::instance(), &CMakeToolManager::defaultCMakeChanged,
[this] { for (Kit *k : KitManager::kits()) fix(k); }); this, [this] { for (Kit *k : KitManager::kits()) fix(k); });
} }
Id CMakeKitAspect::id() Id CMakeKitAspect::id()
@@ -677,7 +677,7 @@ QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const
return g.matches("Ninja"); return g.matches("Ninja");
}); });
if (it != known.constEnd()) { if (it != known.constEnd()) {
const bool hasNinja = [k, tool]() { const bool hasNinja = [k, tool] {
Internal::CMakeSpecificSettings *settings Internal::CMakeSpecificSettings *settings
= Internal::CMakeProjectPlugin::projectTypeSpecificSettings(); = Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
@@ -951,7 +951,7 @@ private:
auto chooser = new VariableChooser(m_dialog); auto chooser = new VariableChooser(m_dialog);
chooser->addSupportedWidget(m_editor); chooser->addSupportedWidget(m_editor);
chooser->addMacroExpanderProvider([this]() { return kit()->macroExpander(); }); chooser->addMacroExpanderProvider([this] { return kit()->macroExpander(); });
m_additionalEditor = new QLineEdit; m_additionalEditor = new QLineEdit;
auto additionalLabel = new QLabel(m_dialog); auto additionalLabel = new QLabel(m_dialog);
@@ -962,7 +962,7 @@ private:
auto additionalChooser = new VariableChooser(m_dialog); auto additionalChooser = new VariableChooser(m_dialog);
additionalChooser->addSupportedWidget(m_additionalEditor); additionalChooser->addSupportedWidget(m_additionalEditor);
additionalChooser->addMacroExpanderProvider([this]() { return kit()->macroExpander(); }); additionalChooser->addMacroExpanderProvider([this] { return kit()->macroExpander(); });
auto additionalLayout = new QHBoxLayout(); auto additionalLayout = new QHBoxLayout();
additionalLayout->addWidget(additionalLabel); additionalLayout->addWidget(additionalLabel);

View File

@@ -142,8 +142,8 @@ FilePaths CMakeProjectImporter::importCandidates()
CMakePresets::Macros::expand(configPreset, env, projectDirectory(), binaryDir); CMakePresets::Macros::expand(configPreset, env, projectDirectory(), binaryDir);
const FilePath binaryFilePath = FilePath::fromString(binaryDir); const FilePath binaryFilePath = FilePath::fromString(binaryDir);
candidates.removeIf( candidates.removeIf([&binaryFilePath](const FilePath &path)
[&binaryFilePath] (const FilePath &path) { return path == binaryFilePath; }); { return path == binaryFilePath; });
} }
} }

View File

@@ -56,7 +56,7 @@ CMakeManager::CMakeManager()
globalContext); globalContext);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
connect(m_runCMakeAction, &QAction::triggered, [this]() { connect(m_runCMakeAction, &QAction::triggered, this, [this] {
runCMake(SessionManager::startupBuildSystem()); runCMake(SessionManager::startupBuildSystem());
}); });
@@ -65,7 +65,7 @@ CMakeManager::CMakeManager()
globalContext); globalContext);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
connect(m_clearCMakeCacheAction, &QAction::triggered, [this]() { connect(m_clearCMakeCacheAction, &QAction::triggered, this, [this] {
clearCMakeCache(SessionManager::startupBuildSystem()); clearCMakeCache(SessionManager::startupBuildSystem());
}); });
@@ -75,7 +75,7 @@ CMakeManager::CMakeManager()
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_runCMakeActionContextMenu, &QAction::triggered, [this]() { connect(m_runCMakeActionContextMenu, &QAction::triggered, this, [this] {
runCMake(ProjectTree::currentBuildSystem()); runCMake(ProjectTree::currentBuildSystem());
}); });
@@ -93,7 +93,7 @@ CMakeManager::CMakeManager()
globalContext); globalContext);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
connect(m_rescanProjectAction, &QAction::triggered, [this]() { connect(m_rescanProjectAction, &QAction::triggered, this, [this] {
rescanProject(ProjectTree::currentBuildSystem()); rescanProject(ProjectTree::currentBuildSystem());
}); });

View File

@@ -550,7 +550,7 @@ QVariant ConfigModelTreeItem::data(int column, int role) const
return dataItem->isUserNew ? "1" : "0"; return dataItem->isUserNew ? "1" : "0";
} }
auto fontRole = [this]() -> QFont { auto fontRole = [this] {
QFont font; QFont font;
font.setBold((dataItem->isUserChanged || dataItem->isUserNew) && !dataItem->isUnset); font.setBold((dataItem->isUserChanged || dataItem->isUserNew) && !dataItem->isUnset);
font.setStrikeOut((!dataItem->inCMakeCache && !dataItem->isUserNew) || dataItem->isUnset); font.setStrikeOut((!dataItem->inCMakeCache && !dataItem->isUserNew) || dataItem->isUnset);

View File

@@ -836,7 +836,7 @@ FileApiData FileApiParser::parseData(QFutureInterface<std::shared_ptr<FileApiQtc
FileApiData result; FileApiData result;
const auto cancelCheck = [&fi, &errorMessage]() -> bool { const auto cancelCheck = [&fi, &errorMessage] {
if (fi.isCanceled()) { if (fi.isCanceled()) {
errorMessage = Tr::tr("CMake parsing was canceled."); errorMessage = Tr::tr("CMake parsing was canceled.");
return true; return true;