1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
/***************************************************************************
* Copyright (C) 2004 by Alexander Dymo *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "propertymachinefactory.h"
#ifndef PURE_QT
#include <klocale.h>
#else
#define i18n QObject::tr
#endif
#include <qmap.h>
#include "property.h"
#include "childproperty.h"
#include "multiproperty.h"
#include "plineedit.h"
#include "pspinbox.h"
#include "pdoublenuminput.h"
#include "pcheckbox.h"
#include "pstringlistedit.h"
#include "pdummywidget.h"
#include "pcombobox.h"
#include "psymbolcombo.h"
#include "pfontcombo.h"
#include "psizeedit.h"
#include "pdateedit.h"
#include "pdatetimeedit.h"
#include "ppointedit.h"
#include "prectedit.h"
#include "psizepolicyedit.h"
#include "pcolorbutton.h"
#include "pyesnobutton.h"
#include "ppixmapedit.h"
#include "pcursoredit.h"
#include "plinestyleedit.h"
#include "purledit.h"
#ifndef PURE_QT
#include "pfontbutton.h"
#include "pcolorcombo.h"
#endif
namespace PropertyLib{
PropertyMachineFactory *PropertyMachineFactory::m_factory = 0;
PropertyMachineFactory::PropertyMachineFactory()
{
}
PropertyMachineFactory::~PropertyMachineFactory()
{
}
Machine *PropertyMachineFactory::machineForProperty(MultiProperty *property)
{
int type = property->type();
QString propertyName = property->name();
QMap<QString, QVariant> valueList = property->valueList();
if (m_registeredForType.contains(propertyName))
return (*m_registeredForType[propertyName])();
switch (type)
{
case Property::String:
return new Machine(new PLineEdit(property));
case Property::Integer:
return new Machine(new PSpinBox(property));
case Property::Boolean:
return new Machine(new PYesNoButton(property));
case Property::Date:
return new Machine(new PDateEdit(property));
case Property::DateTime:
return new Machine(new PDateTimeEdit(property));
case Property::StringList:
return new Machine(new PStringListEdit(property));
case Property::Color:
return new Machine(new PColorButton(property));
#ifndef PURE_QT
case Property::Font:
return new Machine(new PFontButton(property));
#endif
case Property::FileURL:
return new Machine(new PUrlEdit(PUrlEdit::File, property));
case Property::DirectoryURL:
return new Machine(new PUrlEdit(PUrlEdit::Directory, property));
case Property::Double:
return new Machine(new PDoubleNumInput(property));
case Property::Pixmap:
return new Machine(new PPixmapEdit(property));
case Property::ValueFromList:
return new Machine(new PComboBox(property, valueList));
case Property::Symbol:
return new Machine(new PSymbolCombo(property));
case Property::FontName:
return new Machine(new PFontCombo(property));
case Property::LineStyle:
return new Machine(new PLineStyleEdit(property));
case Property::Size:
{
Machine *mach = new Machine(new PSizeEdit(property));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Width, i18n("Width"), i18n("Width")));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Height, i18n("Height"), i18n("Height")));
return mach;
}
case Property::Point:
{
Machine *mach = new Machine(new PPointEdit(property));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_X, i18n("x"), i18n("x")));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_Y, i18n("y"), i18n("y")));
return mach;
}
case Property::Rect:
{
Machine *mach = new Machine(new PRectEdit(property));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_X, i18n("x"), i18n("x")));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Y, i18n("y"), i18n("y")));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Width, i18n("Width"), i18n("Width")));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Height, i18n("Height"), i18n("Height")));
return mach;
}
case Property::SizePolicy:
{
QMap<QString, QVariant> spValues;
spValues[i18n("Fixed")] = QSizePolicy::Fixed;
spValues[i18n("Minimum")] = QSizePolicy::Minimum;
spValues[i18n("Maximum")] = QSizePolicy::Maximum;
spValues[i18n("Preferred")] = QSizePolicy::Preferred;
spValues[i18n("Expanding")] = QSizePolicy::Expanding;
spValues[i18n("Minimum Expanding")] = QSizePolicy::MinimumExpanding;
spValues[i18n("Ignored")] = QSizePolicy::Ignored;
Machine *mach = new Machine(new PSizePolicyEdit(property, spValues));
property->details.append(ChildProperty(property, i18n("hSizeType"), ChildProperty::SizePolicy_HorData, spValues, i18n("Horizontal Size Type")));
property->details.append(ChildProperty(property, i18n("vSizeType"), ChildProperty::SizePolicy_VerData, spValues, i18n("Vertical Size Type")));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_HorStretch, i18n("hStretch"), i18n("Horizontal Stretch")));
property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_VerStretch, i18n("vStretch"), i18n("Vertical Stretch")));
return mach;
}
case Property::Cursor:
{
QMap<QString, QVariant> spValues;
spValues[i18n("Arrow")] = Qt::ArrowCursor;
spValues[i18n("Up Arrow")] = Qt::UpArrowCursor;
spValues[i18n("Cross")] = Qt::CrossCursor;
spValues[i18n("Waiting")] = Qt::WaitCursor;
spValues[i18n("iBeam")] = Qt::IbeamCursor;
spValues[i18n("Size Vertical")] = Qt::SizeVerCursor;
spValues[i18n("Size Horizontal")] = Qt::SizeHorCursor;
spValues[i18n("Size Slash")] = Qt::SizeBDiagCursor;
spValues[i18n("Size Backslash")] = Qt::SizeFDiagCursor;
spValues[i18n("Size All")] = Qt::SizeAllCursor;
spValues[i18n("Blank")] = Qt::BlankCursor;
spValues[i18n("Split Vertical")] = Qt::SplitVCursor;
spValues[i18n("Split Horizontal")] = Qt::SplitHCursor;
spValues[i18n("Pointing Hand")] = Qt::PointingHandCursor;
spValues[i18n("Forbidden")] = Qt::ForbiddenCursor;
spValues[i18n("What's this")] = Qt::WhatsThisCursor;
Machine *mach = new Machine(new PCursorEdit(property, spValues));
return mach;
}
case Property::List:
case Property::Map:
default:
return new Machine(new PDummyWidget(property));
}
}
PropertyMachineFactory *PropertyMachineFactory::getInstance()
{
if (m_factory == 0)
m_factory = new PropertyMachineFactory();
return m_factory;
}
bool PropertyMachineFactory::hasDetailedEditors( int type )
{
if ( (type==Property::Size) || (type==Property::Point) ||
(type==Property::Rect) || (type==Property::SizePolicy) )
return true;
return 0;
}
}
|