KFormDesigner::WidgetFactory Class Reference
#include <widgetfactory.h>
Inheritance diagram for KFormDesigner::WidgetFactory:

Detailed Description
The base class for all widget Factories.
This is the class you need to inherit to create a new Factory. There are few virtuals you need to implement, and some other functions to implement if you want more features.
Widget Creation
To be able to create widgets, you need to implement the create() function, an classes(), which should return all the widgets supported by this factory.
GUI Integration
The following functions allow you to customize even more the look-n-feel of your widgets inside KFormDesigner. You can use createMenuActions() to add custom items in widget's context menu. The previewWidget() is called when the Form gets in Preview mode, and you have a last opportunity to remove all editing-related stuff (see eg Spring class).
You can also choose which properties to show in the Property Editor. By default, most all properties are shown (see implementation for details), but you can hide some reimplementing isPropertyVisibleInternal() (don't forget to call superclass' method) To add new properties, just define new Q_PROPERTY in widget class definition.
Inline editing
KFormDesigner allow you to edit the widget's contents inside Form, without using a dialog. You can of course customize the behaviour of your widgets, using startEditing(). There are some editing modes already implemented in WidgetFactroy, but you can create your own if you want:
- Editing using a line edit (createEditor()): a line edit is created on top of widget, where the user inputs text. As the text changes, changeText() is called (where you should set your widget's text and resize widget to fit the text if needed) and resizeEditor() to update editor's position when widget is moved/resized.
- Editing by disabling event filter: if you call disableFilter(), the event filter on the object is temporarily disabled, so the widget behaves as usual. This can be used for more complex widgets, such as spinbox, date/time edit, etc.
- Other modes: there are 3 other modes, to edit a string list: editList() (for combo box, listbox), to edit rich text: editRichText() (for labels, etc.) and to edit a listview: editListView().
You can also control how your widget are saved/loaded. You can choose which properties to save (see autoSaveProperties()), and save/load custom properties, ie properties that are not Q_PROPERTY but you want to save in the UI file. This is used eg to save combo box or listview contents (see saveSpecialProperty() and readSpecialProperty()).
Special internal properties
Use void setInternalProperty(const QCString& classname, const QCString& property, const QString& value); to set values of special internal properties. Currently these properties are used for customizing popup menu items used for orientation selection. Customization for class ClassName should look like: void setInternalProperty("ClassName", "orientationSelectionPopup", "myicon"); Available internal properties: "orientationSelectionPopup" - set it to "1" if you want a given class to offer orientation selection, so orientation selection popup will be displayed when needed. "orientationSelectionPopup:horizontalIcon" - sets a name of icon for "Horizontal" item for objects of class 'ClassName'. Set this property only for classes supporting orientations. "orientationSelectionPopup:verticalIcon" - the same for "Vertical" item. Set this property only for classes supporting orientations. "orientationSelectionPopup:horizontalText" - sets a i18n'd text for "Horizontal" item for objects of class 'ClassName', e.g. i18n("Insert Horizontal Line"). Set this property only for classes supporting orientations. "orientationSelectionPopup:verticalText" - the same for "Vertical" item, e.g. i18n("Insert Vertical Line"). Set this property only for classes supporting orientations. "dontStartEditingOnInserting" - if not empty, WidgetFactory::startEditing() will not be executed upon widget inseting by a user. "forceShowAdvancedProperty:{propertyname}" - set it to "1" for "{propertyname}" advanced property if you want to force it to be visible even if WidgetLibrary::setAdvancedPropertiesVisible(false) has been called. For example, setting "forceShowAdvancedProperty:pixmap" to "1" unhides "pixmap" property for a given class.
See StdWidgetFactory::StdWidgetFactory() for properties like "Line:orientationSelectionPopup:horizontalIcon".
See the standard factories in formeditor/factories for an example of factories, and how to deal with complex widgets (eg tabwidget).
Definition at line 257 of file widgetfactory.h.
Public Types | |
| enum | CreateWidgetOptions { AnyOrientation = 1, HorizontalOrientation = 2, VerticalOrientation = 4, DesignViewMode = 8, DefaultOptions = AnyOrientation | DesignViewMode } |
| Options used in createWidget(). More... | |
Public Slots | |
| void | resetEditor () |
Public Member Functions | |
| WidgetFactory (QObject *parent=0, const char *name=0) | |
| virtual | ~WidgetFactory () |
| void | addClass (WidgetInfo *w) |
| void | hideClass (const char *classname) |
| const WidgetInfo::Dict | classes () const |
| virtual QWidget * | createWidget (const QCString &classname, QWidget *parent, const char *name, KFormDesigner::Container *container, int options=DefaultOptions)=0 |
| Creates a widget (and if needed a KFormDesigner::Container). | |
| virtual void | createCustomActions (KActionCollection *col) |
| virtual bool | createMenuActions (const QCString &classname, QWidget *w, QPopupMenu *menu, KFormDesigner::Container *container)=0 |
| virtual bool | startEditing (const QCString &classname, QWidget *w, Container *container)=0 |
| virtual bool | previewWidget (const QCString &classname, QWidget *widget, Container *container)=0 |
| virtual bool | clearWidgetContent (const QCString &classname, QWidget *w) |
| virtual bool | saveSpecialProperty (const QCString &classname, const QString &name, const QVariant &value, QWidget *w, QDomElement &parentNode, QDomDocument &parent) |
| virtual bool | readSpecialProperty (const QCString &classname, QDomElement &node, QWidget *w, ObjectTreeItem *item) |
| bool | isPropertyVisible (const QCString &classname, QWidget *w, const QCString &property, bool multiple, bool isTopLevel) |
| virtual QValueList< QCString > | autoSaveProperties (const QCString &classname)=0 |
| QString | propertyDescForName (const QCString &name) |
| QString | propertyDescForValue (const QCString &name) |
| virtual void | setPropertyOptions (WidgetPropertySet &buf, const WidgetInfo &info, QWidget *w) |
| QString | internalProperty (const QCString &classname, const QCString &property) const |
Protected Slots | |
| virtual bool | changeText (const QString &newText) |
| void | changeTextInternal (const QString &text) |
| void | slotTextChanged () |
| void | editorDeleted () |
| void | widgetDestroyed () |
Protected Member Functions | |
| virtual bool | isPropertyVisibleInternal (const QCString &classname, QWidget *w, const QCString &property, bool isTopLevel) |
| virtual bool | propertySetShouldBeReloadedAfterPropertyChange (const QCString &classname, QWidget *w, const QCString &property) |
| void | createEditor (const QCString &classname, const QString &text, QWidget *w, Container *container, QRect geometry, int align, bool useFrame=false, bool multiLine=false, BackgroundMode background=Qt::NoBackground) |
| void | disableFilter (QWidget *w, Container *container) |
| bool | editList (QWidget *w, QStringList &list) |
| bool | editRichText (QWidget *w, QString &text) |
| void | editListView (QListView *listview) |
| virtual bool | eventFilter (QObject *obj, QEvent *ev) |
| void | changeProperty (const char *name, const QVariant &value, Form *form) |
| virtual void | resizeEditor (QWidget *editor, QWidget *widget, const QCString &classname) |
| bool | inheritsFactories () |
| QString | editorText () const |
| void | setEditorText (const QString &text) |
| void | setEditor (QWidget *widget, QWidget *editor) |
| QWidget * | editor (QWidget *widget) const |
| void | setWidget (QWidget *widget, Container *container) |
| QWidget * | widget () const |
| void | setInternalProperty (const QCString &classname, const QCString &property, const QString &value) |
Protected Attributes | |
| WidgetLibrary * | m_library |
| QCString | m_editedWidgetClass |
| QString | m_firstText |
| QGuardedPtr< ResizeHandleSet > | m_handles |
| QGuardedPtr< Container > | m_container |
| WidgetInfo::Dict | m_classesByName |
| QAsciiDict< char > * | m_hiddenClasses |
| QMap< QCString, QString > | m_propDesc |
| i18n stuff | |
| QMap< QCString, QString > | m_propValDesc |
| QMap< QCString, QString > | m_internalProp |
| internal properties | |
| bool | m_showAdvancedProperties |
| QString | m_xmlGUIFileName |
| KXMLGUIClient * | m_guiClient |
| QGuardedPtr< QWidget > | m_widget |
| QGuardedPtr< QWidget > | m_editor |
Friends | |
| class | WidgetLibrary |
Member Enumeration Documentation
|
|
Options used in createWidget().
Definition at line 262 of file widgetfactory.h. |
Constructor & Destructor Documentation
|
||||||||||||
|
Definition at line 150 of file widgetfactory.cpp. References m_classesByName, m_guiClient, m_hiddenClasses, and m_showAdvancedProperties. |
|
|
Definition at line 159 of file widgetfactory.cpp. References m_hiddenClasses. |
Member Function Documentation
|
|
Adds a new class described by w. Definition at line 164 of file widgetfactory.cpp. References KFormDesigner::WidgetInfo::className(), and m_classesByName. Referenced by ContainerFactory::ContainerFactory(), KexiDBFactory::KexiDBFactory(), KexiReportFactory::KexiReportFactory(), and StdWidgetFactory::StdWidgetFactory(). |
|
|
You need to return here a list of the properties that should automatically be saved for a widget belonging to classname, and your custom properties (eg "text" for label or button, "contents" for combobox...). Implemented in ContainerFactory, StdWidgetFactory, KexiDBFactory, and KexiReportFactory. |
|
||||||||||||||||
|
This function is used to modify a property of a widget (eg after editing it). Please use it instead of w->setProperty() to allow sync inside PropertyEditor. Definition at line 508 of file widgetfactory.cpp. References KFormDesigner::WidgetPropertySet::contains(), m_widget, KFormDesigner::Form::selectedWidgets(), and KFormDesigner::FormManager::self(). Referenced by changeText(), StdWidgetFactory::changeText(), KexiDBFactory::changeText(), ContainerFactory::changeText(), StdWidgetFactory::editText(), KexiReportFactory::editText(), and KexiDBFactory::startEditing(). |
|
|
Default implementation changes "text" property. You have to reimplement this function for editing inside the Form to work if your widget's property you want to change isn't named "text". This slot is called when the line edit text changes, and you have to make it really change the good property of the widget using changeProperty() (text, or title, etc.). Reimplemented in ContainerFactory, StdWidgetFactory, and KexiDBFactory. Definition at line 625 of file widgetfactory.cpp. References changeProperty(), and m_container. Referenced by changeTextInternal(). |
|
|
Definition at line 610 of file widgetfactory.cpp. References changeText(), KFormDesigner::WidgetInfo::inheritedClass(), m_classesByName, and m_editedWidgetClass. Referenced by createEditor(), resetEditor(), and slotTextChanged(). |
|
|
Definition at line 285 of file widgetfactory.h. Referenced by KFormDesigner::WidgetLibrary::loadFactoryWidgets(). |
|
||||||||||||
|
Reimplemented in StdWidgetFactory, and KexiDBFactory. Definition at line 604 of file widgetfactory.cpp. |
|
|
Creates custom actions. Reimplement this if you need to add some actions coming from the factory. Reimplemented in KexiDBFactory. Definition at line 302 of file widgetfactory.h. |
|
||||||||||||||||||||||||||||||||||||||||
|
This function creates a KLineEdit to input some text and edit a widget's contents. This can be used in startEditing(). text is the text to display by default in the line edit, w is the edited widget, geometry is the geometry the new line edit should have, and align is Qt::AlignmentFlags of the new line edit. Definition at line 185 of file widgetfactory.cpp. References changeTextInternal(), editor(), editorDeleted(), KFormDesigner::ObjectTreeItem::eventEater(), KFormDesigner::Container::form(), m_editedWidgetClass, m_editor, m_firstText, m_handles, setEditor(), setWidget(), slotTextChanged(), KFormDesigner::WidgetWithSubpropertiesInterface::subwidget(), and widgetDestroyed(). Referenced by StdWidgetFactory::startEditing(), KexiReportFactory::startEditing(), KexiDBFactory::startEditing(), and ContainerFactory::startEditing(). |
|
||||||||||||||||||||
|
This function can be used to add custom items in widget w context menu menu. Implemented in ContainerFactory, StdWidgetFactory, KexiDBFactory, and KexiReportFactory. |
|
||||||||||||||||||||||||
|
Creates a widget (and if needed a KFormDesigner::Container).
Implemented in ContainerFactory, StdWidgetFactory, KexiDBFactory, and KexiReportFactory. |
|
||||||||||||
|
This function provides a simple editing mode : it justs disable event filtering for the widget, and it install it again when the widget loose focus or Enter is pressed. Definition at line 281 of file widgetfactory.cpp. References KFormDesigner::ObjectTreeItem::eventEater(), KFormDesigner::Container::form(), KFormDesigner::ObjectTreeItem::isEnabled(), m_handles, setEditor(), setWidget(), and widgetDestroyed(). Referenced by StdWidgetFactory::startEditing(), and KexiDBFactory::startEditing(). |
|
||||||||||||
|
This function creates a little dialog (a KEditListBox) to modify the contents of a list (of strings). It can be used to modify the contents of a combo box for instance. The modified list is copied into list when the user presses "Ok". Definition at line 315 of file widgetfactory.cpp. Referenced by StdWidgetFactory::startEditing(). |
|
|
This function creates a dialog to modify the contents of a ListView. You can modify both columns and list items. The listview is automatically updated if the user presses "Ok". Definition at line 346 of file widgetfactory.cpp. Referenced by StdWidgetFactory::editListContents(). |
|
|
Definition at line 681 of file widgetfactory.cpp. References editor(), KFormDesigner::WidgetLibrary::factoryForClassName(), m_classesByName, m_editor, m_library, and KFormDesigner::WidgetInfo::parentFactoryName(). Referenced by createEditor(), editor(), editorText(), eventFilter(), resetEditor(), setEditorText(), and KexiDBFactory::startEditing(). |
|
|
This slot is called when the editor is destroyed. Definition at line 494 of file widgetfactory.cpp. References m_handles, m_widget, setEditor(), and setWidget(). Referenced by createEditor(). |
|
|
Definition at line 652 of file widgetfactory.cpp. References editor(), and m_widget. Referenced by resetEditor(), and slotTextChanged(). |
|
||||||||||||
|
This function creates a little editor to modify rich text. It supports alignment, subscript and superscript and all basic formatting properties. If the user presses "Ok", the edited text is put in text. If he presses "Cancel", nothing happens. Definition at line 334 of file widgetfactory.cpp. References KFormDesigner::RichTextDialog::text(). Referenced by StdWidgetFactory::editText(), KexiReportFactory::editText(), and KexiDBFactory::startEditing(). |
|
||||||||||||
|
This function destroys the editor when it loses focus or Enter is pressed. Definition at line 353 of file widgetfactory.cpp. References editor(), KFormDesigner::Container::eventFilter(), m_container, m_firstText, m_widget, resetEditor(), resizeEditor(), and setEditorText(). |
|
|
This method allows to force a class classname to hidden. It is useful if you do not want a class to be available (e.g. because it is not implemented well yet for our purposes). All widget libraries are affected by this setting. Definition at line 177 of file widgetfactory.cpp. References m_hiddenClasses. Referenced by KexiDBFactory::KexiDBFactory(). |
|
|
Definition at line 643 of file widgetfactory.cpp. References m_classesByName. |
|
||||||||||||
|
Definition at line 368 of file widgetfactory.h. |
|
||||||||||||||||||||||||
|
This function is used to know whether the property for the widget w should be shown or not in the PropertyEditor. If multiple is true, then multiple widgets of the same class are selected, and you should only show properties shared by widgets (eg font, color). By default, all properties are shown if multiple == true, and none if multiple == false. Definition at line 544 of file widgetfactory.cpp. References isPropertyVisibleInternal(). |
|
||||||||||||||||||||
|
This function is called when we want to know whether the property should be visible. Implement it in the factory; don't forget to call implementation in the superclass. Default implementation hides "caption", "icon", "sizeIncrement" and "iconText" properties. Reimplemented in ContainerFactory, StdWidgetFactory, KexiDBFactory, and KexiReportFactory. Definition at line 563 of file widgetfactory.cpp. Referenced by isPropertyVisible(). |
|
||||||||||||||||
|
This function is called just before the Form is previewed. It allows widgets to make changes before switching (ie for a Spring, hiding the cross) |
|
|
Definition at line 354 of file widgetfactory.h. Referenced by KFormDesigner::WidgetLibrary::propertyDescForName(). |
|
|
Definition at line 357 of file widgetfactory.h. Referenced by KFormDesigner::WidgetLibrary::propertyDescForValue(). |
|
||||||||||||||||
|
Sometimes property sets should be reloaded when a given property value changed. Implement it in the factory. Default implementation always returns false. Reimplemented in KexiDBFactory. Definition at line 583 of file widgetfactory.cpp. |
|
||||||||||||||||||||
|
This function is called when FormIO finds a property or an unknown element in a .ui file. You can this way load a special property, for example the contents of a listbox.
Definition at line 632 of file widgetfactory.cpp. |
|
|
Definition at line 417 of file widgetfactory.cpp. References changeTextInternal(), editor(), editorText(), KFormDesigner::ObjectTreeItem::eventEater(), KFormDesigner::ObjectTreeItem::isEnabled(), m_container, m_handles, m_widget, setEditor(), KFormDesigner::setRecursiveCursor(), and setWidget(). Referenced by eventFilter(). |
|
||||||||||||||||
|
This function is called when the widget is resized, and the editor size needs to be updated. Reimplemented in ContainerFactory, StdWidgetFactory, and KexiDBFactory. Definition at line 593 of file widgetfactory.cpp. Referenced by eventFilter(). |
|
||||||||||||||||||||||||||||
|
This function is called when FormIO finds a property, at save time, that it cannot handle (ie not a normal property). This way you can save special properties, for example the contents of a listbox.
Reimplemented in ContainerFactory, and StdWidgetFactory. Definition at line 638 of file widgetfactory.cpp. |
|
||||||||||||
|
Definition at line 665 of file widgetfactory.cpp. References KFormDesigner::WidgetLibrary::factory(), m_classesByName, m_editor, m_library, KFormDesigner::WidgetInfo::parentFactoryName(), and setEditor(). Referenced by createEditor(), disableFilter(), editorDeleted(), resetEditor(), and setEditor(). |
|
|
Definition at line 657 of file widgetfactory.cpp. References editor(), and m_widget. Referenced by eventFilter(). |
|
||||||||||||||||
|
Assigns value for internal property property for a class classname. Internal properties are not stored within objects, but can be provided to describe classes' details. Definition at line 714 of file widgetfactory.cpp. References m_internalProp. Referenced by KexiDBFactory::KexiDBFactory(), and StdWidgetFactory::StdWidgetFactory(). |
|
||||||||||||||||
|
This method is called after WidgetPropertySet was filled with properties of a widget w, of class defined by info. Default implementation does nothing. Implement this if you need to set options for properties within the set buf. Definition at line 720 of file widgetfactory.cpp. Referenced by KFormDesigner::WidgetLibrary::setPropertyOptions(). |
|
||||||||||||
|
Definition at line 697 of file widgetfactory.cpp. References KFormDesigner::WidgetLibrary::factory(), m_classesByName, m_container, m_library, m_widget, KFormDesigner::WidgetInfo::parentFactoryName(), and setWidget(). Referenced by createEditor(), ContainerFactory::createMenuActions(), ContainerFactory::createWidget(), disableFilter(), editorDeleted(), resetEditor(), setWidget(), and StdWidgetFactory::startEditing(). |
|
|
Definition at line 598 of file widgetfactory.cpp. References changeTextInternal(), and editorText(). Referenced by createEditor(). |
|
||||||||||||||||
|
Creates (if necessary) an editor to edit the contents of the widget directly in the Form (eg creates a line edit to change the text of a label). classname is the class the widget belongs to, w is the widget to edit and container is the parent container of this widget (to access Form etc.). |
|
|
|
Definition at line 475 of file widgetfactory.cpp. References m_container, m_editor, m_handles, and m_widget. Referenced by createEditor(), and disableFilter(). |
Friends And Related Function Documentation
|
|
Definition at line 510 of file widgetfactory.h. |
Member Data Documentation
|
|
Definition at line 486 of file widgetfactory.h. Referenced by addClass(), changeTextInternal(), editor(), inheritsFactories(), KFormDesigner::WidgetLibrary::loadFactoryWidgets(), setEditor(), setWidget(), and WidgetFactory(). |
|
|
|
Definition at line 476 of file widgetfactory.h. Referenced by changeTextInternal(), and createEditor(). |
|
|
Definition at line 508 of file widgetfactory.h. Referenced by createEditor(), editor(), setEditor(), and widgetDestroyed(). |
|
|
Definition at line 482 of file widgetfactory.h. Referenced by createEditor(), and eventFilter(). |
|
|
Definition at line 505 of file widgetfactory.h. Referenced by WidgetFactory(). |
|
|
Definition at line 483 of file widgetfactory.h. Referenced by createEditor(), disableFilter(), editorDeleted(), resetEditor(), and widgetDestroyed(). |
|
|
Definition at line 487 of file widgetfactory.h. Referenced by hideClass(), KFormDesigner::WidgetLibrary::loadFactories(), WidgetFactory(), and ~WidgetFactory(). |
|
|
internal properties
Definition at line 493 of file widgetfactory.h. Referenced by setInternalProperty(). |
|
|
Definition at line 475 of file widgetfactory.h. Referenced by editor(), KFormDesigner::WidgetLibrary::loadFactories(), setEditor(), and setWidget(). |
|
|
i18n stuff
Definition at line 490 of file widgetfactory.h. Referenced by ContainerFactory::ContainerFactory(), KexiDBFactory::KexiDBFactory(), and StdWidgetFactory::StdWidgetFactory(). |
|
|
Definition at line 491 of file widgetfactory.h. Referenced by ContainerFactory::ContainerFactory(), KexiDBFactory::KexiDBFactory(), and StdWidgetFactory::StdWidgetFactory(). |
|
