Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: ui/base/models/list_model.h

Issue 22339004: Make an AddAll in ListModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rework, add early return Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/apps_model_builder.cc ('k') | ui/base/models/list_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/models/list_model.h
diff --git a/ui/base/models/list_model.h b/ui/base/models/list_model.h
index 9b4440d9a020d2db41d8bfb7adade37fe2ec173e..861d6ffd1e13d0a87d394aadd032d90777acdeec 100644
--- a/ui/base/models/list_model.h
+++ b/ui/base/models/list_model.h
@@ -34,6 +34,19 @@ class ListModel {
AddAt(item_count(), item);
}
+ // Add a vector of items to the end of the model. This triggers one
+ // notification after adding all items. No notification is sent if |new_items|
+ // is empty.
+ void AddAll(ScopedVector<ItemType> new_items) {
+ if (new_items.empty())
+ return;
+
+ const size_t count = item_count();
+ items_.insert(items_.end(), new_items.begin(), new_items.end());
+ new_items.weak_clear();
+ NotifyItemsAdded(count, items_.size() - count);
+ }
+
// Removes an item at given |index| from the model. Note the removed item
// is NOT deleted and it's up to the caller to delete it.
ItemType* RemoveAt(size_t index) {
« no previous file with comments | « chrome/browser/ui/app_list/apps_model_builder.cc ('k') | ui/base/models/list_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698