| 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_TREE_NODE_MODEL_H_ | 5 #ifndef UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
| 6 #define UI_BASE_MODELS_TREE_NODE_MODEL_H_ | 6 #define UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 std::unique_ptr<NodeType> Remove(NodeType* parent, NodeType* node) { | 223 std::unique_ptr<NodeType> Remove(NodeType* parent, NodeType* node) { |
| 224 DCHECK(parent); | 224 DCHECK(parent); |
| 225 int index = parent->GetIndexOf(node); | 225 int index = parent->GetIndexOf(node); |
| 226 std::unique_ptr<NodeType> owned_node = parent->Remove(node); | 226 std::unique_ptr<NodeType> owned_node = parent->Remove(node); |
| 227 NotifyObserverTreeNodesRemoved(parent, index, 1); | 227 NotifyObserverTreeNodesRemoved(parent, index, 1); |
| 228 return owned_node; | 228 return owned_node; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void NotifyObserverTreeNodesAdded(NodeType* parent, int start, int count) { | 231 void NotifyObserverTreeNodesAdded(NodeType* parent, int start, int count) { |
| 232 FOR_EACH_OBSERVER(TreeModelObserver, | 232 for (TreeModelObserver& observer : observer_list_) |
| 233 observer_list_, | 233 observer.TreeNodesAdded(this, parent, start, count); |
| 234 TreeNodesAdded(this, parent, start, count)); | |
| 235 } | 234 } |
| 236 | 235 |
| 237 void NotifyObserverTreeNodesRemoved(NodeType* parent, int start, int count) { | 236 void NotifyObserverTreeNodesRemoved(NodeType* parent, int start, int count) { |
| 238 FOR_EACH_OBSERVER(TreeModelObserver, | 237 for (TreeModelObserver& observer : observer_list_) |
| 239 observer_list_, | 238 observer.TreeNodesRemoved(this, parent, start, count); |
| 240 TreeNodesRemoved(this, parent, start, count)); | |
| 241 } | 239 } |
| 242 | 240 |
| 243 void NotifyObserverTreeNodeChanged(TreeModelNode* node) { | 241 void NotifyObserverTreeNodeChanged(TreeModelNode* node) { |
| 244 FOR_EACH_OBSERVER(TreeModelObserver, | 242 for (TreeModelObserver& observer : observer_list_) |
| 245 observer_list_, | 243 observer.TreeNodeChanged(this, node); |
| 246 TreeNodeChanged(this, node)); | |
| 247 } | 244 } |
| 248 | 245 |
| 249 // TreeModel: | 246 // TreeModel: |
| 250 NodeType* GetRoot() override { | 247 NodeType* GetRoot() override { |
| 251 return root_.get(); | 248 return root_.get(); |
| 252 } | 249 } |
| 253 | 250 |
| 254 int GetChildCount(TreeModelNode* parent) override { | 251 int GetChildCount(TreeModelNode* parent) override { |
| 255 DCHECK(parent); | 252 DCHECK(parent); |
| 256 return AsNode(parent)->child_count(); | 253 return AsNode(parent)->child_count(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 289 |
| 293 // The root. | 290 // The root. |
| 294 std::unique_ptr<NodeType> root_; | 291 std::unique_ptr<NodeType> root_; |
| 295 | 292 |
| 296 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); | 293 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); |
| 297 }; | 294 }; |
| 298 | 295 |
| 299 } // namespace ui | 296 } // namespace ui |
| 300 | 297 |
| 301 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ | 298 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
| OLD | NEW |