SchemePlanWidget.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 <QDebug>
  11. SchemePlanWidget::SchemePlanWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent)
  12. {
  13. setTitle("评估方案规划");
  14. setupUI();
  15. }
  16. void SchemePlanWidget::setType(int type)
  17. {
  18. EvalWidget::setType(type);
  19. setupTabWidget();
  20. }
  21. void SchemePlanWidget::setupUI()
  22. {
  23. m_topLayout->addStretch();
  24. m_export = new PushButton("保存", this);
  25. m_export->setEnabled(false);
  26. m_topLayout->addWidget(m_export);
  27. m_topLayout->addSpacing(10);
  28. connect(m_export, &PushButton::clicked, this, &SchemePlanWidget::slotExportClicked);
  29. }
  30. QList<SchemePlanManager::SchemeProcessInfo> SchemePlanWidget::templateSchemes(int projId, int indexType)
  31. {
  32. QList<SchemePlanManager::SchemeProcessType> types;
  33. switch (indexType) {
  34. case ProjectManager::AbilityIndex: {
  35. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  36. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  37. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  38. break;
  39. }
  40. case ProjectManager::TechIndex: {
  41. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  42. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  43. break;
  44. }
  45. case ProjectManager::OptimalIndex: {
  46. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  47. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  48. SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  49. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  50. break;
  51. }
  52. case ProjectManager::EfficiencyIndex: {
  53. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  54. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  55. SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  56. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  57. break;
  58. }
  59. }
  60. QList<SchemePlanManager::SchemeProcessInfo> schemes;
  61. for (int i = 0; i < types.count(); i++) {
  62. SchemePlanManager::SchemeProcessInfo process;
  63. process.projectId = projId;
  64. process.indexType = indexType;
  65. process.type = types[i];
  66. process.step = i;
  67. schemes.append(process);
  68. }
  69. return schemes;
  70. }
  71. void SchemePlanWidget::setupTabWidget()
  72. {
  73. m_tab->clear();
  74. for (int i : indexList()) {
  75. SchemeFlowWidget *m = new SchemeFlowWidget(this);
  76. connect(m, &SchemeFlowWidget::sigSchemeProcessEdited, this, &SchemePlanWidget::slotSchemeProcessEdited);
  77. QList<SchemePlanManager::SchemeProcessInfo> schemes;
  78. bool ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(schemes);
  79. if (ret && schemes.count() <= 1) {
  80. schemes = templateSchemes(m_proj->id, i);
  81. }
  82. m->loadSchemes(schemes);
  83. ProjectManager::IndexType t = (ProjectManager::IndexType)i;
  84. QString s = ProjectManager::nameOfIndexType(t);
  85. m_tab->addTab(m, s);
  86. }
  87. }
  88. void SchemePlanWidget::slotExportClicked()
  89. {
  90. for (int i = 0; i < m_tab->count(); i++) {
  91. SchemeFlowWidget *w = (SchemeFlowWidget *)m_tab->widget(i);
  92. QList<SchemePlanManager::SchemeProcessInfo> schemes = w->schemes();
  93. }
  94. }
  95. void SchemePlanWidget::slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process)
  96. {
  97. qDebug() << __FUNCTION__ << __LINE__ << process.id << endl;
  98. }