void SetFilter(wxString const& new_filter) { std::set<HotkeyModelCombo*> old_visible; for (auto item : visible_items) old_visible.insert(static_cast<HotkeyModelCombo*>(item.GetID())); visible_items.clear(); wxDataViewItemArray added; wxDataViewItemArray removed; for (auto& combo : children) { bool was_visible = old_visible.count(&combo) > 0; bool is_visible = combo.IsVisible(new_filter); if (is_visible) visible_items.push_back(wxDataViewItem(&combo)); if (was_visible && !is_visible) removed.push_back(wxDataViewItem(&combo)); if (is_visible && !was_visible) added.push_back(wxDataViewItem(&combo)); } if (!added.empty()) model->ItemsAdded(wxDataViewItem(this), added); if (!removed.empty()) model->ItemsDeleted(wxDataViewItem(this), removed); }
void SetFilter(wxRegEx const& new_filter) { std::set<HotkeyModelCombo*> old_visible; for (size_t i = 0; i < visible_items.size(); ++i) old_visible.insert(static_cast<HotkeyModelCombo*>(visible_items[i].GetID())); visible_items.clear(); wxDataViewItemArray added; wxDataViewItemArray removed; for (std::list<HotkeyModelCombo>::iterator it = children.begin(); it != children.end(); ++it) { bool was_visible = old_visible.count(&*it) > 0; bool is_visible = it->IsVisible(new_filter); if (is_visible) visible_items.push_back(wxDataViewItem(&*it)); if (was_visible && !is_visible) removed.push_back(wxDataViewItem(&*it)); if (is_visible && !was_visible) added.push_back(wxDataViewItem(&*it)); } if (!added.empty()) model->ItemsAdded(wxDataViewItem(this), added); if (!removed.empty()) model->ItemsDeleted(wxDataViewItem(this), removed); }
void Delete(wxDataViewItem const& item) { for (auto it = children.begin(); it != children.end(); ++it) { if (&*it == item.GetID()) { model->ItemDeleted(wxDataViewItem(this), wxDataViewItem((void*)&*it)); children.erase(it); return; } } }
void Delete(wxDataViewItem const& item) { for (std::list<HotkeyModelCombo>::iterator it = children.begin(); it != children.end(); ++it) { if (&*it == item.GetID()) { model->ItemDeleted(wxDataViewItem(this), wxDataViewItem((void*)&*it)); children.erase(it); return; } } }
wxDataViewItem AddChild(Combo const& combo) { children.emplace_back(this, combo); visible_items.push_back(wxDataViewItem(&children.back())); model->ItemAdded(wxDataViewItem(this), wxDataViewItem(&children.back())); return wxDataViewItem(&children.back()); }