kexi

objecttreeview.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef OBJECTTREEVIEW_H
00021 #define OBJECTTREEVIEW_H
00022 
00023 #include <klistview.h>
00024 
00025 namespace KFormDesigner {
00026 
00027 class ObjectTreeItem;
00028 class Form;
00029 
00031 class KFORMEDITOR_EXPORT ObjectTreeViewItem : public KListViewItem
00032 {
00033     public:
00034         ObjectTreeViewItem(ObjectTreeViewItem *parent, ObjectTreeItem *item);
00035         ObjectTreeViewItem(KListView *list, ObjectTreeItem *item=0);
00036         virtual ~ObjectTreeViewItem();
00037 
00039         QString name() const;
00040 
00042         ObjectTreeItem* objectTree() const { return m_item; }
00043 
00044         virtual void setOpen( bool o );
00045 
00046     protected:
00048         virtual void paintCell(QPainter *p, const QColorGroup & cg, int column, int width, int align);
00049 
00051         virtual void paintBranches(QPainter *p, const QColorGroup &cg, int w, int y, int h);
00052 
00054         virtual void setup();
00055 
00056     private:
00057         ObjectTreeItem *m_item;
00058 
00059     friend class ObjectTreeView;
00060 };
00061 
00066 class KFORMEDITOR_EXPORT ObjectTreeView : public KListView
00067 {
00068     Q_OBJECT
00069 
00070     public:
00071         ObjectTreeView(QWidget *parent=0, const char *name=0, bool tabStop = false);
00072         virtual ~ObjectTreeView();
00073 
00074         virtual QSize sizeHint() const;
00075 
00079         void setForm(Form *form);
00080 
00082         QString iconNameForClass(const QCString &classname);
00083 
00084     public slots:
00086         void setSelectedWidget(QWidget *w, bool add=false);
00087 
00089         void addItem(ObjectTreeItem *item);
00090 
00092         void removeItem(ObjectTreeItem *item);
00093 
00095         void renameItem(const QCString &oldname, const QCString &newname);
00096 
00097     protected slots:
00099         void displayContextMenu(KListView *list, QListViewItem *item, const QPoint &p);
00100 
00101         void slotColumnSizeChanged(int);
00102 
00104         void slotSelectionChanged();
00105 
00107         void slotBeforeFormDestroyed();
00108 
00109     protected:
00111         ObjectTreeViewItem* loadTree(ObjectTreeItem *item, ObjectTreeViewItem *parent);
00112 
00114         ObjectTreeViewItem* findItem(const QString &name);
00115 
00116     private:
00117         Form *m_form;
00118         ObjectTreeViewItem *m_topItem;
00119 
00120     friend class TabStopDialog;
00121 };
00122 
00123 }
00124 
00125 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys