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);
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,

View File

@@ -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<ObjectsMapDocument>(new ObjectsMapDocument));
});
}

View File

@@ -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);
}

View File

@@ -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?"

View File

@@ -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) {

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -197,7 +197,7 @@ void SquishTestTreeItemDelegate::setModelData(QWidget *editor, QAbstractItemMode
auto sortModel = static_cast<SquishTestTreeSortModel *>(model);
auto sourceModel = static_cast<SquishTestTreeModel *>(sortModel->sourceModel());
auto lineEdit = static_cast<Utils::FancyLineEdit *>(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);

View File

@@ -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);
});
}

View File

@@ -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;
}

View File

@@ -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();