| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_BASE_MODELS_LIST_MODEL_H_ | 5 #ifndef UI_BASE_MODELS_LIST_MODEL_H_ |
| 6 #define UI_BASE_MODELS_LIST_MODEL_H_ | 6 #define UI_BASE_MODELS_LIST_MODEL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 DCHECK_LT(index, item_count()); | 40 DCHECK_LT(index, item_count()); |
| 41 ItemType* item = items_[index]; | 41 ItemType* item = items_[index]; |
| 42 items_.weak_erase(items_.begin() + index); | 42 items_.weak_erase(items_.begin() + index); |
| 43 NotifyItemsRemoved(index, 1); | 43 NotifyItemsRemoved(index, 1); |
| 44 return item; | 44 return item; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Removes all items from the model. This does NOT delete the items. | 47 // Removes all items from the model. This does NOT delete the items. |
| 48 void RemoveAll() { | 48 void RemoveAll() { |
| 49 size_t count = item_count(); | 49 size_t count = item_count(); |
| 50 items_.clear(); | 50 items_.weak_clear(); |
| 51 NotifyItemsRemoved(0, count); | 51 NotifyItemsRemoved(0, count); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Removes an item at given |index| from the model and deletes it. | 54 // Removes an item at given |index| from the model and deletes it. |
| 55 void DeleteAt(size_t index) { | 55 void DeleteAt(size_t index) { |
| 56 delete RemoveAt(index); | 56 delete RemoveAt(index); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Removes and deletes all items from the model. | 59 // Removes and deletes all items from the model. |
| 60 void DeleteAll() { | 60 void DeleteAll() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 private: | 102 private: |
| 103 ScopedVector<ItemType> items_; | 103 ScopedVector<ItemType> items_; |
| 104 ObserverList<ListModelObserver> observers_; | 104 ObserverList<ListModelObserver> observers_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(ListModel<ItemType>); | 106 DISALLOW_COPY_AND_ASSIGN(ListModel<ItemType>); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace ui | 109 } // namespace ui |
| 110 | 110 |
| 111 #endif // UI_BASE_MODELS_LIST_MODEL_H_ | 111 #endif // UI_BASE_MODELS_LIST_MODEL_H_ |
| OLD | NEW |