Jelajahi Sumber

切换到 ProjectInfo

chengxr 1 tahun lalu
induk
melakukan
932247627a

+ 22 - 11
QFD/common/ProjectManager.cpp

@@ -2,7 +2,9 @@
 
 #include <dbService/DBServiceSet.h>
 #include <dbService/UserConfigService.h>
-#include <dbService/EngineerService.h>
+#include <dbService/ProjectService.h>
+
+#include <QMetaEnum>
 
 QString ProjectManager::nameOFIndexType(ProjectManager::IndexType t)
 {
@@ -49,26 +51,35 @@ QList<ProjectManager::IndexType> ProjectManager::indexListOfEvalFlags(EvalTypes
     return list;
 }
 
-ProjectManager::EvalTypes ProjectManager::evalFlags(ProjectInfo proj) const
+ProjectManager::EvalTypes ProjectManager::evalFlags(ProjectInfo proj)
 {
     EvalTypes flags = EvalTypes(proj.estimateType.toInt());
     return flags;
 }
 
-QList<ProjectManager::IndexType> ProjectManager::indexList(ProjectInfo proj) const
+QList<ProjectManager::EvalType> ProjectManager::evalTypeList(EvalTypes types)
 {
-    return indexListOfEvalFlags(evalFlags(proj));
-}
+    QList<ProjectManager::EvalType> list;
 
-int ProjectManager::queryProjects(QList<EngineerInfo *> *projList)
-{
-    bool ret = EngineerService().QueryEngineerList(projList);
+    QMetaEnum metaEnum = QMetaEnum::fromType<EvalType>();
 
-    if (ret) {
-        for (EngineerInfo *proj : *projList) {
-            UserConfigService().QueryUserConfigListInfoByEngineerId(&proj->configs, proj->engineerId);
+    for (int i = 0; i < metaEnum.keyCount(); i++) {
+        EvalType t = EvalType(metaEnum.value(i));
+        if (t != None && (types & t) == t) {
+            list.append(t);
         }
     }
 
+    return list;
+}
+
+QList<ProjectManager::IndexType> ProjectManager::indexList(ProjectInfo proj)
+{
+    return indexListOfEvalFlags(evalFlags(proj));
+}
+
+int ProjectManager::queryProjects(QList<ProjectInfo *> *projList)
+{
+    bool ret = ProjectService().QueryAll(projList);
     return ret ? QF_CODE_SUCCEEDED : QF_CODE_DATA_ERROR;
 }

+ 7 - 5
QFD/common/ProjectManager.h

@@ -3,11 +3,11 @@
 
 #include <QObject>
 
-class EngineerInfo;
 class ProjectInfo;
 
-class ProjectManager
+class ProjectManager : QObject
 {
+    Q_OBJECT
 public:
     /// 指标体系类型
     enum IndexType
@@ -32,15 +32,17 @@ public:
         OverallEfficiency  = 0b1 << 7,  // 综合效能评估
     };
 
+    Q_ENUM(EvalType);
     Q_DECLARE_FLAGS(EvalTypes, EvalType)
 
     static QString nameOfEvalType(EvalType t);
     static QList<IndexType> indexListOfEvalFlags(EvalTypes flags);
 
-    EvalTypes evalFlags(ProjectInfo proj) const;
-    QList<IndexType> indexList(ProjectInfo proj) const;
+    static EvalTypes evalFlags(ProjectInfo proj);
+    static QList<EvalType> evalTypeList(EvalTypes types);
+    static QList<IndexType> indexList(ProjectInfo proj);
 
-    static int queryProjects(QList<EngineerInfo *> *projList);
+    static int queryProjects(QList<ProjectInfo *> *projList);
 };
 
 #endif  // PROJECTMANAGER_H

+ 4 - 4
QFD/view/HomeView.cpp

@@ -87,11 +87,11 @@ void HomeView::refreshTable()
     m_projStateWidget->showProjects(searchResult());
 }
 
-QList<EngineerInfo *> HomeView::searchResult() const
+QList<ProjectInfo *> HomeView::searchResult() const
 {
-    QList<EngineerInfo *> list;
-    for (EngineerInfo *proj : m_projList) {
-        if (proj->engineerName.contains(m_searchLineEdit->text())) {
+    QList<ProjectInfo *> list;
+    for (ProjectInfo *proj : m_projList) {
+        if (proj->projectName.contains(m_searchLineEdit->text())) {
             list.append(proj);
         }
     }

+ 3 - 3
QFD/view/HomeView.h

@@ -3,7 +3,7 @@
 
 #include <QWidget>
 
-class EngineerInfo;
+class ProjectInfo;
 
 class CreateProjWidget;
 class ProjectStateWidget;
@@ -34,7 +34,7 @@ private:
 
     void refreshTable();
 
-    QList<EngineerInfo *> searchResult() const;
+    QList<ProjectInfo *> searchResult() const;
 
 private slots:
     void slotCreateProjClicked();
@@ -53,7 +53,7 @@ private:
 
     CreateProjWidget *m_createProjWidget = nullptr;
 
-    QList<EngineerInfo *> m_projList;
+    QList<ProjectInfo *> m_projList;
 };
 
 #endif  // HOMEVIEW_H

+ 0 - 10
QFD/widgets/CreateProjWidget.cpp

@@ -175,16 +175,6 @@ void CreateProjWidget::slotTextChanged()
     if (lineEdit) {
         lineEdit->setText(lineEdit->text().trimmed());
     }
-    //    qDebug() << __FUNCTION__ << __LINE__ << sender();
-
-    //    TextEdit *textEdit = dynamic_cast<TextEdit *>(sender());
-
-    //    qDebug() << __FUNCTION__ << __LINE__ << (textEdit == nullptr);
-
-    //    if (textEdit != nullptr) {
-    //        qDebug() << __FUNCTION__ << __LINE__ << textEdit->toPlainText();
-    //        textEdit->setPlainText(textEdit->toPlainText().trimmed());
-    //    }
 }
 
 void CreateProjWidget::slotCheckBoxChanged() { }

+ 17 - 36
QFD/widgets/ProjectStateWidget.cpp

@@ -1,5 +1,7 @@
 #include "ProjectStateWidget.h"
 
+#include "common/ProjectManager.h"
+
 #include <dbService/ClassSet.h>
 
 #include <QTableWidget>
@@ -10,11 +12,11 @@
 
 #include <QDebug>
 
-int ProjectStateWidget::rowCount(EngineerInfo *proj)
+int ProjectStateWidget::rowCount(ProjectInfo *proj)
 {
-    int expertCount = proj->configs.count();
-    int rowProj     = std::max(proj->indexList().count(), proj->indexList().count() * expertCount);
-    return rowProj;
+    int evalCount = ProjectManager::evalTypeList(ProjectManager::evalFlags(*proj)).count();
+
+    return evalCount;
 }
 
 ProjectStateWidget::ProjectStateWidget(QWidget *parent) : QWidget(parent)
@@ -23,7 +25,7 @@ ProjectStateWidget::ProjectStateWidget(QWidget *parent) : QWidget(parent)
     initLayout();
 }
 
-void ProjectStateWidget::showProjects(QList<EngineerInfo *> proList)
+void ProjectStateWidget::showProjects(QList<ProjectInfo *> proList)
 {
     m_projTableWidget->clearContents();
     m_projTableWidget->clearSpans();
@@ -35,8 +37,8 @@ void ProjectStateWidget::showProjects(QList<EngineerInfo *> proList)
         QColor color = i % 2 ? QColor(238, 238, 255) : QColor(255, 255, 255);
 
         // 工程名,第0列
-        EngineerInfo *proj     = proList[i];
-        QTableWidgetItem *item = new QTableWidgetItem(proj->engineerName);
+        ProjectInfo *proj      = proList[i];
+        QTableWidgetItem *item = new QTableWidgetItem(proj->projectName);
         setItem(row, 0, item, color);
         int rowProj = rowCount(proj);
         if (rowProj > 1) {
@@ -44,35 +46,14 @@ void ProjectStateWidget::showProjects(QList<EngineerInfo *> proList)
         }
 
         // 指标体系,第1列
-        for (int j = 0; j < proj->indexList().count(); j++) {
-            EngineerInfo::IndexType indexType = proj->indexList()[j];
-            QString indexName                 = EngineerInfo::nameOFIndexType(indexType);
-            QTableWidgetItem *item            = new QTableWidgetItem(indexName);
+        for (int j = 0; j < rowCount(proj); j++) {
+            ProjectManager::EvalType indexType = ProjectManager::evalTypeList(ProjectManager::evalFlags(*proj))[j];
+            QString indexName                  = ProjectManager::nameOfEvalType(indexType);
+            QTableWidgetItem *item             = new QTableWidgetItem(indexName);
             setItem(row, 1, item, color);
-            if (proj->configs.count() > 1) {
-                m_projTableWidget->setSpan(row, 1, proj->configs.count(), 1);
-            }
-
-            // 专家数据,第2、3列
-            // 未配置专家时,添加一个空的专家配置来填充表格
-            QList<UserConfig *> configs = proj->configs;
-            if (configs.count() <= 0) {
-                configs.append(new UserConfig());
-            }
-            for (int k = 0; k < configs.count(); k++) {
-                UserConfig *config        = configs[k];
-                QTableWidgetItem *expItem = new QTableWidgetItem(config->id >= 0 ? config->userName : "无");
-                setItem(row + k, 2, expItem, color);
-
-                unsigned seed = QDateTime::currentDateTime().toTime_t() + pow(row + k, 4);
-                srand(seed);
-                bool loaded                = (rand() % 4) == 0;
-                QTableWidgetItem *loadItem = new QTableWidgetItem(loaded && config->id >= 0 ? "已录入" : "未录入");
-                setItem(row + k, 3, loadItem, color);
-            }
-
-            row += configs.count();
         }
+
+        row += rowCount(proj);
     }
 }
 
@@ -110,10 +91,10 @@ void ProjectStateWidget::initLayout()
     layout()->addWidget(m_projTableWidget);
 }
 
-void ProjectStateWidget::setRowCount(QList<EngineerInfo *> list)
+void ProjectStateWidget::setRowCount(QList<ProjectInfo *> list)
 {
     int count = 0;
-    for (EngineerInfo *proj : list) {
+    for (ProjectInfo *proj : list) {
         int rowProj = rowCount(proj);
         count += rowProj;
     }

+ 4 - 4
QFD/widgets/ProjectStateWidget.h

@@ -3,7 +3,7 @@
 
 #include <QWidget>
 
-class EngineerInfo;
+class ProjectInfo;
 
 class QTableWidget;
 class QVBoxLayout;
@@ -16,11 +16,11 @@ class ProjectStateWidget : public QWidget
 {
     Q_OBJECT
 public:
-    static int rowCount(EngineerInfo *proj);
+    static int rowCount(ProjectInfo *proj);
 
     explicit ProjectStateWidget(QWidget *parent = nullptr);
 
-    void showProjects(QList<EngineerInfo *> list);
+    void showProjects(QList<ProjectInfo *> list);
 
 signals:
 
@@ -28,7 +28,7 @@ private:
     void initialize();
     void initLayout();
 
-    void setRowCount(QList<EngineerInfo *> list);
+    void setRowCount(QList<ProjectInfo *> list);
 
     void setItem(int row, int column, QTableWidgetItem *item, QColor bgColor);