Browse Source

首页重新设计

chengxr 1 year ago
parent
commit
1d94180aa0

+ 6 - 6
QFD/common/ProjectManager.cpp

@@ -37,15 +37,15 @@ QString ProjectManager::nameOfEvalType(ProjectManager::EvalType t)
     }
 }
 
-QList<ProjectManager::IndexType> ProjectManager::indexListOfEvalFlags(EvalTypes flags)
+QList<ProjectManager::IndexType> ProjectManager::indexListOfEvalTypes(EvalTypes types)
 {
     QList<IndexType> list;
 
-    if ((flags & EngineerInfo::Importance) == EngineerInfo::Importance) {
+    if ((types & EngineerInfo::Importance) == EngineerInfo::Importance) {
         list.append(Capability);
         list.append(TechMessaures);
     }
-    if ((flags & EngineerInfo::TechSchema) == EngineerInfo::TechSchema) {
+    if ((types & EngineerInfo::TechSchema) == EngineerInfo::TechSchema) {
         list.append(SchemaEval);
     }
 
@@ -56,8 +56,8 @@ ProjectManager::EvalTypes ProjectManager::evalTypes(ProjectInfo proj)
 {
     int t           = proj.estimateType.toInt();
     t               = 96;
-    EvalTypes flags = EvalTypes(t);
-    return flags;
+    EvalTypes types = EvalTypes(t);
+    return types;
 }
 
 QList<ProjectManager::EvalType> ProjectManager::evalTypeList(EvalTypes types)
@@ -85,7 +85,7 @@ QList<ProjectManager::EvalType> ProjectManager::evalTypeList(ProjectInfo proj)
 
 QList<ProjectManager::IndexType> ProjectManager::indexList(ProjectInfo proj)
 {
-    return indexListOfEvalFlags(evalTypes(proj));
+    return indexListOfEvalTypes(evalTypes(proj));
 }
 
 int ProjectManager::queryProjects(QList<ProjectInfo *> *projList)

+ 1 - 1
QFD/common/ProjectManager.h

@@ -36,7 +36,7 @@ public:
     Q_DECLARE_FLAGS(EvalTypes, EvalType)
 
     static QString nameOfEvalType(EvalType t);
-    static QList<IndexType> indexListOfEvalFlags(EvalTypes flags);
+    static QList<IndexType> indexListOfEvalTypes(EvalTypes flags);
 
     static EvalTypes evalTypes(ProjectInfo proj);
     static QList<EvalType> evalTypeList(EvalTypes types);

+ 4 - 0
QFD/common/QFDIcon.cpp

@@ -11,10 +11,14 @@ QString QFDIcon::iconName(QFDIcon::IconType type)
         return "Detail";
     case Expert:
         return "Expert";
+    case Filter:
+        return "Filter";
     case Logout:
         return "Logout";
     case Minus:
         return "Minus";
+    case Open:
+        return "Open";
     case Project:
         return "Project";
     case Schecme:

+ 2 - 0
QFD/common/QFDIcon.h

@@ -13,8 +13,10 @@ public:
         Data,
         Detail,
         Expert,
+        Filter,
         Logout,
         Minus,
+        Open,
         Project,
         Schecme,
         User,

+ 4 - 0
QFD/resource.qrc

@@ -378,5 +378,9 @@
         <file>resource/svg/Minus_white.svg</file>
         <file>resource/svg/Scheme_black.svg</file>
         <file>resource/svg/Scheme_white.svg</file>
+        <file>resource/svg/Filter_black.svg</file>
+        <file>resource/svg/Filter_white.svg</file>
+        <file>resource/svg/Open_black.svg</file>
+        <file>resource/svg/Open_white.svg</file>
     </qresource>
 </RCC>

+ 1 - 0
QFD/resource/svg/Filter_black.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1695023334840" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4787" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M640 288a64 64 0 1 1 0.032-128.032A64 64 0 0 1 640 288z m123.456-96c-14.304-55.04-64-96-123.456-96s-109.152 40.96-123.456 96H128v64h388.544c14.304 55.04 64 96 123.456 96s109.152-40.96 123.456-96H896V192zM640 864a64 64 0 1 1 0.032-128.032A64 64 0 0 1 640 864m0-192c-59.456 0-109.152 40.96-123.456 96H128v64h388.544c14.304 55.04 64 96 123.456 96s109.152-40.96 123.456-96H896v-64h-132.544c-14.304-55.04-64-96-123.456-96M384 576a64 64 0 1 1 0.032-128.032A64 64 0 0 1 384 576m0-192c-59.456 0-109.152 40.96-123.456 96H128v64h132.544c14.304 55.04 64 96 123.456 96s109.152-40.96 123.456-96H896v-64H507.456c-14.304-55.04-64-96-123.456-96" fill="#000000" p-id="4788"></path></svg>

+ 1 - 0
QFD/resource/svg/Filter_white.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1695023334840" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4787" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M640 288a64 64 0 1 1 0.032-128.032A64 64 0 0 1 640 288z m123.456-96c-14.304-55.04-64-96-123.456-96s-109.152 40.96-123.456 96H128v64h388.544c14.304 55.04 64 96 123.456 96s109.152-40.96 123.456-96H896V192zM640 864a64 64 0 1 1 0.032-128.032A64 64 0 0 1 640 864m0-192c-59.456 0-109.152 40.96-123.456 96H128v64h388.544c14.304 55.04 64 96 123.456 96s109.152-40.96 123.456-96H896v-64h-132.544c-14.304-55.04-64-96-123.456-96M384 576a64 64 0 1 1 0.032-128.032A64 64 0 0 1 384 576m0-192c-59.456 0-109.152 40.96-123.456 96H128v64h132.544c14.304 55.04 64 96 123.456 96s109.152-40.96 123.456-96H896v-64H507.456c-14.304-55.04-64-96-123.456-96" fill="#000000" p-id="4788"></path></svg>

+ 1 - 0
QFD/resource/svg/Open_black.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1695086277524" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6160" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2c-1.5-1.4-3.5-2.2-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256z m635.3 512H159l103.3-256h612.4L771.3 768z" p-id="6161"></path></svg>

+ 1 - 0
QFD/resource/svg/Open_white.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1695086277524" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6160" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2c-1.5-1.4-3.5-2.2-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256z m635.3 512H159l103.3-256h612.4L771.3 768z" p-id="6161" fill="#ffffff"></path></svg>

+ 7 - 0
QFD/view/AboutView.cpp

@@ -17,10 +17,17 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent)
 
 void AboutView::showEvent(QShowEvent *event)
 {
+    qDebug() << __FUNCTION__;
     QWidget::showEvent(event);
     initialize();
 }
 
+void AboutView::hideEvent(QHideEvent *event)
+{
+    qDebug() << __FUNCTION__;
+    QWidget::hideEvent(event);
+}
+
 void AboutView::resizeEvent(QResizeEvent *event)
 {
     QWidget::resizeEvent(event);

+ 2 - 0
QFD/view/AboutView.h

@@ -20,6 +20,8 @@ public:
 private:
     void showEvent(QShowEvent *event) override;
 
+    void hideEvent(QHideEvent *event) override;
+
     void resizeEvent(QResizeEvent *event) override;
 
     void initialize();

+ 42 - 31
QFD/view/HomeView.cpp

@@ -4,6 +4,8 @@
 #include "ProjectStateWidget.h"
 #include "ProjectManager.h"
 #include "QFDAlert.h"
+#include "QFDIcon.h"
+#include "ProjectListWidget.h"
 
 #include <Widgets/Button.h>
 #include <Widgets/LineEdit.h>
@@ -18,7 +20,7 @@ HomeView::HomeView(QWidget *parent) : QWidget(parent) { }
 void HomeView::showEvent(QShowEvent *event)
 {
     if (m_initilized == false) {
-        initialize();
+        initWidgets();
         initLayout();
         connectSignalsAndSlots();
         m_initilized = true;
@@ -26,7 +28,7 @@ void HomeView::showEvent(QShowEvent *event)
 
     QWidget::showEvent(event);
 
-    refreshTable();
+    loadProjects();
 }
 
 void HomeView::hideEvent(QHideEvent *event)
@@ -34,47 +36,56 @@ void HomeView::hideEvent(QHideEvent *event)
     QWidget::hideEvent(event);
 }
 
-void HomeView::initialize()
+void HomeView::initWidgets()
 {
-    m_vBoxLayout = new QVBoxLayout(this);
-
-    m_titleLabel = new QLabel(this);
-    m_titleLabel->setText("工程列表");
+    m_title = new QLabel(this);
+    m_title->setText("项目列表");
     QFont ft("Microsoft YaHei", 12);
-    m_titleLabel->setFont(ft);
-    m_hBoxLayout     = new QHBoxLayout();
-    m_searchLineEdit = new LineEdit(this);
-    m_searchLineEdit->setIsClearButtonEnabled(true);
-    m_searchLineEdit->setPlaceholderText("输入工程名搜索");
-    m_searchLineEdit->setMinimumWidth(300);
-    m_createProjPushButton = new PushButton("新建工程", NEWFLICON(FluentIcon, ADD), this);
+    m_title->setFont(ft);
+
+    m_create = new PushButton("新建", NEWFLICON(FluentIcon, ADD), this);
+    m_create->setToolTip("新建项目");
+
+    m_search = new LineEdit(this);
+    m_search->setIsClearButtonEnabled(true);
+    m_search->setPlaceholderText("输入项目名搜索");
+    m_search->setMinimumWidth(300);
 
-    m_projStateWidget = new ProjectStateWidget(this);
+    m_filter = new PushButton("筛选", NEWFLICON(QFDIcon, Filter), this);
+    m_filter->setToolTip("筛选项目");
+
+    m_projListWidget = new ProjectListWidget(this);
 
     m_createProjWidget = new CreateProjWidget(this);
 }
 
 void HomeView::initLayout()
 {
-    m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
-    m_vBoxLayout->setContentsMargins(15, 10, 10, 15);
-    m_vBoxLayout->addLayout(m_hBoxLayout);
-
-    m_hBoxLayout->addWidget(m_titleLabel);
-    m_hBoxLayout->addSpacing(15);
-    m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
-    m_hBoxLayout->addWidget(m_createProjPushButton, 1, Qt::AlignLeft);
-
-    m_vBoxLayout->addWidget(m_projStateWidget);
+    // 总体布局
+    m_layout = new QVBoxLayout(this);
+    m_layout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+    m_layout->setContentsMargins(15, 10, 10, 15);
+    m_topLayout = new QHBoxLayout();
+    m_layout->addLayout(m_topLayout);
+    m_layout->addWidget(m_projListWidget);
+
+    // 顶部布局
+    m_topLayout->addWidget(m_title);
+    m_topLayout->addSpacing(15);
+    m_topLayout->addWidget(m_create, 1, Qt::AlignLeft);
+
+    m_topLayout->addWidget(m_search, 0, Qt::AlignLeft);
+    m_topLayout->addStretch();
+    m_topLayout->addWidget(m_filter);
 }
 
 void HomeView::connectSignalsAndSlots()
 {
-    connect(m_createProjPushButton, &PushButton::clicked, this, &HomeView::slotCreateProjClicked);
-    connect(m_searchLineEdit, &LineEdit::textChanged, this, &HomeView::slotSearchTextChanged);
+    connect(m_create, &PushButton::clicked, this, &HomeView::slotCreateProjClicked);
+    connect(m_search, &LineEdit::textChanged, this, &HomeView::slotSearchTextChanged);
 }
 
-void HomeView::refreshTable()
+void HomeView::loadProjects()
 {
     qDeleteAll(m_projList);
     m_projList.clear();
@@ -85,14 +96,14 @@ void HomeView::refreshTable()
         return;
     }
 
-    m_projStateWidget->showProjects(searchResult());
+    m_projListWidget->showProjects(searchResult());
 }
 
 QList<ProjectInfo *> HomeView::searchResult() const
 {
     QList<ProjectInfo *> list;
     for (ProjectInfo *proj : m_projList) {
-        if (proj->projectName.contains(m_searchLineEdit->text())) {
+        if (proj->projectName.contains(m_search->text())) {
             list.append(proj);
         }
     }
@@ -109,5 +120,5 @@ void HomeView::slotCreateProjClicked()
 
 void HomeView::slotSearchTextChanged()
 {
-    m_projStateWidget->showProjects(searchResult());
+    m_projListWidget->showProjects(searchResult());
 }

+ 11 - 8
QFD/view/HomeView.h

@@ -7,6 +7,7 @@ class ProjectInfo;
 
 class CreateProjWidget;
 class ProjectStateWidget;
+class ProjectListWidget;
 
 class PushButton;
 class LineEdit;
@@ -28,11 +29,11 @@ public:
     void hideEvent(QHideEvent *event) override;
 
 private:
-    void initialize();
+    void initWidgets();
     void initLayout();
     void connectSignalsAndSlots();
 
-    void refreshTable();
+    void loadProjects();
 
     QList<ProjectInfo *> searchResult() const;
 
@@ -43,13 +44,15 @@ private slots:
 private:
     bool m_initilized = false;
 
-    QVBoxLayout *m_vBoxLayout          = nullptr;
-    QLabel *m_titleLabel               = nullptr;
-    QHBoxLayout *m_hBoxLayout          = nullptr;
-    LineEdit *m_searchLineEdit         = nullptr;
-    PushButton *m_createProjPushButton = nullptr;
+    QVBoxLayout *m_layout    = nullptr;
+    QHBoxLayout *m_topLayout = nullptr;
 
-    ProjectStateWidget *m_projStateWidget = nullptr;
+    QLabel *m_title      = nullptr;
+    PushButton *m_create = nullptr;
+    LineEdit *m_search   = nullptr;
+    PushButton *m_filter = nullptr;
+
+    ProjectListWidget *m_projListWidget = nullptr;
 
     CreateProjWidget *m_createProjWidget = nullptr;
 

+ 7 - 5
QFD/widgets/CreateProjWidget.cpp

@@ -22,13 +22,15 @@ CreateProjWidget::CreateProjWidget(QWidget *parent) : QDialog(parent)
     connectSignalsAndSlots();
 }
 
-const QString CreateProjWidget::projName() const
-{
-    return m_name->text();
-}
-
 void CreateProjWidget::clearInputs()
 {
+    m_taskName->clear();
+    m_evalPurpose->clear();
+    m_evalUnit->clear();
+    m_evalCrew->clear();
+    m_rank->clear();
+    m_note->clear();
+
     m_name->clear();
     m_type1->setChecked(false);
     m_type2->setChecked(false);

+ 0 - 2
QFD/widgets/CreateProjWidget.h

@@ -23,8 +23,6 @@ class CreateProjWidget : public QDialog
 public:
     CreateProjWidget(QWidget *parent = nullptr);
 
-    const QString projName() const;
-
     void clearInputs();
 
     ProjectInfo projectInfo() const;

+ 128 - 102
QFD/widgets/ProjectListWidget.cpp

@@ -1,5 +1,9 @@
 #include "ProjectListWidget.h"
 
+#include "QFDIcon.h"
+#include "ProjectManager.h"
+#include "dbService/ClassSet.h"
+
 #include <Widgets/LineEdit.h>
 #include <Widgets/Button.h>
 #include <Widgets/TreeView.h>
@@ -7,45 +11,136 @@
 #include <QBoxLayout>
 #include <QListWidget>
 #include <QLabel>
+#include <QDateTime>
 
 #include <QDebug>
 
-ProjectListWidget::ProjectListWidget(QWidget *parent) : QWidget(parent)
+ProjectListItemWidget::ProjectListItemWidget(QWidget *parent) : QWidget(parent)
 {
-    initialize();
+    initWidgets();
     initLayout();
-    connectSiganlsAndSlots();
-    refreshList();
 }
 
-void ProjectListWidget::refreshList()
+void ProjectListItemWidget::initWidgets()
+{
+    m_name = new QLabel(this);
+    m_name->setObjectName("name");
+    m_time = new QLabel(this);
+    m_time->setObjectName("time");
+    m_taskLabel = new QLabel(this);
+    m_taskLabel->setObjectName("taskLabel");
+    m_taskLabel->setText("任务名称:");
+    m_task = new QLabel(this);
+    m_task->setObjectName("task");
+    m_typeLabel = new QLabel(this);
+    m_typeLabel->setObjectName("typeLabel");
+    m_typeLabel->setText("评估类型:");
+    m_type = new QLabel(this);
+    m_type->setObjectName("type");
+    m_open = new PushButton("打开", NEWFLICON(QFDIcon, Open), this);
+    m_open->setObjectName("open");
+    m_edit = new PushButton("编辑", NEWFLICON(FluentIcon, EDIT), this);
+    m_edit->setObjectName("edit");
+
+    setStyleSheet("#name {color:#1196db; font-size:15px; font:bold}"
+                  "#time {color:gray}"
+                  "#taskLabel {color: gray;}"
+                  "#task {color: gray;}"
+                  "#typeLabel {color: gray;}"
+                  "#type {color: gray;}");
+}
+
+void ProjectListItemWidget::initLayout()
+{
+    // 总体布局
+    m_layout = new QVBoxLayout(this);
+    m_layout->setMargin(10);
+
+    m_nameLayout = new QHBoxLayout();
+    m_layout->addLayout(m_nameLayout);
+    m_layout->addSpacing(5);
+
+    m_taskLayout = new QHBoxLayout();
+    m_layout->addLayout(m_taskLayout);
+
+    m_typeLayout = new QHBoxLayout();
+    m_layout->addLayout(m_typeLayout);
+
+    m_buttonLayout = new QHBoxLayout();
+    m_layout->addLayout(m_buttonLayout);
+
+    // 名称
+    m_nameLayout->addWidget(m_name);
+    m_nameLayout->addStretch();
+    m_nameLayout->addWidget(m_time);
+
+    // 任务
+    m_taskLayout->setContentsMargins(10, 0, 10, 0);
+    m_taskLayout->addWidget(m_taskLabel);
+    m_taskLayout->addSpacing(5);
+    m_taskLayout->addWidget(m_task);
+    m_taskLayout->addStretch();
+
+    // 类型
+    m_typeLayout->setContentsMargins(10, 0, 10, 0);
+    m_typeLayout->addWidget(m_typeLabel);
+    m_typeLayout->addSpacing(5);
+    m_typeLayout->addWidget(m_type);
+    m_typeLayout->addStretch();
+
+    // 按钮
+    m_buttonLayout->addStretch();
+    m_buttonLayout->addWidget(m_open);
+    m_buttonLayout->addWidget(m_edit);
+}
+
+void ProjectListItemWidget::setData(ProjectInfo *info)
 {
+    m_info = info;
+    if (info == nullptr) {
+        return;
+    }
+
+    m_name->setText(info->projectName);
+
+    QDateTime t = QDateTime::fromTime_t(info->estimateTime.toUInt());
+    m_time->setText(t.toString("yyyy-M-d"));
 
-    for (int i = 1; i <= 20; i++) {
-        QTreeWidgetItem *item1 = new QTreeWidgetItem({ QString("工程%1").arg(i) });
-        m_treeWidget->addTopLevelItem(item1);
-        item1->addChildren({ new QTreeWidgetItem({ "能力需求评估" }), new QTreeWidgetItem({ "技术措施评估" }),
-                             new QTreeWidgetItem({ "技术方案评估" }) });
+    m_task->setText(info->taskName);
+
+    QString tStr;
+    QList<ProjectManager::EvalType> types = ProjectManager::evalTypeList(*info);
+    for (int i = 0; i < types.count(); i++) {
+        tStr += ProjectManager::nameOfEvalType(types[i]);
+        if (i < types.count() - 1) {
+            tStr += "、";
+        }
     }
+    m_type->setText(tStr);
+}
 
-    m_treeWidget->expandAll();
+ProjectListWidget::ProjectListWidget(QWidget *parent) : QWidget(parent)
+{
+    initWidgets();
+    initLayout();
+    connectSiganlsAndSlots();
+}
 
-    return;
-    //    m_listWidget->clear();
+void ProjectListWidget::showProjects(QList<ProjectInfo *> list)
+{
+    m_listWidget->clear();
 
-    //    for (int i = 1; i <= 100; i++) {
-    //        QListWidgetItem *item = new QListWidgetItem;
-    //        item->setSizeHint(QSize(200, 80));
-    //        m_listWidget->addItem(item);
+    for (ProjectInfo *info : list) {
+        ProjectListItemWidget *w = new ProjectListItemWidget(m_listWidget);
+        w->setData(info);
 
-    //        ProjectListItemWidget *w = new ProjectListItemWidget();
-    //        w->setIndex(i);
-    //        w->setName(QString("工程%1").arg(i));
-    //        m_listWidget->setItemWidget(item, w);
-    //    }
+        QListWidgetItem *item = new QListWidgetItem(m_listWidget);
+        item->setSizeHint(QSize(300, 135));
+        m_listWidget->setItemWidget(item, w);
+    }
 }
 
-void ProjectListWidget::initialize()
+void ProjectListWidget::initWidgets()
 {
     QPalette pal(palette());
     pal.setColor(QPalette::Background, QColor("#eeeeee"));
@@ -54,30 +149,26 @@ void ProjectListWidget::initialize()
 
     m_vBoxLayout = new QVBoxLayout(this);
 
-    //    m_listWidget = new QListWidget(this);
+    m_listWidget = new QListWidget(this);
 
-    //    m_listWidget->setAlternatingRowColors(true);
-    //    m_listWidget->setStyleSheet("QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);background: rgb(255, 255, "
-    //                                "255);alternate-background-color: rgb(244, 244, 255);}");
-
-    m_treeWidget = new TreeWidget(this);
-    m_treeWidget->setHeaderHidden(true);
+    m_listWidget->setAlternatingRowColors(true);
+    m_listWidget->setStyleSheet("QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);background: rgb(255, 255, "
+                                "255);alternate-background-color: rgb(244, 244, 255);}");
 }
 
 void ProjectListWidget::initLayout()
 {
     m_vBoxLayout->setMargin(0);
-    //    m_vBoxLayout->addWidget(m_listWidget);
-    m_vBoxLayout->addWidget(m_treeWidget);
+    m_vBoxLayout->addWidget(m_listWidget);
 }
 
 void ProjectListWidget::connectSiganlsAndSlots()
 {
-    //    connect(m_listWidget, &QListWidget::itemDoubleClicked, this, &ProjectListWidget::slotItemDoubleClicked);
-    //    connect(m_listWidget, &QListWidget::itemClicked, this, &ProjectListWidget::slotItemClicked);
-    //    connect(m_listWidget, &QListWidget::currentItemChanged, this, &ProjectListWidget::slotCurrentItemChanged);
-    //    connect(m_listWidget, &QListWidget::currentRowChanged, this, &ProjectListWidget::slotCurrentRowChanged);
-    //    connect(m_listWidget, &QListWidget::itemSelectionChanged, this, &ProjectListWidget::slotItemSelectionChanged);
+    connect(m_listWidget, &QListWidget::itemDoubleClicked, this, &ProjectListWidget::slotItemDoubleClicked);
+    connect(m_listWidget, &QListWidget::itemClicked, this, &ProjectListWidget::slotItemClicked);
+    connect(m_listWidget, &QListWidget::currentItemChanged, this, &ProjectListWidget::slotCurrentItemChanged);
+    connect(m_listWidget, &QListWidget::currentRowChanged, this, &ProjectListWidget::slotCurrentRowChanged);
+    connect(m_listWidget, &QListWidget::itemSelectionChanged, this, &ProjectListWidget::slotItemSelectionChanged);
 }
 
 void ProjectListWidget::slotItemDoubleClicked(QListWidgetItem *item)
@@ -104,68 +195,3 @@ void ProjectListWidget::slotItemSelectionChanged()
 {
     qDebug() << __FUNCTION__ << __LINE__;
 }
-
-ProjectListItemWidget::ProjectListItemWidget(QWidget *parent) : QWidget(parent)
-{
-    initialize();
-    initLayout();
-}
-
-void ProjectListItemWidget::initialize()
-{
-    m_hBoxLayout = new QHBoxLayout(this);
-    m_vBoxLayout = new QVBoxLayout();
-
-    m_indexLabel = new QLabel(this);
-    m_indexLabel->setFixedWidth(20);
-    m_indexLabel->setObjectName("indexLabel");
-    m_nameLabel = new QLabel(this);
-    m_nameLabel->setObjectName("nameLabel");
-    m_typeLabel1 = new QLabel(this);
-    m_typeLabel1->setObjectName("typeLabel1");
-    m_typeLabel1->setContentsMargins(10, 0, 0, 0);
-    m_typeLabel2 = new QLabel(this);
-    m_typeLabel2->setObjectName("typeLabel2");
-    m_typeLabel2->setContentsMargins(10, 0, 0, 0);
-
-    m_typeLabel1->setText("能力与技术重要度评估");
-    m_typeLabel2->setText("技术方案评估");
-
-    setStyleSheet("#indexLabel {font-size:14px}"
-                  "#nameLabel {color:#1196db; font-size:14px; font:bold}"
-                  "#typeLabel1 {color: gray;}"
-                  "#typeLabel2 {color: gray;}");
-}
-
-void ProjectListItemWidget::initLayout()
-{
-    m_hBoxLayout->addWidget(m_indexLabel);
-    m_hBoxLayout->addLayout(m_vBoxLayout);
-    m_hBoxLayout->addStretch();
-
-    m_vBoxLayout->addWidget(m_nameLabel);
-    m_vBoxLayout->addWidget(m_typeLabel1);
-    m_vBoxLayout->addWidget(m_typeLabel2);
-}
-
-void ProjectListItemWidget::setIndex(int index)
-{
-    m_index = index;
-    m_indexLabel->setText(QString::number(index));
-}
-
-int ProjectListItemWidget::index() const
-{
-    return m_index;
-}
-
-void ProjectListItemWidget::setName(const QString name)
-{
-    m_name = name;
-    m_nameLabel->setText(name);
-}
-
-const QString ProjectListItemWidget::name() const
-{
-    return m_name;
-}

+ 27 - 20
QFD/widgets/ProjectListWidget.h

@@ -3,6 +3,8 @@
 
 #include <QWidget>
 
+class ProjectInfo;
+
 class PushButton;
 class ToolButton;
 class LineEdit;
@@ -10,6 +12,7 @@ class TreeWidget;
 
 class QVBoxLayout;
 class QHBoxLayout;
+class QGridLayout;
 class QLabel;
 class QListWidget;
 class QListWidgetItem;
@@ -20,25 +23,30 @@ class ProjectListItemWidget : public QWidget
 public:
     explicit ProjectListItemWidget(QWidget *parent = nullptr);
 
-    void initialize();
-    void initLayout();
-
-    void setIndex(int index);
-    int index() const;
-
-    void setName(const QString name);
-    const QString name() const;
+    void setData(ProjectInfo *info);
 
 private:
-    int m_index;
-    QString m_name;
+    void initWidgets();
+    void initLayout();
 
-    QHBoxLayout *m_hBoxLayout = nullptr;
-    QVBoxLayout *m_vBoxLayout = nullptr;
-    QLabel *m_indexLabel      = nullptr;
-    QLabel *m_nameLabel       = nullptr;
-    QLabel *m_typeLabel1      = nullptr;
-    QLabel *m_typeLabel2      = nullptr;
+private:
+    ProjectInfo *m_info = nullptr;
+
+    QLabel *m_name      = nullptr;
+    QLabel *m_time      = nullptr;
+    QLabel *m_taskLabel = nullptr;
+    QLabel *m_task      = nullptr;
+    QLabel *m_typeLabel = nullptr;
+    QLabel *m_type      = nullptr;
+
+    PushButton *m_edit = nullptr;
+    PushButton *m_open = nullptr;
+
+    QVBoxLayout *m_layout       = nullptr;
+    QHBoxLayout *m_nameLayout   = nullptr;
+    QHBoxLayout *m_taskLayout   = nullptr;
+    QHBoxLayout *m_typeLayout   = nullptr;
+    QHBoxLayout *m_buttonLayout = nullptr;
 };
 
 /// 工程列表
@@ -48,10 +56,10 @@ class ProjectListWidget : public QWidget
 public:
     explicit ProjectListWidget(QWidget *parent = nullptr);
 
-    void refreshList();
+    void showProjects(QList<ProjectInfo *> list);
 
 private:
-    void initialize();
+    void initWidgets();
     void initLayout();
     void connectSiganlsAndSlots();
 
@@ -67,8 +75,7 @@ signals:
 
 private:
     QVBoxLayout *m_vBoxLayout = nullptr;
-    //    QListWidget *m_listWidget = nullptr;
-    TreeWidget *m_treeWidget = nullptr;
+    QListWidget *m_listWidget = nullptr;
 };
 
 #endif  // PROJECTLISTWIDGET_H

+ 2 - 1
QFD/widgets/ProjectStateWidget.cpp

@@ -30,7 +30,8 @@ void ProjectStateWidget::showProjects(QList<ProjectInfo *> proList)
         QColor color = i % 2 ? QColor(238, 238, 255) : QColor(255, 255, 255);
 
         // 工程名,第0列
-        ProjectInfo *proj      = proList[i];
+        ProjectInfo *proj = proList[i];
+        qDebug() << proj->projectName;
         QTableWidgetItem *item = new QTableWidgetItem(proj->projectName);
         setItem(row, 0, item, color);