kexi

objecttree.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
00003    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00004    Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KFORMDESIGNEROBJECTTREE_H
00023 #define KFORMDESIGNEROBJECTTREE_H
00024 
00025 #include <qptrlist.h>
00026 #include <qmap.h>
00027 #include <qdict.h>
00028 #include <qvariant.h>
00029 #include <qstring.h>
00030 #include <qguardedptr.h>
00031 
00032 class QWidget;
00033 class QDomElement;
00034 
00035 namespace KFormDesigner {
00036 
00037 class ObjectTreeItem;
00038 class Container;
00039 class EventEater;
00040 
00042 typedef QPtrList<ObjectTreeItem> ObjectTreeList;
00043 
00045 typedef QPtrListIterator<ObjectTreeItem> ObjectTreeListIterator;
00046 
00048 typedef QDict<ObjectTreeItem> ObjectTreeDict;
00049 
00051 typedef QDictIterator<ObjectTreeItem> ObjectTreeDictIterator;
00052 
00054 typedef QMap<QString, QVariant> QVariantMap;
00055 
00057 typedef QMapConstIterator<QString, QVariant> QVariantMapConstIterator;
00058 
00064 class KFORMEDITOR_EXPORT ObjectTreeItem
00065 {
00066     public:
00067         ObjectTreeItem(const QString &className, const QString &name, QWidget *widget, Container *parentContainer, Container *container=0);
00068         virtual ~ObjectTreeItem();
00069 
00070         QString name() const { return m_name; }
00071         QString className() const { return m_className; }
00072         QWidget* widget() const { return m_widget; }
00073         EventEater* eventEater() const { return m_eater; }
00074         ObjectTreeItem* parent() const { return m_parent; }
00075         ObjectTreeList* children() { return &m_children; }
00076 
00079         const QVariantMap* modifiedProperties() const { return &m_props;}
00080 
00082         Container* container() const { return m_container;}
00083 
00084         void setWidget(QWidget *w) { m_widget = w; }
00085         void setParent(ObjectTreeItem *parent)  { m_parent = parent;}
00086 
00087         void debug(int ident);
00088         void rename(const QString &name);
00089 
00090         void addChild(ObjectTreeItem *it);
00091         void removeChild(ObjectTreeItem *it);
00092 
00096         void addModifiedProperty(const QCString &property, const QVariant &oldValue);
00097         void storeUnknownProperty(QDomElement &el);
00098 
00102         void addSubproperty(const QCString &property, const QVariant& value);
00103 
00106         QMap<QString, QVariant>* subproperties() const { return m_subprops; }
00107 
00108         void setPixmapName(const QCString &property, const QString &name);
00109         QString pixmapName(const QCString &property);
00110 
00111         void setEnabled(bool enabled)  { m_enabled = enabled; }
00112         bool isEnabled() const { return m_enabled; }
00113 
00114         int gridRow() const { return m_row; }
00115         int gridCol() const { return m_col; }
00116         int gridRowSpan() const { return m_rowspan; }
00117         int gridColSpan() const { return m_colspan; }
00118         bool spanMultipleCells() const { return m_span; }
00119         void setGridPos(int row, int col, int rowspan, int colspan);
00120 
00121     protected:
00122         QString m_className;
00123         QString m_name;
00124         ObjectTreeList  m_children;
00125         QGuardedPtr<Container> m_container;
00126         QMap<QString, QVariant> m_props;
00127         QMap<QString, QVariant> *m_subprops;
00128         QString  m_unknownProps;
00129         QMap<QCString, QString> m_pixmapNames;
00130         ObjectTreeItem* m_parent;
00131         QGuardedPtr<QWidget> m_widget;
00132         QGuardedPtr<EventEater> m_eater;
00133 
00134         bool  m_enabled;
00135 
00136         int m_row, m_col, m_rowspan, m_colspan;
00137         bool m_span;
00138 
00139         friend class ObjectTree;
00140         friend class FormIO;
00141 };
00142 
00145 class KFORMEDITOR_EXPORT ObjectTree : public ObjectTreeItem
00146 {
00147     public:
00148         ObjectTree(const QString &className=QString::null, const QString &name=QString::null,
00149             QWidget *widget=0, Container *container=0);
00150         virtual ~ObjectTree();
00151 
00154         bool rename(const QString &oldname, const QString &newname );
00156         bool reparent(const QString &name, const QString &newparent);
00157 
00159         ObjectTreeItem* lookup(const QString &name);
00160 
00163         ObjectTreeDict* dict() { return &m_treeDict; }
00164 
00165         void addItem(ObjectTreeItem *parent, ObjectTreeItem *c);
00166         void removeItem(const QString &name);
00167         void removeItem(ObjectTreeItem *c);
00168 
00176         QCString generateUniqueName(const QCString &prefix, bool numberSuffixRequired = true);
00177 
00178     private:
00179         ObjectTreeDict m_treeDict;
00180 };
00181 
00182 }
00183 
00184 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys