From f6913ce7913c2f26bf346b000b61bdd0b0eef872 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 8 Dec 2022 00:47:19 +0100 Subject: [PATCH] Squish: Pass context object to lambda connections Remove some unneeded lambda () brackets. Glue lambda brackets with parameters brackets. Change-Id: I8f08699c23e2cb624ac32f0f11cfe8f5703a3d7c Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/squish/objectsmapdocument.cpp | 2 +- src/plugins/squish/objectsmapeditor.cpp | 2 +- src/plugins/squish/squishfilehandler.cpp | 14 ++---- src/plugins/squish/squishnavigationwidget.cpp | 48 +++++++------------ src/plugins/squish/squishoutputpane.cpp | 2 +- src/plugins/squish/squishsettings.cpp | 7 ++- src/plugins/squish/squishtesttreemodel.cpp | 23 ++++----- src/plugins/squish/squishtesttreeview.cpp | 2 +- src/plugins/squish/squishtools.cpp | 9 ++-- src/plugins/squish/squishwizardpages.cpp | 13 +++-- src/plugins/squish/suiteconf.cpp | 2 +- 11 files changed, 48 insertions(+), 76 deletions(-) diff --git a/src/plugins/squish/objectsmapdocument.cpp b/src/plugins/squish/objectsmapdocument.cpp index 0d277900d6b..85f9b2ce5fc 100644 --- a/src/plugins/squish/objectsmapdocument.cpp +++ b/src/plugins/squish/objectsmapdocument.cpp @@ -26,7 +26,7 @@ ObjectsMapDocument::ObjectsMapDocument() { setMimeType(Constants::SQUISH_OBJECTSMAP_MIMETYPE); setId(Constants::OBJECTSMAP_EDITOR_ID); - connect(m_contentModel, &ObjectsMapModel::modelChanged, this, [this]() { setModified(true); }); + connect(m_contentModel, &ObjectsMapModel::modelChanged, this, [this] { setModified(true); }); } Core::IDocument::OpenResult ObjectsMapDocument::open(QString *errorString, diff --git a/src/plugins/squish/objectsmapeditor.cpp b/src/plugins/squish/objectsmapeditor.cpp index aab0bf87fe7..731fd5d6b05 100644 --- a/src/plugins/squish/objectsmapeditor.cpp +++ b/src/plugins/squish/objectsmapeditor.cpp @@ -40,7 +40,7 @@ ObjectsMapEditorFactory::ObjectsMapEditorFactory() setId(Constants::OBJECTSMAP_EDITOR_ID); setDisplayName(Tr::tr("Squish Object Map Editor")); addMimeType(Constants::SQUISH_OBJECTSMAP_MIMETYPE); - setEditorCreator([]() { + setEditorCreator([] { return new ObjectsMapEditor(QSharedPointer(new ObjectsMapDocument)); }); } diff --git a/src/plugins/squish/squishfilehandler.cpp b/src/plugins/squish/squishfilehandler.cpp index 3ae0cd8edf2..f240aba20f8 100644 --- a/src/plugins/squish/squishfilehandler.cpp +++ b/src/plugins/squish/squishfilehandler.cpp @@ -64,20 +64,17 @@ public: QPushButton *okButton = buttons->button(QDialogButtonBox::Ok); okButton->setEnabled(false); - connect(okButton, &QPushButton::clicked, - this, &QDialog::accept); + connect(okButton, &QPushButton::clicked, this, &QDialog::accept); connect(buttons->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject); connect(&aut, &QComboBox::currentIndexChanged, - this, [okButton] (int index) { - okButton->setEnabled(index > 0); - }); + this, [okButton](int index) { okButton->setEnabled(index > 0); }); setWindowTitle(Tr::tr("Recording Settings")); auto squishTools = SquishTools::instance(); QApplication::setOverrideCursor(Qt::WaitCursor); - squishTools->queryServerSettings([this] (const QString &out, const QString &) { + squishTools->queryServerSettings([this](const QString &out, const QString &) { SquishServerSettings s; s.setFromXmlOutput(out); QApplication::restoreOverrideCursor(); @@ -522,12 +519,9 @@ void SquishFileHandler::updateSquishServerGlobalScripts() auto squishTools = SquishTools::instance(); if (squishTools->state() != SquishTools::Idle) { // postpone - we can't queue this currently - QTimer::singleShot(1500, [this]() { - updateSquishServerGlobalScripts(); - }); + QTimer::singleShot(1500, this, [this] { updateSquishServerGlobalScripts(); }); return; } - squishTools->requestSetSharedFolders(m_sharedFolders); } diff --git a/src/plugins/squish/squishnavigationwidget.cpp b/src/plugins/squish/squishnavigationwidget.cpp index 537aad11949..4f6c703566d 100644 --- a/src/plugins/squish/squishnavigationwidget.cpp +++ b/src/plugins/squish/squishnavigationwidget.cpp @@ -62,28 +62,18 @@ SquishNavigationWidget::SquishNavigationWidget(QWidget *parent) connect(m_view, &QTreeView::expanded, this, &SquishNavigationWidget::onExpanded); connect(m_view, &QTreeView::collapsed, this, &SquishNavigationWidget::onCollapsed); connect(m_view, &QTreeView::activated, this, &SquishNavigationWidget::onItemActivated); - connect(m_model, - &QAbstractItemModel::rowsInserted, - this, - &SquishNavigationWidget::onRowsInserted); + connect(m_model, &QAbstractItemModel::rowsInserted, + this, &SquishNavigationWidget::onRowsInserted); connect(m_model, &QAbstractItemModel::rowsRemoved, this, &SquishNavigationWidget::onRowsRemoved); - connect(m_view, - &SquishTestTreeView::runTestCase, - SquishFileHandler::instance(), - &SquishFileHandler::runTestCase); - connect(m_view, - &SquishTestTreeView::recordTestCase, - this, - &SquishNavigationWidget::onRecordTestCase); - connect(m_view, - &SquishTestTreeView::runTestSuite, - SquishFileHandler::instance(), - &SquishFileHandler::runTestSuite); - connect(m_view, - &SquishTestTreeView::openObjectsMap, - SquishFileHandler::instance(), - &SquishFileHandler::openObjectsMap); - connect(SquishFileHandler::instance(), &SquishFileHandler::suitesOpened, this, [this]() { + connect(m_view, &SquishTestTreeView::runTestCase, + SquishFileHandler::instance(), &SquishFileHandler::runTestCase); + connect(m_view, &SquishTestTreeView::recordTestCase, + this, &SquishNavigationWidget::onRecordTestCase); + connect(m_view, &SquishTestTreeView::runTestSuite, + SquishFileHandler::instance(), &SquishFileHandler::runTestSuite); + connect(m_view, &SquishTestTreeView::openObjectsMap, + SquishFileHandler::instance(), &SquishFileHandler::openObjectsMap); + connect(SquishFileHandler::instance(), &SquishFileHandler::suitesOpened, this, [this] { const QModelIndex &suitesIndex = m_view->model()->index(1, 0); if (m_view->isExpanded(suitesIndex)) onExpanded(suitesIndex); @@ -113,7 +103,7 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event) menu.addAction(deleteTestCase); menu.addSeparator(); - connect(runThisTestCase, &QAction::triggered, [suiteName, caseName]() { + connect(runThisTestCase, &QAction::triggered, [suiteName, caseName] { SquishFileHandler::instance()->runTestCase(suiteName, caseName); }); break; @@ -131,14 +121,14 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event) menu.addAction(deleteTestSuite); menu.addSeparator(); - connect(runThisTestSuite, &QAction::triggered, [suiteName]() { + connect(runThisTestSuite, &QAction::triggered, [suiteName] { SquishFileHandler::instance()->runTestSuite(suiteName); }); - connect(addNewTestCase, &QAction::triggered, [this, idx]() { + connect(addNewTestCase, &QAction::triggered, this, [this, idx] { onNewTestCaseTriggered(idx); }); - connect(closeTestSuite, &QAction::triggered, [suiteName]() { + connect(closeTestSuite, &QAction::triggered, [suiteName] { SquishFileHandler::instance()->closeTestSuite(suiteName); }); break; @@ -157,7 +147,7 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event) QAction *removeSharedFolder = new QAction(Tr::tr("Remove Shared Folder"), &menu); menu.addAction(removeSharedFolder); menu.addSeparator(); - connect(removeSharedFolder, &QAction::triggered, this, [this, idx]() { + connect(removeSharedFolder, &QAction::triggered, this, [this, idx] { onRemoveSharedFolderTriggered(idx.row(), idx.parent()); }); } @@ -177,9 +167,7 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event) QAction *createNewTestSuite = new QAction(Tr::tr("Create New Test Suite..."), &menu); menu.addAction(createNewTestSuite); - connect(createNewTestSuite, - &QAction::triggered, - this, []() { + connect(createNewTestSuite, &QAction::triggered, this, [] { auto command = Core::ActionManager::command(Utils::Id("Wizard.Impl.S.SquishTestSuite")); if (command && command->action()) command->action()->trigger(); @@ -196,7 +184,7 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event) QAction *closeAllSuites = new QAction(Tr::tr("Close All Test Suites"), &menu); menu.addAction(closeAllSuites); - connect(closeAllSuites, &QAction::triggered, this, [this]() { + connect(closeAllSuites, &QAction::triggered, this, [this] { if (QMessageBox::question(this, Tr::tr("Close All Test Suites"), Tr::tr("Close all test suites?" diff --git a/src/plugins/squish/squishoutputpane.cpp b/src/plugins/squish/squishoutputpane.cpp index 3e958b111ab..21a73810ef5 100644 --- a/src/plugins/squish/squishoutputpane.cpp +++ b/src/plugins/squish/squishoutputpane.cpp @@ -84,7 +84,7 @@ SquishOutputPane::SquishOutputPane(QObject *parent) m_outputPane->addTab(m_outputWidget, Tr::tr("Test Results")); m_outputPane->addTab(m_runnerServerLog, Tr::tr("Runner/Server Log")); - connect(m_outputPane, &QTabWidget::currentChanged, this, [this]() { navigateStateChanged(); }); + connect(m_outputPane, &QTabWidget::currentChanged, this, [this] { navigateStateChanged(); }); connect(m_treeView, &Utils::TreeView::activated, this, &SquishOutputPane::onItemActivated); connect(header, &QHeaderView::sectionResized, this, &SquishOutputPane::onSectionResized); connect(m_model, &SquishResultModel::requestExpansion, this, [this](QModelIndex idx) { diff --git a/src/plugins/squish/squishsettings.cpp b/src/plugins/squish/squishsettings.cpp index 40c2c8a1539..cedc6fb7b59 100644 --- a/src/plugins/squish/squishsettings.cpp +++ b/src/plugins/squish/squishsettings.cpp @@ -90,8 +90,7 @@ SquishSettings::SquishSettings() minimizeIDE.setToolTip(Tr::tr("Minimize IDE automatically while running or recording test cases.")); minimizeIDE.setDefaultValue(true); - connect(&local, &BoolAspect::volatileValueChanged, - this, [this] (bool checked) { + connect(&local, &BoolAspect::volatileValueChanged, this, [this](bool checked) { serverHost.setEnabled(!checked); serverPort.setEnabled(!checked); }); @@ -376,7 +375,7 @@ SquishServerSettingsWidget::SquishServerSettingsWidget(QWidget *parent) auto edit = new QPushButton(Tr::tr("Edit"), this); auto remove = new QPushButton(Tr::tr("Remove"), this); - auto updateButtons = [add, edit, remove] (const QModelIndex &idx) { + auto updateButtons = [add, edit, remove](const QModelIndex &idx) { add->setEnabled(idx.isValid()); bool enabled = idx.isValid() && idx.parent() != QModelIndex(); edit->setEnabled(enabled); @@ -419,7 +418,7 @@ SquishServerSettingsWidget::SquishServerSettingsWidget(QWidget *parent) // query settings SquishTools *squishTools = SquishTools::instance(); - squishTools->queryServerSettings([this, progress] (const QString &out, const QString &) { + squishTools->queryServerSettings([this, progress](const QString &out, const QString &) { m_serverSettings.setFromXmlOutput(out); m_originalSettings.setFromXmlOutput(out); repopulateApplicationView(); diff --git a/src/plugins/squish/squishtesttreemodel.cpp b/src/plugins/squish/squishtesttreemodel.cpp index 3733d10f8fb..e4b8f61d4a1 100644 --- a/src/plugins/squish/squishtesttreemodel.cpp +++ b/src/plugins/squish/squishtesttreemodel.cpp @@ -174,21 +174,14 @@ SquishTestTreeModel::SquishTestTreeModel(QObject *parent) rootItem()->appendChild(m_squishSharedFolders); rootItem()->appendChild(m_squishSuitesRoot); - connect(m_squishFileHandler, - &SquishFileHandler::testTreeItemCreated, - this, - &SquishTestTreeModel::addTreeItem); - connect(m_squishFileHandler, - &SquishFileHandler::suiteTreeItemModified, - this, - &SquishTestTreeModel::onSuiteTreeItemModified); - connect(m_squishFileHandler, - &SquishFileHandler::suiteTreeItemRemoved, - this, - &SquishTestTreeModel::onSuiteTreeItemRemoved); - connect(m_squishFileHandler, - &SquishFileHandler::clearedSharedFolders, - this, [this]() { m_squishSharedFolders->removeChildren(); }); + connect(m_squishFileHandler, &SquishFileHandler::testTreeItemCreated, + this, &SquishTestTreeModel::addTreeItem); + connect(m_squishFileHandler, &SquishFileHandler::suiteTreeItemModified, + this, &SquishTestTreeModel::onSuiteTreeItemModified); + connect(m_squishFileHandler, &SquishFileHandler::suiteTreeItemRemoved, + this, &SquishTestTreeModel::onSuiteTreeItemRemoved); + connect(m_squishFileHandler, &SquishFileHandler::clearedSharedFolders, + this, [this] { m_squishSharedFolders->removeChildren(); }); m_instance = this; } diff --git a/src/plugins/squish/squishtesttreeview.cpp b/src/plugins/squish/squishtesttreeview.cpp index 225fe1c86a3..8f3c1237483 100644 --- a/src/plugins/squish/squishtesttreeview.cpp +++ b/src/plugins/squish/squishtesttreeview.cpp @@ -197,7 +197,7 @@ void SquishTestTreeItemDelegate::setModelData(QWidget *editor, QAbstractItemMode auto sortModel = static_cast(model); auto sourceModel = static_cast(sortModel->sourceModel()); auto lineEdit = static_cast(editor); - auto removeFormerlyAdded = [sortModel, sourceModel, &index](){ + auto removeFormerlyAdded = [sortModel, sourceModel, &index] { auto item = sourceModel->itemForIndex(sortModel->mapToSource(index)); QTC_ASSERT(item, return); sourceModel->destroyItem(item); diff --git a/src/plugins/squish/squishtools.cpp b/src/plugins/squish/squishtools.cpp index 4a33d45cf3a..1a60f90cf96 100644 --- a/src/plugins/squish/squishtools.cpp +++ b/src/plugins/squish/squishtools.cpp @@ -142,8 +142,7 @@ SquishTools::SquishTools(QObject *parent) if (m_runnerProcess.processId() != -1) interruptRunner(); }); - connect(&m_perspective, &SquishPerspective::stopRequested, - this, [this] () { + connect(&m_perspective, &SquishPerspective::stopRequested, this, [this] { bool interrupted = m_squishRunnerState == RunnerState::Interrupted; RunnerState state = interrupted ? RunnerState::CancelRequestedWhileInterrupted : RunnerState::CancelRequested; @@ -1122,7 +1121,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column) m_requestVarsTimer = new QTimer(this); m_requestVarsTimer->setSingleShot(true); m_requestVarsTimer->setInterval(1000); - connect(m_requestVarsTimer, &QTimer::timeout, this, [this]() { + connect(m_requestVarsTimer, &QTimer::timeout, this, [this] { m_runnerProcess.write("print variables\n"); }); m_requestVarsTimer->start(); @@ -1174,7 +1173,7 @@ void SquishTools::onResultsDirChanged(const QString &filePath) } else { disconnect(m_resultsFileWatcher); // results.xml is created as soon some output has been opened - so try again in a second - QTimer::singleShot(1000, this, [this, filePath]() { onResultsDirChanged(filePath); }); + QTimer::singleShot(1000, this, [this, filePath] { onResultsDirChanged(filePath); }); } } @@ -1201,7 +1200,7 @@ void SquishTools::minimizeQtCreatorWindows() window->showMinimized(); if (!m_lastTopLevelWindows.contains(window)) { m_lastTopLevelWindows.append(window); - connect(window, &QWindow::destroyed, this, [this, window]() { + connect(window, &QWindow::destroyed, this, [this, window] { m_lastTopLevelWindows.removeOne(window); }); } diff --git a/src/plugins/squish/squishwizardpages.cpp b/src/plugins/squish/squishwizardpages.cpp index 62535b5a3ce..3a1915c7a45 100644 --- a/src/plugins/squish/squishwizardpages.cpp +++ b/src/plugins/squish/squishwizardpages.cpp @@ -369,17 +369,16 @@ bool SquishFileGenerator::writeFile(const ProjectExplorer::JsonWizard *, return true; } -bool SquishFileGenerator::allDone(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file, - QString *errorMessage) +bool SquishFileGenerator::allDone(const ProjectExplorer::JsonWizard *wizard, + Core::GeneratedFile *file, QString *errorMessage) { Q_UNUSED(wizard) Q_UNUSED(errorMessage) - if (m_mode == "TestSuite") { - if (file->filePath().fileName() == "suite.conf") - QTimer::singleShot(0, [filePath = file->filePath()] { - SquishFileHandler::instance()->openTestSuite(filePath); - }); + if (m_mode == "TestSuite" && file->filePath().fileName() == "suite.conf") { + QMetaObject::invokeMethod(SquishFileHandler::instance(), [filePath = file->filePath()] { + SquishFileHandler::instance()->openTestSuite(filePath); + }, Qt::QueuedConnection); } return true; } diff --git a/src/plugins/squish/suiteconf.cpp b/src/plugins/squish/suiteconf.cpp index 17e7c383f52..4b34a94bd5c 100644 --- a/src/plugins/squish/suiteconf.cpp +++ b/src/plugins/squish/suiteconf.cpp @@ -32,7 +32,7 @@ static QStringList parseHelper(const QStringView input) QStringList result; QString chunk; - auto appendChunk = [&]() { + auto appendChunk = [&] { if (!chunk.isEmpty()) result.append(chunk); chunk.clear();