diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-11-30 09:59:14 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-30 12:07:45 +0100 |
commit | 169beff21ef85e57da23fc870fd4e8b937e10ef3 (patch) | |
tree | 58dfe8cfdde5a14ee31190da6dd79df85f4da00f /Libraries | |
parent | b532b2d3ca895f1dbc5c74fa7044c2ca7bafdeec (diff) | |
download | serenity-169beff21ef85e57da23fc870fd4e8b937e10ef3.zip |
LibGUI: Add a ModelSelection::add_all(Vector) API
Using add() is very slow due to the change notifications.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/ModelSelection.cpp | 12 | ||||
-rw-r--r-- | Libraries/LibGUI/ModelSelection.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Libraries/LibGUI/ModelSelection.cpp b/Libraries/LibGUI/ModelSelection.cpp index 5b4d208883..2a22336855 100644 --- a/Libraries/LibGUI/ModelSelection.cpp +++ b/Libraries/LibGUI/ModelSelection.cpp @@ -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()); diff --git a/Libraries/LibGUI/ModelSelection.h b/Libraries/LibGUI/ModelSelection.h index d40cea4a36..78e0585250 100644 --- a/Libraries/LibGUI/ModelSelection.h +++ b/Libraries/LibGUI/ModelSelection.h @@ -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(); |