IndexSystemWidget.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. qDebug() << __FUNCTION__ << __LINE__ << endl;
  26. QMenu *menu = new QMenu();
  27. QAction *act1 = menu->addAction("全选");
  28. connect(act1, &QAction::triggered, this, &IndexSystemWidget::slotSelectAllNodes);
  29. QAction *act2 = menu->addAction("清空");
  30. connect(act2, &QAction::triggered, this, &IndexSystemWidget::slotClearAllNodes);
  31. if (m_mindView->root() == nullptr) {
  32. QAction *act3 = menu->addAction("创建根节点");
  33. connect(act3, &QAction::triggered, this, &IndexSystemWidget::slotCreateRootNode);
  34. }
  35. menu->exec(event->globalPos());
  36. QWidget::contextMenuEvent(event);
  37. }
  38. void IndexSystemWidget::slotSelectAllNodes()
  39. {
  40. qDebug() << __FUNCTION__ << __LINE__ << endl;
  41. }
  42. void IndexSystemWidget::slotClearAllNodes()
  43. {
  44. qDebug() << __FUNCTION__ << __LINE__ << endl;
  45. }
  46. void IndexSystemWidget::slotCreateRootNode()
  47. {
  48. qDebug() << __FUNCTION__ << __LINE__ << endl;
  49. CNodeData n = CNodeData(m_proj->id, m_type, 0);
  50. n.name = m_proj->projectName;
  51. m_mindView->addNode(n);
  52. }