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

Side by Side Diff: app/tree_node_model.h

Issue 365005: Converting the Cookies options page from a TableView to a TreeView... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 APP_TREE_NODE_MODEL_H_ 5 #ifndef APP_TREE_NODE_MODEL_H_
6 #define APP_TREE_NODE_MODEL_H_ 6 #define APP_TREE_NODE_MODEL_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Returns the number of children. 102 // Returns the number of children.
103 int GetChildCount() const { 103 int GetChildCount() const {
104 return static_cast<int>(children_->size()); 104 return static_cast<int>(children_->size());
105 } 105 }
106 106
107 // Returns the number of all nodes in teh subtree rooted at this node, 107 // Returns the number of all nodes in teh subtree rooted at this node,
108 // including this node. 108 // including this node.
109 int GetTotalNodeCount() const { 109 int GetTotalNodeCount() const {
110 int count = 1; // Start with one to include the node itself. 110 int count = 1; // Start with one to include the node itself.
111 for (size_t i = 0; i < children_->size(); ++i) { 111 for (size_t i = 0; i < children_->size(); ++i) {
112 TreeNode<NodeType>* child = children_[i]; 112 const TreeNode<NodeType>* child = children_[i];
113 count += child->GetTotalNodeCount(); 113 count += child->GetTotalNodeCount();
114 } 114 }
115 return count; 115 return count;
116 } 116 }
117 117
118 // Returns a child by index. 118 // Returns a child by index.
119 NodeType* GetChild(int index) { 119 NodeType* GetChild(int index) {
120 DCHECK(index >= 0 && index < GetChildCount()); 120 DCHECK(index >= 0 && index < GetChildCount());
121 return children_[index]; 121 return children_[index];
122 } 122 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 DCHECK(parent); 238 DCHECK(parent);
239 return AsNode(parent)->GetChild(index); 239 return AsNode(parent)->GetChild(index);
240 } 240 }
241 241
242 virtual TreeModelNode* GetParent(TreeModelNode* node) { 242 virtual TreeModelNode* GetParent(TreeModelNode* node) {
243 DCHECK(node); 243 DCHECK(node);
244 return AsNode(node)->GetParent(); 244 return AsNode(node)->GetParent();
245 } 245 }
246 246
247 NodeType* AsNode(TreeModelNode* model_node) { 247 NodeType* AsNode(TreeModelNode* model_node) {
248 return reinterpret_cast<NodeType*>(model_node); 248 return static_cast<NodeType*>(model_node);
249 } 249 }
250 250
251 // Sets the title of the specified node. 251 // Sets the title of the specified node.
252 virtual void SetTitle(TreeModelNode* node, 252 virtual void SetTitle(TreeModelNode* node,
253 const std::wstring& title) { 253 const std::wstring& title) {
254 DCHECK(node); 254 DCHECK(node);
255 AsNode(node)->SetTitle(title); 255 AsNode(node)->SetTitle(title);
256 NotifyObserverTreeNodeChanged(node); 256 NotifyObserverTreeNodeChanged(node);
257 } 257 }
258 258
(...skipping 29 matching lines...) Expand all
288 // The root. 288 // The root.
289 scoped_ptr<NodeType> root_; 289 scoped_ptr<NodeType> root_;
290 290
291 // The observer. 291 // The observer.
292 TreeModelObserver* observer_; 292 TreeModelObserver* observer_;
293 293
294 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); 294 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel);
295 }; 295 };
296 296
297 #endif // APP_TREE_NODE_MODEL_H_ 297 #endif // APP_TREE_NODE_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698