23#include "customproperty.h"
28#include "cursoredit.h"
30#include "datetimeedit.h"
31#include "dummywidget.h"
33#include "linestyleedit.h"
34#include "pixmapedit.h"
38#include "sizepolicyedit.h"
40#include "stringlistedit.h"
41#include "stringedit.h"
42#include "symbolcombo.h"
46#include <tqvaluelist.h>
51static KStaticDeleter<KoProperty::FactoryManager> m_managerDeleter;
56CustomPropertyFactory::CustomPropertyFactory(TQObject *parent)
61CustomPropertyFactory::~CustomPropertyFactory()
67class FactoryManagerPrivate
70 FactoryManagerPrivate() {}
71 ~FactoryManagerPrivate() {}
74 TQIntDict<CustomPropertyFactory> registeredWidgets;
75 TQIntDict<CustomPropertyFactory> registeredCustomProperties;
81FactoryManager::FactoryManager()
82: TQObject(0,
"KoProperty::FactoryManager")
84 d =
new FactoryManagerPrivate();
87FactoryManager::~FactoryManager()
96 m_managerDeleter.setObject( m_manager,
new FactoryManager() );
107 if(d->registeredWidgets.find(editorType))
108 kopropertywarn <<
"FactoryManager::registerFactoryForEditor(): "
109 "Overriding already registered custom widget type \"" << editorType <<
"\"" << endl;
110 d->registeredWidgets.replace(editorType, widgetFactory);
116 TQValueList<int>::ConstIterator endIt = editorTypes.constEnd();
117 for(TQValueList<int>::ConstIterator it = editorTypes.constBegin(); it != endIt; ++it)
121CustomPropertyFactory *
124 return d->registeredWidgets.find(type);
133 const int type =
property->type();
135 CustomPropertyFactory *factory = d->registeredWidgets.find(type);
137 return factory->createCustomWidget(property);
141 return new CursorEdit(property);
144 return new ComboBox(property);
153 return new StringEdit(property);
162 case SizePolicy_HorStretch:
163 case SizePolicy_VerStretch:
165 return new IntEdit(property);
167 return new DoubleEdit(property);
170 TQVariant thirdState =
property ?
property->option(
"3rdState") : TQVariant();
171 if (thirdState.toString().isEmpty())
172 return new BoolEdit(property);
174 return new ThreeStateBoolEdit(property);
177 return new DateEdit(property);
179 return new TimeEdit(property);
181 return new DateTimeEdit(property);
183 return new StringListEdit(property);
185 return new ColorButton(property);
187 return new FontEdit(property);
189 return new PixmapEdit(property);
193 return new SymbolCombo(property);
198 return new URLEdit(property);
200 return new LineStyleEdit(property);
204 return new SizeEdit(property);
206 return new PointEdit(property);
208 return new RectEdit(property);
210 return new SizePolicyEdit(property);
215 kopropertywarn <<
"No editor for property " <<
property->name() <<
" of type " <<
property->type() << endl;
216 return new DummyWidget(property);
227 if(d->registeredCustomProperties.find(propertyType))
228 kopropertywarn <<
"FactoryManager::registerFactoryForProperty(): "
229 "Overriding already registered custom property type \"" << propertyType <<
"\"" << endl;
231 d->registeredCustomProperties.replace(propertyType, factory);
236 CustomPropertyFactory *factory)
238 TQValueList<int>::ConstIterator endIt = propertyTypes.constEnd();
239 for(TQValueList<int>::ConstIterator it = propertyTypes.constBegin(); it != endIt; ++it)
246 const int type = parent->
type();
247 CustomPropertyFactory *factory = d->registeredWidgets.find(type);
249 return factory->createCustomProperty(parent);
252 case Size:
case Size_Width:
case Size_Height:
254 case Point:
case Point_X:
case Point_Y:
256 case Rect:
case Rect_X:
case Rect_Y:
case Rect_Width:
case Rect_Height:
258 case SizePolicy:
case SizePolicy_HorStretch:
case SizePolicy_VerStretch:
259 case SizePolicy_HorData:
case SizePolicy_VerData:
Base class for custom properties.
Manages factories providing custom editors and properties.
void registerFactoryForProperties(const TQValueList< int > &propertyTypes, CustomPropertyFactory *factory)
Widget * createWidgetForProperty(Property *property)
static FactoryManager * self()
void registerFactoryForEditors(const TQValueList< int > &editorTypes, CustomPropertyFactory *factory)
void registerFactoryForEditor(int editorType, CustomPropertyFactory *factory)
CustomProperty * createCustomProperty(Property *parent)
CustomPropertyFactory * factoryForEditorType(int type)
void registerFactoryForProperty(int propertyType, CustomPropertyFactory *factory)
Custom property implementation for TQPoint type.
The base class representing a single property.
ListData * listData() const
Custom property implementation for TQRect type.
Custom property implementation for TQSize type.
Custom property implementation for TQSizePolicy type.
Namespace for a set of classes implementing generic properties framework.
@ List
TQValueList<TQVariant>.
@ Symbol
unicode symbol code
@ Rect
rectangle (x,y, width, height)
@ DirectoryURL
url of a directory
@ Size
size (width, height)
@ SizePolicy
size policy (horizontal, vertical)