LibGUI: Add a ModelSelection::add_all(Vector) API

Using add() is very slow due to the change notifications.
This commit is contained in:
AnotherTest 2020-11-30 09:59:14 +03:30 committed by Andreas Kling
parent b532b2d3ca
commit 169beff21e
Notes: sideshowbarker 2024-07-19 01:09:14 +09:00
2 changed files with 13 additions and 0 deletions

View file

@ -64,6 +64,18 @@ void ModelSelection::add(const ModelIndex& index)
notify_selection_changed();
}
void ModelSelection::add_all(const Vector<ModelIndex>& indices)
{
{
TemporaryChange notify_change { m_disable_notify, true };
for (auto& index : indices)
add(index);
}
if (m_notify_pending)
notify_selection_changed();
}
void ModelSelection::toggle(const ModelIndex& index)
{
ASSERT(index.is_valid());

View file

@ -59,6 +59,7 @@ public:
void set(const ModelIndex&);
void add(const ModelIndex&);
void add_all(const Vector<ModelIndex>&);
void toggle(const ModelIndex&);
bool remove(const ModelIndex&);
void clear();