Skip to content

Commit

Permalink
Move reaction logic for FilterStrings change from lambda to dedicated…
Browse files Browse the repository at this point in the history
… slot.
  • Loading branch information
przemek83 committed Dec 26, 2024
1 parent 99edf31 commit 3f1e64d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 9 additions & 6 deletions examples/Examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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;
Expand Down Expand Up @@ -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(','));
}
4 changes: 3 additions & 1 deletion examples/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -63,4 +63,6 @@ private slots:
void filterDoublesValuesChanged(double min, double max);

void filterDatesValuesChanged(QDate from, QDate to, bool filterEmptyDates);

void filterStringsValuesChanged(QStringList bannedItems);
};

0 comments on commit 3f1e64d

Please sign in to comment.