libyui
YTreeItem.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YTreeItem.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 #ifndef YTreeItem_h
26 #define YTreeItem_h
27 
28 #include "YItem.h"
29 
35 class YTreeItem: public YItem
36 {
37 public:
41  YTreeItem( const std::string & label,
42  bool isOpen = false );
43 
44  YTreeItem( const std::string & label,
45  const std::string & iconName,
46  bool isOpen = false );
47 
56  const std::string & label,
57  bool isOpen = false );
58 
60  const std::string & label,
61  const std::string & iconName,
62  bool isOpen = false );
63 
69  virtual ~YTreeItem();
70 
75  virtual const char * itemClass() const { return "YTreeItem"; }
76 
82  virtual bool hasChildren() const { return ! _children.empty(); }
83 
89  virtual YItemIterator childrenBegin() { return _children.begin(); }
90  virtual YItemConstIterator childrenBegin() const { return _children.begin(); }
91 
97  virtual YItemIterator childrenEnd() { return _children.end(); }
98  virtual YItemConstIterator childrenEnd() const { return _children.end(); }
99 
107  virtual void addChild( YItem * item_disown );
108 
112  virtual void deleteChildren();
113 
121  bool isOpen() const;
122 
126  void setOpen( bool open = true );
127  void setClosed() { setOpen( false ); }
128 
134  virtual YTreeItem * parent() const { return _parent; }
135 
136 private:
137 
138  YTreeItem * _parent;
139  YItemCollection _children;
140  bool _isOpen;
141 };
142 
143 
144 #endif // YTreeItem_h
virtual void deleteChildren()
Definition: YTreeItem.cc:86
YItemCollection::iterator YItemIterator
Mutable iterator over YItemCollection.
Definition: YItem.h:42
void setOpen(bool open=true)
Definition: YTreeItem.cc:107
virtual bool hasChildren() const
Definition: YTreeItem.h:82
virtual YItemIterator childrenEnd()
Definition: YTreeItem.h:97
std::string label() const
Definition: YItem.h:97
virtual void addChild(YItem *item_disown)
Definition: YTreeItem.cc:80
std::vector< YItem * > YItemCollection
Collection of pointers to YItem.
Definition: YItem.h:39
std::string iconName() const
Definition: YItem.h:107
bool isOpen() const
Definition: YTreeItem.cc:101
virtual const char * itemClass() const
Definition: YTreeItem.h:75
virtual YTreeItem * parent() const
Definition: YTreeItem.h:134
YTreeItem(const std::string &label, bool isOpen=false)
Definition: YItem.h:55
virtual ~YTreeItem()
Definition: YTreeItem.cc:74
YItemCollection::const_iterator YItemConstIterator
Const iterator over YItemCollection.
Definition: YItem.h:45
virtual YItemIterator childrenBegin()
Definition: YTreeItem.h:89
Definition: YTreeItem.h:35