mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Refactor std::any_of into lambda
Rewrite 16cc218097
to avoid the lambda accessing external variable
is_req_column_type
This commit is contained in:
parent
be88133b15
commit
6db868ab64
@ -1683,13 +1683,16 @@ void CsvImpPriceAssist::preview_refresh_table ()
|
||||
preview_style_column (i, combostore);
|
||||
|
||||
auto column_types = price_imp->column_types_price();
|
||||
GncPricePropType req_column_type;
|
||||
auto is_req_column_type = [&req_column_type] (GncPricePropType column_type)->bool
|
||||
{ return column_type == req_column_type; };
|
||||
auto any_of_type = [](std::vector<GncPricePropType>& column_types,
|
||||
GncPricePropType req_column_type) -> bool
|
||||
{
|
||||
return std::any_of (column_types.begin(), column_types.end(),
|
||||
[&req_column_type](GncPricePropType column_type) -> bool
|
||||
{ return column_type == req_column_type; });
|
||||
};
|
||||
|
||||
// look for a namespace column, clear the commodity combo
|
||||
req_column_type = GncPricePropType::FROM_NAMESPACE; // Used by is_column_type()
|
||||
if (std::any_of (column_types.begin(), column_types.end(), is_req_column_type))
|
||||
if (any_of_type (column_types, GncPricePropType::FROM_NAMESPACE))
|
||||
{
|
||||
g_signal_handlers_block_by_func (commodity_selector, (gpointer) csv_price_imp_preview_commodity_sel_cb, this);
|
||||
set_commodity_for_combo (GTK_COMBO_BOX(commodity_selector), nullptr);
|
||||
@ -1697,8 +1700,7 @@ void CsvImpPriceAssist::preview_refresh_table ()
|
||||
}
|
||||
|
||||
// look for a symbol column, clear the commodity combo
|
||||
req_column_type = GncPricePropType::FROM_SYMBOL; // Used by is_column_type()
|
||||
if (std::any_of (column_types.begin(), column_types.end(), is_req_column_type))
|
||||
if (any_of_type (column_types, GncPricePropType::FROM_SYMBOL))
|
||||
{
|
||||
g_signal_handlers_block_by_func (commodity_selector, (gpointer) csv_price_imp_preview_commodity_sel_cb, this);
|
||||
set_commodity_for_combo (GTK_COMBO_BOX(commodity_selector), nullptr);
|
||||
@ -1706,8 +1708,7 @@ void CsvImpPriceAssist::preview_refresh_table ()
|
||||
}
|
||||
|
||||
// look for a currency column, clear the currency combo
|
||||
req_column_type = GncPricePropType::TO_CURRENCY; // Used by is_column_type()
|
||||
if (std::any_of (column_types.begin(), column_types.end(), is_req_column_type))
|
||||
if (any_of_type (column_types, GncPricePropType::TO_CURRENCY))
|
||||
{
|
||||
g_signal_handlers_block_by_func (currency_selector, (gpointer) csv_price_imp_preview_currency_sel_cb, this);
|
||||
set_commodity_for_combo (GTK_COMBO_BOX(currency_selector), nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user