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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "propertysheet.h"
#include "mrml_elements.h"
#include "mrml_shared.h"
#include <knuminput.h>
#include <tqwidget.h>
using namespace KMrml;
template class TQValueList<TQDomElement>;
PropertySheet::PropertySheet()
{
init();
}
PropertySheet::PropertySheet( const TQDomElement& elem )
{
init();
initFromDOM( elem );
}
PropertySheet::PropertySheet( const PropertySheet& ps )
{
*this = ps;
}
PropertySheet& PropertySheet::operator= ( const PropertySheet& ps )
{
if ( &ps == this )
return *this;
m_visibility = ps.m_visibility;
m_type = ps.m_type;
m_caption = ps.m_caption;
m_id = ps.m_id;
m_sendType = ps.m_sendType;
m_sendName = ps.m_sendName;
m_sendValue = ps.m_sendValue;
m_minRange = ps.m_minRange;
m_maxRange = ps.m_maxRange;
m_stepSize = ps.m_stepSize;
m_minSubsetSize = ps.m_minSubsetSize;
m_maxSubsetSize = ps.m_maxSubsetSize;
// deep copy of m_subSheets
TQPtrListIterator<PropertySheet> it( ps.m_subSheets );
for ( ; it.current(); ++it )
m_subSheets.append( new PropertySheet( *it.current() ) );
return *this;
}
void PropertySheet::init()
{
m_subSheets.setAutoDelete( true );
m_visibility = Visible;
}
void PropertySheet::initFromDOM( const TQDomElement& elem )
{
m_subSheets.clear();
m_visibility = getVisibility( elem.attribute( MrmlShared::visibility() ));
m_type = getType( elem.attribute( MrmlShared::propertySheetType() ) );
m_caption = elem.attribute( MrmlShared::caption() );
m_id = elem.attribute( MrmlShared::propertySheetId() );
m_sendType = getSendType( elem.attribute( MrmlShared::sendType() ));
m_sendName = elem.attribute( MrmlShared::sendName() );
m_sendValue = elem.attribute( MrmlShared::sendValue() );
m_minRange = toInt( elem.attribute( MrmlShared::from() ));
m_maxRange = toInt( elem.attribute( MrmlShared::to() ));
m_stepSize = toInt( elem.attribute( MrmlShared::step() ));
m_minSubsetSize = toInt( elem.attribute( MrmlShared::minSubsetSize() ));
m_maxSubsetSize = toInt( elem.attribute( MrmlShared::maxSubsetSize() ));
TQValueList<TQDomElement> tqchildren =
KMrml::directChildElements( elem, MrmlShared::propertySheet() );
TQValueListConstIterator<TQDomElement> it = tqchildren.begin();
for ( ; it != tqchildren.end(); ++it )
m_subSheets.append( new PropertySheet( *it ) );
}
TQWidget * PropertySheet::createWidget( TQWidget */*parent*/, const char */*name*/ )
{
TQWidget *w = 0L;
switch ( m_type )
{
case Numeric:
{
// KIntNumInput *input = new KIntNumInput();
break;
}
case Subset:
{
if ( m_minSubsetSize == 1 && m_maxSubsetSize == 1 )
{
}
break;
}
default:
qDebug("** can't create widget for type: %i", m_type);
}
return w;
}
//
// static methods
//
PropertySheet::Visibility PropertySheet::getVisibility( const TQString& value )
{
Visibility vis;
if ( value == MrmlShared::invisible() )
vis = Invisible;
else if ( value == MrmlShared::popup() )
vis = Popup;
else
vis = Visible; // default value
return vis;
}
PropertySheet::Type PropertySheet::getType( const TQString& value )
{
Type type = (Type) 0;
if ( value == MrmlShared::multiSet() )
type = MultiSet;
else if ( value == MrmlShared::subset() )
type = Subset;
else if ( value == MrmlShared::setElement() )
type = SetElement;
else if ( value == MrmlShared::boolean() )
type = Boolean;
else if ( value == MrmlShared::numeric() )
type = Numeric;
else if ( value == MrmlShared::textual() )
type = Textual;
else if ( value == MrmlShared::panel() )
type = Panel;
else if ( value == MrmlShared::clone() )
type = Clone;
else if ( value == MrmlShared::reference() )
type = Reference;
return type;
}
PropertySheet::SendType PropertySheet::getSendType( const TQString& value )
{
SendType type = (SendType) 0;
if ( value == MrmlShared::element() )
type = Element;
else if ( value == MrmlShared::attribute() )
type = Attribute;
else if ( value == MrmlShared::attributeName() )
type = AttributeName;
else if ( value == MrmlShared::attributeValue() )
type = AttributeValue;
else if ( value == MrmlShared::tqchildren() )
type = Children;
else if ( value == MrmlShared::none() )
type = None;
return type;
}
int PropertySheet::toInt( const TQString& value, int defaultValue )
{
bool ok = false;
int res = value.toInt( &ok );
return ok ? res : defaultValue;
}
|