• 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 
23 namespace PropertyLib{
24 
25 MultiProperty::MultiProperty(Property *prop)
26  :m_propertyList(0)
27 {
28  list.append(prop);
29 }
30 
31 MultiProperty::MultiProperty(PropertyList *propertyList)
32  :m_propertyList(propertyList)
33 {
34 }
35 
36 MultiProperty::MultiProperty(PropertyList *propertyList, Property *prop)
37  :m_propertyList(propertyList)
38 {
39  list.append(prop);
40 }
41 
42 MultiProperty::~MultiProperty()
43 {
44 }
45 
46 TQString MultiProperty::name() const
47 {
48  if (list.count() >= 1)
49  return list.getFirst()->name();
50  return TQString();
51 }
52 
53 int MultiProperty::type() const
54 {
55  if (list.count() >= 1)
56  return list.getFirst()->type();
57  return TQVariant::Invalid;
58 }
59 
60 TQVariant 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 
78 TQString 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 
96 bool 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 
114 bool 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 
132 TQMap<TQString, TQVariant> MultiProperty::valueList() const
133 {
134  if (list.count() >= 1)
135  return list.getFirst()->valueList;
136  return TQMap<TQString, TQVariant>();
137 }
138 
139 void 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 
150 void MultiProperty::setType(int type)
151 {
152 }
153 */
154 void 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 
168 void 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 
179 void MultiProperty::setValueList(const TQMap<TQString, TQVariant> &valueList)
180 {
181  Property *property;
182  for (property = list.first(); property; property = list.next())
183  property->setValueList(valueList);
184 }
185 
186 void MultiProperty::addProperty(Property *prop)
187 {
188  list.append(prop);
189 }
190 
191 void 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 
200 bool MultiProperty::operator ==(const MultiProperty &prop) const
201 {
202  if ( (type() == prop.type()) && (name() == prop.name()) )
203  return true;
204  return false;
205 }
206 
207 bool 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 
216 void MultiProperty::addProperty( MultiProperty *prop)
217 {
218  Property *property;
219  for (property = prop->list.first(); property; property = prop->list.next())
220  addProperty(property);
221 }
222 
223 void MultiProperty::removeProperty( MultiProperty *prop)
224 {
225  Property *property;
226  for (property = prop->list.first(); property; property = prop->list.next())
227  removeProperty(property);
228 }
229 
230 TQVariant MultiProperty::findValueDescription() const
231 {
232  TQVariant val = value();
233  if (type() != Property::ValueFromList)
234  return val;
235  TQMap<TQString, TQVariant> vl = valueList();
236  for (TQMap<TQString, TQVariant>::const_iterator it = vl.begin(); it != vl.end(); ++ it)
237  {
238  if (it.data() == val)
239  return it.key();
240  }
241  return "";
242 }
243 
244 TQVariant MultiProperty::findValueDescription(TQVariant val) const
245 {
246  if (type() != Property::ValueFromList)
247  return val;
248  TQMap<TQString, TQVariant> vl = valueList();
249  for (TQMap<TQString, TQVariant>::const_iterator it = vl.begin(); it != vl.end(); ++ it)
250  {
251  if (it.data() == val)
252  return it.key();
253  }
254  return "";
255 }
256 
257 bool MultiProperty::valid() const
258 {
259  return list.count() != 0;
260 }
261 
262 void 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::Property::description
virtual TQString description() const
Definition: property.cpp:91
PropertyLib::MultiProperty::undo
void undo()
Reverts the property value to previous setting.
Definition: multiproperty.cpp:262
PropertyLib::MultiProperty::readOnly
bool readOnly() const
Returns the readonly attribute of a property.
Definition: multiproperty.cpp:96
PropertyLib
Namespace which contain property editing classes.
Definition: childproperty.cpp:29
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::operator==
bool operator==(const MultiProperty &prop) const
Compares two multiproperties.
Definition: multiproperty.cpp:200
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::valueList
TQMap< TQString, TQVariant > valueList() const
The string-to-value correspondence list of the property.
Definition: multiproperty.cpp:132
PropertyLib::MultiProperty::type
int type() const
Returns the type of a property.
Definition: multiproperty.cpp:53
PropertyLib::Property::oldValue
virtual TQVariant oldValue() const
Gets the previous property value.
Definition: property.cpp:121
multiproperty.h
Contains PropertyLib::MultiProperty class.
PropertyLib::Property::setValueList
virtual void setValueList(const TQMap< TQString, TQVariant > &list)
Sets the string-to-value correspondence list of the property.
Definition: property.cpp:101
PropertyLib::MultiProperty::setDescription
void setDescription(const TQString &description)
Sets the description of a property.
Definition: multiproperty.cpp:139
PropertyLib::Property::readOnly
virtual bool readOnly() const
Tells if the property is read only.
Definition: property.cpp:106
propertylist.h
Contains PropertyLib::PropertyList class.
PropertyLib::MultiProperty::value
TQVariant value() const
Returns the value of a property.
Definition: multiproperty.cpp:60
PropertyLib::MultiProperty::name
TQString name() const
Returns the name of a property.
Definition: multiproperty.cpp:46
PropertyLib::MultiProperty::visible
bool visible() const
Returns the visibility attribute of a property.
Definition: multiproperty.cpp:114
PropertyLib::Property::value
virtual TQVariant value() const
Definition: property.cpp:77
PropertyLib::MultiProperty::removeProperty
void removeProperty(Property *prop)
Removes property from the list.
Definition: multiproperty.cpp:191
PropertyLib::MultiProperty::description
TQString description() const
Returns the description of a property.
Definition: multiproperty.cpp:78
PropertyLib::PropertyList::propertyValueChanged
void propertyValueChanged(Property *property)
Emitted when the value of the property is changed.
PropertyLib::Property::ValueFromList
string value from a list
Definition: property.h:107
PropertyLib::PropertyList
The list of properties.
Definition: propertylist.h:55
PropertyLib::MultiProperty::setValue
void setValue(const TQVariant &value)
Sets the value of a property.
Definition: multiproperty.cpp:154
PropertyLib::Property::type
virtual int type() const
Definition: property.cpp:67
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::MultiProperty::addProperty
void addProperty(Property *prop)
Adds property to the list.
Definition: multiproperty.cpp:186
PropertyLib::Property
Property.
Definition: property.h:62
PropertyLib::MultiProperty::findValueDescription
TQVariant findValueDescription() const
Finds string description for a value.
Definition: multiproperty.cpp:230
PropertyLib::MultiProperty
Holds a list of properties with the same name and type.
Definition: multiproperty.h:49
PropertyLib::Property::setDescription
virtual void setDescription(const TQString &description)
Sets the description of the property.
Definition: property.cpp:96
PropertyLib::MultiProperty::MultiProperty
MultiProperty(Property *prop)
Constructs multiproperty with one property which is not connected to a property list.
Definition: multiproperty.cpp:25
PropertyLib::Property::setValue
virtual void setValue(const TQVariant &value, bool rememberOldValue=true)
Sets the value of the property.
Definition: property.cpp:82

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.8.13
This website is maintained by Timothy Pearson.