summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-08 17:17:48 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-08 17:17:48 +0000
commit368f3a7502802277d24d219c2ed0fdac09f36470 (patch)
treebd877d741c470fa411a53710b3b2f06cc5fa5ae0 /ui
parent39529b33b5e80e5be1d583dfd43f0d692209cbf3 (diff)
downloadchromium_src-368f3a7502802277d24d219c2ed0fdac09f36470.zip
chromium_src-368f3a7502802277d24d219c2ed0fdac09f36470.tar.gz
chromium_src-368f3a7502802277d24d219c2ed0fdac09f36470.tar.bz2
Rename IndexOfChild to GetIndexOf. Part 1
This is part of a serie of patches to make the TreeNode more closer to style used in the Views Tree API (see views/view.h for reference). BUG=None TEST=None Review URL: http://codereview.chromium.org/6623037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/models/tree_model.h12
-rw-r--r--ui/base/models/tree_node_model.h10
-rw-r--r--ui/base/models/tree_node_model_unittest.cc10
3 files changed, 16 insertions, 16 deletions
diff --git a/ui/base/models/tree_model.h b/ui/base/models/tree_model.h
index c133c0b..190115b 100644
--- a/ui/base/models/tree_model.h
+++ b/ui/base/models/tree_model.h
@@ -59,16 +59,16 @@ class TreeModel {
// see SetRootShown for details.
virtual TreeModelNode* GetRoot() = 0;
- // Returns the number of children in the specified node.
+ // Returns the number of children in |parent|.
virtual int GetChildCount(TreeModelNode* parent) = 0;
- // Returns the child node at the specified index.
+ // Returns the child node of |parent| at |index|.
virtual TreeModelNode* GetChild(TreeModelNode* parent, int index) = 0;
- // Returns the index of child node at the specified index.
- virtual int IndexOfChild(TreeModelNode* parent, TreeModelNode* child) = 0;
+ // Returns the index of |child| in |parent|.
+ virtual int GetIndexOf(TreeModelNode* parent, TreeModelNode* child) = 0;
- // Returns the parent of a node, or NULL if node is the root.
+ // Returns the parent of |node|, or NULL if |node| is the root.
virtual TreeModelNode* GetParent(TreeModelNode* node) = 0;
// Adds an observer of the model.
@@ -77,7 +77,7 @@ class TreeModel {
// Removes an observer of the model.
virtual void RemoveObserver(TreeModelObserver* observer) = 0;
- // Sets the title of the specified node.
+ // Sets the title of |node|.
// This is only invoked if the node is editable and the user edits a node.
virtual void SetTitle(TreeModelNode* node, const string16& title);
diff --git a/ui/base/models/tree_node_model.h b/ui/base/models/tree_node_model.h
index 0c64625..34f6ee8 100644
--- a/ui/base/models/tree_node_model.h
+++ b/ui/base/models/tree_node_model.h
@@ -86,7 +86,7 @@ class TreeNode : public TreeModelNode {
// If the node has a parent, remove it from its parent.
NodeType* node_parent = child->GetParent();
if (node_parent)
- node_parent->Remove(node_parent->IndexOfChild(child));
+ node_parent->Remove(node_parent->GetIndexOf(child));
child->parent_ = static_cast<NodeType*>(this);
children_->insert(children_->begin() + index, child);
}
@@ -143,8 +143,8 @@ class TreeNode : public TreeModelNode {
return parent_;
}
- // Returns the index of the specified child, or -1 if node is a not a child.
- int IndexOfChild(const NodeType* node) const {
+ // Returns the index of |node|, or -1 if |node| is not a child of this.
+ int GetIndexOf(const NodeType* node) const {
DCHECK(node);
typename std::vector<NodeType*>::const_iterator i =
std::find(children_->begin(), children_->end(), node);
@@ -249,9 +249,9 @@ class TreeNodeModel : public TreeModel {
return AsNode(parent)->GetChild(index);
}
- virtual int IndexOfChild(TreeModelNode* parent, TreeModelNode* child) {
+ virtual int GetIndexOf(TreeModelNode* parent, TreeModelNode* child) {
DCHECK(parent);
- return AsNode(parent)->IndexOfChild(AsNode(child));
+ return AsNode(parent)->GetIndexOf(AsNode(child));
}
virtual TreeModelNode* GetParent(TreeModelNode* node) {
diff --git a/ui/base/models/tree_node_model_unittest.cc b/ui/base/models/tree_node_model_unittest.cc
index c4747d4..afeed6d 100644
--- a/ui/base/models/tree_node_model_unittest.cc
+++ b/ui/base/models/tree_node_model_unittest.cc
@@ -171,7 +171,7 @@ TEST_F(TreeNodeModelTest, RemoveAllNodes) {
// |-- child1
// | |-- foo1
// +-- child2
-TEST_F(TreeNodeModelTest, IndexOfChild) {
+TEST_F(TreeNodeModelTest, GetIndexOf) {
TreeNodeWithValue<int>* root =
new TreeNodeWithValue<int>(ASCIIToUTF16("root"), 0);
TreeNodeModel<TreeNodeWithValue<int> > model(root);
@@ -190,10 +190,10 @@ TEST_F(TreeNodeModelTest, IndexOfChild) {
new TreeNodeWithValue<int>(ASCIIToUTF16("foo1"), 0);
model.Add(child1, 0, foo1);
- ASSERT_EQ(0, model.IndexOfChild(root, child1));
- ASSERT_EQ(1, model.IndexOfChild(root, child2));
- ASSERT_EQ(0, model.IndexOfChild(child1, foo1));
- ASSERT_EQ(-1, model.IndexOfChild(root, foo1));
+ ASSERT_EQ(0, model.GetIndexOf(root, child1));
+ ASSERT_EQ(1, model.GetIndexOf(root, child2));
+ ASSERT_EQ(0, model.GetIndexOf(child1, foo1));
+ ASSERT_EQ(-1, model.GetIndexOf(root, foo1));
}
// Verify whether a specified node has or not an ancestor.