IndexSystemWidget.cpp 1.4 KB

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