Browse Source

修复 crash.
录入数据

chengxr 1 year ago
parent
commit
18e7982d79

+ 1 - 1
ExpertClient/SchemePlanManager.cpp

@@ -15,7 +15,7 @@ QString SchemePlanManager::stringFromDataSource(SchemePlanManager::SchemeDataSou
         return "导入专家数据";
 
     case FromMeasurement:
-        return "导入实测数据";
+        return "添加实测数据";
     }
 }
 

+ 3 - 0
QFD/common/ProjectManager.cpp

@@ -7,6 +7,9 @@
 #include <QMetaEnum>
 #include <QDebug>
 
+int kDemoProjId1 = 113;
+int kDemoProjId2 = 999;
+
 QString ProjectManager::nameOfIndexType(ProjectManager::IndexType t)
 {
     switch (t) {

+ 3 - 0
QFD/common/ProjectManager.h

@@ -3,6 +3,9 @@
 
 #include <QObject>
 
+extern int kDemoProjId1;
+extern int kDemoProjId2;
+
 class ProjectInfo;
 
 class ProjectManager : QObject

+ 1 - 1
QFD/common/SchemePlanManager.cpp

@@ -13,7 +13,7 @@ QString SchemePlanManager::stringFromDataSource(SchemePlanManager::SchemeDataSou
     case FromExpert:
         return "导入专家数据";
     case FromMeasurement:
-        return "导入实测数据";
+        return "添加实测数据";
     case FromScheme:
         return "专家导入";
     }

+ 2 - 2
QFD/widgets/ConfigMeasureDataWidget.cpp

@@ -28,7 +28,7 @@ void ConfigMeasureDataWidget::setProcess(SchemePlanManager::SchemeProcessInfo pr
 
 void ConfigMeasureDataWidget::initWidget()
 {
-    m_titleLabel = new QLabel("导入实测数据", this);
+    m_titleLabel = new QLabel("添加实测数据", this);
     m_titleLabel->setObjectName("titleLabel");
     m_titleLabel->setFixedHeight(50);
     m_titleLabel->setContentsMargins(10, 0, 0, 0);
@@ -78,7 +78,7 @@ void ConfigMeasureDataWidget::addTestData()
 {
     bool rightPage = (m_process.type == SchemePlanManager::ImportWeightData
                       && m_process.indexType == ProjectManager::OptimalIndex);
-    bool rightProj = m_process.projectId == 126;
+    bool rightProj = m_process.projectId == kDemoProjId2;
     if (!rightPage || !rightProj) {
         return;
     }

+ 1 - 1
QFD/widgets/DataTableWidget.cpp

@@ -472,7 +472,7 @@ void DataTableWidget::addTestMesureData()
 {
     bool rightPage = (m_process.type == SchemePlanManager::ImportWeightData
                       && m_process.indexType == ProjectManager::OptimalIndex);
-    bool rightProj = m_process.projectId == 126;
+    bool rightProj = m_process.projectId == kDemoProjId2;
     if (!rightPage || !rightProj) {
         return;
     }

+ 3 - 3
QFD/widgets/EvalReportWidget.cpp

@@ -241,7 +241,7 @@ void EvalReportWidget::showIndexWeight()
             model->setVerticalHeaderItem(j, vHeader);
 
             QStandardItem *item = new QStandardItem("0.5");
-            if (m_proj->id == 113) {
+            if (m_proj->id == kDemoProjId1) {
                 if (m_indexType == ProjectManager::OptimalIndex) {
                     item->setText(QString("%1").arg(optiCC[i][j]));
                 } else if (m_indexType == ProjectManager::EfficiencyIndex) {
@@ -392,7 +392,7 @@ void EvalReportWidget::showSchemeScore()
             item->setEditable(false);
             PlotView::Data data { vHeader->text(), scheme->score };
 
-            if (m_proj->id == 113 && m_indexType == ProjectManager::OptimalIndex) {
+            if (m_proj->id == kDemoProjId1 && m_indexType == ProjectManager::OptimalIndex) {
                 item->setText(QString("%1").arg(scoreList[i]));
                 data.value = scoreList[i];
             }
@@ -454,7 +454,7 @@ void EvalReportWidget::makePlotClear(PlotView *plotView)
 
 void EvalReportWidget::loadWeightData()
 {
-    bool rightProj = m_proj->id == 126;
+    bool rightProj = m_proj->id == kDemoProjId2;
     if (!rightProj) {
         return;
     }

+ 8 - 2
QFD/widgets/GreyClusteringConfigWidget.cpp

@@ -207,8 +207,14 @@ void GreyClusteringConfigWidget::initClusteringItems()
                     item.value->leftExtension  = effInfo->extendLeft.toDouble();
                     item.value->rightExtension = effInfo->extendRight.toDouble();
                     //[0:0],[0:0],[0:0]
-                    QStringList valueList = effInfo->effectIndexValue.split(",");
-                    int align             = qMin(valueList.size(), item.value->greyRanges.size());
+                    QStringList valueList;
+                    if (effInfo->effectIndexValue.length() > 0) {
+                        valueList = effInfo->effectIndexValue.split(",");
+                    }
+
+                    int align = qMin(valueList.size(), item.value->greyRanges.size());
+
+                    qDebug() << __FUNCTION__ << __LINE__ << effInfo->effectIndexValue << valueList << align << endl;
                     for (int str = 0; str < align; str++) {
                         //[0:0]
                         QStringList lr = valueList.at(str).mid(1, valueList.at(str).size() - 2).split(":");

+ 9 - 3
QFD/widgets/GreyClusteringSampleTable.cpp

@@ -6,6 +6,8 @@
 #include "dbService/EffectIndexInfoService.h"
 #include "algorithm/GreyClusterEvaluation.h"
 
+#include "ProjectManager.h"
+
 #include <QHeaderView>
 #include <QDebug>
 #include <QMessageBox>
@@ -443,8 +445,12 @@ void GreyClusteringSampleTable::initClusteringItems()
                     item.value->leftExtension  = effInfo->extendLeft.toDouble();
                     item.value->rightExtension = effInfo->extendRight.toDouble();
                     //[0:0],[0:0],[0:0]
-                    QStringList valueList = effInfo->effectIndexValue.split(",");
-                    int align             = qMin(valueList.size(), item.value->greyRanges.size());
+                    QStringList valueList;
+                    if (effInfo->effectIndexValue.length() > 0) {
+                        valueList = effInfo->effectIndexValue.split(",");
+                    }
+
+                    int align = qMin(valueList.size(), item.value->greyRanges.size());
                     for (int str = 0; str < align; str++) {
                         //[0:0]
                         QStringList lr = valueList.at(str).mid(1, valueList.at(str).size() - 2).split(":");
@@ -457,7 +463,7 @@ void GreyClusteringSampleTable::initClusteringItems()
     }
 
     qDeleteAll(effectIndexInfoList);
-    if (projectid == 113) {
+    if (projectid == kDemoProjId1) {
         QVector<double> left = { 2, 35, 2, 90, 2.5, 35, 70, 2.5, 35, 30, 2.5, 70, 25, 2, 50, 1, 45, 8, 60, 1 };
 
         QVector<double> right = { 4, 20, 3, 40, 0.5, 55, 90, 1.2, 55, 70, 1.2, 90, 60, 6, 20, 3, 75, 25, 25, 3 };

+ 2 - 4
QFD/widgets/IndexSystemWidget.cpp

@@ -42,16 +42,14 @@ void IndexSystemWidget::contextMenuEvent(QContextMenuEvent *event)
         QAction *act3 = new QAction("创建根节点");
         menu->addAction(act3);
         connect(act3, &QAction::triggered, this, &IndexSystemWidget::slotCreateRootNode);
+
+        menu->exec(event->globalPos() + QPoint(-40, -20));
     } else {
         //        QAction *act2 = new QAction("清空");
         //        menu->addAction(act2);
         //        connect(act2, &QAction::triggered, this, &IndexSystemWidget::slotClearAllNodes);
     }
 
-    if (menu->actions().size() > 0) {
-        menu->exec(event->globalPos() + QPoint(-40, -20));
-    }
-
     QWidget::contextMenuEvent(event);
 }