|
@@ -4,6 +4,7 @@
|
|
|
#include "ProjectManager.h"
|
|
|
|
|
|
#include <dbService/ClassSet.h>
|
|
|
+#include <dbService/SchemeProcessService.h>
|
|
|
|
|
|
#include <QGroupBox>
|
|
|
#include <QCheckBox>
|
|
@@ -89,13 +90,10 @@ static void setStyle_()
|
|
|
)");
|
|
|
}
|
|
|
|
|
|
-SchemeFlowWidget::SchemeFlowWidget(ProjectInfo *proj, int indexType, QWidget *parent) : QWidget(parent), m_proj(proj)
|
|
|
+SchemeFlowWidget::SchemeFlowWidget(ProjectInfo *proj, QWidget *parent) : QWidget(parent), m_proj(proj)
|
|
|
{
|
|
|
setStyle_();
|
|
|
-
|
|
|
initWidget();
|
|
|
-
|
|
|
- setType(indexType);
|
|
|
}
|
|
|
|
|
|
SchemeFlowWidget::~SchemeFlowWidget()
|
|
@@ -103,23 +101,52 @@ SchemeFlowWidget::~SchemeFlowWidget()
|
|
|
delete m_graphModel;
|
|
|
}
|
|
|
|
|
|
+ProjectInfo *SchemeFlowWidget::proj() const
|
|
|
+{
|
|
|
+ return m_proj;
|
|
|
+}
|
|
|
+
|
|
|
void SchemeFlowWidget::setType(int t)
|
|
|
{
|
|
|
m_indexType = t;
|
|
|
- refresh();
|
|
|
+
|
|
|
+ QList<SchemePlanManager::SchemeProcessInfo> schemes;
|
|
|
+
|
|
|
+ bool ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(schemes);
|
|
|
+
|
|
|
+ if (ret && schemes.count() <= 1) {
|
|
|
+ schemes = templateSchemes(m_proj->id, m_indexType);
|
|
|
+ emit sigSchemeProcessCreated();
|
|
|
+ }
|
|
|
+ loadSchemes(schemes);
|
|
|
}
|
|
|
|
|
|
-QList<SchemePlanManager::SchemeProcessInfo> SchemeFlowWidget::schemeTemplate(int projId, int indexType)
|
|
|
+int SchemeFlowWidget::indexType() const
|
|
|
{
|
|
|
- /// 方案流程模板
|
|
|
+ return m_indexType;
|
|
|
+}
|
|
|
|
|
|
+QList<SchemePlanManager::SchemeProcessInfo> SchemeFlowWidget::schemes() const
|
|
|
+{
|
|
|
+ QList<SchemePlanManager::SchemeProcessInfo> schemes;
|
|
|
+
|
|
|
+ for (int id : m_graphModel->allNodeIds()) {
|
|
|
+ auto v = m_graphModel->nodeData(id, NodeRole::Widget);
|
|
|
+ FlowGraphCommonNodeWidget *w = v.value<FlowGraphCommonNodeWidget *>();
|
|
|
+ SchemePlanManager::SchemeProcessInfo process = w->process();
|
|
|
+ }
|
|
|
+
|
|
|
+ return schemes;
|
|
|
+}
|
|
|
+
|
|
|
+QList<SchemePlanManager::SchemeProcessInfo> SchemeFlowWidget::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 };
|
|
|
- // types = { SchemePlanManager::IndexSystem };
|
|
|
break;
|
|
|
}
|
|
|
case ProjectManager::TechIndex: {
|
|
@@ -177,7 +204,7 @@ void SchemeFlowWidget::clearAllNodes()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void SchemeFlowWidget::refresh()
|
|
|
+void SchemeFlowWidget::loadSchemes(const QList<SchemePlanManager::SchemeProcessInfo> &schems)
|
|
|
{
|
|
|
clearAllNodes();
|
|
|
|
|
@@ -186,13 +213,12 @@ void SchemeFlowWidget::refresh()
|
|
|
NodeId invalidId = 999;
|
|
|
NodeId lastId = invalidId;
|
|
|
|
|
|
- QList<SchemePlanManager::SchemeProcessInfo> scheme = schemeTemplate(m_proj->id, m_indexType);
|
|
|
- for (int i = 0; i < scheme.count(); i++) {
|
|
|
+ for (int i = 0; i < schems.count(); i++) {
|
|
|
NodeId id = m_graphModel->addNode(FlowCommonData().type().id);
|
|
|
m_graphModel->setNodeData(id, NodeRole::Position, QPointF(0, y));
|
|
|
FlowGraphCommonNodeWidget *w = new FlowGraphCommonNodeWidget();
|
|
|
connect(w, &FlowGraphCommonNodeWidget::sigProcessChanged, this, &SchemeFlowWidget::slotSchemeProcessEdited);
|
|
|
- SchemePlanManager::SchemeProcessInfo process = scheme[i];
|
|
|
+ SchemePlanManager::SchemeProcessInfo process = schems[i];
|
|
|
w->setProcess(process);
|
|
|
if (w->isTitleHidden()) {
|
|
|
m_graphModel->setNodeData(id, NodeRole::Caption, SchemePlanManager::processName(process));
|
|
@@ -211,5 +237,5 @@ void SchemeFlowWidget::refresh()
|
|
|
|
|
|
void SchemeFlowWidget::slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process)
|
|
|
{
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << process.algorithm << endl;
|
|
|
+ emit sigSchemeProcessEdited(process);
|
|
|
}
|