lib
KoProperty::FactoryManager Class Reference
#include <factory.h>
Detailed Description
Manages factories providing custom editors and properties.This class is static, you don't need to create an instance of it. It's used to enable the custom property/editors system. You may want to create your own property types and/or editors to:
- Create your own editors for some special kind of properties, not included in KProperty basic editors;
- Create composed properties, which contain more than one value. Child items will then be created in the Editor (that's how rect, size properties are created).
Using Custom Properties
To create a custom property, create a subclass of CustomProperty class. You need to implement some virtual functions, to customise the behaviour of your property (see CustomProperty api doc). If you create a composed property, both parent and children properties must have custom (different) types.Then, you need to register the new created type, using registerFactoryForProperty(). The second parameter is an instance of CustomPropertyFactory-derived class implementing createCustomProperty() method.
To create a property of this type, just use the normal constructor, overriding the type parameter with the type you registered.
Using Custom Editors
First, create a subclass of Widget, and implement all the virtuals you need to tweak the property editor. You can find examples of editors in the src/editors/ directory.Then, register it using registerFactoryForEditor(), as for properties (see test/ dir for an example of custom editor). You can also register a new editor for a basic type, if the basic editor doesn't fit your needs (if you have created a better editor, send us the code, and it may get included in KProperty library).
Every time a property of this type is created, createCustomWidget() method for the custom CustomPropertyFactory-derived factory object you registered will be called to create the custom editor widget item.
- Author:
- Cedric Pasteur <cedric.pasteur@free.fr>
Alexander Dymo <cloudtemple@mskat.net>
Definition at line 97 of file factory.h.
Public Member Functions | |
void | registerFactoryForEditor (int editorType, CustomPropertyFactory *factory) |
void | registerFactoryForEditors (const QValueList< int > &editorTypes, CustomPropertyFactory *factory) |
CustomPropertyFactory * | factoryForEditorType (int type) |
Widget * | createWidgetForProperty (Property *property) |
void | registerFactoryForProperty (int propertyType, CustomPropertyFactory *factory) |
void | registerFactoryForProperties (const QValueList< int > &propertyTypes, CustomPropertyFactory *factory) |
CustomProperty * | createCustomProperty (Property *parent) |
Static Public Member Functions | |
static FactoryManager * | self () |
Friends | |
class | KStaticDeleter< KoProperty::FactoryManager > |
Member Function Documentation
CustomProperty * FactoryManager::createCustomProperty | ( | Property * | parent | ) |
This function is called in Property::Property() to create (optional) custom property. It creates the custom property for built-in types, or calls one of createCustomProperty function previously registered for other types.
Definition at line 241 of file factory.cpp.
Creates and returns the editor for given property type. Warning: editor and viewer widgets won't have parent widget. Property editor cares about reparenting and deletion of returned widgets in machines. If createWidget is false, just create child properties, not widget.
Definition at line 131 of file factory.cpp.
CustomPropertyFactory * FactoryManager::factoryForEditorType | ( | int | type | ) |
- Returns:
- custom factory for type type or NULL if there is no such property type registered. To create a custom widget createWidgetForProperty() should be rather used.
Definition at line 125 of file factory.cpp.
void FactoryManager::registerFactoryForEditor | ( | int | editorType, | |
CustomPropertyFactory * | factory | |||
) |
Registers a custom factory factory for handling property editor for editorType. This custom factory will be used before defaults when widgetForProperty() is called. creator is not owned by this Factory object, but it's good idea to instantiate CustomPropertyFactory object itself as a child of Factory parent. For example:
MyCustomPropertyFactory *f = new MyCustomPropertyFactory(KoProperty::Factory::self());
KoProperty::Factory::self()->registerEditor( MyCustomType, f );
Definition at line 106 of file factory.cpp.
void FactoryManager::registerFactoryForEditors | ( | const QValueList< int > & | editorTypes, | |
CustomPropertyFactory * | factory | |||
) |
Registers custom factory factory for handling property editors for editorTypes.
- See also:
- registerFactoryForEditor().
Definition at line 117 of file factory.cpp.
void FactoryManager::registerFactoryForProperties | ( | const QValueList< int > & | propertyTypes, | |
CustomPropertyFactory * | factory | |||
) |
Registers a custom property factory that handles a CustomProperty for types.
- See also:
- registerFactoryForProperty()
Definition at line 232 of file factory.cpp.
void FactoryManager::registerFactoryForProperty | ( | int | propertyType, | |
CustomPropertyFactory * | factory | |||
) |
Registers a custom factory that handles a CustomProperty of a type type. This function will be called every time a property of type is created.
Definition at line 220 of file factory.cpp.
FactoryManager * FactoryManager::self | ( | ) | [static] |
The documentation for this class was generated from the following files: