summaryrefslogtreecommitdiffstats
path: root/src/kbfxplasmacanvasstack.cpp
blob: 6f7ae67caf4c31500c6acfb60e7b37c7bf21b28d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 *   Copyright (C) 2006
 *   Siraj Razick <siraj@kdemail.net>
 *   PhobosK <phobosk@mail.kbfx.org>
 *   see Also AUTHORS
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License version 2 as
 *   published by the Free Software Foundation
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "kbfxplasmacanvasstack.h"

KbfxPlasmaCanvasStack::KbfxPlasmaCanvasStack()
{

	m_current= 0;//set to NULL
	m_count =  0;
	m_height  = 0;
	m_width = 0;
	m_groupChain.setAutoDelete ( TRUE );
	m_name = "Unset:Faulty plugin";
}

KbfxPlasmaCanvasStack::~KbfxPlasmaCanvasStack()
{
//TODO: needs to manage memory here


	for ( uint i = 0; i < ( uint ) m_count; ++i )
	{

		m_groupChain.at ( i )->~KbfxPlasmaCanvasGroupView();
		m_groupChain.remove ( m_groupChain.at ( i ) );

	}

	Dict::Iterator it;

	for ( it = m_dict.begin();it != m_dict.end();++it )
	{
		m_dict.remove ( it );
	}

	delete m_current;

}


void
KbfxPlasmaCanvasStack::raise ( uint id )
{

	KbfxPlasmaCanvasGroupView * _gvPtr =  m_groupChain.at ( id );

	if ( !_gvPtr )
		tqDebug ( "Error item not in Stack" );
	else
	{
		for ( uint i = 0; i < m_groupChain.count (); ++i )
		{
			m_groupChain.at ( i )->hide();
		}
		m_height = _gvPtr->height();
		_gvPtr->show();
	}


}



bool
KbfxPlasmaCanvasStack::contains ( TQString name )
{
//FIXME:Depricated Data Structure Needs fixing
	if ( m_dict.contains ( name ) == true )
		return true;
	else
		return false;

}


void
KbfxPlasmaCanvasStack::addGroup ( KbfxPlasmaCanvasGroupView * gPtr )
{
	if ( gPtr == NULL )
	{
		tqDebug
		( "KbfxPlasmaCanvasStack.cpp:34:Null Pointer Passed to addGroup()" );
		return;
	}
	else
	{
		m_groupChain.append ( gPtr );
		m_height = gPtr->height();
		m_width = gPtr->width();
		//   KbfxPlasmaDataStack stackinfo;
///	stackinfo
		m_dict[gPtr->name() ] = m_count;

		m_count++;
	}
}

KbfxPlasmaCanvasStack::Dict
KbfxPlasmaCanvasStack::getDict()
{
	return m_dict;
}

void
KbfxPlasmaCanvasStack::hide()
{
	for ( uint i = 0; i < m_groupChain.count (); ++i )
	{
		m_groupChain.at ( i )->hide();
	}
}


void
KbfxPlasmaCanvasStack::raiseByName ( TQString name )
{
	for ( uint i = 0; i < m_groupChain.count (); ++i )
	{
		m_groupChain.at ( i )->hide();
	}


	for ( uint i = 0; i < m_groupChain.count (); ++i )
	{
		if ( m_groupChain.at ( i )->name() == name )
		{
			m_groupChain.at ( i )->show();
			m_height = m_groupChain.at ( i )->height();
		}
	}

}




KbfxPlasmaCanvasGroupView *
KbfxPlasmaCanvasStack::activeViewByName ( TQString name )
{


	for ( uint i = 0; i < m_groupChain.count (); ++i )
	{
		if ( m_groupChain.at ( i )->name() == name )
		{
			return m_groupChain.at ( i );
		}
	}

	return new KbfxPlasmaCanvasGroupView();
}


TQString
KbfxPlasmaCanvasStack::getItemName ( int id )
{
	return m_groupChain.at ( id )->name();
}

#include "kbfxplasmacanvasstack.moc"