• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Property Editing Library
 

KDevelop Property Editing Library

  • lib
  • widgets
  • propeditor
multiproperty.cpp
1/***************************************************************************
2 * Copyright (C) 2004 by Alexander Dymo <cloudtemple@mskat.net> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU Library General Public License as *
6 * published by the Free Software Foundation; either version 2 of the *
7 * License, or (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Library General Public *
15 * License along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
19#include "multiproperty.h"
20
21#include "propertylist.h"
22
23namespace PropertyLib{
24
25MultiProperty::MultiProperty(Property *prop)
26 :m_propertyList(0)
27{
28 list.append(prop);
29}
30
31MultiProperty::MultiProperty(PropertyList *propertyList)
32 :m_propertyList(propertyList)
33{
34}
35
36MultiProperty::MultiProperty(PropertyList *propertyList, Property *prop)
37 :m_propertyList(propertyList)
38{
39 list.append(prop);
40}
41
42MultiProperty::~MultiProperty()
43{
44}
45
46TQString MultiProperty::name() const
47{
48 if (list.count() >= 1)
49 return list.getFirst()->name();
50 return TQString();
51}
52
53int MultiProperty::type() const
54{
55 if (list.count() >= 1)
56 return list.getFirst()->type();
57 return TQVariant::Invalid;
58}
59
60TQVariant MultiProperty::value() const
61{
62 TQVariant value;
63 if (list.count() >= 1)
64 value = list.getFirst()->value();
65
66 TQPtrListIterator<Property> it(list);
67 Property *property;
68 while ((property = it.current()) != 0)
69 {
70 if (property->value() != value)
71 return TQVariant::Invalid;
72 ++it;
73 }
74
75 return value;
76}
77
78TQString MultiProperty::description() const
79{
80 TQString description;
81 if (list.count() >= 1)
82 description = list.getFirst()->description();
83
84 TQPtrListIterator<Property> it(list);
85 Property *property;
86 while ((property = it.current()) != 0)
87 {
88 if (property->description() != description)
89 return TQString();
90 ++it;
91 }
92
93 return description;
94}
95
96bool MultiProperty::readOnly() const
97{
98 bool v = true;
99 if (list.count() >= 1)
100 v = list.getFirst()->readOnly();
101
102 TQPtrListIterator<Property> it(list);
103 Property *property;
104 while ((property = it.current()) != 0)
105 {
106 if (property->readOnly() != v)
107 return false;
108 ++it;
109 }
110
111 return v;
112}
113
114bool MultiProperty::visible() const
115{
116 bool v = true;
117 if (list.count() >= 1)
118 v = list.getFirst()->readOnly();
119
120 TQPtrListIterator<Property> it(list);
121 Property *property;
122 while ((property = it.current()) != 0)
123 {
124 if (property->visible() != v)
125 return false;
126 ++it;
127 }
128
129 return v;
130}
131
132TQStringVariantMap MultiProperty::valueList() const
133{
134 if (list.count() >= 1)
135 return list.getFirst()->valueList;
136 return TQStringVariantMap();
137}
138
139void MultiProperty::setDescription(const TQString &description)
140{
141 Property *property;
142 for (property = list.first(); property; property = list.next())
143 property->setDescription(description);
144}
145
146/*void MultiProperty::setName(const TQString &name)
147{
148}
149
150void MultiProperty::setType(int type)
151{
152}
153*/
154void MultiProperty::setValue(const TQVariant &value)
155{
156 Property *property;
157 for (property = list.first(); property; property = list.next())
158 {
159 property->setValue(value);
160 if (m_propertyList)
161 {
162// tqWarning("emit change");
163 emit m_propertyList->propertyValueChanged(property);
164 }
165 }
166}
167
168void MultiProperty::setValue(const TQVariant &value, bool emitChange)
169{
170 Property *property;
171 for (property = list.first(); property; property = list.next())
172 {
173 property->setValue(value);
174 if (emitChange && m_propertyList)
175 emit m_propertyList->propertyValueChanged(property);
176 }
177}
178
179void MultiProperty::setValueList(const TQStringVariantMap &valueList)
180{
181 Property *property;
182 for (property = list.first(); property; property = list.next())
183 property->setValueList(valueList);
184}
185
186void MultiProperty::addProperty(Property *prop)
187{
188 list.append(prop);
189}
190
191void MultiProperty::removeProperty(Property *prop)
192{
193/* tqWarning("op >> removing %s", prop->name().ascii());
194 tqWarning("op >> list is %d", list.count());*/
195 /*bool b = */list.remove(prop);
196/* tqWarning("op >> list is %d", list.count());
197 tqWarning("op >> removal is %s", b?"true":"false"); */
198}
199
200bool MultiProperty::operator ==(const MultiProperty &prop) const
201{
202 if ( (type() == prop.type()) && (name() == prop.name()) )
203 return true;
204 return false;
205}
206
207bool MultiProperty::operator ==(const Property &prop) const
208{
209/* tqWarning("MultiProperty::operator == for %s = %s", name().ascii(), prop.name().ascii());
210 tqWarning("MultiProperty::operator == for %d = %d", type(), prop.type());*/
211 if ( (type() == prop.type()) && (name() == prop.name()) )
212 return true;
213 return false;
214}
215
216void MultiProperty::addProperty( MultiProperty *prop)
217{
218 Property *property;
219 for (property = prop->list.first(); property; property = prop->list.next())
220 addProperty(property);
221}
222
223void MultiProperty::removeProperty( MultiProperty *prop)
224{
225 Property *property;
226 for (property = prop->list.first(); property; property = prop->list.next())
227 removeProperty(property);
228}
229
230TQVariant MultiProperty::findValueDescription() const
231{
232 TQVariant val = value();
233 if (type() != Property::ValueFromList)
234 return val;
235 TQStringVariantMap vl = valueList();
236 for (TQStringVariantMap::const_iterator it = vl.begin(); it != vl.end(); ++ it)
237 {
238 if (it.data() == val)
239 return it.key();
240 }
241 return "";
242}
243
244TQVariant MultiProperty::findValueDescription(TQVariant val) const
245{
246 if (type() != Property::ValueFromList)
247 return val;
248 TQStringVariantMap vl = valueList();
249 for (TQStringVariantMap::const_iterator it = vl.begin(); it != vl.end(); ++ it)
250 {
251 if (it.data() == val)
252 return it.key();
253 }
254 return "";
255}
256
257bool MultiProperty::valid() const
258{
259 return list.count() != 0;
260}
261
262void MultiProperty::undo()
263{
264 Property *property;
265 for (property = list.first(); property; property = list.next())
266 {
267 property->setValue(property->oldValue(), false);
268 if (m_propertyList)
269 emit m_propertyList->propertyValueChanged(property);
270 }
271}
272
273}
PropertyLib::MultiProperty
Holds a list of properties with the same name and type.
Definition multiproperty.h:50
PropertyLib::MultiProperty::operator==
bool operator==(const MultiProperty &prop) const
Compares two multiproperties.
Definition multiproperty.cpp:200
PropertyLib::MultiProperty::type
int type() const
Returns the type of a property.
Definition multiproperty.cpp:53
PropertyLib::MultiProperty::setValue
void setValue(const TQVariant &value)
Sets the value of a property.
Definition multiproperty.cpp:154
PropertyLib::MultiProperty::MultiProperty
MultiProperty(Property *prop)
Constructs multiproperty with one property which is not connected to a property list.
Definition multiproperty.cpp:25
PropertyLib::MultiProperty::valueList
TQStringVariantMap valueList() const
The string-to-value correspondence list of the property.
Definition multiproperty.cpp:132
PropertyLib::MultiProperty::valid
bool valid() const
Returns true if the multiproperty has no properties in the list (i.e.
Definition multiproperty.cpp:257
PropertyLib::MultiProperty::undo
void undo()
Reverts the property value to previous setting.
Definition multiproperty.cpp:262
PropertyLib::MultiProperty::description
TQString description() const
Returns the description of a property.
Definition multiproperty.cpp:78
PropertyLib::MultiProperty::name
TQString name() const
Returns the name of a property.
Definition multiproperty.cpp:46
PropertyLib::MultiProperty::setDescription
void setDescription(const TQString &description)
Sets the description of a property.
Definition multiproperty.cpp:139
PropertyLib::MultiProperty::visible
bool visible() const
Returns the visibility attribute of a property.
Definition multiproperty.cpp:114
PropertyLib::MultiProperty::setValueList
void setValueList(const TQMap< TQString, TQVariant > &valueList)
Sets the list of possible values of a property.
Definition multiproperty.cpp:179
PropertyLib::MultiProperty::addProperty
void addProperty(Property *prop)
Adds property to the list.
Definition multiproperty.cpp:186
PropertyLib::MultiProperty::readOnly
bool readOnly() const
Returns the readonly attribute of a property.
Definition multiproperty.cpp:96
PropertyLib::MultiProperty::findValueDescription
TQVariant findValueDescription() const
Finds string description for a value.
Definition multiproperty.cpp:230
PropertyLib::MultiProperty::removeProperty
void removeProperty(Property *prop)
Removes property from the list.
Definition multiproperty.cpp:191
PropertyLib::MultiProperty::value
TQVariant value() const
Returns the value of a property.
Definition multiproperty.cpp:60
PropertyLib::PropertyList
The list of properties.
Definition propertylist.h:56
PropertyLib::PropertyList::propertyValueChanged
void propertyValueChanged(Property *property)
Emitted when the value of the property is changed.
PropertyLib::Property
Property.
Definition property.h:62
PropertyLib::Property::readOnly
virtual bool readOnly() const
Tells if the property is read only.
Definition property.cpp:106
PropertyLib::Property::visible
virtual bool visible() const
Tells if the property is visible.
Definition property.cpp:111
PropertyLib::Property::name
virtual TQString name() const
Definition property.cpp:57
PropertyLib::Property::description
virtual TQString description() const
Definition property.cpp:91
PropertyLib::Property::setValue
virtual void setValue(const TQVariant &value, bool rememberOldValue=true)
Sets the value of the property.
Definition property.cpp:82
PropertyLib::Property::setDescription
virtual void setDescription(const TQString &description)
Sets the description of the property.
Definition property.cpp:96
PropertyLib::Property::oldValue
virtual TQVariant oldValue() const
Gets the previous property value.
Definition property.cpp:121
PropertyLib::Property::type
virtual int type() const
Definition property.cpp:67
PropertyLib::Property::value
virtual TQVariant value() const
Definition property.cpp:77
PropertyLib::Property::setValueList
virtual void setValueList(const TQStringVariantMap &list)
Sets the string-to-value correspondence list of the property.
Definition property.cpp:101
PropertyLib::Property::ValueFromList
@ ValueFromList
string value from a list
Definition property.h:107
multiproperty.h
Contains PropertyLib::MultiProperty class.
PropertyLib
Namespace which contain property editing classes.
Definition childproperty.cpp:29
propertylist.h
Contains PropertyLib::PropertyList class.

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Property Editing Library by doxygen 1.9.8
This website is maintained by Timothy Pearson.