libyui
3.0.5
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Enumerations
Friends
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 <sh@suse.de>
22
23
/-*/
24
25
#ifndef YTreeItem_h
26
#define YTreeItem_h
27
28
#include "YItem.h"
29
30
31
32
/**
33
* Item class for tree items.
34
*
35
* This class implements children management.
36
**/
37
class
YTreeItem
:
public
YItem
38
{
39
public
:
40
/**
41
* Constructors for toplevel items.
42
**/
43
YTreeItem
(
const
std::string &
label
,
44
bool
isOpen
=
false
);
45
46
YTreeItem
(
const
std::string & label,
47
const
std::string &
iconName
,
48
bool
isOpen
=
false
);
49
50
/**
51
* Constructors for items that have a parent item.
52
*
53
* They will automatically register this item with the parent item. The
54
* parent assumes ownership of this item and will delete it in its (the
55
* parent's) destructor.
56
**/
57
YTreeItem
(
YTreeItem
*
parent
,
58
const
std::string & label,
59
bool
isOpen
=
false
);
60
61
YTreeItem
(
YTreeItem
* parent,
62
const
std::string & label,
63
const
std::string & iconName,
64
bool
isOpen
=
false
);
65
66
/**
67
* Destructor.
68
*
69
* This will delete all children.
70
**/
71
virtual
~YTreeItem
();
72
73
/**
74
* Return 'true' if this item has any child items.
75
*
76
* Reimplemented from YItem.
77
**/
78
virtual
bool
hasChildren
()
const
{
return
! _children.empty(); }
79
80
/**
81
* Return an iterator that points to the first child item of this item.
82
*
83
* Reimplemented from YItem.
84
**/
85
virtual
YItemIterator
childrenBegin
() {
return
_children.begin(); }
86
virtual
YItemConstIterator
childrenBegin
()
const
{
return
_children.begin(); }
87
88
/**
89
* Return an iterator that points after the last child item of this item.
90
*
91
* Reimplemented from YItem.
92
**/
93
virtual
YItemIterator
childrenEnd
() {
return
_children.end(); }
94
virtual
YItemConstIterator
childrenEnd
()
const
{
return
_children.end(); }
95
96
/**
97
* Add a child item to this item.
98
*
99
* Note that the constructors that accept a parent pointer will
100
* automatically add themselves to their parent, so applications will
101
* normally not have to call this function.
102
**/
103
virtual
void
addChild
(
YItem
* item_disown );
104
105
/**
106
* Delete all child items.
107
**/
108
virtual
void
deleteChildren
();
109
110
/**
111
* Return 'true' if this tree item should be displayed open (with its
112
* children visible) by default.
113
*
114
* Notice that this will always return 'false' for tree items without
115
* children.
116
**/
117
bool
isOpen
()
const
;
118
119
/**
120
* Change the 'isOpen' flag.
121
**/
122
void
setOpen
(
bool
open );
123
124
/**
125
* Returns this item's parent item or 0 if it is a toplevel item.
126
*
127
* Reimplemented from YItem.
128
**/
129
virtual
YTreeItem
*
parent
()
const
{
return
_parent; }
130
131
private
:
132
133
YTreeItem
* _parent;
134
YItemCollection _children;
135
bool
_isOpen;
136
};
137
138
139
#endif // YTreeItem_h
src
YTreeItem.h
Generated by
1.8.3.1