Kexi API Documentation (2.0 alpha)

KFormDesigner::FormIO Class Reference

#include <formIO.h>

List of all members.


Detailed Description

A class to save/load forms from .ui files.

You don't need to create a FormIO object, as all methods are static.
This class is able to read and write Forms to .ui files, and to save each type of properties, including set and enum properties, and pixmaps(pixmap-related code was taken from Qt Designer).

Definition at line 74 of file formIO.h.

Public Member Functions

 FormIO ()
 ~FormIO ()

Static Public Member Functions

static bool saveFormToDom (Form *form, QDomDocument &domDoc)
static bool saveFormToFile (Form *form, const QString &filename=QString::null)
static bool saveFormToString (Form *form, QString &dest, int indent=0)
static bool saveFormToByteArray (Form *form, QByteArray &dest)
static bool loadFormFromDom (Form *form, QWidget *container, QDomDocument &domDoc)
static bool loadFormFromByteArray (Form *form, QWidget *container, QByteArray &src, bool preview=false)
static bool loadFormFromString (Form *form, QWidget *container, QString &src, bool preview=false)
static bool loadFormFromFile (Form *form, QWidget *container, const QString &filename=QString::null)
static void saveWidget (ObjectTreeItem *item, QDomElement &parent, QDomDocument &domDoc, bool insideGridLayout=false)
static void cleanClipboard (QDomElement &uiElement)
static void loadWidget (Container *container, const QDomElement &el, QWidget *parent=0)
static void savePropertyElement (QDomElement &parentNode, QDomDocument &domDoc, const QString &tagName, const QString &property, const QVariant &value)
static QVariant readPropertyValue (QDomNode node, QObject *obj, const QString &name)
static void savePropertyValue (QDomElement &parentNode, QDomDocument &parent, const char *name, const QVariant &value, QWidget *w, WidgetLibrary *lib=0)

Static Protected Member Functions

static void writeVariant (QDomDocument &parent, QDomElement &parentNode, QVariant value)
static void createToplevelWidget (Form *form, QWidget *container, QDomElement &element)
static QString saveImage (QDomDocument &domDoc, const QPixmap &pixmap)
static QPixmap loadImage (QDomDocument domDoc, const QString &name)
static void readChildNodes (ObjectTreeItem *tree, Container *container, const QDomElement &el, QWidget *w)
static void addIncludeFileName (const QString &include, QDomDocument &domDoc)


Constructor & Destructor Documentation

FormIO::FormIO  ) 
 

Definition at line 93 of file formIO.cpp.

FormIO::~FormIO  ) 
 

Definition at line 97 of file formIO.cpp.


Member Function Documentation

void FormIO::addIncludeFileName const QString include,
QDomDocument &  domDoc
[static, protected]
 

Adds an include file name to be saved in the "includehints" part of .ui file, which is needed by uic.

Definition at line 1465 of file formIO.cpp.

Referenced by saveWidget().

void FormIO::cleanClipboard QDomElement &  uiElement  )  [static]
 

Cleans the "UI" QDomElement after saving widget. It deletes the "includes" element not needed when pasting, and make sure all the "widget" elements are at the beginning. Call this after copying a widget, before pasting.

Definition at line 1095 of file formIO.cpp.

Referenced by KFormDesigner::FormManager::copyWidget(), and KFormDesigner::DeleteWidgetCommand::DeleteWidgetCommand().

void FormIO::createToplevelWidget Form form,
QWidget container,
QDomElement &  element
[static, protected]
 

Creates a toplevel widget from the QDomElement element in the Form form, with parent as parent widget. It calls readPropertyValue() and loadWidget() to load child widgets.

Definition at line 1263 of file formIO.cpp.

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

Referenced by loadFormFromDom().

bool FormIO::loadFormFromByteArray Form form,
QWidget container,
QByteArray &  src,
bool  preview = false
[static]
 

Loads a form from the src QByteArray.

See also:
loadFormFromDom(), loadForm().
Returns:
true if loading succeeded.

Definition at line 220 of file formIO.cpp.

References loadFormFromDom().

bool FormIO::loadFormFromDom Form form,
QWidget container,
QDomDocument &  domDoc
[static]
 

Loads a form from the domDoc QDomDocument. Called by loadForm() and loadFormData().

Returns:
true if loading succeeded.

Definition at line 311 of file formIO.cpp.

References KFormDesigner::Form::connectionBuffer(), createToplevelWidget(), KFormDesigner::Form::headerProperties(), KFormDesigner::Form::objectTree(), KFormDesigner::Form::pixmapCollection(), KFormDesigner::Form::setFormatVersion(), KFormDesigner::Form::setOriginalFormatVersion(), KFormDesigner::Form::tabStops(), and KFormDesigner::version().

Referenced by KexiFormView::initForm(), loadFormFromByteArray(), loadFormFromFile(), loadFormFromString(), and KFormDesigner::FormManager::previewForm().

bool FormIO::loadFormFromFile Form form,
QWidget container,
const QString filename = QString::null
[static]
 

Loads the .ui file filename in the Form form. If filename is null or not given, a Open File dialog will be shown to select the file to open. createToplevelWidget() is used to load the Form's toplevel widget.

Returns:
true if loading succeeded.
Todo:
Add errors code and error dialog

Definition at line 272 of file formIO.cpp.

References file, and loadFormFromDom().

Referenced by SubForm::setFormName().

bool FormIO::loadFormFromString Form form,
QWidget container,
QString src,
bool  preview = false
[static]
 

Definition at line 244 of file formIO.cpp.

References loadFormFromDom().

Referenced by KexiReportView::loadForm(), KexiFormView::loadForm(), KexiDBSubForm::setFormName(), and KexiSubReport::setReportName().

QPixmap FormIO::loadImage QDomDocument  domDoc,
const QString name
[static, protected]
 

Returns:
the loaded pixmap This function loads the pixmap named name in the DOM document domDoc. Decoding code is taken from QT Designer.

Definition at line 1548 of file formIO.cpp.

References len.

Referenced by readPropertyValue().

void FormIO::loadWidget Container container,
const QDomElement &  el,
QWidget parent = 0
[static]
 

Loads the widget associated to the QDomElement el into the Container container, with parent as parent widget. If parent = 0, the Container::widget() is used as parent widget. This is used to copy/paste widgets.

Definition at line 1108 of file formIO.cpp.

References KFormDesigner::WidgetFactory::DefaultOptions, KFormDesigner::Form::designMode(), KFormDesigner::WidgetFactory::DesignViewMode, KFormDesigner::Container::form(), KFormDesigner::Container::Grid, KFormDesigner::Container::layout(), KFormDesigner::Container::layoutType(), KFormDesigner::Container::objectTree(), readChildNodes(), KFormDesigner::ObjectTreeItem::setGridPos(), KFormDesigner::WidgetWithSubpropertiesInterface::subwidget(), and KFormDesigner::Container::widget().

Referenced by KFormDesigner::PasteWidgetCommand::execute(), readChildNodes(), and KFormDesigner::DeleteWidgetCommand::unexecute().

void FormIO::readChildNodes ObjectTreeItem tree,
Container container,
const QDomElement &  el,
QWidget w
[static, protected]
 

Reads the child nodes of a "widget" element.

Definition at line 1311 of file formIO.cpp.

References KFormDesigner::Container::form(), KFormDesigner::Container::Grid, KFormDesigner::Container::HBox, KFormDesigner::Container::HFlow, loadWidget(), readPropertyValue(), KexiFlowLayout::setJustified(), KexiFlowLayout::setOrientation(), KFormDesigner::WidgetWithSubpropertiesInterface::subwidget(), KFormDesigner::Container::VBox, and KFormDesigner::Container::VFlow.

Referenced by createToplevelWidget(), and loadWidget().

QVariant FormIO::readPropertyValue QDomNode  node,
QObject *  obj,
const QString name
[static]
 

Read an object property in the DOM doc.

Parameters:
node the QDomNode of the property
obj the widget whose property is being read
name the name of the property being read

Definition at line 737 of file formIO.cpp.

References loadImage(), KFormDesigner::Form::pixmapCollection(), KFormDesigner::ObjectTreeItem::setPixmapName(), and KFormDesigner::WidgetWithSubpropertiesInterface::subwidget().

Referenced by readChildNodes(), StdWidgetFactory::readListItem(), StdWidgetFactory::readSpecialProperty(), and ContainerFactory::readSpecialProperty().

bool FormIO::saveFormToByteArray Form form,
QByteArray &  dest
[static]
 

Saves the form inside the dest QByteArray.

Returns:
true if saving succeeded.
See also:
saveFormToDom(), saveForm()

Definition at line 134 of file formIO.cpp.

References saveFormToDom().

bool FormIO::saveFormToDom Form form,
QDomDocument &  domDoc
[static]
 

Save the Form in the domDoc QDomDocument. Called by saveForm().

Returns:
true if saving succeeded.
See also:
saveForm()

Definition at line 154 of file formIO.cpp.

References saveWidget().

Referenced by KFormDesigner::FormManager::previewForm(), saveFormToByteArray(), saveFormToFile(), and saveFormToString().

bool FormIO::saveFormToFile Form form,
const QString filename = QString::null
[static]
 

Save the Form form to the file filename. If filename is null or not given, a Save File dialog will be shown to choose dest file.

Returns:
true if saving succeeded.
Todo:
Add errors code and error dialog

Definition at line 102 of file formIO.cpp.

References file, KFormDesigner::Form::filename(), saveFormToDom(), and KFormDesigner::Form::setFilename().

bool FormIO::saveFormToString Form form,
QString dest,
int  indent = 0
[static]
 

Saves the Form to the dest string. indent can be specified to apply indentation.

Returns:
true if saving succeeded.
See also:
saveForm()

Definition at line 144 of file formIO.cpp.

References saveFormToDom().

Referenced by KexiReportView::beforeSwitchTo(), KexiFormView::beforeSwitchTo(), KFormDesigner::FormManager::showFormUICode(), KexiReportView::storeData(), and KexiFormView::storeData().

QString FormIO::saveImage QDomDocument &  domDoc,
const QPixmap &  pixmap
[static, protected]
 

Returns:
the name of the pixmap saved, to use to access it This function save the QPixmap pixmap into the DOM document domDoc. The pixmap is converted to XPM and compressed for compatibility with Qt Designer. Encoding code is taken from Designer.

Definition at line 1496 of file formIO.cpp.

References len.

Referenced by savePropertyValue().

void FormIO::savePropertyElement QDomElement &  parentNode,
QDomDocument &  domDoc,
const QString tagName,
const QString property,
const QVariant &  value
[static]
 

Save an element in the domDoc as child of parentNode. The element will be saved like this :

 <$(tagName) name = "$(property)">< value_as_XML ><$(tagName)/>

Definition at line 728 of file formIO.cpp.

References writeVariant().

Referenced by StdWidgetFactory::saveListItem(), StdWidgetFactory::saveSpecialProperty(), ContainerFactory::saveSpecialProperty(), and saveWidget().

void FormIO::savePropertyValue QDomElement &  parentNode,
QDomDocument &  parent,
const char *  name,
const QVariant &  value,
QWidget w,
WidgetLibrary lib = 0
[static]
 

Write an object property in the DOM doc.

Parameters:
parentNode the DOM document to write to
name the name of the property being saved
value the value of this property
w the widget whose property is being saved
lib the widget library for which the property is being saved
Properties of subwidget are saved with subwidget="true" arribute added to 'property' XML element.

Definition at line 401 of file formIO.cpp.

References KFormDesigner::ObjectTreeItem::pixmapName(), saveImage(), KFormDesigner::WidgetLibrary::saveSpecialProperty(), KFormDesigner::WidgetWithSubpropertiesInterface::subwidget(), and writeVariant().

Referenced by Spring::saveSpring(), and saveWidget().

void FormIO::saveWidget ObjectTreeItem item,
QDomElement &  parent,
QDomDocument &  domDoc,
bool  insideGridLayout = false
[static]
 

Saves the widget associated to the ObjectTreeItem item into DOM document domDoc, with parent as parent node. It calls readPropertyValue() for each object property, readAttribute() for each attribute and itself to save child widgets.

Returns:
true if saving succeeded. This is used to copy/paste widgets.

Definition at line 905 of file formIO.cpp.

References addIncludeFileName(), KFormDesigner::ObjectTreeItem::children(), KFormDesigner::ObjectTreeItem::className(), KFormDesigner::ObjectTreeItem::container(), KFormDesigner::Container::Grid, KFormDesigner::ObjectTreeItem::gridCol(), KFormDesigner::ObjectTreeItem::gridColSpan(), KFormDesigner::ObjectTreeItem::gridRow(), KFormDesigner::ObjectTreeItem::gridRowSpan(), KFormDesigner::Container::HBox, KFormDesigner::Container::HFlow, KFormDesigner::WidgetLibrary::includeFileName(), KFormDesigner::Container::layoutTypeToString(), KFormDesigner::Form::library(), KFormDesigner::ObjectTreeItem::m_unknownProps, KFormDesigner::ObjectTreeItem::modifiedProperties(), KFormDesigner::Container::NoLayout, KFormDesigner::ObjectTreeItem::parent(), savePropertyElement(), savePropertyValue(), Spring::saveSpring(), KFormDesigner::WidgetLibrary::savingName(), KFormDesigner::ObjectTreeItem::spanMultipleCells(), KFormDesigner::Container::VBox, KFormDesigner::Container::VFlow, KFormDesigner::ObjectTreeItem::widget(), and KexiFlowLayout::widgetList().

Referenced by KFormDesigner::FormManager::copyWidget(), KFormDesigner::DeleteWidgetCommand::DeleteWidgetCommand(), and saveFormToDom().

void FormIO::writeVariant QDomDocument &  parent,
QDomElement &  parentNode,
QVariant  value
[static, protected]
 

Saves the QVariant value as text to be included in an xml file, with parentNode.

Definition at line 477 of file formIO.cpp.

Referenced by savePropertyElement(), and savePropertyValue().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:50:59 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003