Add RemoveItemsByName()

Helper function to remove Items by name from std::queue of Item
This commit is contained in:
WarmUpTill 2024-04-29 20:40:42 +02:00 committed by WarmUpTill
parent ce501bd972
commit d71c87535f
2 changed files with 17 additions and 0 deletions

View File

@ -347,4 +347,18 @@ void Item::Save(obs_data_t *obj) const
obs_data_set_string(obj, "name", _name.c_str());
}
void RemoveItemsByName(std::deque<std::shared_ptr<Item>> &items,
const QStringList &names)
{
for (const auto &name : names) {
items.erase(std::remove_if(
items.begin(), items.end(),
[name](const std::shared_ptr<Item> &item) {
return item->Name() ==
name.toStdString();
}),
items.end());
}
}
} // namespace advss

View File

@ -32,6 +32,9 @@ protected:
friend ItemSettingsDialog;
};
void EXPORT RemoveItemsByName(std::deque<std::shared_ptr<Item>> &items,
const QStringList &names);
class ItemSettingsDialog : public QDialog {
Q_OBJECT