• 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
61namespace PropertyLib{
62
63PropertyMachineFactory *PropertyMachineFactory::m_factory = 0;
64
65PropertyMachineFactory::PropertyMachineFactory()
66{
67}
68
69PropertyMachineFactory::~PropertyMachineFactory()
70{
71}
72
73Machine *PropertyMachineFactory::machineForProperty(MultiProperty *property)
74{
75 int type = property->type();
76 TQString propertyName = property->name();
77 TQStringVariantMap 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 TQStringVariantMap 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 TQStringVariantMap 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
192PropertyMachineFactory *PropertyMachineFactory::getInstance()
193{
194 if (m_factory == 0)
195 m_factory = new PropertyMachineFactory();
196 return m_factory;
197}
198
199bool 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::ChildProperty
Child property.
Definition childproperty.h:43
PropertyLib::MultiProperty
Holds a list of properties with the same name and type.
Definition multiproperty.h:50
PropertyLib::PColorButton
Property editor with color chooser button.
Definition pcolorbutton.h:37
PropertyLib::PComboBox
Property editor with combobox.
Definition pcombobox.h:36
PropertyLib::PCursorEdit
Property editor for TQCursor values.
Definition pcursoredit.h:31
PropertyLib::PDateEdit
Property editor for TQDate values.
Definition pdateedit.h:33
PropertyLib::PDateTimeEdit
Property editor for TQDateTime values.
Definition pdatetimeedit.h:33
PropertyLib::PDoubleNumInput
Property editor with double num input box.
Definition pdoublenuminput.h:37
PropertyLib::PDummyWidget
Property editor with empty widget.
Definition pdummywidget.h:41
PropertyLib::PFontButton
Property editor with font chooser button.
Definition pfontbutton.h:33
PropertyLib::PFontCombo
Property editor with font combo box.
Definition pfontcombo.h:36
PropertyLib::PLineEdit
Property editor with line edit.
Definition plineedit.h:32
PropertyLib::PLineStyleEdit
Line style editor.
Definition plinestyleedit.h:32
PropertyLib::PPixmapEdit
Property editor which shows a pixmap and allows to load it from file.
Definition ppixmapedit.h:34
PropertyLib::PPointEdit
Property editor for TQPoint values.
Definition ppointedit.h:33
PropertyLib::PRectEdit
Property editor for TQRect values.
Definition prectedit.h:33
PropertyLib::PSizeEdit
Property editor for TQSize values.
Definition psizeedit.h:35
PropertyLib::PSizePolicyEdit
Property editor for TQSizePolicy values.
Definition psizepolicyedit.h:35
PropertyLib::PSpinBox
Property editor with integer num input box.
Definition pspinbox.h:32
PropertyLib::PStringListEdit
Property editor with string list editor.
Definition pstringlistedit.h:36
PropertyLib::PSymbolCombo
Property editor with char selector.
Definition psymbolcombo.h:35
PropertyLib::PUrlEdit
Property editor with an url editor to choose the location of file or directory.
Definition purledit.h:40
PropertyLib::PYesNoButton
Property editor with yes-no button to edit boolean values.
Definition pyesnobutton.h:33
PropertyLib::PropertyMachineFactory
Factory to create property editors and property viewers.
Definition propertymachinefactory.h:69
PropertyLib::PropertyMachineFactory::machineForProperty
Machine * machineForProperty(MultiProperty *property)
Creates and returns the editor for given property type.
Definition propertymachinefactory.cpp:73
PropertyLib::PropertyMachineFactory::getInstance
static PropertyMachineFactory * getInstance()
Definition propertymachinefactory.cpp:192
PropertyLib::Property::Rect
@ Rect
rectangle (x,y, width, height)
Definition property.h:76
PropertyLib::Property::FileURL
@ FileURL
url of a file
Definition property.h:110
PropertyLib::Property::Symbol
@ Symbol
unicode symbol code
Definition property.h:108
PropertyLib::Property::ValueFromList
@ ValueFromList
string value from a list
Definition property.h:107
PropertyLib::Property::List
@ List
TQValueList<TQVariant>.
Definition property.h:70
PropertyLib::Property::Double
@ Double
double
Definition property.h:87
PropertyLib::Property::FontName
@ FontName
font name, e.g.
Definition property.h:109
PropertyLib::Property::Font
@ Font
font
Definition property.h:73
PropertyLib::Property::StringList
@ StringList
string list
Definition property.h:72
PropertyLib::Property::Map
@ Map
TQStringVariantMap.
Definition property.h:69
PropertyLib::Property::Integer
@ Integer
integer
Definition property.h:84
PropertyLib::Property::Color
@ Color
color
Definition property.h:78
PropertyLib::Property::LineStyle
@ LineStyle
line style
Definition property.h:112
PropertyLib::Property::Pixmap
@ Pixmap
pixmap
Definition property.h:74
PropertyLib::Property::Point
@ Point
point (x,y)
Definition property.h:82
PropertyLib::Property::DirectoryURL
@ DirectoryURL
url of a directory
Definition property.h:111
PropertyLib::Property::DateTime
@ DateTime
date and time
Definition property.h:96
PropertyLib::Property::Date
@ Date
date
Definition property.h:94
PropertyLib::Property::Boolean
@ Boolean
boolean
Definition property.h:86
PropertyLib::Property::Cursor
@ Cursor
cursor
Definition property.h:92
PropertyLib::Property::String
@ String
string
Definition property.h:71
PropertyLib::Property::Size
@ Size
size (width, height)
Definition property.h:77
PropertyLib::Property::SizePolicy
@ SizePolicy
size policy (horizontal, vertical)
Definition property.h:93
multiproperty.h
Contains PropertyLib::MultiProperty class.
PropertyLib
Namespace which contain property editing classes.
Definition childproperty.cpp:29
property.h
Contains PropertyLib::Property class and PropertyLib::Property::PropertyType enum.
propertymachinefactory.h
Contains PropertyLib::PropertyMachineFactory class and PropertyLib::Machine structure.
PropertyLib::Machine
Machine for a property type.
Definition propertymachinefactory.h:46

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