Kexi API Documentation (2.0 alpha)

KFormDesigner::FormManager Class Reference

#include <formmanager.h>

Inheritance diagram for KFormDesigner::FormManager:

KexiFormManager List of all members.

Detailed Description

This is Form Designer's main class, which is used by external APIs to access FormDesigner.

This is the class you have to use to integrate FormDesigner into another program. It deals with creating, saving and loading Form, as well as widget insertion and copying. It also ensures all the components (ObjectTreeView, Form and PropertyEditor) are synced, and link them. It holds the WidgetLibrary, the WidgetPropertySet, links to ObjectTreeView and PropertyEditor, as well as the copied widget and the insert state.

Definition at line 72 of file formmanager.h.

Public Types

enum  Options { HideEventsInPopupMenu = 1, SkipFileActions = 2, HideSignalSlotConnections = 4 }

Public Slots

void deleteWidget ()
void copyWidget ()
void cutWidget ()
void pasteWidget ()
void selectAll ()
void clearWidgetContent ()
void undo ()
void redo ()
void editTabOrder ()
void adjustWidgetSize ()
void editFormPixmapCollection ()
void editConnections ()
void layoutHBox ()
 Lay out selected widgets using HBox layout (calls CreateLayoutCommand).
void layoutVBox ()
 Lay out selected widgets using VBox layout.
void layoutGrid ()
 Lay out selected widgets using Grid layout.
void layoutHSplitter ()
 Lay out selected widgets in an horizontal splitter.
void layoutVSplitter ()
 Lay out selected widgets in a verticak splitter.
void layoutHFlow ()
 Lay out selected widgets using HFlow layout.
void layoutVFlow ()
 Lay out selected widgets using VFlow layout.
void breakLayout ()
 Breaks selected layout(calls BreakLayoutCommand).
void alignWidgetsToLeft ()
void alignWidgetsToRight ()
void alignWidgetsToTop ()
void alignWidgetsToBottom ()
void alignWidgetsToGrid ()
void adjustSizeToGrid ()
void adjustWidthToSmall ()
 Resize all selected widgets to the width of the narrowest widget.
void adjustWidthToBig ()
 Resize all selected widgets to the width of the widest widget.
void adjustHeightToSmall ()
 Resize all selected widgets to the height of the shortest widget.
void adjustHeightToBig ()
 Resize all selected widgets to the height of the tallest widget.
void bringWidgetToFront ()
void sendWidgetToBack ()
void insertWidget (const QCString &classname)
void stopInsert ()
void slotPointerClicked ()
 Slot called when the user presses 'Pointer' icon. Switch to Default mode.
void startCreatingConnection ()
 Enter the Connection creation mode.
void stopCreatingConnection ()
 Leave the Connection creation mode.
void windowChanged (QWidget *w)
void deleteWidgetLater (QWidget *w)
 Used to delayed widgets' deletion (in Container::deleteItem()).
void showFormUICode ()
void changeFont ()

Signals

void propertySetSwitched (KoProperty::Set *set, bool forceReload=false, const QCString &propertyToSelect=QCString())
void dirty (KFormDesigner::Form *form, bool isDirty=true)
void widgetSelected (KFormDesigner::Form *form, bool multiple)
void formWidgetSelected (KFormDesigner::Form *form)
void noFormSelected ()
void undoEnabled (bool enabled, const QString &text=QString::null)
void redoEnabled (bool enabled, const QString &text=QString::null)
void createFormSlot (KFormDesigner::Form *form, const QString &widget, const QString &signal)
void connectionCreated (KFormDesigner::Form *form, KFormDesigner::Connection &connection)
void connectionAborted (KFormDesigner::Form *form)
void autoTabStopsSet (KFormDesigner::Form *form, bool set)
void aboutToDeleteForm (KFormDesigner::Form *form)
void formCreated (KFormDesigner::Form *form)

Public Member Functions

 FormManager (QObject *parent=0, int options=0, const char *name=0)
virtual ~FormManager ()
ActionList createActions (WidgetLibrary *lib, KActionCollection *collection, KXMLGUIClient *client)
virtual void enableAction (const char *name, bool enable)=0
virtual KActionaction (const char *name)=0
bool isPasteEnabled ()
WidgetPropertySetpropertySet () const
bool isInserting () const
QCString selectedClass () const
void setInsertPoint (const QPoint &p)
bool isCreatingConnection ()
ConnectioncreatedConnection ()
void resetCreatedConnection ()
void createSignalMenu (QWidget *w)
 Creates and display a menu with all the signals of widget w.
void createSlotMenu (QWidget *w)
 Creates and display a menu with all the slots of widget w.
void emitCreateSlot (const QString &widget, const QString &value)
 Emits the signal createFormSlot(). Used by WidgetPropertySet.
FormactiveForm () const
FormformForWidget (QWidget *w)
bool isTopLevel (QWidget *w)
virtual void showPropertySet (WidgetPropertySet *set, bool forceReload=false, const QCString &propertyToSelect=QCString())
void blockPropertyEditorUpdating (void *blockingObject)
void unblockPropertyEditorUpdating (void *blockingObject, WidgetPropertySet *set)
void setEditor (KoProperty::Editor *editor)
void setObjectTreeView (ObjectTreeView *treeview)
void previewForm (Form *form, QWidget *w, Form *toForm=0)
void importForm (Form *form=0, bool preview=false)
void deleteForm (Form *form)
void createContextMenu (QWidget *w, Container *container, bool popupAtCursor=true)
bool snapWidgetsToGrid ()
int contextMenuKey () const
void emitWidgetSelected (KFormDesigner::Form *form, bool multiple)
void emitFormWidgetSelected (KFormDesigner::Form *form)
void emitNoFormSelected ()
bool isRedoing () const

Static Public Member Functions

static WidgetLibrarycreateWidgetLibrary (FormManager *m, const QStringList &supportedFactoryGroups)
 Creates widget library for supportedFactoryGroups and initializes FormManager singleton.
static FormManagerself ()
 Access to FormManager singleton.

Protected Slots

void deleteWidgetLaterTimeout ()
void buddyChosen (int id)
void menuSignalChosen (int id)
void slotStyle ()
void slotConnectionCreated (KFormDesigner::Form *, KFormDesigner::Connection &)
void slotSettingsChanged (int category)

Protected Member Functions

void initForm (Form *form)
void createLayout (int layoutType)
void alignWidgets (int type)
void enableFormActions ()
void disableWidgetActions ()
void emitUndoEnabled (bool enabled, const QString &text)
void emitRedoEnabled (bool enabled, const QString &text)

Protected Attributes

bool m_emitSelectionSignalsUpdatesPropertySet: 1

Friends

class PropertyCommand
class GeometryPropertyCommand
class CutWidgetCommand
class Form


Member Enumeration Documentation

enum KFormDesigner::FormManager::Options
 

Options for creating FormManager objects. These are really bit-flags and may be or-ed together.

Enumeration values:
HideEventsInPopupMenu 
SkipFileActions 
HideSignalSlotConnections 

Definition at line 94 of file formmanager.h.


Constructor & Destructor Documentation

FormManager::FormManager QObject *  parent = 0,
int  options = 0,
const char *  name = 0
 

Constructs FormManager object. Using options you can control manager's behaviour, see Options.

Definition at line 108 of file formmanager.cpp.

References connectionCreated(), deleteWidgetLaterTimeout(), m_emitSelectionSignalsUpdatesPropertySet, slotConnectionCreated(), and slotSettingsChanged().

FormManager::~FormManager  )  [virtual]
 

Definition at line 151 of file formmanager.cpp.

References KoMacro::_self, and m_managerDeleter.


Member Function Documentation

void KFormDesigner::FormManager::aboutToDeleteForm KFormDesigner::Form form  )  [signal]
 

Signal emitted before the form gets finally deleted. form is still a valid pointer, but the widgets inside the form are in unknown state.

virtual KAction* KFormDesigner::FormManager::action const char *  name  )  [pure virtual]
 

Returns:
action for name.
See also:
enableAction()

Implemented in KexiFormManager.

Form * FormManager::activeForm  )  const
 

Returns:
The Form actually active and focused.

Definition at line 577 of file formmanager.cpp.

Referenced by KexiFormManager::action(), adjustHeightToBig(), adjustHeightToSmall(), adjustSizeToGrid(), adjustWidgetSize(), adjustWidthToBig(), adjustWidthToSmall(), alignWidgets(), alignWidgetsToGrid(), breakLayout(), bringWidgetToFront(), buddyChosen(), clearWidgetContent(), copyWidget(), createContextMenu(), cutWidget(), deleteWidget(), editConnections(), editFormPixmapCollection(), editTabOrder(), emitNoFormSelected(), emitWidgetSelected(), isTopLevel(), menuSignalChosen(), pasteWidget(), redo(), selectAll(), sendWidgetToBack(), KexiFormManager::setDataSourceFieldOrExpression(), KexiFormManager::setFormDataSource(), showFormUICode(), KexiFormManager::slotHistoryCommandExecuted(), slotStyle(), stopCreatingConnection(), and undo().

void FormManager::adjustHeightToBig  )  [slot]
 

Resize all selected widgets to the height of the tallest widget.

Definition at line 1347 of file formmanager.cpp.

References activeForm(), and KFormDesigner::AdjustSizeCommand::SizeToBigHeight.

void FormManager::adjustHeightToSmall  )  [slot]
 

Resize all selected widgets to the height of the shortest widget.

Definition at line 1337 of file formmanager.cpp.

References activeForm(), and KFormDesigner::AdjustSizeCommand::SizeToSmallHeight.

void FormManager::adjustSizeToGrid  )  [slot]
 

Definition at line 1307 of file formmanager.cpp.

References activeForm(), and KFormDesigner::AdjustSizeCommand::SizeToGrid.

void FormManager::adjustWidgetSize  )  [slot]
 

Adjusts the size of the selected widget, ie resize it to its size hint.

Definition at line 1287 of file formmanager.cpp.

References activeForm(), and KFormDesigner::AdjustSizeCommand::SizeToFit.

void FormManager::adjustWidthToBig  )  [slot]
 

Resize all selected widgets to the width of the widest widget.

Definition at line 1327 of file formmanager.cpp.

References activeForm(), and KFormDesigner::AdjustSizeCommand::SizeToBigWidth.

void FormManager::adjustWidthToSmall  )  [slot]
 

Resize all selected widgets to the width of the narrowest widget.

Definition at line 1317 of file formmanager.cpp.

References activeForm(), and KFormDesigner::AdjustSizeCommand::SizeToSmallWidth.

void FormManager::alignWidgets int  type  )  [protected]
 

Function called by all other AlignWidgets*() function. Calls AlignWidgetsCommand.

Definition at line 1242 of file formmanager.cpp.

References activeForm().

Referenced by alignWidgetsToBottom(), alignWidgetsToLeft(), alignWidgetsToRight(), and alignWidgetsToTop().

void FormManager::alignWidgetsToBottom  )  [slot]
 

Definition at line 1281 of file formmanager.cpp.

References KFormDesigner::AlignWidgetsCommand::AlignToBottom, and alignWidgets().

void FormManager::alignWidgetsToGrid  )  [slot]
 

Definition at line 1297 of file formmanager.cpp.

References activeForm(), and KFormDesigner::AlignWidgetsCommand::AlignToGrid.

void FormManager::alignWidgetsToLeft  )  [slot]
 

Definition at line 1263 of file formmanager.cpp.

References KFormDesigner::AlignWidgetsCommand::AlignToLeft, and alignWidgets().

void FormManager::alignWidgetsToRight  )  [slot]
 

Definition at line 1269 of file formmanager.cpp.

References KFormDesigner::AlignWidgetsCommand::AlignToRight, and alignWidgets().

void FormManager::alignWidgetsToTop  )  [slot]
 

Definition at line 1275 of file formmanager.cpp.

References KFormDesigner::AlignWidgetsCommand::AlignToTop, and alignWidgets().

void KFormDesigner::FormManager::autoTabStopsSet KFormDesigner::Form form,
bool  set
[signal]
 

Signal emitted when "autoTabStops" is changed.

Referenced by editTabOrder().

void FormManager::blockPropertyEditorUpdating void *  blockingObject  ) 
 

Definition at line 1169 of file formmanager.cpp.

void FormManager::breakLayout  )  [slot]
 

Breaks selected layout(calls BreakLayoutCommand).

Definition at line 1130 of file formmanager.cpp.

References activeForm(), KFormDesigner::Container::NoLayout, KFormDesigner::Container::setLayout(), and KFormDesigner::Container::widget().

void FormManager::bringWidgetToFront  )  [slot]
 

Definition at line 1357 of file formmanager.cpp.

References activeForm().

void FormManager::buddyChosen int  id  )  [protected, slot]
 

Slot called when a buddy is chosen in the buddy list. Sets the label buddy.

Definition at line 997 of file formmanager.cpp.

References activeForm(), and KFormDesigner::ObjectTreeItem::widget().

Referenced by createContextMenu().

void FormManager::changeFont  )  [slot]
 

Executes font dialog and changes it for currently selected widget(s).

Definition at line 1658 of file formmanager.cpp.

References dirty(), and KFormDesigner::WidgetPropertySet::property().

void FormManager::clearWidgetContent  )  [slot]
 

Clears the contents of the selected widget(s) (eg for a line edit or a listview).

Definition at line 1392 of file formmanager.cpp.

References activeForm().

void KFormDesigner::FormManager::connectionAborted KFormDesigner::Form form  )  [signal]
 

Signal emitted when the Connection creation by drag-and-drop is aborted by user.

Referenced by stopCreatingConnection().

void KFormDesigner::FormManager::connectionCreated KFormDesigner::Form form,
KFormDesigner::Connection connection
[signal]
 

Signal emitted when the Connection creation by drag-and-drop ends. connection is the created Connection. You should copy it, because it is deleted just after the signal is emitted.

Referenced by FormManager(), and menuSignalChosen().

int KFormDesigner::FormManager::contextMenuKey  )  const [inline]
 

Definition at line 208 of file formmanager.h.

void FormManager::copyWidget  )  [slot]
 

Copies the slected widget and all its children of the active Form using an XML representation.

Definition at line 724 of file formmanager.cpp.

References activeForm(), KFormDesigner::FormIO::cleanClipboard(), KFormDesigner::removeChildrenFromList(), and KFormDesigner::FormIO::saveWidget().

ActionList FormManager::createActions WidgetLibrary lib,
KActionCollection *  collection,
KXMLGUIClient *  client
 

Creates all the KActions related to widget insertion, and plug them into the collection. client XML GUI client is used to call lib->addCustomWidgetActions(client). These actions are automatically connected to insertWidget() slot.

Returns:
a QPtrList of the created actions.

Definition at line 195 of file formmanager.cpp.

References KFormDesigner::WidgetLibrary::addCustomWidgetActions(), KFormDesigner::WidgetLibrary::createWidgetActions(), HideSignalSlotConnections, insertWidget(), slotPointerClicked(), slotStyle(), and startCreatingConnection().

void FormManager::createContextMenu QWidget w,
Container container,
bool  popupAtCursor = true
 

This function creates and displays the context menu corresponding to the widget w. The menu item are disabled if necessary, and the widget specific part is added (menu from the factory and buddy selection).

Definition at line 840 of file formmanager.cpp.

References activeForm(), buddyChosen(), KFormDesigner::Container::form(), HideEventsInPopupMenu, menuSignalChosen(), PLUG_ACTION, and KFormDesigner::Container::widget().

Connection* KFormDesigner::FormManager::createdConnection  )  [inline]
 

Returns:
the Connection being created.

Definition at line 136 of file formmanager.h.

void KFormDesigner::FormManager::createFormSlot KFormDesigner::Form form,
const QString widget,
const QString signal
[signal]
 

Signal emitted when the user choose a signal in 'Events' menu in context menu, or in 'Events' in property editor. The code editor should then create the slot connected to this signal.

Referenced by menuSignalChosen().

void FormManager::createLayout int  layoutType  )  [protected]
 

Function called by the "Lay out in..." menu items. It creates a layout from the currently selected widgets (that must have the same parent). Calls CreateLayoutCommand.

Definition at line 1095 of file formmanager.cpp.

References KFormDesigner::ObjectTreeItem::container(), KFormDesigner::WidgetPropertySet::contains(), and KFormDesigner::Container::layoutTypeToString().

Referenced by layoutGrid(), layoutHBox(), layoutHFlow(), layoutHSplitter(), layoutVBox(), layoutVFlow(), and layoutVSplitter().

void FormManager::createSignalMenu QWidget w  ) 
 

Creates and display a menu with all the signals of widget w.

Definition at line 788 of file formmanager.cpp.

References menuSignalChosen(), and resetCreatedConnection().

void FormManager::createSlotMenu QWidget w  ) 
 

Creates and display a menu with all the slots of widget w.

Definition at line 809 of file formmanager.cpp.

References menuSignalChosen(), resetCreatedConnection(), and KFormDesigner::Connection::signal().

WidgetLibrary * FormManager::createWidgetLibrary FormManager m,
const QStringList &  supportedFactoryGroups
[static]
 

Creates widget library for supportedFactoryGroups and initializes FormManager singleton.

m should be always the same for every call.

Definition at line 169 of file formmanager.cpp.

References KoMacro::_self, and m_managerDeleter.

Referenced by KexiFormPart::KexiFormPart(), KexiReportPart::KexiReportPart(), and KFormDesignerKDevPart::KFormDesignerKDevPart().

void FormManager::cutWidget  )  [slot]
 

Cuts (ie Copies and deletes) the selected widget and all its children of the active Form using an XML representation.

Definition at line 756 of file formmanager.cpp.

References activeForm(), and CutWidgetCommand.

void FormManager::deleteForm Form form  ) 
 

Deletes the Form form and removes it from our list.

Definition at line 594 of file formmanager.cpp.

References propertySetSwitched().

void FormManager::deleteWidget  )  [slot]
 

Deletes the selected widget in active Form and all of its children.

Definition at line 705 of file formmanager.cpp.

References activeForm().

void FormManager::deleteWidgetLater QWidget w  )  [slot]
 

Used to delayed widgets' deletion (in Container::deleteItem()).

Definition at line 1402 of file formmanager.cpp.

void FormManager::deleteWidgetLaterTimeout  )  [protected, slot]
 

Definition at line 1411 of file formmanager.cpp.

Referenced by FormManager().

void KFormDesigner::FormManager::dirty KFormDesigner::Form form,
bool  isDirty = true
[signal]
 

This signal is emitted when any change is made to the Form form, so it will need to be saved.

Referenced by changeFont(), editTabOrder(), and windowChanged().

void FormManager::disableWidgetActions  )  [protected]
 

Definition at line 1616 of file formmanager.cpp.

References enableAction().

Referenced by emitNoFormSelected().

void FormManager::editConnections  )  [slot]
 

Creates a dialog to edit the Connection of activeForm().

Definition at line 1230 of file formmanager.cpp.

References activeForm(), KFormDesigner::ConnectionDialog::exec(), and HideSignalSlotConnections.

void FormManager::editFormPixmapCollection  )  [slot]
 

Creates a dialog to edit the activeForm() PixmapCollection.

Definition at line 1220 of file formmanager.cpp.

References activeForm().

void FormManager::editTabOrder  )  [slot]
 

Displays a dialog where the user can modify the tab order of the active Form, by drag-n-drop or using up/down buttons.

Definition at line 1187 of file formmanager.cpp.

References activeForm(), KFormDesigner::TabStopDialog::autoTabStops(), autoTabStopsSet(), dirty(), and KFormDesigner::TabStopDialog::exec().

void KFormDesigner::FormManager::emitCreateSlot const QString widget,
const QString value
[inline]
 

Emits the signal createFormSlot(). Used by WidgetPropertySet.

Definition at line 150 of file formmanager.h.

void FormManager::emitFormWidgetSelected KFormDesigner::Form form  ) 
 

Definition at line 1530 of file formmanager.cpp.

References enableAction(), enableFormActions(), formWidgetSelected(), KFormDesigner::Container::NoLayout, KFormDesigner::Form::objectTree(), KFormDesigner::Form::selectedWidgets(), and KFormDesigner::Form::toplevelContainer().

void FormManager::emitNoFormSelected  ) 
 

Definition at line 1568 of file formmanager.cpp.

References activeForm(), disableWidgetActions(), enableAction(), HideSignalSlotConnections, noFormSelected(), and SkipFileActions.

Referenced by windowChanged().

void FormManager::emitRedoEnabled bool  enabled,
const QString text
[protected]
 

Definition at line 1651 of file formmanager.cpp.

References enableAction(), and redoEnabled().

void FormManager::emitUndoEnabled bool  enabled,
const QString text
[protected]
 

Definition at line 1644 of file formmanager.cpp.

References enableAction(), and undoEnabled().

void FormManager::emitWidgetSelected KFormDesigner::Form form,
bool  multiple
 

Definition at line 1468 of file formmanager.cpp.

References activeForm(), KFormDesigner::ObjectTreeItem::container(), enableAction(), enableFormActions(), KFormDesigner::Container::layoutType(), KFormDesigner::Container::NoLayout, KFormDesigner::Form::objectTree(), KFormDesigner::Form::selectedWidgets(), and widgetSelected().

virtual void KFormDesigner::FormManager::enableAction const char *  name,
bool  enable
[pure virtual]
 

Enables or disables actions name. KFD uses KPart's, action collection here. Kexi implements this to get (shared) actions defined elsewhere.

Implemented in KexiFormManager.

Referenced by disableWidgetActions(), emitFormWidgetSelected(), emitNoFormSelected(), emitRedoEnabled(), emitUndoEnabled(), emitWidgetSelected(), and enableFormActions().

void FormManager::enableFormActions  )  [protected]
 

Definition at line 1595 of file formmanager.cpp.

References enableAction(), HideSignalSlotConnections, isPasteEnabled(), and SkipFileActions.

Referenced by emitFormWidgetSelected(), and emitWidgetSelected().

void KFormDesigner::FormManager::formCreated KFormDesigner::Form form  )  [signal]
 

Signal emitted when new form gets created.

Form * FormManager::formForWidget QWidget w  ) 
 

Returns:
the Form whose toplevel widget is w, or 0 if there is not or the Form is in preview mode.

Definition at line 583 of file formmanager.cpp.

References KFormDesigner::Form::toplevelContainer(), and KFormDesigner::Form::widget().

void KFormDesigner::FormManager::formWidgetSelected KFormDesigner::Form form  )  [signal]
 

Signal emitted when the form widget is selected inside form. Use this to update actions state.

Referenced by emitFormWidgetSelected().

void FormManager::importForm Form form = 0,
bool  preview = false
 

Adds a existing form w and changes it to a container

Definition at line 610 of file formmanager.cpp.

References initForm(), and KFormDesigner::Form::setDesignMode().

void FormManager::initForm Form form  )  [protected]
 

Inits the Form, adds it to m_forms, and conects slots.

Definition at line 622 of file formmanager.cpp.

References windowChanged().

Referenced by importForm().

void FormManager::insertWidget const QCString &  classname  )  [slot]
 

This slot is called when the user presses a "Widget" toolbar button or a "Widget" menu item. Prepares all Forms for creation of a new widget (ie changes cursor ...).

Definition at line 281 of file formmanager.cpp.

References KFormDesigner::FormPrivate::cursors, KFormDesigner::Form::d, stopCreatingConnection(), KFormDesigner::Form::toplevelContainer(), and KFormDesigner::Form::widget().

Referenced by createActions().

bool KFormDesigner::FormManager::isCreatingConnection  )  [inline]
 

Returns:
If we are creating a Connection by drag-and-drop or not.

Definition at line 133 of file formmanager.h.

Referenced by windowChanged().

bool KFormDesigner::FormManager::isInserting  )  const [inline]
 

Returns:
true if one of the insert buttons was pressed and the forms are ready to create a widget.

Definition at line 123 of file formmanager.h.

bool FormManager::isPasteEnabled  ) 
 

Definition at line 255 of file formmanager.cpp.

Referenced by enableFormActions().

bool KFormDesigner::FormManager::isRedoing  )  const [inline]
 

Definition at line 220 of file formmanager.h.

bool FormManager::isTopLevel QWidget w  ) 
 

Returns:
true if w is a toplevel widget, ie. it is the main widget of a Form (so it should have a caption , an icon ...)

Definition at line 689 of file formmanager.cpp.

References activeForm(), and KFormDesigner::ObjectTreeItem::parent().