Selaa lähdekoodia

提交灰色采集界面

Signed-off-by: codeClown <zhaomengshou@126.com>
codeClown 1 vuosi sitten
vanhempi
commit
f21f9b9e55

+ 2 - 0
QFD/QFD.pro

@@ -113,6 +113,7 @@ SOURCES += \
     widgets/ExpertListWidget.cpp \
     widgets/GreyClusteringConfigWidget.cpp \
     widgets/GreyClusteringItemDelegate.cpp \
+    widgets/GreyClusteringSampleTable.cpp \
     widgets/IndexSystemWidget.cpp \
     widgets/LoginWidget.cpp \
     widgets/MultiLevelHeaderView.cpp \
@@ -174,6 +175,7 @@ HEADERS += \
     widgets/ExpertListWidget.h \
     widgets/GreyClusteringConfigWidget.h \
     widgets/GreyClusteringItemDelegate.h \
+    widgets/GreyClusteringSampleTable.h \
     widgets/IndexSystemWidget.h \
     widgets/LoginWidget.h \
     widgets/MultiLevelHeaderView.h \

+ 1 - 1
QFD/widgets/EvalSchemeWidget.cpp

@@ -176,7 +176,7 @@ void EvalSchemeWidget::refreshSchemeView()
     m_description->setText(desc);
 }
 
-void EvalSchemeWidget::loadScheme(const QString scheme)
+void EvalSchemeWidget::loadScheme(const QString &scheme)
 {
     if (m_schemes.contains(scheme) == false) {
         return;

+ 1 - 1
QFD/widgets/EvalSchemeWidget.h

@@ -63,7 +63,7 @@ public:
 
     void refreshSchemeView();
 
-    void loadScheme(const QString scheme);
+    void loadScheme(const QString &scheme);
 
     void updateButtonState();
 

+ 1 - 1
QFD/widgets/ExpertListWidget.cpp

@@ -17,7 +17,7 @@ ExpertListWidget::ExpertListWidget(QWidget *parent) : QWidget(parent)
     connectSignalsAndSlots();
 }
 
-void ExpertListWidget::showUsers(QList<QFUser *> list)
+void ExpertListWidget::showUsers(const QList<QFUser *> &list)
 {
     m_listWidget->clear();
 

+ 1 - 1
QFD/widgets/ExpertListWidget.h

@@ -18,7 +18,7 @@ class ExpertListWidget : public QWidget
 public:
     explicit ExpertListWidget(QWidget *parent = nullptr);
 
-    void showUsers(QList<QFUser *> list);
+    void showUsers(const QList<QFUser *> &list);
 
     bool hasSelectedItem() const;
 

+ 22 - 13
QFD/widgets/GreyClusteringConfigWidget.cpp

@@ -12,15 +12,26 @@ GreyClusteringConfigWidget::GreyClusteringConfigWidget(int grayNumber, QWidget *
 {
     ui->setupUi(this);
 
+    ui->grayConfigTableView->setAlternatingRowColors(false);
+    ui->grayConfigTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+    ui->grayConfigTableView->horizontalHeader()->setStyleSheet(
+            "QHeaderView::section{background:rgb(244,244,244);color: black;}");
+    ui->grayConfigTableView->verticalHeader()->setStyleSheet(
+            "QHeaderView::section{background:rgb(244,244,244);color: black;}");
+    ui->grayConfigTableView->verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
+    ui->grayConfigTableView->setSelectionMode(QAbstractItemView::SingleSelection);
+
     m_model = new QStandardItemModel();
     ui->grayConfigTableView->setModel(m_model);
 
-    ui->stackedWidget->setCurrentIndex(1);
+    ui->stackedWidget->setCurrentIndex(0);
     ui->grayNumber->setText(QString::number(grayNumber));
     initFormLayout();
-    refreshTablView();
+    refreshTableView();
+
+    resize(1200, 800);
 
-    resize(800, 800);
+    //    ui->grayConfigTableView->setEditTriggers(QAbstractItemView::CurrentChanged); //单击触发
 }
 
 GreyClusteringConfigWidget::~GreyClusteringConfigWidget()
@@ -88,7 +99,7 @@ struct IndexItem
     int colSpan;
 };
 
-void GreyClusteringConfigWidget::refreshTablView()
+void GreyClusteringConfigWidget::refreshTableView()
 {
     int rows            = 9;
     int cols            = 9;
@@ -96,13 +107,7 @@ void GreyClusteringConfigWidget::refreshTablView()
 
     m_grayNames   = QStringList { "较差类", "一般类", "较好类" };
     QTableView *t = ui->grayConfigTableView;
-
-    t->setAlternatingRowColors(false);
-    t->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
-    t->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}");
-    t->verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}");
-    t->verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
-    t->setSelectionMode(QAbstractItemView::SingleSelection);
+    m_model->clear();
 
     // 设置表头
     {
@@ -166,7 +171,11 @@ void GreyClusteringConfigWidget::refreshTablView()
     }
 
     for (int c = 0; c < m_grayNames.size(); ++c) {
-        t->setItemDelegateForColumn(c + nodeDepth + 1, new GreyClusteringItemDelegate());
+        t->setItemDelegateForColumn(c + nodeDepth + 1, new GreyClusteringItemRangeDelegate(t));
+    }
+
+    for (int c = m_grayNames.size(); c < m_grayNames.size() + 2; ++c) {
+        t->setItemDelegateForColumn(c + nodeDepth + 1, new GreyClusteringItemSpinDelegate(t));
     }
 }
 
@@ -191,6 +200,6 @@ void GreyClusteringConfigWidget::onConfirmClick()
     }
     m_grayNames = names;
 
-    refreshTablView();
+    refreshTableView();
     ui->stackedWidget->setCurrentIndex(1);
 }

+ 1 - 1
QFD/widgets/GreyClusteringConfigWidget.h

@@ -18,7 +18,7 @@ public:
 
 private:
     void initFormLayout();
-    void refreshTablView();
+    void refreshTableView();
 
 private slots:
     void onConfirmClick();

+ 45 - 8
QFD/widgets/GreyClusteringItemDelegate.cpp

@@ -2,25 +2,25 @@
 
 #include <QMessageBox>
 
-GreyClusteringItemDelegate::GreyClusteringItemDelegate(QObject *parent) : QStyledItemDelegate(parent) { }
+GreyClusteringItemRangeDelegate::GreyClusteringItemRangeDelegate(QObject *parent) : QStyledItemDelegate(parent) { }
 
-QWidget *GreyClusteringItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */,
-                                                  const QModelIndex & /* index */) const
+QWidget *GreyClusteringItemRangeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */,
+                                                       const QModelIndex & /* index */) const
 {
     RangeSpin *editor = new RangeSpin(parent);
 
     return editor;
 }
 
-void GreyClusteringItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
+void GreyClusteringItemRangeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
 {
     QString value      = index.model()->data(index, Qt::EditRole).toString();
     RangeSpin *spinBox = static_cast<RangeSpin *>(editor);
     spinBox->setValue(value);
 }
 
-void GreyClusteringItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
-                                              const QModelIndex &index) const
+void GreyClusteringItemRangeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+                                                   const QModelIndex &index) const
 {
     RangeSpin *spinBox = static_cast<RangeSpin *>(editor);
     if (!spinBox->valid()) {
@@ -32,10 +32,47 @@ void GreyClusteringItemDelegate::setModelData(QWidget *editor, QAbstractItemMode
     model->setData(index, value, Qt::EditRole);
 }
 
-void GreyClusteringItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
-                                                      const QModelIndex & /* index */) const
+void GreyClusteringItemRangeDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
+                                                           const QModelIndex & /* index */) const
 {
     QRect rect = option.rect;
     rect.adjust(-10, -10, 10, 10);
     editor->setGeometry(rect);
 }
+
+GreyClusteringItemSpinDelegate::GreyClusteringItemSpinDelegate(QObject *parent) : QStyledItemDelegate(parent) { }
+
+QWidget *GreyClusteringItemSpinDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */,
+                                                      const QModelIndex & /* index */) const
+{
+    QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
+
+    editor->setFrame(false);
+    editor->setMinimum(-10000);
+    editor->setMaximum(10000);
+    return editor;
+}
+
+void GreyClusteringItemSpinDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
+{
+    double value = index.model()->data(index, Qt::EditRole).toDouble();
+
+    QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox *>(editor);
+    spinBox->setValue(value);
+}
+
+void GreyClusteringItemSpinDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+                                                  const QModelIndex &index) const
+{
+    QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox *>(editor);
+    spinBox->interpretText();
+    int value = spinBox->value();
+
+    model->setData(index, value, Qt::EditRole);
+}
+
+void GreyClusteringItemSpinDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
+                                                          const QModelIndex &index) const
+{
+    editor->setGeometry(option.rect);
+}

+ 39 - 19
QFD/widgets/GreyClusteringItemDelegate.h

@@ -18,16 +18,16 @@ public:
         setStyleSheet("RangeSpin{background-color:gray} QLabel{color:white}");
         hLayout->setMargin(0);
         hLayout->setSpacing(0);
-        QLabel *minLabel = new QLabel("");
-        QLabel *maxLabel = new QLabel("");
-        m_minSpin        = new QDoubleSpinBox;
-        m_maxSpin        = new QDoubleSpinBox;
-        m_minSpin->setRange(-1000, 1000);
-        m_maxSpin->setRange(-1000, 1000);
+        QLabel *minLabel = new QLabel("");
+        QLabel *maxLabel = new QLabel("");
+        m_leftSpin       = new QDoubleSpinBox;
+        m_rightSpin      = new QDoubleSpinBox;
+        m_leftSpin->setRange(-1000, 1000);
+        m_rightSpin->setRange(-1000, 1000);
 
         hLayout->addWidget(minLabel);
-        hLayout->addWidget(m_minSpin);
-        hLayout->addWidget(m_maxSpin);
+        hLayout->addWidget(m_leftSpin);
+        hLayout->addWidget(m_rightSpin);
         hLayout->addWidget(maxLabel);
         setLayout(hLayout);
     }
@@ -41,38 +41,58 @@ public:
 
     bool valid() const
     {
-        if (m_minSpin->value() < m_maxSpin->value()) {
-            return true;
-        }
+        // 值好像有方向,不好控制
+
+        //        if (m_leftSpin->value() < m_rightSpin->value()) {
+        //            return true;
+        //        }
+
+        //        return false;
 
-        return false;
+        return true;
     }
 
     void setValue(const QString &value)
     {
         if (!value.isEmpty()) {
             QStringList tmp = value.mid(1, value.size() - 2).replace(" ", "").split(",");
-            m_minSpin->setValue(tmp[0].toDouble());
-            m_maxSpin->setValue(tmp[1].toDouble());
+            m_leftSpin->setValue(tmp[0].toDouble());
+            m_rightSpin->setValue(tmp[1].toDouble());
         }
     }
 
 private slots:
-    void onConfirm() { m_result = QString("[%1, %2]").arg(m_minSpin->value()).arg(m_maxSpin->value()); }
+    void onConfirm() { m_result = QString("[%1, %2]").arg(m_leftSpin->value()).arg(m_rightSpin->value()); }
 
 private:
-    QDoubleSpinBox *m_minSpin;
-    QDoubleSpinBox *m_maxSpin;
+    QDoubleSpinBox *m_leftSpin;
+    QDoubleSpinBox *m_rightSpin;
 
     QString m_result;
 };
 
-class GreyClusteringItemDelegate : public QStyledItemDelegate
+class GreyClusteringItemRangeDelegate : public QStyledItemDelegate
+{
+    Q_OBJECT
+
+public:
+    GreyClusteringItemRangeDelegate(QObject *parent = 0);
+
+    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+
+    void setEditorData(QWidget *editor, const QModelIndex &index) const override;
+    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
+
+    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
+                              const QModelIndex &index) const override;
+};
+
+class GreyClusteringItemSpinDelegate : public QStyledItemDelegate
 {
     Q_OBJECT
 
 public:
-    GreyClusteringItemDelegate(QObject *parent = 0);
+    GreyClusteringItemSpinDelegate(QObject *parent = 0);
 
     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
 

+ 260 - 0
QFD/widgets/GreyClusteringSampleTable.cpp

@@ -0,0 +1,260 @@
+#include "GreyClusteringItemDelegate.h"
+#include "GreyClusteringSampleTable.h"
+#include "MultiLevelHeaderView.h"
+
+#include <QHeaderView>
+#include <QDebug>
+
+/**
+ * example
+ * QVector<GreyClusteringItem> gcItems;
+    gcItems << GreyClusteringItem { "火力", 0, 0, 9, 1, nullptr };
+    QSharedPointer<GreyClusteringValue> sg = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units                              = "m";
+    sg->weiget                             = 2;
+    sg->greyRanges << GreyRange { "较差类", true, 85, true, 100 };
+    sg->greyRanges << GreyRange { "一般类", true, 100, true, 115 };
+    sg->greyRanges << GreyRange { "较好类", true, 115, true, 125 };
+    sg->leftExtension  = 70;
+    sg->rightExtension = 140;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "火炮口径", 0, 1, 1, 2, sg };
+
+    gcItems << GreyClusteringItem { "初速", 1, 1, 3, 1, nullptr };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "m";
+    sg->weiget = 4;
+    sg->greyRanges << GreyRange { "较差类", true, 1600, true, 1300 };
+    sg->greyRanges << GreyRange { "一般类", true, 1600, true, 1900 };
+    sg->greyRanges << GreyRange { "较好类", true, 1600, true, 1900 };
+    sg->leftExtension  = 500;
+    sg->rightExtension = 220;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "穿甲弹", 1, 2, 1, 1, sg };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "m";
+    sg->weiget = 4;
+    sg->greyRanges << GreyRange { "较差类", true, 1000, true, 1200 };
+    sg->greyRanges << GreyRange { "一般类", true, 1200, true, 1400 };
+    sg->greyRanges << GreyRange { "较好类", true, 1200, true, 1400 };
+    sg->leftExtension  = 600;
+    sg->rightExtension = 1700;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "破甲弹", 2, 2, 1, 1, sg };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "m";
+    sg->weiget = 4;
+    sg->greyRanges << GreyRange { "较差类", true, 500, false, 650 };
+    sg->greyRanges << GreyRange { "一般类", true, 650, false, 800 };
+    sg->greyRanges << GreyRange { "较好类", true, 800, false, 1000 };
+    sg->leftExtension  = 400;
+    sg->rightExtension = 1100;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "榴弹", 3, 2, 1, 1, sg };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "";
+    sg->weiget = 5;
+    sg->greyRanges << GreyRange { "较差类", true, 0.5, false, 0.65 };
+    sg->greyRanges << GreyRange { "一般类", true, 0.65, false, 0.75 };
+    sg->greyRanges << GreyRange { "较好类", true, 0.75, false, 0.9 };
+    sg->leftExtension  = 0.45;
+    sg->rightExtension = 0.95;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "首发命中", 4, 1, 1, 2, sg };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "m";
+    sg->weiget = 5;
+    sg->greyRanges << GreyRange { "较差类", true, 800, false, 1200 };
+    sg->greyRanges << GreyRange { "一般类", true, 1200, false, 1600 };
+    sg->greyRanges << GreyRange { "较好类", true, 1600, false, 2200 };
+    sg->leftExtension  = 500;
+    sg->rightExtension = 2500;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "直射距离", 5, 1, 1, 2, sg };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "发";
+    sg->weiget = 3;
+    sg->greyRanges << GreyRange { "较差类", true, 30, false, 40 };
+    sg->greyRanges << GreyRange { "一般类", true, 40, false, 50 };
+    sg->greyRanges << GreyRange { "较好类", true, 50, false, 65 };
+    sg->leftExtension  = 28;
+    sg->rightExtension = 70;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "弹药基数", 6, 1, 1, 2, sg };
+    gcItems << GreyClusteringItem { "时间", 7, 1, 2, 1, nullptr };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "s";
+    sg->weiget = 3;
+    sg->greyRanges << GreyRange { "较差类", true, 11, false, 10 };
+    sg->greyRanges << GreyRange { "一般类", true, 10, false, 7 };
+    sg->greyRanges << GreyRange { "较好类", true, 7, false, 4 };
+    sg->leftExtension  = 12;
+    sg->rightExtension = 3;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "静对静", 7, 2, 1, 1, sg };
+
+    sg         = QSharedPointer<GreyClusteringValue>(new GreyClusteringValue);
+    sg->units  = "s";
+    sg->weiget = 3;
+    sg->greyRanges << GreyRange { "较差类", true, 14, false, 12 };
+    sg->greyRanges << GreyRange { "一般类", true, 12, false, 10 };
+    sg->greyRanges << GreyRange { "较好类", true, 10, false, 7 };
+    sg->leftExtension  = 15;
+    sg->rightExtension = 5;
+    sg->oldValue       = 0;
+    sg->newValue       = 0;
+    gcItems << GreyClusteringItem { "静对动", 8, 2, 1, 1, sg };
+
+    GreyClusteringSampleTable gcst(gcItems, 3, 9);
+    gcst.resize(1200, 800);
+    gcst.refreshTableView();
+    gcst.show();
+ */
+
+GreyClusteringSampleTable::GreyClusteringSampleTable(const QVector<GreyClusteringItem> &gcItems, int nodeDepth,
+                                                     int rowNodes, QWidget *parent)
+    : QTableView(parent), m_greyClusterings(gcItems), m_nodeDepth(nodeDepth), m_rowNodes(rowNodes)
+{
+    m_model = new QStandardItemModel();
+    this->setModel(m_model);
+
+    init();
+}
+
+void GreyClusteringSampleTable::refreshTableView()
+{
+    m_model->clear();
+
+    if (m_greyClusterings.size() == 0) {
+        return;
+    }
+
+    QStringList greyNames;  // 灰数
+    for (auto &item : m_greyClusterings) {
+        if (!item.value.isNull()) {
+            for (const auto &s : item.value->greyRanges) {
+                greyNames << s.name;
+            }
+            break;
+        }
+    }
+
+    int colCount = m_nodeDepth + 6 + greyNames.size();
+
+    // 设置表头
+    {
+        auto hHeader = new MultiLevelHeaderView(Qt::Horizontal, 2, colCount, this);
+        hHeader->setSectionResizeMode(QHeaderView::Stretch);
+
+        hHeader->setCellSpan(0, 0, 2, m_nodeDepth);       // 指标占位
+        for (int n = 0; n < 2 + greyNames.size(); ++n) {  //  单位+权重+灰度级占位
+            hHeader->setCellSpan(0, m_nodeDepth + n, 2, 1);
+        }
+        hHeader->setCellSpan(0, m_nodeDepth + 2 + greyNames.size(), 1, 2);  // 延拓值占位
+        hHeader->setCellSpan(1, m_nodeDepth + 2 + greyNames.size(), 1, 1);
+        hHeader->setCellSpan(1, m_nodeDepth + 2 + greyNames.size() + 1, 1, 1);
+
+        hHeader->setCellSpan(0, m_nodeDepth + 4 + greyNames.size(), 1, 2);  // 实现值占位
+        hHeader->setCellSpan(1, m_nodeDepth + 4 + greyNames.size(), 1, 1);
+        hHeader->setCellSpan(1, m_nodeDepth + 4 + greyNames.size() + 1, 1, 1);
+
+        // 一级
+        hHeader->setCellText(0, 0, QString("指标"));
+        hHeader->setCellText(0, m_nodeDepth, QString("单位"));
+        hHeader->setCellText(0, m_nodeDepth + 1, QString("权重"));
+        for (int i = 0; i < greyNames.size(); ++i) {
+            hHeader->setCellText(0, m_nodeDepth + 2 + i, greyNames.at(i));
+        }
+        hHeader->setCellText(0, m_nodeDepth + 2 + greyNames.size(), QString("延拓值"));
+        hHeader->setCellText(0, m_nodeDepth + 4 + greyNames.size(), QString("实现值"));
+        // 二级
+        hHeader->setCellText(1, m_nodeDepth + 2 + greyNames.size(), "左");
+        hHeader->setCellText(1, m_nodeDepth + 3 + greyNames.size(), "右");
+        hHeader->setCellText(1, m_nodeDepth + 4 + greyNames.size(), "改前");
+        hHeader->setCellText(1, m_nodeDepth + 5 + greyNames.size(), "改后");
+
+        this->setHorizontalHeader(hHeader);
+    }
+
+    m_model->setColumnCount(colCount);
+    m_model->setRowCount(m_rowNodes);
+
+    for (const auto &item : m_greyClusterings) {
+        // 第一步,设置指标名
+        auto s = new QStandardItem(item.indexName);
+        s->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+        s->setTextAlignment(Qt::AlignCenter);
+        s->setToolTip(item.indexName);
+        m_model->setItem(item.row, item.col, s);
+        if (item.rowSpan > 1 || item.colSpan > 1) {
+            this->setSpan(item.row, item.col, item.rowSpan, item.colSpan);
+        }
+
+        // 第二步,查看当前指标下是否附带值
+
+        if (!item.value.isNull()) {
+            int offset = item.colSpan;
+            m_model->setItem(item.row, item.col + offset, new QStandardItem(item.value->units));  // 单位
+            ++offset;
+            m_model->setItem(item.row, item.col + offset,
+                             new QStandardItem(QString::number(item.value->weiget)));  // 权重
+            ++offset;
+            for (auto &range : item.value->greyRanges) {  // 灰度级
+                QString r;
+                r += range.leftClose ? "[" : "(";
+                r += QString("%1, %2").arg(range.leftValue).arg(range.rightValue);
+                r += range.rightClose ? "]" : ")";
+                m_model->setItem(item.row, item.col + offset, new QStandardItem(r));
+                ++offset;
+            }
+            m_model->setItem(item.row, item.col + offset,
+                             new QStandardItem(QString::number(item.value->leftExtension)));  // 延拓值左
+            ++offset;
+            m_model->setItem(item.row, item.col + offset,
+                             new QStandardItem(QString::number(item.value->rightExtension)));  // 延拓值右
+            ++offset;
+            m_model->setItem(item.row, item.col + offset,
+                             new QStandardItem(QString::number(item.value->oldValue)));  // 实现值前
+            ++offset;
+            m_model->setItem(item.row, item.col + offset,
+                             new QStandardItem(QString::number(item.value->newValue)));  // 实现值后
+
+            ++offset;
+
+            for (int c = item.colSpan; c < offset - 2; ++c) {
+                m_model->item(item.row, item.col + c)->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+                m_model->item(item.row, item.col + c)->setTextAlignment(Qt::AlignCenter);
+            }
+
+            for (int c = offset - 2; c < offset; ++c) {
+                m_model->item(item.row, item.col + c)->setTextAlignment(Qt::AlignCenter);
+                this->setItemDelegateForColumn(item.col + c, new GreyClusteringItemSpinDelegate(this));
+            }
+        }
+    }
+}
+
+void GreyClusteringSampleTable::init()
+{
+    setAlternatingRowColors(false);
+    horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+    horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}");
+    verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}");
+    verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
+    setSelectionMode(QAbstractItemView::SingleSelection);
+}

+ 62 - 0
QFD/widgets/GreyClusteringSampleTable.h

@@ -0,0 +1,62 @@
+#ifndef GREYCLUSTERINGSAMPLETABLE_H
+#define GREYCLUSTERINGSAMPLETABLE_H
+
+#include <QStandardItemModel>
+#include <QTableView>
+#include <QVector>
+#include <QSharedPointer>
+
+struct GreyRange
+{
+    QString name;
+    bool leftClose;  // 左闭合
+    double leftValue;
+    bool rightClose;  // 右闭合
+    double rightValue;
+};
+
+struct GreyClusteringValue
+{
+    QString units;  // 单位
+    double weiget;
+    QVector<GreyRange> greyRanges;  // 灰类
+
+    double leftExtension;   // 延拓值左
+    double rightExtension;  // 延拓值右
+
+    double oldValue;  // 实现值改前
+    double newValue;  // 实现值改后
+};
+
+struct GreyClusteringItem
+{
+    QString indexName;  // 指标名字
+    int row;
+    int col;
+    int rowSpan;
+    int colSpan;
+
+    QSharedPointer<GreyClusteringValue> value;
+};
+
+class GreyClusteringSampleTable : public QTableView
+{
+    Q_OBJECT
+
+public:
+    GreyClusteringSampleTable(const QVector<GreyClusteringItem> &gcItems, int nodeDepth, int rowNodes,
+                              QWidget *parent = nullptr);
+
+    void refreshTableView();
+
+private:
+    void init();
+
+private:
+    QVector<GreyClusteringItem> m_greyClusterings;
+    QStandardItemModel *m_model;
+    int m_nodeDepth;  // 节点深度
+    int m_rowNodes;   //
+};
+
+#endif  // GREYCLUSTERINGSAMPLETABLE_H

+ 3 - 3
QFD/widgets/ProjectStateWidget.cpp

@@ -18,7 +18,7 @@ ProjectStateWidget::ProjectStateWidget(QWidget *parent) : QWidget(parent)
     initLayout();
 }
 
-void ProjectStateWidget::showProjects(QList<ProjectInfo *> proList)
+void ProjectStateWidget::showProjects(const QList<ProjectInfo *> &proList)
 {
     m_projTableWidget->clearContents();
     m_projTableWidget->clearSpans();
@@ -87,7 +87,7 @@ void ProjectStateWidget::initLayout()
     layout()->addWidget(m_projTableWidget);
 }
 
-void ProjectStateWidget::setRowCount(QList<ProjectInfo *> list)
+void ProjectStateWidget::setRowCount(const QList<ProjectInfo *> &list)
 {
     int count = 0;
     for (ProjectInfo *proj : list) {
@@ -97,7 +97,7 @@ void ProjectStateWidget::setRowCount(QList<ProjectInfo *> list)
     m_projTableWidget->setRowCount(count);
 }
 
-void ProjectStateWidget::setItem(int row, int column, QTableWidgetItem *item, QColor bgColor)
+void ProjectStateWidget::setItem(int row, int column, QTableWidgetItem *item, const QColor &bgColor)
 {
     item->setBackgroundColor(bgColor);
     item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);

+ 3 - 3
QFD/widgets/ProjectStateWidget.h

@@ -18,7 +18,7 @@ class ProjectStateWidget : public QWidget
 public:
     explicit ProjectStateWidget(QWidget *parent = nullptr);
 
-    void showProjects(QList<ProjectInfo *> list);
+    void showProjects(const QList<ProjectInfo *> &list);
 
 signals:
 
@@ -26,9 +26,9 @@ private:
     void initialize();
     void initLayout();
 
-    void setRowCount(QList<ProjectInfo *> list);
+    void setRowCount(const QList<ProjectInfo *> &list);
 
-    void setItem(int row, int column, QTableWidgetItem *item, QColor bgColor);
+    void setItem(int row, int column, QTableWidgetItem *item, const QColor &bgColor);
 
 private:
     QVBoxLayout *m_vBoxLayout = nullptr;

+ 1 - 1
QFD/widgets/SchemeFlowWidget.cpp

@@ -200,7 +200,7 @@ void SchemeFlowWidget::refresh()
     }
 }
 
-void SchemeFlowWidget::slotSchemeProcessEdited(SchemePlanManager::SchemeProcessInfo process)
+void SchemeFlowWidget::slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process)
 {
     qDebug() << __FUNCTION__ << __LINE__ << process.algorithm << endl;
 }

+ 2 - 2
QFD/widgets/SchemeFlowWidget.h

@@ -13,7 +13,7 @@
 #include <QtNodes/BasicGraphicsScene>
 #include <QtNodes/ConnectionStyle>
 #include <QtNodes/DataFlowGraphicsScene>
-//#include <QtNodes/GraphicsView>
+// #include <QtNodes/GraphicsView>
 #include <QtNodes/GraphicsViewStyle>
 #include <QtNodes/NodeDelegateModelRegistry>
 
@@ -58,7 +58,7 @@ private:
     void refresh();
 
 private slots:
-    void slotSchemeProcessEdited(SchemePlanManager::SchemeProcessInfo process);
+    void slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process);
 
 private:
     ProjectInfo *m_proj = nullptr;