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

Side by Side Diff: ui/base/models/tree_model.h

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months 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
« no previous file with comments | « ui/base/models/table_model_observer.h ('k') | ui/base/models/tree_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_BASE_MODELS_TREE_MODEL_H_
6 #define UI_BASE_MODELS_TREE_MODEL_H_
7
8 #include <vector>
9
10 #include "base/strings/string16.h"
11 #include "ui/base/ui_base_export.h"
12
13 namespace gfx {
14 class ImageSkia;
15 }
16
17 namespace ui {
18
19 class TreeModel;
20
21 // TreeModelNode --------------------------------------------------------------
22
23 // Type of class returned from the model.
24 class TreeModelNode {
25 public:
26 // Returns the title for the node.
27 virtual const base::string16& GetTitle() const = 0;
28
29 protected:
30 virtual ~TreeModelNode() {}
31 };
32
33 // Observer for the TreeModel. Notified of significant events to the model.
34 class UI_BASE_EXPORT TreeModelObserver {
35 public:
36 // Notification that nodes were added to the specified parent.
37 virtual void TreeNodesAdded(TreeModel* model,
38 TreeModelNode* parent,
39 int start,
40 int count) = 0;
41
42 // Notification that nodes were removed from the specified parent.
43 virtual void TreeNodesRemoved(TreeModel* model,
44 TreeModelNode* parent,
45 int start,
46 int count) = 0;
47
48 // Notification that the contents of a node has changed.
49 virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) = 0;
50
51 protected:
52 virtual ~TreeModelObserver() {}
53 };
54
55 // TreeModel ------------------------------------------------------------------
56
57 // The model for TreeView.
58 class UI_BASE_EXPORT TreeModel {
59 public:
60 // Returns the root of the tree. This may or may not be shown in the tree,
61 // see SetRootShown for details.
62 virtual TreeModelNode* GetRoot() = 0;
63
64 // Returns the number of children in |parent|.
65 virtual int GetChildCount(TreeModelNode* parent) = 0;
66
67 // Returns the child node of |parent| at |index|.
68 virtual TreeModelNode* GetChild(TreeModelNode* parent, int index) = 0;
69
70 // Returns the index of |child| in |parent|.
71 virtual int GetIndexOf(TreeModelNode* parent, TreeModelNode* child) = 0;
72
73 // Returns the parent of |node|, or NULL if |node| is the root.
74 virtual TreeModelNode* GetParent(TreeModelNode* node) = 0;
75
76 // Adds an observer of the model.
77 virtual void AddObserver(TreeModelObserver* observer) = 0;
78
79 // Removes an observer of the model.
80 virtual void RemoveObserver(TreeModelObserver* observer) = 0;
81
82 // Sets the title of |node|.
83 // This is only invoked if the node is editable and the user edits a node.
84 virtual void SetTitle(TreeModelNode* node, const base::string16& title);
85
86 // Returns the set of icons for the nodes in the tree. You only need override
87 // this if you don't want to use the default folder icons.
88 virtual void GetIcons(std::vector<gfx::ImageSkia>* icons) {}
89
90 // Returns the index of the icon to use for |node|. Return -1 to use the
91 // default icon. The index is relative to the list of icons returned from
92 // GetIcons.
93 virtual int GetIconIndex(TreeModelNode* node);
94
95 protected:
96 virtual ~TreeModel() {}
97 };
98
99 } // namespace ui
100
101 #endif // UI_BASE_MODELS_TREE_MODEL_H_
OLDNEW
« no previous file with comments | « ui/base/models/table_model_observer.h ('k') | ui/base/models/tree_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698