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

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

Issue 10332264: ui/base/models: Remove unnecessary virtuals from ListModel functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « no previous file | no next file » | 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 cf30df2a421db625bb7d85569c9b0ab9fee7ce15..78e8d7d6c5fbace52d6d014dc5c99639db748d45 100644
--- a/ui/base/models/list_model.h
+++ b/ui/base/models/list_model.h
@@ -21,18 +21,23 @@ template <class ItemType>
class ListModel {
public:
ListModel() {}
- virtual ~ListModel() {}
+ ~ListModel() {}
// Adds |item| to the model at given |index|.
- virtual void AddAt(size_t index, ItemType* item) {
+ void AddAt(size_t index, ItemType* item) {
DCHECK_LE(index, item_count());
items_->insert(items_.begin() + index, item);
NotifyItemsAdded(index, 1);
}
+ // Convenience function to append an item to the model.
+ void Add(ItemType* item) {
+ AddAt(item_count(), item);
+ }
+
// 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.
- virtual ItemType* RemoveAt(size_t index) {
+ ItemType* RemoveAt(size_t index) {
DCHECK_LT(index, item_count());
ItemType* item = items_[index];
items_->erase(items_.begin() + index);
@@ -41,29 +46,24 @@ class ListModel {
}
// Removes all items from the model. This does NOT delete the items.
- virtual void RemoveAll() {
+ void RemoveAll() {
size_t count = item_count();
items_->clear();
NotifyItemsRemoved(0, count);
}
// Removes an item at given |index| from the model and deletes it.
- virtual void DeleteAt(size_t index) {
+ void DeleteAt(size_t index) {
delete RemoveAt(index);
}
// Removes and deletes all items from the model.
- virtual void DeleteAll() {
+ void DeleteAll() {
size_t count = item_count();
items_.reset();
NotifyItemsRemoved(0, count);
}
- // Convenience function to append an item to the model.
- void Add(ItemType* item) {
- AddAt(item_count(), item);
- }
-
void AddObserver(ListModelObserver* observer) {
observers_.AddObserver(observer);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698