From 3f1e64d863cc179d4246fe474232b00ef5c45c94 Mon Sep 17 00:00:00 2001 From: przemek83 <4788832+przemek83@users.noreply.github.com> Date: Thu, 26 Dec 2024 15:25:16 +0100 Subject: [PATCH] Move reaction logic for FilterStrings change from lambda to dedicated slot. --- examples/Examples.cpp | 15 +++++++++------ examples/Examples.h | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/Examples.cpp b/examples/Examples.cpp index c01c1ac..aa67743 100644 --- a/examples/Examples.cpp +++ b/examples/Examples.cpp @@ -67,12 +67,10 @@ FilterDates* Examples::getFilterDates() return &filterDates_; } -FilterStrings* Examples::createFilterStrings() +FilterStrings* Examples::getFilterStrings() { - QObject::connect(&filterStrings_, &FilterStrings::newStringFilter, &info_, - [&info = info_](const QStringList& bannedItems) { - info.setText("Names Filter: " + bannedItems.join(',')); - }); + QObject::connect(&filterStrings_, &FilterStrings::newStringFilter, this, + &Examples::filterStringsValuesChanged); filterStrings_.setCheckable(true); return &filterStrings_; @@ -90,7 +88,7 @@ QVBoxLayout* Examples::createLeftWidgetColumn() leftLayout->addWidget(getFilterIntegers()); leftLayout->addWidget(getFilterDoubles()); leftLayout->addWidget(getFilterDates()); - leftLayout->addWidget(createFilterStrings()); + leftLayout->addWidget(getFilterStrings()); leftLayout->addWidget(&info_); leftLayout->addStretch(); return leftLayout; @@ -215,3 +213,8 @@ void Examples::filterDatesValuesChanged(QDate from, QDate to, info_.setText(msg); } + +void Examples::filterStringsValuesChanged(QStringList bannedItems) +{ + info_.setText("Names Filter: " + bannedItems.join(',')); +} diff --git a/examples/Examples.h b/examples/Examples.h index cb4fa75..ce23155 100644 --- a/examples/Examples.h +++ b/examples/Examples.h @@ -24,7 +24,7 @@ class Examples : public QWidget FilterNumbers* getFilterIntegers(); FilterNumbers* getFilterDoubles(); FilterDates* getFilterDates(); - FilterStrings* createFilterStrings(); + FilterStrings* getFilterStrings(); QVBoxLayout* createLeftWidgetColumn(); QGroupBox* wrapProgressBar(const QString& name, ProgressBar* progressBar, QPushButton* startStopButton); @@ -63,4 +63,6 @@ private slots: void filterDoublesValuesChanged(double min, double max); void filterDatesValuesChanged(QDate from, QDate to, bool filterEmptyDates); + + void filterStringsValuesChanged(QStringList bannedItems); };