oopapidocs
2.0
|
00001 #ifndef QOBJECTTREE_H 00002 #define QOBJECTTREE_H 00003 00004 #include <QList> 00005 #include <QWidget> 00006 #include <QObject> 00007 #include <QApplication> 00008 #include <QTreeWidget> 00009 #include <QMetaObject> 00010 #include <QAbstractItemModel> 00011 #include <QAbstractItemView> 00012 #include <QMenu> 00013 #include <QMouseEvent> 00014 #include "obexport.h" 00015 class QObjectTreeItem : public QObject 00016 { 00017 Q_OBJECT 00018 public: 00019 QObject *m_obj; 00020 00021 QObjectTreeItem(QObject *obj_in, QObjectTreeItem *parent = 0); 00022 ~QObjectTreeItem(); 00023 00024 void appendChild(QObjectTreeItem *child); 00025 void removeChild(int row); 00026 00027 QObjectTreeItem *child(int row); 00028 int childCount() const; 00029 int columnCount() const; 00030 QVariant data(int column) const; 00031 int row() const; 00032 QObjectTreeItem *parent(); 00033 QObjectTreeItem *find_child(QObject *ptr); 00034 public slots: 00035 void on_object_destroyed(); 00036 00037 private: 00038 QList<QObjectTreeItem*> m_childItems; 00039 QString m_object_type; 00040 QObjectTreeItem *m_parentItem; 00041 }; 00042 00047 class OBJECTBROWSER_EXPORT QObjectTreeModel : public QAbstractItemModel 00048 { 00049 Q_OBJECT 00050 00051 public: 00052 QObjectTreeModel(QObject *parent = 0); 00053 ~QObjectTreeModel(); 00054 00056 static void addExtraObject(QObject* extra); 00057 00058 QVariant data(const QModelIndex &index, int role) const; 00059 Qt::ItemFlags flags(const QModelIndex &index) const; 00060 QVariant headerData(int section, Qt::Orientation orientation, 00061 int role = Qt::DisplayRole) const; 00062 QModelIndex index(int row, int column, 00063 const QModelIndex &parent = QModelIndex()) const; 00064 QModelIndex parent(const QModelIndex &index) const; 00065 QObjectTreeItem *find_item(QObjectTreeItem *ptr,QObject *obj); 00066 QModelIndex getindex(QObject *obj); 00067 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00068 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00069 void refresh(); 00070 void clear_persistent_data(QModelIndex index); 00071 void refresh(const QModelIndex &aIndex); 00072 00073 QObjectTreeItem *rootItem; 00074 static QList<QObject*> sm_extraObjects; 00075 }; 00076 00077 class OBJECTBROWSER_EXPORT QObjectTree : public QTreeView { 00078 Q_OBJECT 00079 public: 00080 QMenu *widget_menu; 00081 QObjectTree(); 00082 void setup_widget_menu(); 00083 virtual ~QObjectTree(); 00084 protected: 00085 void currentChanged ( const QModelIndex & current, const QModelIndex & previous ); 00086 void mousePressEvent ( QMouseEvent * event ); 00087 signals: 00088 void current_item_changed(); 00089 void show_widget(); 00090 void hide_widget(); 00091 void focus_widget(); 00092 }; 00093 00094 00095 #endif 00096