SchemePlanWidget.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #include "SchemePlanWidget.h"
  2. #include "SchemeFlowWidget.h"
  3. #include "ProjectManager.h"
  4. #include <dbService/ClassSet.h>
  5. #include <dbService/SchemeProcessService.h>
  6. #include <CSchemeView.h>
  7. #include <Widgets/Button.h>
  8. #include <QTabWidget>
  9. #include <QLayout>
  10. //#include <QTextEdit>
  11. #include <QDebug>
  12. SchemePlanWidget::SchemePlanWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent)
  13. {
  14. setTitle("评估方案规划");
  15. setupUI();
  16. }
  17. void SchemePlanWidget::setType(int type)
  18. {
  19. EvalWidget::setType(type);
  20. setupTabWidget();
  21. }
  22. void SchemePlanWidget::setupUI()
  23. {
  24. m_topLayout->addStretch();
  25. m_export = new PushButton("保存", this);
  26. m_export->setEnabled(false);
  27. m_topLayout->addWidget(m_export);
  28. m_topLayout->addSpacing(10);
  29. m_export->setHidden(true);
  30. // m_description = new QTextEdit(this);
  31. // m_description->setPlainText("方案说明");
  32. // m_description->setFixedWidth(240);
  33. // m_contentLayout->addWidget(m_description);
  34. connect(m_export, &PushButton::clicked, this, &SchemePlanWidget::slotExportClicked);
  35. }
  36. QList<SchemePlanManager::SchemeProcessInfo> SchemePlanWidget::templateSchemes(int projId, int indexType)
  37. {
  38. QList<SchemePlanManager::SchemeProcessType> types;
  39. switch (indexType) {
  40. case ProjectManager::AbilityIndex: {
  41. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  42. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  43. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  44. break;
  45. }
  46. case ProjectManager::TechIndex: {
  47. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  48. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  49. break;
  50. }
  51. case ProjectManager::OptimalIndex: {
  52. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  53. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  54. SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  55. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  56. break;
  57. }
  58. case ProjectManager::EfficiencyIndex: {
  59. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  60. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  61. SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  62. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  63. break;
  64. }
  65. }
  66. QList<SchemePlanManager::SchemeProcessInfo> schemes;
  67. for (int i = 0; i < types.count(); i++) {
  68. SchemePlanManager::SchemeProcessInfo process;
  69. process.projectId = projId;
  70. process.indexType = indexType;
  71. process.type = types[i];
  72. process.step = i;
  73. process.dSource = SchemePlanManager::processOptionalDataSource(process).first();
  74. process.algorithm = SchemePlanManager::processOptionalAlgorithms(process).first();
  75. schemes.append(process);
  76. }
  77. return schemes;
  78. }
  79. void SchemePlanWidget::setupTabWidget()
  80. {
  81. m_tab->clear();
  82. for (int i : indexList()) {
  83. SchemeFlowWidget *m = new SchemeFlowWidget(this);
  84. connect(m, &SchemeFlowWidget::sigSchemeProcessEdited, this, &SchemePlanWidget::slotSchemeProcessEdited);
  85. QList<SchemePlanManager::SchemeProcessInfo> schemes;
  86. bool ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(schemes, m_proj->id, i);
  87. if (ret && schemes.count() <= 0) {
  88. schemes = templateSchemes(m_proj->id, i);
  89. ret = SchemeProcessService().AddAllSchemeProcess(schemes);
  90. }
  91. if (ret) {
  92. m->loadSchemes(schemes);
  93. }
  94. ProjectManager::IndexType t = (ProjectManager::IndexType)i;
  95. QString s = ProjectManager::nameOfIndexType(t);
  96. m_tab->addTab(m, s);
  97. }
  98. }
  99. void SchemePlanWidget::slotExportClicked()
  100. {
  101. for (int i = 0; i < m_tab->count(); i++) {
  102. SchemeFlowWidget *w = (SchemeFlowWidget *)m_tab->widget(i);
  103. QList<SchemePlanManager::SchemeProcessInfo> schemes = w->schemes();
  104. }
  105. }
  106. void SchemePlanWidget::slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process)
  107. {
  108. qDebug() << __FUNCTION__ << __LINE__ << process.algorithm << endl;
  109. SchemeProcessService().UpdateSchemeProcess(process);
  110. }