Browse Source

评估任务页面跳转

chengxr 1 year ago
parent
commit
a522348a93

+ 2 - 0
QFD/QFD.pro

@@ -83,6 +83,7 @@ SOURCES += \
     widgets/DataCollectionWidget.cpp \
     widgets/DataProcessingWidget.cpp \
     widgets/EvalSchemeWidget.cpp \
+    widgets/EvalWidget.cpp \
     widgets/EvaluateOptionWidget.cpp \
     widgets/ExpertInfoWidget.cpp \
     widgets/ExpertListWidget.cpp \
@@ -118,6 +119,7 @@ HEADERS += \
     widgets/DataCollectionWidget.h \
     widgets/DataProcessingWidget.h \
     widgets/EvalSchemeWidget.h \
+    widgets/EvalWidget.h \
     widgets/EvaluateOptionWidget.h \
     widgets/ExpertInfoWidget.h \
     widgets/ExpertListWidget.h \

+ 3 - 1
QFD/common/QFDAlert.cpp

@@ -45,11 +45,13 @@ void QFDAlert::showAlertWithCode(int code, QWidget *w)
     } else if (code == QF_CODE_PROJ_CREATE_FALIED) {
         msg = "创建失败";
     } else if (code == QF_CODE_PROJ_NOT_EDITABLE) {
-        msg = "该项目类型不支持修改";
+        msg = "该类型项目不支持修改";
     } else if (code == QF_CODE_PROJ_UPDATE_FALIED) {
         msg = "更新失败";
     } else if (code == QF_CODE_PROJ_DELETE_FALIED) {
         msg = "删除失败";
+    } else if (code == QF_CODE_EVAL_NOT_SUPPORTED) {
+        msg = "不支持的评估类型";
     }
 
     if (!msg.isEmpty()) {

+ 2 - 0
QFD/dbService/ClassSet.h

@@ -31,6 +31,8 @@ const int QF_CODE_PROJ_NOT_EDITABLE  = 2024;
 const int QF_CODE_PROJ_UPDATE_FALIED = 2025;
 const int QF_CODE_PROJ_DELETE_FALIED = 2026;
 
+const int QF_CODE_EVAL_NOT_SUPPORTED = 2030;
+
 /**
  * @projectName   QFD
  * @author        cyh

+ 9 - 0
QFD/view/MainWindow.cpp

@@ -10,11 +10,14 @@
 #include "SettingView.h"
 #include "UserView.h"
 
+#include "ProjectManager.h"
+
 #include "dbService/ClassSet.h"
 
 #include "QFDConfig.h"
 
 #include "common/QFDIcon.h"
+#include "QFDAlert.h"
 
 #include <QFramelessWindow.h>
 
@@ -239,6 +242,12 @@ void MainWindow::slotNaviItemClicked()
 
 void MainWindow::slotOpenProject(ProjectInfo *proj)
 {
+    QList<ProjectManager::EvalType> l = ProjectManager::evalTypeList(*proj);
+    if (l.count() <= 0) {
+        QFDAlert::showAlertWithCode(QF_CODE_EVAL_NOT_SUPPORTED, this);
+        return;
+    }
+
     QString n = QString("project_%1").arg(proj->id);
     int index = m_stackWidget->index(n);
     if (index >= 0) {

+ 28 - 8
QFD/view/ProjectView.cpp

@@ -3,6 +3,10 @@
 #include "ProjectListWidget.h"
 #include "RenameWidget.h"
 #include "ConfigExpertWidget.h"
+#include "IndexSystemWidget.h"
+#include "EvalSchemeWidget.h"
+#include "DataCollectionWidget.h"
+#include "DataProcessingWidget.h"
 
 #include "common/ProjectManager.h"
 
@@ -14,6 +18,7 @@
 
 #include <QBoxLayout>
 #include <QLabel>
+#include <QStackedWidget>
 
 #include <QDebug>
 
@@ -69,12 +74,23 @@ void ProjectView::initWidgets()
     m_tree->setFixedWidth(200);
 
     // 分割线
-    m_contentSeperator = new QWidget(this);
-    m_contentSeperator->setFixedWidth(1);
-    QPalette pal(m_contentSeperator->palette());
+    m_seperator = new QWidget(this);
+    m_seperator->setFixedWidth(1);
+    QPalette pal(m_seperator->palette());
     pal.setColor(QPalette::Background, QColor("#aaaaaa"));
-    m_contentSeperator->setAutoFillBackground(true);
-    m_contentSeperator->setPalette(pal);
+    m_seperator->setAutoFillBackground(true);
+    m_seperator->setPalette(pal);
+
+    m_stack          = new QStackedWidget(this);
+    m_indexSystem    = new IndexSystemWidget(m_stack, 1);
+    m_evalScheme     = new EvalSchemeWidget(m_stack, 2);
+    m_dataCollection = new DataCollectionWidget(m_stack, 3);
+    m_dataProcessing = new DataProcessingWidget(m_stack, 4);
+
+    m_stack->addWidget(m_indexSystem);
+    m_stack->addWidget(m_evalScheme);
+    m_stack->addWidget(m_dataCollection);
+    m_stack->addWidget(m_dataProcessing);
 }
 
 void ProjectView::initLayout()
@@ -91,8 +107,8 @@ void ProjectView::initLayout()
     m_headerLayout->addSpacing(10);
 
     m_contentLayout->addWidget(m_tree);
-    m_contentLayout->addWidget(m_contentSeperator);
-    m_contentLayout->addStretch();
+    m_contentLayout->addWidget(m_seperator);
+    m_contentLayout->addWidget(m_stack);
 }
 
 void ProjectView::connectSigalsAndSlots()
@@ -112,8 +128,10 @@ void ProjectView::itemClicked(QTreeWidgetItem *item, int column)
         taskIndex = item->parent()->indexOfChild(item);
     }
 
+    // 点击一级条目时, 选中其首个子条目
     if (taskIndex < 0) {
-        item->child(0)->setSelected(true);
+        taskIndex = 0;
+        item->child(taskIndex)->setSelected(true);
     }
 
     ProjectManager::EvalType type = ProjectManager::evalTypeList(*m_proj)[typeIndex];
@@ -121,4 +139,6 @@ void ProjectView::itemClicked(QTreeWidgetItem *item, int column)
 
     qDebug() << __FUNCTION__ << __LINE__ << typeIndex << taskIndex << m_proj->projectName << typeName
              << m_tree->selectedItems().first()->text(0) << endl;
+
+    m_stack->setCurrentIndex(taskIndex);
 }

+ 16 - 4
QFD/view/ProjectView.h

@@ -5,6 +5,11 @@
 
 class ProjectInfo;
 
+class IndexSystemWidget;
+class EvalSchemeWidget;
+class DataCollectionWidget;
+class DataProcessingWidget;
+
 class PushButton;
 class TreeWidget;
 
@@ -12,6 +17,7 @@ class QVBoxLayout;
 class QHBoxLayout;
 class QLabel;
 class QTreeWidgetItem;
+class QStackedWidget;
 
 /// 工程视图
 class ProjectView : public QWidget
@@ -43,10 +49,16 @@ private:
     QHBoxLayout *m_headerLayout  = nullptr;
     QHBoxLayout *m_contentLayout = nullptr;
 
-    QLabel *m_title             = nullptr;
-    PushButton *m_close         = nullptr;
-    TreeWidget *m_tree          = nullptr;
-    QWidget *m_contentSeperator = nullptr;
+    QLabel *m_title      = nullptr;
+    PushButton *m_close  = nullptr;
+    TreeWidget *m_tree   = nullptr;
+    QWidget *m_seperator = nullptr;
+
+    QStackedWidget *m_stack                = nullptr;
+    IndexSystemWidget *m_indexSystem       = nullptr;
+    EvalSchemeWidget *m_evalScheme         = nullptr;
+    DataCollectionWidget *m_dataCollection = nullptr;
+    DataProcessingWidget *m_dataProcessing = nullptr;
 };
 
 #endif  // PROJECTVIEW_H

+ 3 - 3
QFD/widgets/DataCollectionWidget.cpp

@@ -1,6 +1,6 @@
-#include "DataCollectionWidget.h"
+#include "DataCollectionWidget.h"
 
-DataCollectionWidget::DataCollectionWidget(QWidget *parent) : QWidget(parent)
+DataCollectionWidget::DataCollectionWidget(QWidget *parent, int type) : EvalWidget(type, parent)
 {
-
+    setTitle("评估数据采集");
 }

+ 3 - 3
QFD/widgets/DataCollectionWidget.h

@@ -1,17 +1,17 @@
 #ifndef DATACOLLECTIONWIDGET_H
 #define DATACOLLECTIONWIDGET_H
 
-#include <QWidget>
+#include "EvalWidget.h"
 
 /**
  * @brief The DataCollectionWidget class
  * 数据采集
  */
-class DataCollectionWidget : public QWidget
+class DataCollectionWidget : public EvalWidget
 {
     Q_OBJECT
 public:
-    explicit DataCollectionWidget(QWidget *parent = nullptr);
+    explicit DataCollectionWidget(QWidget *parent = nullptr, int type = 0);
 
 signals:
 };

+ 3 - 3
QFD/widgets/DataProcessingWidget.cpp

@@ -1,6 +1,6 @@
-#include "DataProcessingWidget.h"
+#include "DataProcessingWidget.h"
 
-DataProcessingWidget::DataProcessingWidget(QWidget *parent) : QWidget(parent)
+DataProcessingWidget::DataProcessingWidget(QWidget *parent, int type) : EvalWidget(type, parent)
 {
-
+    setTitle("评估数据处理");
 }

+ 3 - 3
QFD/widgets/DataProcessingWidget.h

@@ -1,17 +1,17 @@
 #ifndef DATAPROCESSINGWIDGET_H
 #define DATAPROCESSINGWIDGET_H
 
-#include <QWidget>
+#include "EvalWidget.h"
 
 /**
  * @brief The DataProcessingWidget class
  * 数据处理
  */
-class DataProcessingWidget : public QWidget
+class DataProcessingWidget : public EvalWidget
 {
     Q_OBJECT
 public:
-    explicit DataProcessingWidget(QWidget *parent = nullptr);
+    explicit DataProcessingWidget(QWidget *parent = nullptr, int type = 0);
 
 signals:
 };

+ 3 - 3
QFD/widgets/EvalSchemeWidget.cpp

@@ -1,6 +1,6 @@
-#include "EvalSchemeWidget.h"
+#include "EvalSchemeWidget.h"
 
-EvalSchemeWidget::EvalSchemeWidget(QWidget *parent) : QWidget(parent)
+EvalSchemeWidget::EvalSchemeWidget(QWidget *parent, int type) : EvalWidget(type, parent)
 {
-
+    setTitle("评估方案规划");
 }

+ 3 - 3
QFD/widgets/EvalSchemeWidget.h

@@ -1,17 +1,17 @@
 #ifndef EVALSCHEMEWIDGET_H
 #define EVALSCHEMEWIDGET_H
 
-#include <QWidget>
+#include "EvalWidget.h"
 
 /**
  * @brief The EvalSchemeWidget class
  * 评估方案
  */
-class EvalSchemeWidget : public QWidget
+class EvalSchemeWidget : public EvalWidget
 {
     Q_OBJECT
 public:
-    explicit EvalSchemeWidget(QWidget *parent = nullptr);
+    explicit EvalSchemeWidget(QWidget *parent = nullptr, int type = 0);
 
 signals:
 };

+ 53 - 0
QFD/widgets/EvalWidget.cpp

@@ -0,0 +1,53 @@
+#include "EvalWidget.h"
+
+#include <QLabel>
+#include <QLayout>
+
+#include <QDebug>
+
+EvalWidget::EvalWidget(int type, QWidget *parent) : QWidget(parent), m_type(type)
+{
+    initWidgets();
+    initLayout();
+}
+
+int EvalWidget::type() const
+{
+    return m_type;
+}
+
+void EvalWidget::setType(int type)
+{
+    m_type = type;
+}
+
+void EvalWidget::setTitle(const QString title)
+{
+    m_title->setText(title);
+}
+
+void EvalWidget::initWidgets()
+{
+    m_title = new QLabel(this);
+    QFont ft("Microsoft YaHei", 12);
+    m_title->setFont(ft);
+
+    // 分割线
+    m_seperator = new QWidget(this);
+    m_seperator->setFixedHeight(1);
+    QPalette pal(m_seperator->palette());
+    pal.setColor(QPalette::Background, QColor("#aaaaaa"));
+    m_seperator->setAutoFillBackground(true);
+    m_seperator->setPalette(pal);
+}
+
+void EvalWidget::initLayout()
+{
+    m_layout        = new QVBoxLayout(this);
+    m_contentLayout = new QVBoxLayout();
+
+    m_layout->addWidget(m_title);
+    m_layout->addWidget(m_seperator);
+    m_layout->addLayout(m_contentLayout);
+    m_layout->addStretch();
+}

+ 36 - 0
QFD/widgets/EvalWidget.h

@@ -0,0 +1,36 @@
+#ifndef EVALWIDGET_H
+#define EVALWIDGET_H
+
+#include <QWidget>
+
+class QVBoxLayout;
+class QLabel;
+
+class EvalWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit EvalWidget(int type, QWidget *parent = nullptr);
+
+    int type() const;
+    void setType(int type);
+
+    void setTitle(const QString title);
+
+    void initWidgets();
+
+    void initLayout();
+
+protected:
+    int m_type = 0;
+
+    QVBoxLayout *m_layout        = nullptr;
+    QVBoxLayout *m_contentLayout = nullptr;
+
+    QLabel *m_title      = nullptr;
+    QWidget *m_seperator = nullptr;
+
+signals:
+};
+
+#endif  // EVALWIDGET_H

+ 3 - 3
QFD/widgets/IndexSystemWidget.cpp

@@ -1,6 +1,6 @@
-#include "IndexSystemWidget.h"
+#include "IndexSystemWidget.h"
 
-IndexSystemWidget::IndexSystemWidget(QWidget *parent) : QWidget(parent)
+IndexSystemWidget::IndexSystemWidget(QWidget *parent, int type) : EvalWidget(type, parent)
 {
-
+    setTitle("指标体系设计");
 }

+ 3 - 3
QFD/widgets/IndexSystemWidget.h

@@ -1,17 +1,17 @@
 #ifndef INDEXSYSTEMWIDGET_H
 #define INDEXSYSTEMWIDGET_H
 
-#include <QWidget>
+#include "EvalWidget.h"
 
 /**
  * @brief The IndexSystemWidget class
  * 指标体系
  */
-class IndexSystemWidget : public QWidget
+class IndexSystemWidget : public EvalWidget
 {
     Q_OBJECT
 public:
-    explicit IndexSystemWidget(QWidget *parent = nullptr);
+    explicit IndexSystemWidget(QWidget *parent = nullptr, int type = 0);
 
 signals:
 };