libyui
2.42.5
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Enumerations
Friends
YTreeItem.cc
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.cc
20
21
Author: Stefan Hundhammer <sh@suse.de>
22
23
/-*/
24
25
#include "YTreeItem.h"
26
27
28
YTreeItem::YTreeItem
(
const
std::string & label,
29
bool
isOpen )
30
:
YItem
( label )
31
, _parent( 0 )
32
, _isOpen( isOpen )
33
{
34
}
35
36
37
YTreeItem::YTreeItem
(
const
std::string & label,
38
const
std::string & iconName,
39
bool
isOpen )
40
:
YItem
( label, iconName )
41
, _parent( 0 )
42
, _isOpen( isOpen )
43
{
44
}
45
46
47
YTreeItem::YTreeItem
(
YTreeItem
* parent,
48
const
std::string & label,
49
bool
isOpen )
50
:
YItem
( label )
51
, _parent( parent )
52
, _isOpen( isOpen )
53
{
54
if
( parent )
55
parent->
addChild
(
this
);
56
}
57
58
59
YTreeItem::YTreeItem
(
YTreeItem
* parent,
60
const
std::string & label,
61
const
std::string & iconName,
62
bool
isOpen )
63
:
YItem
( label, iconName )
64
, _parent( parent )
65
, _isOpen( isOpen )
66
{
67
if
( parent )
68
parent->
addChild
(
this
);
69
}
70
71
72
YTreeItem::~YTreeItem
()
73
{
74
deleteChildren
();
75
}
76
77
78
void
YTreeItem::addChild
(
YItem
* child )
79
{
80
_children.push_back( child );
81
}
82
83
84
void
YTreeItem::deleteChildren
()
85
{
86
YItemIterator it =
childrenBegin
();
87
88
while
( it !=
childrenEnd
() )
89
{
90
YItem
* child = *it;
91
++it;
92
delete
child;
93
}
94
95
_children.clear();
96
}
97
98
99
bool
YTreeItem::isOpen
()
const
100
{
101
return
hasChildren
() ? _isOpen :
false
;
102
}
103
104
105
void
YTreeItem::setOpen
(
bool
open )
106
{
107
_isOpen = open;
108
}
src
YTreeItem.cc
Generated by
1.8.3