1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #ifndef CMINDVIEW_H
- #define CMINDVIEW_H
- #include <QGraphicsView>
- #include <list>
- #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<CNodeData> 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<QGraphicsItem *> m_items;
- bool m_align = true;
- bool m_isMovingItem = false;
- bool m_allowEdit = true;
- };
- #endif // CMINDVIEW_H
|