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 
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 KFORMDESIGNEROBJECTTREE_H
00022 #define KFORMDESIGNEROBJECTTREE_H
00023 
00024 #include <qptrlist.h>
00025 #include <qmap.h>
00026 #include <qdict.h>
00027 #include <qvariant.h>
00028 #include <qstring.h>
00029 #include <qguardedptr.h>
00030 
00031 class QWidget;
00032 class QDomElement;
00033 
00034 namespace KFormDesigner {
00035 
00036 class ObjectTreeItem;
00037 class Container;
00038 class EventEater;
00039 
00041 typedef QPtrList<ObjectTreeItem> ObjectTreeList;
00042 
00044 typedef QPtrListIterator<ObjectTreeItem> ObjectTreeListIterator;
00045 
00047 typedef QDict<ObjectTreeItem> ObjectTreeDict;
00048 
00050 typedef QDictIterator<ObjectTreeItem> ObjectTreeDictIterator;
00051 
00053 typedef QMap<QString, QVariant> QVariantMap;
00054 
00056 typedef QMapConstIterator<QString, QVariant> QVariantMapConstIterator;
00057 
00063 class KFORMEDITOR_EXPORT ObjectTreeItem
00064 {
00065     public:
00066         ObjectTreeItem(const QString &className, const QString &name, QWidget *widget, Container *parentContainer, Container *container=0);
00067         virtual ~ObjectTreeItem();
00068 
00069         QString name() const { return m_name; }
00070         QString className() const { return m_className; }
00071         QWidget* widget() const { return m_widget; }
00072         EventEater* eventEater() const { return m_eater; }
00073         ObjectTreeItem* parent() const { return m_parent; }
00074         ObjectTreeList* children() { return &m_children; }
00075 
00078         const QVariantMap* modifiedProperties() const { return &m_props;}
00079 
00081         Container* container() const { return m_container;}
00082 
00083         void setWidget(QWidget *w) { m_widget = w; }
00084         void setParent(ObjectTreeItem *parent)  { m_parent = parent;}
00085 
00086         void debug(int ident);
00087         void rename(const QString &name);
00088 
00089         void addChild(ObjectTreeItem *it);
00090         void removeChild(ObjectTreeItem *it);
00091 
00095         void addModifiedProperty(const QCString &property, const QVariant &oldValue);
00096         void storeUnknownProperty(QDomElement &el);
00097 
00098         void setPixmapName(const QCString &property, const QString &name);
00099         QString pixmapName(const QCString &property);
00100 
00101         void setEnabled(bool enabled)  { m_enabled = enabled; }
00102         bool isEnabled() const { return m_enabled; }
00103 
00104         int gridRow() const { return m_row; }
00105         int gridCol() const { return m_col; }
00106         int gridRowSpan() const { return m_rowspan; }
00107         int gridColSpan() const { return m_colspan; }
00108         bool spanMultipleCells() const { return m_span; }
00109         void setGridPos(int row, int col, int rowspan, int colspan);
00110 
00111     protected:
00112         QString m_className;
00113         QString m_name;
00114         ObjectTreeList  m_children;
00115         QGuardedPtr<Container> m_container;
00116         QMap<QString, QVariant> m_props;
00117         QString  m_unknownProps;
00118         QMap<QCString, QString> m_pixmapNames;
00119         ObjectTreeItem* m_parent;
00120         QGuardedPtr<QWidget> m_widget;
00121         QGuardedPtr<EventEater> m_eater;
00122 
00123         bool  m_enabled;
00124 
00125         int m_row, m_col, m_rowspan, m_colspan;
00126         bool m_span;
00127 
00128         friend class ObjectTree;
00129         friend class FormIO;
00130 };
00131 
00134 class KFORMEDITOR_EXPORT ObjectTree : public ObjectTreeItem
00135 {
00136     public:
00137         ObjectTree(const QString &className=QString::null, const QString &name=QString::null,
00138             QWidget *widget=0, Container *container=0);
00139         virtual ~ObjectTree();
00140 
00143         bool rename(const QString &oldname, const QString &newname );
00145         bool reparent(const QString &name, const QString &newparent);
00146 
00148         ObjectTreeItem* lookup(const QString &name);
00149 
00152         ObjectTreeDict* dict() { return &m_treeDict; }
00153 
00154         void addItem(ObjectTreeItem *parent, ObjectTreeItem *c);
00155         void removeItem(const QString &name);
00156         void removeItem(ObjectTreeItem *c);
00157 
00165         QCString generateUniqueName(const QCString &prefix, bool numberSuffixRequired = true);
00166 
00167     private:
00168         ObjectTreeDict  m_treeDict;
00169 };
00170 
00171 }
00172 
00173 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys