IndexSystemWidget.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "IndexSystemWidget.h"
  2. #include <dbService/ClassSet.h>
  3. #include <CCanvas/CMindView.h>
  4. #include <CMind.h>
  5. #include <Widgets/Menu.h>
  6. #include <QLayout>
  7. #include <QMenu>
  8. #include <QContextMenuEvent>
  9. #include <QDebug>
  10. IndexSystemWidget::IndexSystemWidget(ProjectInfo *proj, int type, QWidget *parent) : EvalWidget(proj, type, parent)
  11. {
  12. setTitle("指标体系设计");
  13. initWidgets();
  14. initLayout();
  15. }
  16. void IndexSystemWidget::initWidgets()
  17. {
  18. m_mindView = new CMindView(this);
  19. }
  20. void IndexSystemWidget::initLayout()
  21. {
  22. m_contentLayout->addWidget(m_mindView);
  23. }
  24. void IndexSystemWidget::contextMenuEvent(QContextMenuEvent *event)
  25. {
  26. RoundMenu *menu = new RoundMenu();
  27. if (m_mindView->root() == nullptr) {
  28. QAction *act3 = new QAction("创建根节点");
  29. menu->addAction(act3);
  30. connect(act3, &QAction::triggered, this, &IndexSystemWidget::slotCreateRootNode);
  31. } else {
  32. QAction *act2 = new QAction("清空");
  33. menu->addAction(act2);
  34. connect(act2, &QAction::triggered, this, &IndexSystemWidget::slotClearAllNodes);
  35. }
  36. menu->exec(event->globalPos() + QPoint(-40, -20));
  37. QWidget::contextMenuEvent(event);
  38. }
  39. void IndexSystemWidget::slotSelectAllNodes()
  40. {
  41. qDebug() << __FUNCTION__ << __LINE__ << endl;
  42. }
  43. void IndexSystemWidget::slotClearAllNodes()
  44. {
  45. m_mindView->clear();
  46. }
  47. void IndexSystemWidget::slotCreateRootNode()
  48. {
  49. CNodeData n = CNodeData(m_proj->id, m_type, 0);
  50. n.name = m_proj->projectName;
  51. m_mindView->addNode(n);
  52. }