Squish: Pass context object to lambda connections

Remove some unneeded lambda () brackets.
Glue lambda brackets with parameters brackets.

Change-Id: I8f08699c23e2cb624ac32f0f11cfe8f5703a3d7c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Jarek Kobus
2022-12-08 00:47:19 +01:00
parent 0ddc0eb8e9
commit f6913ce791
11 changed files with 48 additions and 76 deletions

View File

@@ -26,7 +26,7 @@ ObjectsMapDocument::ObjectsMapDocument()
{ {
setMimeType(Constants::SQUISH_OBJECTSMAP_MIMETYPE); setMimeType(Constants::SQUISH_OBJECTSMAP_MIMETYPE);
setId(Constants::OBJECTSMAP_EDITOR_ID); 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, Core::IDocument::OpenResult ObjectsMapDocument::open(QString *errorString,

View File

@@ -40,7 +40,7 @@ ObjectsMapEditorFactory::ObjectsMapEditorFactory()
setId(Constants::OBJECTSMAP_EDITOR_ID); setId(Constants::OBJECTSMAP_EDITOR_ID);
setDisplayName(Tr::tr("Squish Object Map Editor")); setDisplayName(Tr::tr("Squish Object Map Editor"));
addMimeType(Constants::SQUISH_OBJECTSMAP_MIMETYPE); addMimeType(Constants::SQUISH_OBJECTSMAP_MIMETYPE);
setEditorCreator([]() { setEditorCreator([] {
return new ObjectsMapEditor(QSharedPointer<ObjectsMapDocument>(new ObjectsMapDocument)); return new ObjectsMapEditor(QSharedPointer<ObjectsMapDocument>(new ObjectsMapDocument));
}); });
} }

View File

@@ -64,14 +64,11 @@ public:
QPushButton *okButton = buttons->button(QDialogButtonBox::Ok); QPushButton *okButton = buttons->button(QDialogButtonBox::Ok);
okButton->setEnabled(false); okButton->setEnabled(false);
connect(okButton, &QPushButton::clicked, connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
this, &QDialog::accept);
connect(buttons->button(QDialogButtonBox::Cancel), &QPushButton::clicked, connect(buttons->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
this, &QDialog::reject); this, &QDialog::reject);
connect(&aut, &QComboBox::currentIndexChanged, connect(&aut, &QComboBox::currentIndexChanged,
this, [okButton] (int index) { this, [okButton](int index) { okButton->setEnabled(index > 0); });
okButton->setEnabled(index > 0);
});
setWindowTitle(Tr::tr("Recording Settings")); setWindowTitle(Tr::tr("Recording Settings"));
auto squishTools = SquishTools::instance(); auto squishTools = SquishTools::instance();
@@ -522,12 +519,9 @@ void SquishFileHandler::updateSquishServerGlobalScripts()
auto squishTools = SquishTools::instance(); auto squishTools = SquishTools::instance();
if (squishTools->state() != SquishTools::Idle) { if (squishTools->state() != SquishTools::Idle) {
// postpone - we can't queue this currently // postpone - we can't queue this currently
QTimer::singleShot(1500, [this]() { QTimer::singleShot(1500, this, [this] { updateSquishServerGlobalScripts(); });
updateSquishServerGlobalScripts();
});
return; return;
} }
squishTools->requestSetSharedFolders(m_sharedFolders); squishTools->requestSetSharedFolders(m_sharedFolders);
} }

View File

@@ -62,28 +62,18 @@ SquishNavigationWidget::SquishNavigationWidget(QWidget *parent)
connect(m_view, &QTreeView::expanded, this, &SquishNavigationWidget::onExpanded); connect(m_view, &QTreeView::expanded, this, &SquishNavigationWidget::onExpanded);
connect(m_view, &QTreeView::collapsed, this, &SquishNavigationWidget::onCollapsed); connect(m_view, &QTreeView::collapsed, this, &SquishNavigationWidget::onCollapsed);
connect(m_view, &QTreeView::activated, this, &SquishNavigationWidget::onItemActivated); connect(m_view, &QTreeView::activated, this, &SquishNavigationWidget::onItemActivated);
connect(m_model, connect(m_model, &QAbstractItemModel::rowsInserted,
&QAbstractItemModel::rowsInserted, this, &SquishNavigationWidget::onRowsInserted);
this,
&SquishNavigationWidget::onRowsInserted);
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &SquishNavigationWidget::onRowsRemoved); connect(m_model, &QAbstractItemModel::rowsRemoved, this, &SquishNavigationWidget::onRowsRemoved);
connect(m_view, connect(m_view, &SquishTestTreeView::runTestCase,
&SquishTestTreeView::runTestCase, SquishFileHandler::instance(), &SquishFileHandler::runTestCase);
SquishFileHandler::instance(), connect(m_view, &SquishTestTreeView::recordTestCase,
&SquishFileHandler::runTestCase); this, &SquishNavigationWidget::onRecordTestCase);
connect(m_view, connect(m_view, &SquishTestTreeView::runTestSuite,
&SquishTestTreeView::recordTestCase, SquishFileHandler::instance(), &SquishFileHandler::runTestSuite);
this, connect(m_view, &SquishTestTreeView::openObjectsMap,
&SquishNavigationWidget::onRecordTestCase); SquishFileHandler::instance(), &SquishFileHandler::openObjectsMap);
connect(m_view, connect(SquishFileHandler::instance(), &SquishFileHandler::suitesOpened, this, [this] {
&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); const QModelIndex &suitesIndex = m_view->model()->index(1, 0);
if (m_view->isExpanded(suitesIndex)) if (m_view->isExpanded(suitesIndex))
onExpanded(suitesIndex); onExpanded(suitesIndex);
@@ -113,7 +103,7 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(deleteTestCase); menu.addAction(deleteTestCase);
menu.addSeparator(); menu.addSeparator();
connect(runThisTestCase, &QAction::triggered, [suiteName, caseName]() { connect(runThisTestCase, &QAction::triggered, [suiteName, caseName] {
SquishFileHandler::instance()->runTestCase(suiteName, caseName); SquishFileHandler::instance()->runTestCase(suiteName, caseName);
}); });
break; break;
@@ -131,14 +121,14 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(deleteTestSuite); menu.addAction(deleteTestSuite);
menu.addSeparator(); menu.addSeparator();
connect(runThisTestSuite, &QAction::triggered, [suiteName]() { connect(runThisTestSuite, &QAction::triggered, [suiteName] {
SquishFileHandler::instance()->runTestSuite(suiteName); SquishFileHandler::instance()->runTestSuite(suiteName);
}); });
connect(addNewTestCase, &QAction::triggered, [this, idx]() { connect(addNewTestCase, &QAction::triggered, this, [this, idx] {
onNewTestCaseTriggered(idx); onNewTestCaseTriggered(idx);
}); });
connect(closeTestSuite, &QAction::triggered, [suiteName]() { connect(closeTestSuite, &QAction::triggered, [suiteName] {
SquishFileHandler::instance()->closeTestSuite(suiteName); SquishFileHandler::instance()->closeTestSuite(suiteName);
}); });
break; break;
@@ -157,7 +147,7 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
QAction *removeSharedFolder = new QAction(Tr::tr("Remove Shared Folder"), &menu); QAction *removeSharedFolder = new QAction(Tr::tr("Remove Shared Folder"), &menu);
menu.addAction(removeSharedFolder); menu.addAction(removeSharedFolder);
menu.addSeparator(); menu.addSeparator();
connect(removeSharedFolder, &QAction::triggered, this, [this, idx]() { connect(removeSharedFolder, &QAction::triggered, this, [this, idx] {
onRemoveSharedFolderTriggered(idx.row(), idx.parent()); 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); QAction *createNewTestSuite = new QAction(Tr::tr("Create New Test Suite..."), &menu);
menu.addAction(createNewTestSuite); menu.addAction(createNewTestSuite);
connect(createNewTestSuite, connect(createNewTestSuite, &QAction::triggered, this, [] {
&QAction::triggered,
this, []() {
auto command = Core::ActionManager::command(Utils::Id("Wizard.Impl.S.SquishTestSuite")); auto command = Core::ActionManager::command(Utils::Id("Wizard.Impl.S.SquishTestSuite"));
if (command && command->action()) if (command && command->action())
command->action()->trigger(); command->action()->trigger();
@@ -196,7 +184,7 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
QAction *closeAllSuites = new QAction(Tr::tr("Close All Test Suites"), &menu); QAction *closeAllSuites = new QAction(Tr::tr("Close All Test Suites"), &menu);
menu.addAction(closeAllSuites); menu.addAction(closeAllSuites);
connect(closeAllSuites, &QAction::triggered, this, [this]() { connect(closeAllSuites, &QAction::triggered, this, [this] {
if (QMessageBox::question(this, if (QMessageBox::question(this,
Tr::tr("Close All Test Suites"), Tr::tr("Close All Test Suites"),
Tr::tr("Close all test suites?" Tr::tr("Close all test suites?"

View File

@@ -84,7 +84,7 @@ SquishOutputPane::SquishOutputPane(QObject *parent)
m_outputPane->addTab(m_outputWidget, Tr::tr("Test Results")); m_outputPane->addTab(m_outputWidget, Tr::tr("Test Results"));
m_outputPane->addTab(m_runnerServerLog, Tr::tr("Runner/Server Log")); 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(m_treeView, &Utils::TreeView::activated, this, &SquishOutputPane::onItemActivated);
connect(header, &QHeaderView::sectionResized, this, &SquishOutputPane::onSectionResized); connect(header, &QHeaderView::sectionResized, this, &SquishOutputPane::onSectionResized);
connect(m_model, &SquishResultModel::requestExpansion, this, [this](QModelIndex idx) { connect(m_model, &SquishResultModel::requestExpansion, this, [this](QModelIndex idx) {

View File

@@ -90,8 +90,7 @@ SquishSettings::SquishSettings()
minimizeIDE.setToolTip(Tr::tr("Minimize IDE automatically while running or recording test cases.")); minimizeIDE.setToolTip(Tr::tr("Minimize IDE automatically while running or recording test cases."));
minimizeIDE.setDefaultValue(true); minimizeIDE.setDefaultValue(true);
connect(&local, &BoolAspect::volatileValueChanged, connect(&local, &BoolAspect::volatileValueChanged, this, [this](bool checked) {
this, [this] (bool checked) {
serverHost.setEnabled(!checked); serverHost.setEnabled(!checked);
serverPort.setEnabled(!checked); serverPort.setEnabled(!checked);
}); });

View File

@@ -174,21 +174,14 @@ SquishTestTreeModel::SquishTestTreeModel(QObject *parent)
rootItem()->appendChild(m_squishSharedFolders); rootItem()->appendChild(m_squishSharedFolders);
rootItem()->appendChild(m_squishSuitesRoot); rootItem()->appendChild(m_squishSuitesRoot);
connect(m_squishFileHandler, connect(m_squishFileHandler, &SquishFileHandler::testTreeItemCreated,
&SquishFileHandler::testTreeItemCreated, this, &SquishTestTreeModel::addTreeItem);
this, connect(m_squishFileHandler, &SquishFileHandler::suiteTreeItemModified,
&SquishTestTreeModel::addTreeItem); this, &SquishTestTreeModel::onSuiteTreeItemModified);
connect(m_squishFileHandler, connect(m_squishFileHandler, &SquishFileHandler::suiteTreeItemRemoved,
&SquishFileHandler::suiteTreeItemModified, this, &SquishTestTreeModel::onSuiteTreeItemRemoved);
this, connect(m_squishFileHandler, &SquishFileHandler::clearedSharedFolders,
&SquishTestTreeModel::onSuiteTreeItemModified); this, [this] { m_squishSharedFolders->removeChildren(); });
connect(m_squishFileHandler,
&SquishFileHandler::suiteTreeItemRemoved,
this,
&SquishTestTreeModel::onSuiteTreeItemRemoved);
connect(m_squishFileHandler,
&SquishFileHandler::clearedSharedFolders,
this, [this]() { m_squishSharedFolders->removeChildren(); });
m_instance = this; m_instance = this;
} }

View File

@@ -197,7 +197,7 @@ void SquishTestTreeItemDelegate::setModelData(QWidget *editor, QAbstractItemMode
auto sortModel = static_cast<SquishTestTreeSortModel *>(model); auto sortModel = static_cast<SquishTestTreeSortModel *>(model);
auto sourceModel = static_cast<SquishTestTreeModel *>(sortModel->sourceModel()); auto sourceModel = static_cast<SquishTestTreeModel *>(sortModel->sourceModel());
auto lineEdit = static_cast<Utils::FancyLineEdit *>(editor); auto lineEdit = static_cast<Utils::FancyLineEdit *>(editor);
auto removeFormerlyAdded = [sortModel, sourceModel, &index](){ auto removeFormerlyAdded = [sortModel, sourceModel, &index] {
auto item = sourceModel->itemForIndex(sortModel->mapToSource(index)); auto item = sourceModel->itemForIndex(sortModel->mapToSource(index));
QTC_ASSERT(item, return); QTC_ASSERT(item, return);
sourceModel->destroyItem(item); sourceModel->destroyItem(item);

View File

@@ -142,8 +142,7 @@ SquishTools::SquishTools(QObject *parent)
if (m_runnerProcess.processId() != -1) if (m_runnerProcess.processId() != -1)
interruptRunner(); interruptRunner();
}); });
connect(&m_perspective, &SquishPerspective::stopRequested, connect(&m_perspective, &SquishPerspective::stopRequested, this, [this] {
this, [this] () {
bool interrupted = m_squishRunnerState == RunnerState::Interrupted; bool interrupted = m_squishRunnerState == RunnerState::Interrupted;
RunnerState state = interrupted ? RunnerState::CancelRequestedWhileInterrupted RunnerState state = interrupted ? RunnerState::CancelRequestedWhileInterrupted
: RunnerState::CancelRequested; : RunnerState::CancelRequested;
@@ -1122,7 +1121,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
m_requestVarsTimer = new QTimer(this); m_requestVarsTimer = new QTimer(this);
m_requestVarsTimer->setSingleShot(true); m_requestVarsTimer->setSingleShot(true);
m_requestVarsTimer->setInterval(1000); 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_runnerProcess.write("print variables\n");
}); });
m_requestVarsTimer->start(); m_requestVarsTimer->start();
@@ -1174,7 +1173,7 @@ void SquishTools::onResultsDirChanged(const QString &filePath)
} else { } else {
disconnect(m_resultsFileWatcher); disconnect(m_resultsFileWatcher);
// results.xml is created as soon some output has been opened - so try again in a second // 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(); window->showMinimized();
if (!m_lastTopLevelWindows.contains(window)) { if (!m_lastTopLevelWindows.contains(window)) {
m_lastTopLevelWindows.append(window); m_lastTopLevelWindows.append(window);
connect(window, &QWindow::destroyed, this, [this, window]() { connect(window, &QWindow::destroyed, this, [this, window] {
m_lastTopLevelWindows.removeOne(window); m_lastTopLevelWindows.removeOne(window);
}); });
} }

View File

@@ -369,17 +369,16 @@ bool SquishFileGenerator::writeFile(const ProjectExplorer::JsonWizard *,
return true; return true;
} }
bool SquishFileGenerator::allDone(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file, bool SquishFileGenerator::allDone(const ProjectExplorer::JsonWizard *wizard,
QString *errorMessage) Core::GeneratedFile *file, QString *errorMessage)
{ {
Q_UNUSED(wizard) Q_UNUSED(wizard)
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
if (m_mode == "TestSuite") { if (m_mode == "TestSuite" && file->filePath().fileName() == "suite.conf") {
if (file->filePath().fileName() == "suite.conf") QMetaObject::invokeMethod(SquishFileHandler::instance(), [filePath = file->filePath()] {
QTimer::singleShot(0, [filePath = file->filePath()] {
SquishFileHandler::instance()->openTestSuite(filePath); SquishFileHandler::instance()->openTestSuite(filePath);
}); }, Qt::QueuedConnection);
} }
return true; return true;
} }

View File

@@ -32,7 +32,7 @@ static QStringList parseHelper(const QStringView input)
QStringList result; QStringList result;
QString chunk; QString chunk;
auto appendChunk = [&]() { auto appendChunk = [&] {
if (!chunk.isEmpty()) if (!chunk.isEmpty())
result.append(chunk); result.append(chunk);
chunk.clear(); chunk.clear();