00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef TREEMODEL_H
00010 #define TREEMODEL_H
00011
00012 #include "JavaQxQSwing.h"
00013
00014
00015
00016
00017
00018 class JQTreeBridge;
00019
00026 class JAVAQX_EXPORT TreeNode
00027 {
00028 public:
00029 TreeNode();
00030 TreeNode(jobject node, TreeNode *parent);
00031 virtual ~TreeNode();
00032 public:
00033 jobject node();
00034 TreeNode *parent();
00035 QVariant data();
00036 int row();
00037 int childCount();
00038 bool isLeaf();
00039 TreeNode *child(int row);
00040 void addChild(TreeNode *child);
00041 public:
00042 static void initialize(JNIEnv *env, jclass cls);
00043 private:
00044 void expand();
00045 private:
00046 jobject m_node;
00047 TreeNode *m_parentNode;
00048 int m_childCount;
00049 QList<TreeNode *> m_childNodes;
00050 private:
00051 static jmethodID sm_getChildCountMID;
00052 static jmethodID sm_getChildAtMID;
00053 };
00054
00055
00056
00057
00058
00065 class JAVAQX_EXPORT TreeModel : public QAbstractItemModel
00066 {
00067 public:
00068 TreeModel(JQTreeBridge *treeBridge);
00069 virtual ~TreeModel();
00070 public:
00071 TreeNode *getRootNode();
00072 public:
00073 Qt::ItemFlags flags(const QModelIndex &index) const;
00074 QModelIndex parent(const QModelIndex &index) const;
00075 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00076 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00077 QModelIndex index(int row, int column,
00078 const QModelIndex &parent = QModelIndex()) const;
00079 QVariant data(const QModelIndex &index, int role) const;
00080 QVariant headerData(int section, Qt::Orientation orientation,
00081 int role = Qt::DisplayRole) const;
00082 private:
00083 JQTreeBridge *m_treeBridge;
00084 TreeNode *m_rootNode;
00085 TreeNode *m_modelRootNode;
00086 };
00087
00088 #endif // TREEMODEL_H
00089
00090
00091
00092
00093
00094
00095
00096