kexi

formIO.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef FORMIO_H
00022 #define FORMIO_H
00023 
00024 #include <qobject.h>
00025 #include <qdict.h>
00026 #include <qstring.h>
00027 #include <qwidget.h>
00028 #include <qmap.h>
00029 
00030 class QString;
00031 class QDomElement;
00032 class QDomNode;
00033 class QDomDocument;
00034 class QDomText;
00035 class QVariant;
00036 class QLabel;
00037 
00039 class KFORMEDITOR_EXPORT CustomWidget : public QWidget
00040 {
00041     Q_OBJECT
00042 
00043     public:
00044         CustomWidget(const QCString &className, QWidget *parent, const char *name);
00045         virtual ~CustomWidget();
00046 
00047         virtual void paintEvent(QPaintEvent *ev);
00048 
00049     private:
00050         QCString m_className;
00051 };
00052 
00053 namespace KFormDesigner {
00054 
00055 class WidgetPropertySet;
00056 class Form;
00057 class ObjectTreeItem;
00058 class Container;
00059 class WidgetLibrary;
00060 
00063 #define KFORMDESIGNER_VERSION 2
00064 
00066 KFORMEDITOR_EXPORT uint version();
00067 
00073 
00074 class KFORMEDITOR_EXPORT FormIO : public QObject
00075 {
00076     Q_OBJECT
00077 
00078     public:
00079         FormIO();
00080         ~FormIO();
00081 
00085         static bool saveFormToDom(Form *form, QDomDocument &domDoc);
00086 
00092         static bool saveFormToFile(Form *form, const QString &filename=QString::null);
00093 
00098         static bool saveFormToString(Form *form, QString &dest, int indent = 0);
00099 
00104         static bool saveFormToByteArray(Form *form, QByteArray &dest);
00105 
00108         static bool loadFormFromDom(Form *form, QWidget *container, QDomDocument &domDoc);
00109 
00114         static bool loadFormFromByteArray(Form *form, QWidget *container, QByteArray &src,
00115             bool preview=false);
00116 
00117         static bool loadFormFromString(Form *form, QWidget *container, QString &src, bool preview=false);
00118 
00125         static bool loadFormFromFile(Form *form, QWidget *container, const QString &filename=QString::null);
00126 
00134         static void saveWidget(ObjectTreeItem *item, QDomElement &parent, QDomDocument &domDoc,
00135             bool insideGridLayout=false);
00136 
00140         static void cleanClipboard(QDomElement &uiElement);
00141 
00147         static void loadWidget(Container *container,
00148             const QDomElement &el, QWidget *parent=0);
00149 
00155         static void savePropertyElement(QDomElement &parentNode, QDomDocument &domDoc, const QString &tagName,
00156             const QString &property, const QVariant &value);
00157 
00163         static QVariant readPropertyValue(QDomNode node, QObject *obj, const QString &name);
00164 
00172         static void savePropertyValue(QDomElement &parentNode, QDomDocument &parent, const char *name,
00173             const QVariant &value, QWidget *w, WidgetLibrary *lib=0);
00174 
00175     protected:
00177         static void writeVariant(QDomDocument &parent, QDomElement &parentNode, QVariant value);
00178 
00183         static void createToplevelWidget(Form *form, QWidget *container, QDomElement &element);
00184 
00190         static QString saveImage(QDomDocument &domDoc, const QPixmap &pixmap);
00191 
00196         static QPixmap loadImage(QDomDocument domDoc, const QString& name);
00197 
00199         static void readChildNodes(ObjectTreeItem *tree, Container *container, 
00200             const QDomElement &el, QWidget *w);
00201 
00204         static void addIncludeFileName(const QString &include, QDomDocument &domDoc);
00205 
00206     private:
00207         // This dict stores buddies associations until the Form is completely loaded.
00208         static QDict<QLabel>  *m_buddies;
00209 
00211         //static QWidgdet  *m_currentWidget;
00212         static ObjectTreeItem   *m_currentItem;
00213         static Form *m_currentForm;
00214         static bool m_savePixmapsInline;
00215 };
00216 
00217 }
00218 
00219 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys