|
@@ -14,7 +14,6 @@
|
|
|
CMindView::CMindView(QWidget *parent) : QGraphicsView(new QGraphicsScene(), parent)
|
|
|
{
|
|
|
setRenderHints(QPainter::Antialiasing); // 抗锯齿
|
|
|
- testItems();
|
|
|
}
|
|
|
|
|
|
CMind *CMindView::mind() const
|
|
@@ -28,49 +27,20 @@ void CMindView::setMind(CMind *mind)
|
|
|
refresh();
|
|
|
}
|
|
|
|
|
|
-void CMindView::refresh() { }
|
|
|
-
|
|
|
-void CMindView::setALignment(CMindView::Alignment align)
|
|
|
-{
|
|
|
- m_align = align;
|
|
|
-}
|
|
|
-
|
|
|
-void CMindView::contextMenuEvent(QContextMenuEvent *event)
|
|
|
+void CMindView::refresh()
|
|
|
{
|
|
|
- QMenu *menu = new QMenu();
|
|
|
-
|
|
|
- QAction *selectAction = menu->addAction("全选");
|
|
|
- connect(selectAction, &QAction::triggered, this, &CMindView::slotSelectAllNodes);
|
|
|
-
|
|
|
- QAction *clearAction = menu->addAction("清空");
|
|
|
- connect(clearAction, &QAction::triggered, this, &CMindView::slotClearAllNodes);
|
|
|
-
|
|
|
- if (m_mind != nullptr && m_mind->nodeList().count() <= 0) {
|
|
|
- QAction *root = menu->addAction("创建根节点");
|
|
|
- connect(root, &QAction::triggered, this, &CMindView::slotCreateRootNode);
|
|
|
+ for (CNodeData n : m_mind->nodeList()) {
|
|
|
+ CNodeItem *item = new CNodeItem(n.number);
|
|
|
+ item->setText(n.name);
|
|
|
+ item->setPos(QPointF());
|
|
|
+ scene()->addItem(item->rectItem());
|
|
|
+ scene()->addItem(item->textItem());
|
|
|
}
|
|
|
-
|
|
|
- menu->exec(event->globalPos());
|
|
|
-
|
|
|
- QGraphicsView::contextMenuEvent(event);
|
|
|
-}
|
|
|
-
|
|
|
-void CMindView::slotCreateRootNode()
|
|
|
-{
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
-
|
|
|
- CNodeItem *item = new CNodeItem(0, this);
|
|
|
- scene()->addItem(item->rectItem());
|
|
|
}
|
|
|
|
|
|
-void CMindView::slotClearAllNodes()
|
|
|
-{
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
-}
|
|
|
-
|
|
|
-void CMindView::slotSelectAllNodes()
|
|
|
+void CMindView::setALignment(CMindView::Alignment align)
|
|
|
{
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
+ m_align = align;
|
|
|
}
|
|
|
|
|
|
void CMindView::testItems()
|