objecttree.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
3 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
4 Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KFORMDESIGNEROBJECTTREE_H
23#define KFORMDESIGNEROBJECTTREE_H
24
25#include <tqptrlist.h>
26#include <tqmap.h>
27#include <tqdict.h>
28#include <tqvariant.h>
29#include <tqstring.h>
30#include <tqguardedptr.h>
31
32class TQWidget;
33class TQDomElement;
34
35namespace KFormDesigner {
36
37class ObjectTreeItem;
38class Container;
39class EventEater;
40
42typedef TQPtrList<ObjectTreeItem> ObjectTreeList;
43
46
48typedef TQDict<ObjectTreeItem> ObjectTreeDict;
49
52
58class KFORMEDITOR_EXPORT ObjectTreeItem
59{
60 public:
61 ObjectTreeItem(const TQString &className, const TQString &name, TQWidget *widget, Container *parentContainer, Container *container=0);
62 virtual ~ObjectTreeItem();
63
64 TQString name() const { return m_name; }
65 TQString className() const { return m_className; }
66 TQWidget* widget() const { return m_widget; }
67 EventEater* eventEater() const { return m_eater; }
68 ObjectTreeItem* parent() const { return m_parent; }
69 ObjectTreeList* children() { return &m_children; }
70
73 const TQStringVariantMap* modifiedProperties() const { return &m_props;}
74
76 Container* container() const { return m_container;}
77
78 void setWidget(TQWidget *w) { m_widget = w; }
79 void setParent(ObjectTreeItem *parent) { m_parent = parent;}
80
81 void debug(int ident);
82 void rename(const TQString &name);
83
84 void addChild(ObjectTreeItem *it);
85 void removeChild(ObjectTreeItem *it);
86
90 void addModifiedProperty(const TQCString &property, const TQVariant &oldValue);
91 void storeUnknownProperty(TQDomElement &el);
92
96 void addSubproperty(const TQCString &property, const TQVariant& value);
97
100 TQStringVariantMap* subproperties() const { return m_subprops; }
101
102 void setPixmapName(const TQCString &property, const TQString &name);
103 TQString pixmapName(const TQCString &property);
104
105 void setEnabled(bool enabled) { m_enabled = enabled; }
106 bool isEnabled() const { return m_enabled; }
107
108 int gridRow() const { return m_row; }
109 int gridCol() const { return m_col; }
110 int gridRowSpan() const { return m_rowspan; }
111 int gridColSpan() const { return m_colspan; }
112 bool spanMultipleCells() const { return m_span; }
113 void setGridPos(int row, int col, int rowspan, int colspan);
114
115 protected:
116 TQString m_className;
117 TQString m_name;
118 ObjectTreeList m_children;
119 TQGuardedPtr<Container> m_container;
120 TQStringVariantMap m_props;
121 TQStringVariantMap *m_subprops;
122 TQString m_unknownProps;
123 TQMap<TQCString, TQString> m_pixmapNames;
124 ObjectTreeItem* m_parent;
125 TQGuardedPtr<TQWidget> m_widget;
126 TQGuardedPtr<EventEater> m_eater;
127
128 bool m_enabled;
129
130 int m_row, m_col, m_rowspan, m_colspan;
131 bool m_span;
132
133 friend class ObjectTree;
134 friend class FormIO;
135};
136
139class KFORMEDITOR_EXPORT ObjectTree : public ObjectTreeItem
140{
141 public:
142 ObjectTree(const TQString &className=TQString(), const TQString &name=TQString(),
143 TQWidget *widget=0, Container *container=0);
144 virtual ~ObjectTree();
145
148 bool rename(const TQString &oldname, const TQString &newname );
150 bool reparent(const TQString &name, const TQString &newparent);
151
153 ObjectTreeItem* lookup(const TQString &name);
154
157 ObjectTreeDict* dict() { return &m_treeDict; }
158
159 void addItem(ObjectTreeItem *parent, ObjectTreeItem *c);
160 void removeItem(const TQString &name);
161 void removeItem(ObjectTreeItem *c);
162
170 TQCString generateUniqueName(const TQCString &prefix, bool numberSuffixRequired = true);
171
172 private:
173 ObjectTreeDict m_treeDict;
174};
175
176}
177
178#endif
This class makes a container out of any TQWidget.
Definition container.h:74
This class is used to filter the events from any widget (and all its subwidgets) and direct it to the...
Definition container.h:48
An item representing a widget Holds the properties of a widget (classname, name, parent,...
Definition objecttree.h:59
Container * container() const
Definition objecttree.h:76
const TQStringVariantMap * modifiedProperties() const
Definition objecttree.h:73
TQStringVariantMap * subproperties() const
Definition objecttree.h:100
Represents all the objects available within a form. This class holds ObjectTreeItem for each widget i...
Definition objecttree.h:140
ObjectTreeDict * dict()
Definition objecttree.h:157
TQPtrList< ObjectTreeItem > ObjectTreeList
An list of ObjectTreeItem pointers.
Definition objecttree.h:42
TQDictIterator< ObjectTreeItem > ObjectTreeDictIterator
An iterator for ObjectTreeDict.
Definition objecttree.h:51
TQPtrListIterator< ObjectTreeItem > ObjectTreeListIterator
An iterator for ObjectTreeList.
Definition objecttree.h:45
type * findParent(TQObject *o, const char *className, TQObject *&prevPrev)
TQDict< ObjectTreeItem > ObjectTreeDict
A TQString-based disctionary of ObjectTreeItem pointers.
Definition objecttree.h:48
KEXI_DB_EXPORT void debug(const QuerySchemaParameterList &list)
Shows debug information for list.