#include "IndexSystemWidget.h" #include #include #include #include #include #include #include #include #include #include IndexSystemWidget::IndexSystemWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent) { setTitle("指标体系设计"); initWidgets(); initLayout(); connectSignalsAndSlots(); } void IndexSystemWidget::initWidgets() { m_mindView = new CMindView(this); } void IndexSystemWidget::initLayout() { m_contentLayout->addWidget(m_mindView); } void IndexSystemWidget::connectSignalsAndSlots() { connect(m_mindView, &CMindView::sigAddSubNode, this, &IndexSystemWidget::slotAddSubNode); connect(m_mindView->mind(), &CMind::sigRemoveNode, this, &IndexSystemWidget::slotRemoveNode); } void IndexSystemWidget::setType(int type) { EvalWidget::setType(type); QList list; bool ret = CNodeDataService().QueryAll(list, proj()->id, type); if (ret) { m_mindView->setNodeList(list); } } void IndexSystemWidget::contextMenuEvent(QContextMenuEvent *event) { RoundMenu *menu = new RoundMenu(); if (m_mindView->root() == nullptr) { QAction *act3 = new QAction("创建根节点"); menu->addAction(act3); connect(act3, &QAction::triggered, this, &IndexSystemWidget::slotCreateRootNode); } else { QAction *act2 = new QAction("清空"); menu->addAction(act2); connect(act2, &QAction::triggered, this, &IndexSystemWidget::slotClearAllNodes); } menu->exec(event->globalPos() + QPoint(-40, -20)); QWidget::contextMenuEvent(event); } void IndexSystemWidget::addNode(CNodeData node) { qDebug() << __FUNCTION__ << __LINE__ << node.number << endl; if (m_mindView->mind()->canAddNode(node)) { int id = CNodeDataService().AddCNodeData(node); if (id >= 0) { node.id = id; m_mindView->addNode(node); } } } void IndexSystemWidget::removeNode(int id) { qDebug() << __FUNCTION__ << __LINE__ << id << endl; } void IndexSystemWidget::slotSelectAllNodes() { qDebug() << __FUNCTION__ << __LINE__ << endl; } void IndexSystemWidget::slotClearAllNodes() { m_mindView->clear(); } void IndexSystemWidget::slotCreateRootNode() { CNodeData n = CNodeData(m_proj->id, m_type, 0); n.name = m_proj->projectName; addNode(n); } void IndexSystemWidget::slotAddSubNode(int pNumber) { if (pNumber < 0) { return; } CNodeData data = m_mindView->root()->data(); CNodeData n = CNodeData(data.projectId, data.evalType, m_mindView->mind()->maxNumber() + 1, pNumber); addNode(n); } void IndexSystemWidget::slotRemoveNode(int id) { removeNode(id); }