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

KDevelop Property Editing Library

  • lib
  • widgets
  • propeditor
childproperty.cpp
1 /***************************************************************************
2  * Copyright (C) 2004 by Alexander Dymo *
3  * cloudtemple@mskat.net *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Library General Public License as *
7  * published by the Free Software Foundation; either version 2 of the *
8  * License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Library General Public *
16  * License along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #include "childproperty.h"
21 
22 #include <tqsize.h>
23 #include <tqpoint.h>
24 #include <tqrect.h>
25 #include <tqsizepolicy.h>
26 
27 #include "multiproperty.h"
28 
29 namespace PropertyLib{
30 
31 ChildProperty::ChildProperty(MultiProperty *parent, int type, ChildPropertyType childType, const TQString &name,
32  const TQString &description, const TQVariant &value, bool save, bool readOnly)
33  :Property(type, name, description, value, save, readOnly), m_parent(parent), m_childType(childType)
34 {
35 }
36 
37 ChildProperty::ChildProperty(MultiProperty *parent, const TQString & name, ChildPropertyType childType,
38  const TQMap<TQString, TQVariant> &v_valueList, const TQString &description,
39  const TQVariant &value, bool save, bool readOnly)
40  :Property(name, v_valueList, description, value, save, readOnly), m_parent(parent), m_childType(childType)
41 {
42 }
43 
44 void ChildProperty::setValue(const TQVariant &value, bool // rememberOldValue
45  )
46 {
47  tqWarning("ChildProperty::setValue");
48  if (!m_parent->valid())
49  return;
50  switch (m_parent->type())
51  {
52  case Size:
53  {
54  tqWarning("ChildProperty::setValue for TQSize");
55  TQSize v = m_parent->value().toSize();
56  if (m_childType == Size_Height)
57  v.setHeight(value.toInt());
58  else if (m_childType == Size_Width)
59  v.setWidth(value.toInt());
60  m_parent->setValue(v);
61  break;
62  }
63  case Point:
64  {
65  tqWarning("ChildProperty::setValue for TQPoint");
66  TQPoint v = m_parent->value().toPoint();
67  if (m_childType == Point_X)
68  v.setX(value.toInt());
69  else if (m_childType == Point_Y)
70  v.setY(value.toInt());
71  m_parent->setValue(v);
72  break;
73  }
74  case Rect:
75  {
76  tqWarning("ChildProperty::setValue for TQRect");
77  TQRect v = m_parent->value().toRect();
78  if (m_childType == Rect_X)
79  v.setX(value.toInt());
80  else if (m_childType == Rect_Y)
81  v.setY(value.toInt());
82  else if (m_childType == Rect_Width)
83  v.setWidth(value.toInt());
84  else if (m_childType == Rect_Height)
85  v.setHeight(value.toInt());
86  m_parent->setValue(v);
87  break;
88  }
89  case SizePolicy:
90  {
91  tqWarning("ChildProperty::setValue for TQSizePolicy");
92  TQSizePolicy v = m_parent->value().toSizePolicy();
93  if (m_childType == SizePolicy_HorData)
94  v.setHorData(TQSizePolicy::SizeType(value.toInt()));
95  else if (m_childType == SizePolicy_VerData)
96  v.setVerData(TQSizePolicy::SizeType(value.toInt()));
97  else if (m_childType == SizePolicy_HorStretch)
98  v.setHorStretch(value.toInt());
99  else if (m_childType == SizePolicy_VerStretch)
100  v.setVerStretch(value.toInt());
101  m_parent->setValue(v);
102  break;
103  }
104  }
105 }
106 
107 TQVariant ChildProperty::value( ) const
108 {
109  if (!m_parent->valid())
110  return TQVariant();
111  switch (m_parent->type())
112  {
113  case Size:
114  if (m_childType == Size_Height)
115  return m_parent->value().toSize().height();
116  else if (m_childType == Size_Width)
117  return m_parent->value().toSize().width();
118  case Point:
119  if (m_childType == Point_X)
120  return m_parent->value().toPoint().x();
121  else if (m_childType == Point_Y)
122  return m_parent->value().toPoint().y();
123  case Rect:
124  if (m_childType == Rect_X)
125  return m_parent->value().toRect().x();
126  else if (m_childType == Rect_Y)
127  return m_parent->value().toRect().y();
128  else if (m_childType == Rect_Width)
129  return m_parent->value().toRect().width();
130  else if (m_childType == Rect_Height)
131  return m_parent->value().toRect().height();
132  case SizePolicy:
133  if (m_childType == SizePolicy_HorData)
134  return m_parent->value().toSizePolicy().horData();
135  else if (m_childType == SizePolicy_VerData)
136  return m_parent->value().toSizePolicy().verData();
137  else if (m_childType == SizePolicy_HorStretch)
138  return m_parent->value().toSizePolicy().horStretch();
139  else if (m_childType == SizePolicy_VerStretch)
140  return m_parent->value().toSizePolicy().verStretch();
141  }
142  return TQVariant();
143 }
144 
145 }
PropertyLib::Property::SizePolicy
size policy (horizontal, vertical)
Definition: property.h:93
PropertyLib::Property::description
virtual TQString description() const
Definition: property.cpp:91
PropertyLib::Property::Point
point (x,y)
Definition: property.h:82
PropertyLib
Namespace which contain property editing classes.
Definition: childproperty.cpp:29
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::type
int type() const
Returns the type of a property.
Definition: multiproperty.cpp:53
multiproperty.h
Contains PropertyLib::MultiProperty class.
PropertyLib::Property::readOnly
virtual bool readOnly() const
Tells if the property is read only.
Definition: property.cpp:106
PropertyLib::MultiProperty::value
TQVariant value() const
Returns the value of a property.
Definition: multiproperty.cpp:60
PropertyLib::MultiProperty::setValue
void setValue(const TQVariant &value)
Sets the value of a property.
Definition: multiproperty.cpp:154
PropertyLib::Property::Size
size (width, height)
Definition: property.h:77
PropertyLib::Property::name
virtual TQString name() const
Definition: property.cpp:57
PropertyLib::Property
Property.
Definition: property.h:62
PropertyLib::ChildProperty::ChildProperty
ChildProperty()
Constructs empty property.
Definition: childproperty.h:61
PropertyLib::MultiProperty
Holds a list of properties with the same name and type.
Definition: multiproperty.h:49
PropertyLib::ChildProperty::value
virtual TQVariant value() const
Definition: childproperty.cpp:107
PropertyLib::Property::Rect
rectangle (x,y, width, height)
Definition: property.h:76
PropertyLib::ChildProperty::setValue
virtual void setValue(const TQVariant &value, bool rememberOldValue=true)
Sets the value of the property.
Definition: childproperty.cpp:44

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.