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

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: 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..3b8459c3ce5bc71993463ef201df32e40434c823 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.
+ void AddAll(ScopedVector<ItemType> new_items) {
+ size_t count = item_count();
xiyuan 2013/08/06 03:42:07 nit: const size_t
calamity 2013/08/07 07:19:40 Done.
+ std::vector<ItemType*> new_items_released;
+ new_items.release(&new_items_released);
+ items_.insert(items_.end(),
+ new_items_released.begin(),
+ new_items_released.end());
xiyuan 2013/08/06 03:42:07 How about getting rid of |new_items_released| and
calamity 2013/08/07 07:19:40 Done.
+ NotifyItemsAdded(count, new_items_released.size());
+ }
+
+
xiyuan 2013/08/06 03:42:07 nit: nuke one empty line
calamity 2013/08/07 07:19:40 Done.
// 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