123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef CNODE_H
- #define CNODE_H
- #include <QObject>
- struct CNodeData
- {
- int id = -1; // 节点 id, 对应数据库节点表中的 id, 数据库自动生成
- int projectId = -1; // 项目 id, 对应数据库项目表中的 id, 为脑图所属项目, 数据库自动生成
- int indexType = 0; // 指标类型
- int number = -1; // 节点编号, 作用域为当前脑图, 0 为根节点
- int pNumber = -1; // 父节点编号
- QString name = "新节点"; // 名称
- QString remark = ""; // 备注
- QString dimension = ""; //量纲
- CNodeData(int projId = -1, int indexType = 0, int number = -1, int pNumber = -1, int id = -1);
- bool isValid() const;
- bool isNull() const;
- bool isCached() const;
- bool hasParent() const;
- bool isSameMind(CNodeData n) const;
- };
- class CNode : public QObject
- {
- Q_OBJECT
- public:
- explicit CNode(QObject *parent = nullptr);
- const CNode *pNode() const; // 父节点
- const CNode *rNode() const; // 根节点
- QList<CNode *> cNodes() const; // 孩子节点
- int height() const; // 节点的高度
- int depth() const; // 节点的深度
- int leaves() const; // 叶子节点个数或包含的路径条数
- ///
- /// \brief sizeOfLevel 以此节点为根节点的子树中,某一层的节点数
- /// \param lev 节点层级,当前节点为1,向下递增
- /// \return 节点数
- ///
- int sizeOfLevel(int lev) const;
- signals:
- };
- #endif // CNODE_H
|