123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #include "SchemePlanWidget.h"
- #include "SchemeFlowWidget.h"
- #include "ProjectManager.h"
- #include <dbService/ClassSet.h>
- #include <dbService/SchemeProcessService.h>
- #include <CSchemeView.h>
- #include <Widgets/Button.h>
- #include <QTabWidget>
- #include <QLayout>
- #include <QDebug>
- SchemePlanWidget::SchemePlanWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent)
- {
- setTitle("评估方案规划");
- setupUI();
- }
- void SchemePlanWidget::setType(int type)
- {
- EvalWidget::setType(type);
- setupTabWidget();
- }
- void SchemePlanWidget::setupUI()
- {
- m_topLayout->addStretch();
- m_export = new PushButton("保存", this);
- m_export->setEnabled(false);
- m_topLayout->addWidget(m_export);
- m_topLayout->addSpacing(10);
- m_export->setHidden(true);
- connect(m_export, &PushButton::clicked, this, &SchemePlanWidget::slotExportClicked);
- }
- QList<SchemePlanManager::SchemeProcessInfo> SchemePlanWidget::templateSchemes(int projId, int indexType)
- {
- QList<SchemePlanManager::SchemeProcessType> types;
- switch (indexType) {
- case ProjectManager::AbilityIndex: {
- types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
- SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
- SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
- break;
- }
- case ProjectManager::TechIndex: {
- types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
- SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
- break;
- }
- case ProjectManager::OptimalIndex: {
- types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
- SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
- SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
- SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
- break;
- }
- case ProjectManager::EfficiencyIndex: {
- types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
- SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
- SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
- SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
- break;
- }
- }
- QList<SchemePlanManager::SchemeProcessInfo> schemes;
- for (int i = 0; i < types.count(); i++) {
- SchemePlanManager::SchemeProcessInfo process;
- process.projectId = projId;
- process.indexType = indexType;
- process.type = types[i];
- process.step = i;
- schemes.append(process);
- }
- return schemes;
- }
- void SchemePlanWidget::setupTabWidget()
- {
- m_tab->clear();
- for (int i : indexList()) {
- SchemeFlowWidget *m = new SchemeFlowWidget(this);
- connect(m, &SchemeFlowWidget::sigSchemeProcessEdited, this, &SchemePlanWidget::slotSchemeProcessEdited);
- QList<SchemePlanManager::SchemeProcessInfo> schemes;
- bool ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(schemes, m_proj->id, i);
- if (ret && schemes.count() <= 0) {
- schemes = templateSchemes(m_proj->id, i);
- ret = SchemeProcessService().AddAllSchemeProcess(schemes);
- }
- if (ret) {
- for (SchemePlanManager::SchemeProcessInfo process : schemes) {
- qDebug() << __FUNCTION__ << __LINE__ << process.id << process.step << process.type << endl;
- }
- m->loadSchemes(schemes);
- }
- ProjectManager::IndexType t = (ProjectManager::IndexType)i;
- QString s = ProjectManager::nameOfIndexType(t);
- m_tab->addTab(m, s);
- }
- }
- void SchemePlanWidget::slotExportClicked()
- {
- for (int i = 0; i < m_tab->count(); i++) {
- SchemeFlowWidget *w = (SchemeFlowWidget *)m_tab->widget(i);
- QList<SchemePlanManager::SchemeProcessInfo> schemes = w->schemes();
- }
- }
- void SchemePlanWidget::slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process)
- {
- qDebug() << __FUNCTION__ << __LINE__ << process.id << endl;
- }
|