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 <algorithm> | 8 #include <algorithm> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 for (size_t i = 0; i < children_.size(); ++i) | 99 for (size_t i = 0; i < children_.size(); ++i) |
100 children_[i]->parent_ = NULL; | 100 children_[i]->parent_ = NULL; |
101 children_.weak_clear(); | 101 children_.weak_clear(); |
102 } | 102 } |
103 | 103 |
104 // Removes all existing children without deleting the nodes and adds all nodes | 104 // Removes all existing children without deleting the nodes and adds all nodes |
105 // contained in |children| into this node as children. | 105 // contained in |children| into this node as children. |
106 void SetChildren(const std::vector<NodeType*>& children) { | 106 void SetChildren(const std::vector<NodeType*>& children) { |
107 RemoveAll(); | 107 RemoveAll(); |
108 for (size_t i = 0; i < children.size(); ++i) | 108 for (size_t i = 0; i < children.size(); ++i) |
109 Add(children[i], i); | 109 Add(children[i], static_cast<int>(i)); |
110 } | 110 } |
111 | 111 |
112 // Returns the parent node, or NULL if this is the root node. | 112 // Returns the parent node, or NULL if this is the root node. |
113 const NodeType* parent() const { return parent_; } | 113 const NodeType* parent() const { return parent_; } |
114 NodeType* parent() { return parent_; } | 114 NodeType* parent() { return parent_; } |
115 | 115 |
116 // Returns true if this is the root node. | 116 // Returns true if this is the root node. |
117 bool is_root() const { return parent_ == NULL; } | 117 bool is_root() const { return parent_ == NULL; } |
118 | 118 |
119 // Returns the number of children. | 119 // Returns the number of children. |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 // The root. | 297 // The root. |
298 scoped_ptr<NodeType> root_; | 298 scoped_ptr<NodeType> root_; |
299 | 299 |
300 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); | 300 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); |
301 }; | 301 }; |
302 | 302 |
303 } // namespace ui | 303 } // namespace ui |
304 | 304 |
305 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ | 305 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
OLD | NEW |