summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-11-30 09:59:14 +0330
committerAndreas Kling <kling@serenityos.org>2020-11-30 12:07:45 +0100
commit169beff21ef85e57da23fc870fd4e8b937e10ef3 (patch)
tree58dfe8cfdde5a14ee31190da6dd79df85f4da00f
parentb532b2d3ca895f1dbc5c74fa7044c2ca7bafdeec (diff)
downloadserenity-169beff21ef85e57da23fc870fd4e8b937e10ef3.zip
LibGUI: Add a ModelSelection::add_all(Vector) API
Using add() is very slow due to the change notifications.
-rw-r--r--Libraries/LibGUI/ModelSelection.cpp12
-rw-r--r--Libraries/LibGUI/ModelSelection.h1
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();