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

KDevelop Property Editing Library

  • lib
  • widgets
  • propeditor
propertymachinefactory.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 "propertymachinefactory.h"
21 
22 #ifndef PURE_QT
23 #include <tdelocale.h>
24 #else
25 #define i18n TQObject::tr
26 #endif
27 
28 #include <tqmap.h>
29 
30 #include "property.h"
31 #include "childproperty.h"
32 #include "multiproperty.h"
33 #include "plineedit.h"
34 #include "pspinbox.h"
35 #include "pdoublenuminput.h"
36 #include "pcheckbox.h"
37 #include "pstringlistedit.h"
38 #include "pdummywidget.h"
39 #include "pcombobox.h"
40 #include "psymbolcombo.h"
41 #include "pfontcombo.h"
42 #include "psizeedit.h"
43 #include "pdateedit.h"
44 #include "pdatetimeedit.h"
45 #include "ppointedit.h"
46 #include "prectedit.h"
47 #include "psizepolicyedit.h"
48 #include "pcolorbutton.h"
49 #include "pyesnobutton.h"
50 #include "ppixmapedit.h"
51 #include "pcursoredit.h"
52 #include "plinestyleedit.h"
53 #include "purledit.h"
54 
55 
56 #ifndef PURE_QT
57 #include "pfontbutton.h"
58 #include "pcolorcombo.h"
59 #endif
60 
61 namespace PropertyLib{
62 
63 PropertyMachineFactory *PropertyMachineFactory::m_factory = 0;
64 
65 PropertyMachineFactory::PropertyMachineFactory()
66 {
67 }
68 
69 PropertyMachineFactory::~PropertyMachineFactory()
70 {
71 }
72 
73 Machine *PropertyMachineFactory::machineForProperty(MultiProperty *property)
74 {
75  int type = property->type();
76  TQString propertyName = property->name();
77  TQMap<TQString, TQVariant> valueList = property->valueList();
78 
79  if (m_registeredForType.contains(propertyName))
80  return (*m_registeredForType[propertyName])();
81 
82  switch (type)
83  {
84  case Property::String:
85  return new Machine(new PLineEdit(property));
86  case Property::Integer:
87  return new Machine(new PSpinBox(property));
88  case Property::Boolean:
89  return new Machine(new PYesNoButton(property));
90  case Property::Date:
91  return new Machine(new PDateEdit(property));
92  case Property::DateTime:
93  return new Machine(new PDateTimeEdit(property));
94  case Property::StringList:
95  return new Machine(new PStringListEdit(property));
96  case Property::Color:
97  return new Machine(new PColorButton(property));
98 #ifndef PURE_QT
99  case Property::Font:
100  return new Machine(new PFontButton(property));
101 #endif
102  case Property::FileURL:
103  return new Machine(new PUrlEdit(PUrlEdit::File, property));
104  case Property::DirectoryURL:
105  return new Machine(new PUrlEdit(PUrlEdit::Directory, property));
106 
107  case Property::Double:
108  return new Machine(new PDoubleNumInput(property));
109  case Property::Pixmap:
110  return new Machine(new PPixmapEdit(property));
111 
112  case Property::ValueFromList:
113  return new Machine(new PComboBox(property, valueList));
114  case Property::Symbol:
115  return new Machine(new PSymbolCombo(property));
116  case Property::FontName:
117  return new Machine(new PFontCombo(property));
118  case Property::LineStyle:
119  return new Machine(new PLineStyleEdit(property));
120 
121  case Property::Size:
122  {
123  Machine *mach = new Machine(new PSizeEdit(property));
124  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Width, i18n("Width"), i18n("Width")));
125  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Height, i18n("Height"), i18n("Height")));
126  return mach;
127  }
128  case Property::Point:
129  {
130  Machine *mach = new Machine(new PPointEdit(property));
131  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_X, i18n("x"), i18n("x")));
132  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_Y, i18n("y"), i18n("y")));
133  return mach;
134  }
135  case Property::Rect:
136  {
137  Machine *mach = new Machine(new PRectEdit(property));
138  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_X, i18n("x"), i18n("x")));
139  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Y, i18n("y"), i18n("y")));
140  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Width, i18n("Width"), i18n("Width")));
141  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Height, i18n("Height"), i18n("Height")));
142  return mach;
143  }
144  case Property::SizePolicy:
145  {
146  TQMap<TQString, TQVariant> spValues;
147  spValues[i18n("Fixed")] = TQSizePolicy::Fixed;
148  spValues[i18n("Minimum")] = TQSizePolicy::Minimum;
149  spValues[i18n("Maximum")] = TQSizePolicy::Maximum;
150  spValues[i18n("Preferred")] = TQSizePolicy::Preferred;
151  spValues[i18n("Expanding")] = TQSizePolicy::Expanding;
152  spValues[i18n("Minimum Expanding")] = TQSizePolicy::MinimumExpanding;
153  spValues[i18n("Ignored")] = TQSizePolicy::Ignored;
154 
155  Machine *mach = new Machine(new PSizePolicyEdit(property, spValues));
156  property->details.append(ChildProperty(property, i18n("hSizeType"), ChildProperty::SizePolicy_HorData, spValues, i18n("Horizontal Size Type")));
157  property->details.append(ChildProperty(property, i18n("vSizeType"), ChildProperty::SizePolicy_VerData, spValues, i18n("Vertical Size Type")));
158  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_HorStretch, i18n("hStretch"), i18n("Horizontal Stretch")));
159  property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_VerStretch, i18n("vStretch"), i18n("Vertical Stretch")));
160  return mach;
161  }
162  case Property::Cursor:
163  {
164  TQMap<TQString, TQVariant> spValues;
165  spValues[i18n("Arrow")] = TQt::ArrowCursor;
166  spValues[i18n("Up Arrow")] = TQt::UpArrowCursor;
167  spValues[i18n("Cross")] = TQt::CrossCursor;
168  spValues[i18n("Waiting")] = TQt::WaitCursor;
169  spValues[i18n("iBeam")] = TQt::IbeamCursor;
170  spValues[i18n("Size Vertical")] = TQt::SizeVerCursor;
171  spValues[i18n("Size Horizontal")] = TQt::SizeHorCursor;
172  spValues[i18n("Size Slash")] = TQt::SizeBDiagCursor;
173  spValues[i18n("Size Backslash")] = TQt::SizeFDiagCursor;
174  spValues[i18n("Size All")] = TQt::SizeAllCursor;
175  spValues[i18n("Blank")] = TQt::BlankCursor;
176  spValues[i18n("Split Vertical")] = TQt::SplitVCursor;
177  spValues[i18n("Split Horizontal")] = TQt::SplitHCursor;
178  spValues[i18n("Pointing Hand")] = TQt::PointingHandCursor;
179  spValues[i18n("Forbidden")] = TQt::ForbiddenCursor;
180  spValues[i18n("What's this")] = TQt::WhatsThisCursor;
181  Machine *mach = new Machine(new PCursorEdit(property, spValues));
182  return mach;
183  }
184 
185  case Property::List:
186  case Property::Map:
187  default:
188  return new Machine(new PDummyWidget(property));
189  }
190 }
191 
192 PropertyMachineFactory *PropertyMachineFactory::getInstance()
193 {
194  if (m_factory == 0)
195  m_factory = new PropertyMachineFactory();
196  return m_factory;
197 }
198 
199 bool PropertyMachineFactory::hasDetailedEditors( int type )
200 {
201  if ( (type==Property::Size) || (type==Property::Point) ||
202  (type==Property::Rect) || (type==Property::SizePolicy) )
203  return true;
204  return 0;
205 }
206 
207 }
PropertyLib::PDoubleNumInput
Property editor with double num input box.
Definition: pdoublenuminput.h:36
PropertyLib::Property::StringList
string list
Definition: property.h:72
PropertyLib::PDateTimeEdit
Property editor for TQDateTime values.
Definition: pdatetimeedit.h:32
PropertyLib::Property::SizePolicy
size policy (horizontal, vertical)
Definition: property.h:93
PropertyLib::PLineEdit
Property editor with line edit.
Definition: plineedit.h:32
PropertyLib::PDummyWidget
Property editor with empty widget.
Definition: pdummywidget.h:40
PropertyLib::Property::List
TQValueList<TQVariant>
Definition: property.h:70
PropertyLib::PComboBox
Property editor with combobox.
Definition: pcombobox.h:36
PropertyLib::Property::Pixmap
pixmap
Definition: property.h:74
PropertyLib::Property::Map
TQMap<TQString, TQVariant>
Definition: property.h:69
PropertyLib::Property::Point
point (x,y)
Definition: property.h:82
PropertyLib::Property::Date
date
Definition: property.h:94
PropertyLib::ChildProperty
Child property.
Definition: childproperty.h:43
PropertyLib
Namespace which contain property editing classes.
Definition: childproperty.cpp:29
PropertyLib::Property::Integer
integer
Definition: property.h:84
PropertyLib::Property::FontName
font name, e.g.
Definition: property.h:109
propertymachinefactory.h
Contains PropertyLib::PropertyMachineFactory class and PropertyLib::Machine structure.
PropertyLib::PCursorEdit
Property editor for TQCursor values.
Definition: pcursoredit.h:30
PropertyLib::PColorButton
Property editor with color chooser button.
Definition: pcolorbutton.h:36
multiproperty.h
Contains PropertyLib::MultiProperty class.
PropertyLib::PYesNoButton
Property editor with yes-no button to edit boolean values.
Definition: pyesnobutton.h:32
property.h
Contains PropertyLib::Property class and PropertyLib::Property::PropertyType enum.
PropertyLib::PRectEdit
Property editor for TQRect values.
Definition: prectedit.h:32
PropertyLib::Property::DirectoryURL
url of a directory
Definition: property.h:111
PropertyLib::PLineStyleEdit
Line style editor.
Definition: plinestyleedit.h:32
PropertyLib::Property::DateTime
date and time
Definition: property.h:96
PropertyLib::PropertyMachineFactory::getInstance
static PropertyMachineFactory * getInstance()
Definition: propertymachinefactory.cpp:192
PropertyLib::PSizePolicyEdit
Property editor for TQSizePolicy values.
Definition: psizepolicyedit.h:34
PropertyLib::PropertyMachineFactory
Factory to create property editors and property viewers.
Definition: propertymachinefactory.h:69
PropertyLib::Property::Color
color
Definition: property.h:78
PropertyLib::Property::Font
font
Definition: property.h:73
PropertyLib::PSizeEdit
Property editor for TQSize values.
Definition: psizeedit.h:34
PropertyLib::PDateEdit
Property editor for TQDate values.
Definition: pdateedit.h:32
PropertyLib::Property::String
string
Definition: property.h:71
PropertyLib::Property::ValueFromList
string value from a list
Definition: property.h:107
PropertyLib::PSymbolCombo
Property editor with char selector.
Definition: psymbolcombo.h:35
PropertyLib::PFontCombo
Property editor with font combo box.
Definition: pfontcombo.h:36
PropertyLib::PUrlEdit
Property editor with an url editor to choose the location of file or directory.
Definition: purledit.h:39
PropertyLib::PFontButton
Property editor with font chooser button.
Definition: pfontbutton.h:32
PropertyLib::Property::Boolean
boolean
Definition: property.h:86
PropertyLib::Property::Cursor
cursor
Definition: property.h:92
PropertyLib::Property::Size
size (width, height)
Definition: property.h:77
PropertyLib::Property::Symbol
unicode symbol code
Definition: property.h:108
PropertyLib::Property::LineStyle
line style
Definition: property.h:112
PropertyLib::Property::FileURL
url of a file
Definition: property.h:110
PropertyLib::PPointEdit
Property editor for TQPoint values.
Definition: ppointedit.h:32
PropertyLib::MultiProperty
Holds a list of properties with the same name and type.
Definition: multiproperty.h:49
PropertyLib::PStringListEdit
Property editor with string list editor.
Definition: pstringlistedit.h:35
PropertyLib::PSpinBox
Property editor with integer num input box.
Definition: pspinbox.h:32
PropertyLib::PPixmapEdit
Property editor which shows a pixmap and allows to load it from file.
Definition: ppixmapedit.h:33
PropertyLib::PropertyMachineFactory::machineForProperty
Machine * machineForProperty(MultiProperty *property)
Creates and returns the editor for given property type.
Definition: propertymachinefactory.cpp:73
PropertyLib::Property::Double
double
Definition: property.h:87
PropertyLib::Machine
Machine for a property type.
Definition: propertymachinefactory.h:46
PropertyLib::Property::Rect
rectangle (x,y, width, height)
Definition: property.h:76

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.