Browse Source

添加方案视图

chengxr 1 year ago
parent
commit
2954e1b9a9

+ 2 - 0
QFD/QFD.pro

@@ -99,6 +99,7 @@ SOURCES += \
     widgets/AppInfoWidget.cpp \
     widgets/ConfigExpertDataWidget.cpp \
     widgets/ConfigMeasureDataWidget.cpp \
+    widgets/ConfigSchemeDataWidget.cpp \
     widgets/CreateProjWidget.cpp \
     widgets/CustomPie.cpp \
     widgets/CustomPieChart.cpp \
@@ -168,6 +169,7 @@ HEADERS += \
     widgets/AppInfoWidget.h \
     widgets/ConfigExpertDataWidget.h \
     widgets/ConfigMeasureDataWidget.h \
+    widgets/ConfigSchemeDataWidget.h \
     widgets/CreateProjWidget.h \
     widgets/CustomPie.h \
     widgets/CustomPieChart.h \

+ 5 - 2
QFD/common/SchemePlanManager.cpp

@@ -10,12 +10,12 @@ QString SchemePlanManager::stringFromDataSource(SchemePlanManager::SchemeDataSou
     switch (src) {
     case NoData:
         return "无";
-
     case FromExpert:
         return "导入专家数据";
-
     case FromMeasurement:
         return "导入实测数据";
+    case FromScheme:
+        return "添加方案";
     }
 }
 
@@ -84,6 +84,9 @@ SchemePlanManager::processOptionalDataSource(const SchemeProcessInfo &process)
     if (process.type == ImportEvalData && process.indexType == ProjectManager::EfficiencyIndex) {
         return { FromMeasurement };
     }
+    if (process.type == ImportEvalData && process.indexType == ProjectManager::OptimalIndex) {
+        return { FromScheme };
+    }
     if (process.type == ImportWeightData || process.type == ImportEvalData) {
         return { FromExpert, FromMeasurement };
     }

+ 1 - 0
QFD/common/SchemePlanManager.h

@@ -32,6 +32,7 @@ public:
         NoData = -1,
         FromExpert,       // 来自专家评估
         FromMeasurement,  // 来自实测
+        FromScheme,       // 添加方案
     };
 
     static QString stringFromDataSource(SchemeDataSource src);

+ 0 - 1
QFD/dbService/SqlDBHelper.cpp

@@ -10,7 +10,6 @@ QSqlDatabase SqlDBHelper::getDatabase(SqlDBHelper::SqlDBType dbType, const QStri
     QSettings config("config.ini", QSettings::IniFormat);
     config.setIniCodec("UTF-8");
     dbType = static_cast<SqlDBHelper::SqlDBType>(config.value("USERCONFIG/DbType", "").toInt());
-    qDebug() << "-------------------" << dbType;
     switch (dbType) {
     case SqlDBHelper::SqlDBType::SQLITE3: {
         if (configFinished) {

+ 6 - 7
QFD/widgets/ConfigMeasureDataWidget.cpp

@@ -32,8 +32,8 @@ void ConfigMeasureDataWidget::initWidget()
     m_tipsLabel = new QLabel("已导入的数据将会显示在这里", this);
     m_tipsLabel->setObjectName("tipsLabel");
     m_tipsLabel->setHidden(true);
-    m_exportButton = new QPushButton(NEWFLICON(FluentIcon, DOWNLOAD)->icon(), "", this);
-    m_exportButton->setToolTip("导入数据");
+    m_addButton = new QPushButton(NEWFLICON(FluentIcon, DOWNLOAD)->icon(), "", this);
+    m_addButton->setToolTip("导入数据");
     m_listWidget = new QListWidget(this);
 
     setStyleSheet("#titleLabel {color:#333333; font-size:16px}"
@@ -44,8 +44,7 @@ void ConfigMeasureDataWidget::initWidget()
                   "QPushButton::pressed {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, "
                   "stop: 1 #f6f7fa);}"
                   "QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);}"
-                  "QListView::item {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #ffffff, stop: 0.9 "
-                  "#ffffff,stop: 1 #eeeeee);height:44;}");
+                  "QListView::item {height:44;}");
 }
 
 void ConfigMeasureDataWidget::initLayout()
@@ -62,15 +61,15 @@ void ConfigMeasureDataWidget::initLayout()
 
     m_headerLayout->addWidget(m_listTitleLabel);
     m_headerLayout->addStretch();
-    m_headerLayout->addWidget(m_exportButton);
+    m_headerLayout->addWidget(m_addButton);
 }
 
 void ConfigMeasureDataWidget::connectSignalsAndSlots()
 {
-    connect(m_exportButton, &PushButton::clicked, this, &ConfigMeasureDataWidget::slotExportClicked);
+    connect(m_addButton, &PushButton::clicked, this, &ConfigMeasureDataWidget::slotAddDataClicked);
 }
 
-void ConfigMeasureDataWidget::slotExportClicked()
+void ConfigMeasureDataWidget::slotAddDataClicked()
 {
     qDebug() << __FUNCTION__ << __LINE__ << endl;
 }

+ 4 - 4
QFD/widgets/ConfigMeasureDataWidget.h

@@ -28,7 +28,7 @@ private:
     void connectSignalsAndSlots();
 
 private slots:
-    void slotExportClicked();
+    void slotAddDataClicked();
 
 private:
     SchemePlanManager::SchemeProcessInfo m_process;
@@ -38,9 +38,9 @@ private:
 
     QLabel *m_titleLabel = nullptr;
 
-    QLabel *m_listTitleLabel    = nullptr;
-    QLabel *m_tipsLabel         = nullptr;
-    QPushButton *m_exportButton = nullptr;
+    QLabel *m_listTitleLabel = nullptr;
+    QLabel *m_tipsLabel      = nullptr;
+    QPushButton *m_addButton = nullptr;
 
     QListWidget *m_listWidget = nullptr;
 };

+ 75 - 0
QFD/widgets/ConfigSchemeDataWidget.cpp

@@ -0,0 +1,75 @@
+#include "ConfigSchemeDataWidget.h"
+
+#include <Widgets/Button.h>
+#include <Common/Icon.h>
+
+#include <QLabel>
+#include <QListWidget>
+#include <QBoxLayout>
+
+#include <QDebug>
+
+ConfigSchemeDataWidget::ConfigSchemeDataWidget(QWidget *parent) : QWidget(parent)
+{
+    initWidget();
+    initLayout();
+    connectSignalsAndSlots();
+}
+
+void ConfigSchemeDataWidget::setProcess(SchemePlanManager::SchemeProcessInfo process)
+{
+    m_process = process;
+}
+
+void ConfigSchemeDataWidget::initWidget()
+{
+    m_titleLabel = new QLabel("添加方案数据", this);
+    m_titleLabel->setObjectName("titleLabel");
+    m_titleLabel->setFixedHeight(50);
+    m_titleLabel->setContentsMargins(10, 0, 0, 0);
+    m_listTitleLabel = new QLabel("方案列表", this);
+    m_listTitleLabel->setObjectName("listTitleLabel");
+    m_tipsLabel = new QLabel("已导入的数据将会显示在这里", this);
+    m_tipsLabel->setObjectName("tipsLabel");
+    m_tipsLabel->setHidden(true);
+    m_addButton = new QPushButton(NEWFLICON(FluentIcon, DOWNLOAD)->icon(), "", this);
+    m_addButton->setToolTip("添加方案");
+    m_listWidget = new QListWidget(this);
+
+    setStyleSheet("#titleLabel {color:#333333; font-size:16px}"
+                  "#listTitleLabel {color:#333333; font-size:12px}"
+                  "QPushButton {border: 0;background-color: qlineargradient(x1: 0, y1: 0, x2: "
+                  "0, y2: 1,stop: 0 #f8f8f8, stop: 1 #f8f8f8);}"
+                  "QPushButton::hover {border: 1px solid rgba(0, 0, 0, 0.073);}"
+                  "QPushButton::pressed {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, "
+                  "stop: 1 #f6f7fa);}"
+                  "QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);}"
+                  "QListView::item {height:44;}");
+}
+
+void ConfigSchemeDataWidget::initLayout()
+{
+    m_layout = new QVBoxLayout(this);
+    m_layout->setMargin(0);
+    m_layout->setSpacing(0);
+    m_layout->addWidget(m_titleLabel);
+    m_headerLayout = new QHBoxLayout();
+    m_layout->addLayout(m_headerLayout);
+    m_layout->addSpacing(10);
+    m_layout->addWidget(m_tipsLabel);
+    m_layout->addWidget(m_listWidget);
+
+    m_headerLayout->addWidget(m_listTitleLabel);
+    m_headerLayout->addStretch();
+    m_headerLayout->addWidget(m_addButton);
+}
+
+void ConfigSchemeDataWidget::connectSignalsAndSlots()
+{
+    connect(m_addButton, &PushButton::clicked, this, &ConfigSchemeDataWidget::slotAddDataClicked);
+}
+
+void ConfigSchemeDataWidget::slotAddDataClicked()
+{
+    qDebug() << __FUNCTION__ << __LINE__ << endl;
+}

+ 47 - 0
QFD/widgets/ConfigSchemeDataWidget.h

@@ -0,0 +1,47 @@
+#ifndef CONFIGSCHEMEDATAWIDGET_H
+#define CONFIGSCHEMEDATAWIDGET_H
+
+#include <QWidget>
+
+#include "SchemePlanManager.h"
+
+class QPushButton;
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QLabel;
+class QListWidget;
+
+class ConfigSchemeDataWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit ConfigSchemeDataWidget(QWidget *parent = nullptr);
+    void setProcess(SchemePlanManager::SchemeProcessInfo process);
+
+signals:
+
+private:
+    void initWidget();
+    void initLayout();
+    void connectSignalsAndSlots();
+
+private slots:
+    void slotAddDataClicked();
+
+private:
+    SchemePlanManager::SchemeProcessInfo m_process;
+
+    QVBoxLayout *m_layout       = nullptr;
+    QHBoxLayout *m_headerLayout = nullptr;
+
+    QLabel *m_titleLabel = nullptr;
+
+    QLabel *m_listTitleLabel = nullptr;
+    QLabel *m_tipsLabel      = nullptr;
+    QPushButton *m_addButton = nullptr;
+
+    QListWidget *m_listWidget = nullptr;
+};
+
+#endif  // CONFIGSCHEMEDATAWIDGET_H

+ 13 - 0
QFD/widgets/DataCollectionWidget.cpp

@@ -3,6 +3,7 @@
 #include "DataTableWidget.h"
 #include "ConfigExpertDataWidget.h"
 #include "ConfigMeasureDataWidget.h"
+#include "ConfigSchemeDataWidget.h"
 
 #include "EvalDataManager.h"
 #include "algorithm/HierarchicalAnalysis.h"
@@ -36,11 +37,16 @@ DataCollectionWidget::DataCollectionWidget(ProjectInfo *proj, QWidget *parent) :
     setTitle("评估数据采集");
     m_configExpert  = new ConfigExpertDataWidget(this);
     m_configMeasure = new ConfigMeasureDataWidget(this);
+    m_configScheme  = new ConfigSchemeDataWidget(this);
+
     m_configMeasure->setFixedWidth(256);
+    m_configScheme->setFixedWidth(256);
     m_contentLayout->addWidget(m_configExpert);
     m_contentLayout->addWidget(m_configMeasure);
+    m_contentLayout->addWidget(m_configScheme);
     m_configExpert->setHidden(true);
     m_configMeasure->setHidden(true);
+    m_configScheme->setHidden(true);
 
     m_calcBtn = new PushButton("更新数据");
     m_topLayout->addStretch();
@@ -153,11 +159,18 @@ void DataCollectionWidget::slotTabCurrentChanged(int index)
             m_configMeasure->setProcess(table->process());
         }
         m_configMeasure->setVisible(meaure);
+
+        bool scheme = (table->process().dSource == SchemePlanManager::FromScheme);
+        if (scheme) {
+            m_configScheme->setProcess(table->process());
+        }
+        m_configScheme->setVisible(scheme);
     }
 
     if (table == nullptr) {
         m_configExpert->setHidden(true);
         m_configMeasure->setHidden(true);
+        m_configScheme->setHidden(true);
     }
 }
 

+ 2 - 0
QFD/widgets/DataCollectionWidget.h

@@ -5,6 +5,7 @@
 
 class ConfigExpertDataWidget;
 class ConfigMeasureDataWidget;
+class ConfigSchemeDataWidget;
 
 class UserConfig;
 class QFUser;
@@ -42,6 +43,7 @@ signals:
 private:
     ConfigExpertDataWidget *m_configExpert   = nullptr;
     ConfigMeasureDataWidget *m_configMeasure = nullptr;
+    ConfigSchemeDataWidget *m_configScheme   = nullptr;
 
     PushButton *m_calcBtn = nullptr;
 };