123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #include "IndexSystemWidget.h"
- #include <dbService/ClassSet.h>
- #include <dbService/CNodeDataService.h>
- #include <CMindView.h>
- #include <CMind.h>
- #include <CNodeItem.h>
- #include <Widgets/Menu.h>
- #include <QLayout>
- #include <QMenu>
- #include <QContextMenuEvent>
- #include <QDebug>
- 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<CNodeData> 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);
- }
|