#ifndef CMINDVIEW_H #define CMINDVIEW_H #include #include #include "CNode.h" #include "CMind.h" class CNodeItem; class CMindView : public QGraphicsView { Q_OBJECT public: explicit CMindView(QWidget *parent = nullptr); CMind *mind() const; void setNodeList(QList list); void addNode(CNodeData n); // 添加一个节点 void updateNode(CNodeData n); // 更新 void clear(); // 清空 void refreshItems(); void collectItems(CNodeItem *node); void setALignNodes(bool align); CNodeItem *root() const; void refreshNodeGeometry(CNodeItem *node, QPointF topLeft = QPointF()); void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; bool isCloseToEdge(); void moveToCenter(); void testData(); void updateCursor(QPoint pos); void setAllowEdit(bool allow); bool allowEdit() const; public slots: void slotEditNode(CNodeData n); void slotAddSubNode(int pNumber); // 指定父节点, 创建子节点 void slotRemoveNode(int number); // 移除节点 void slotTextChanged(); // 编辑节点 void slotWillBeginEditing(); signals: void sigEditNode(CNodeData n); void sigAddSubNode(int pNumber); void sigNodeChanged(CNodeData n); private: CMind *m_mind = nullptr; CNodeItem *m_root = nullptr; QGraphicsItemGroup *m_group = nullptr; // 场景中显示的项目 QList m_items; bool m_align = true; bool m_isMovingItem = false; bool m_allowEdit = true; }; #endif // CMINDVIEW_H