Browse Source

工程列表

chengxr 1 year ago
parent
commit
20c89b7de8

+ 13 - 11
QFD/view/ExpertManageView.cpp

@@ -33,9 +33,11 @@ void ExpertManageView::initialize()
     m_searchLineEdit = new SearchLineEdit(this);
     m_searchLineEdit->setPlaceholderText("搜索");
     m_searchLineEdit->setMinimumWidth(300);
-    m_addExpertPushButton = new PushButton("添加", NEWFLICON(FluentIcon, ADD), this);
-    m_detailPushButton    = new PushButton("查看详情", NEWFLICON(QFDIcon, Detail), this);
-    m_deletePushButton    = new PushButton("删除", NEWFLICON(FluentIcon, DELETE), this);
+    m_addExpertButton = new PushButton("添加", NEWFLICON(FluentIcon, ADD), this);
+    m_detailButton    = new ToolButton(NEWFLICON(QFDIcon, Detail), this);
+    m_detailButton->setToolTip("详细信息");
+    m_deleteButton = new ToolButton(NEWFLICON(FluentIcon, DELETE), this);
+    m_deleteButton->setToolTip("删除用户");
 
     m_expertInfoWidget = new ExpertInfoWidget(this);
     m_expertListWidget = new ExpertListWidget(this);
@@ -51,10 +53,10 @@ void ExpertManageView::initLayout()
     m_hBoxLayout->addWidget(m_titleLabel);
     m_hBoxLayout->addSpacing(15);
     m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
-    m_hBoxLayout->addWidget(m_addExpertPushButton, 1, Qt::AlignLeft);
+    m_hBoxLayout->addWidget(m_addExpertButton, 1, Qt::AlignLeft);
     m_hBoxLayout->addStretch();
-    m_hBoxLayout->addWidget(m_detailPushButton);
-    m_hBoxLayout->addWidget(m_deletePushButton);
+    m_hBoxLayout->addWidget(m_detailButton);
+    m_hBoxLayout->addWidget(m_deleteButton);
     setListButtonHidden(true);
 
     m_vBoxLayout->addWidget(m_expertListWidget);
@@ -62,9 +64,9 @@ void ExpertManageView::initLayout()
 
 void ExpertManageView::connectSignalsAndSlots()
 {
-    connect(m_addExpertPushButton, &PushButton::clicked, this, &ExpertManageView::slotAddExpertClicked);
-    connect(m_detailPushButton, &PushButton::clicked, this, &ExpertManageView::slotDetailClicked);
-    connect(m_deletePushButton, &PushButton::clicked, this, &ExpertManageView::slotDeleteClicked);
+    connect(m_addExpertButton, &PushButton::clicked, this, &ExpertManageView::slotAddExpertClicked);
+    connect(m_detailButton, &PushButton::clicked, this, &ExpertManageView::slotDetailClicked);
+    connect(m_deleteButton, &PushButton::clicked, this, &ExpertManageView::slotDeleteClicked);
     connect(m_expertListWidget, &ExpertListWidget::signalSelectionChanged, this,
             &ExpertManageView::slotListSelectionChanged);
     connect(m_expertListWidget, &ExpertListWidget::siganlItemDoubleClicked, this,
@@ -73,8 +75,8 @@ void ExpertManageView::connectSignalsAndSlots()
 
 void ExpertManageView::setListButtonHidden(bool hidden)
 {
-    m_detailPushButton->setHidden(hidden);
-    m_deletePushButton->setHidden(hidden);
+    m_detailButton->setHidden(hidden);
+    m_deleteButton->setHidden(hidden);
 }
 
 void ExpertManageView::showExpertInfo()

+ 8 - 7
QFD/view/ExpertManageView.h

@@ -7,6 +7,7 @@ class ExpertInfoWidget;
 class ExpertListWidget;
 
 class PushButton;
+class ToolButton;
 class SearchLineEdit;
 
 class QVBoxLayout;
@@ -41,13 +42,13 @@ private slots:
     void slotListItemDoubleClicked();
 
 private:
-    QVBoxLayout *m_vBoxLayout         = nullptr;
-    QLabel *m_titleLabel              = nullptr;
-    QHBoxLayout *m_hBoxLayout         = nullptr;
-    SearchLineEdit *m_searchLineEdit  = nullptr;
-    PushButton *m_addExpertPushButton = nullptr;
-    PushButton *m_detailPushButton    = nullptr;
-    PushButton *m_deletePushButton    = nullptr;
+    QVBoxLayout *m_vBoxLayout        = nullptr;
+    QLabel *m_titleLabel             = nullptr;
+    QHBoxLayout *m_hBoxLayout        = nullptr;
+    SearchLineEdit *m_searchLineEdit = nullptr;
+    PushButton *m_addExpertButton    = nullptr;
+    ToolButton *m_detailButton       = nullptr;
+    ToolButton *m_deleteButton       = nullptr;
 
     ExpertInfoWidget *m_expertInfoWidget = nullptr;
     ExpertListWidget *m_expertListWidget = nullptr;

+ 33 - 1
QFD/view/ProjectView.cpp

@@ -1,6 +1,38 @@
-#include "ProjectView.h"
+#include "ProjectView.h"
+
+#include "ProjectListWidget.h"
+
+#include <QBoxLayout>
+#include <QLabel>
 
 ProjectView::ProjectView(QWidget *parent) : QWidget(parent)
 {
+    initialize();
+    initLayout();
+    connectSiganlsAndSlots();
+}
+
+void ProjectView::initialize()
+{
+    m_hBoxLayout     = new QHBoxLayout(this);
+    m_projListWidget = new ProjectListWidget(this);
+    m_projListWidget->setFixedWidth(300);
+    m_projDetailWidget = new QWidget(this);
+    m_projLayout       = new QVBoxLayout();
 
+    m_projNameLabel = new QLabel(this);
+    m_projNameLabel->setText("工程名");
 }
+
+void ProjectView::initLayout()
+{
+    m_hBoxLayout->setMargin(0);
+    m_hBoxLayout->addWidget(m_projListWidget);
+    m_hBoxLayout->addStrut(8);
+    m_hBoxLayout->addWidget(m_projDetailWidget);
+
+    m_projDetailWidget->setLayout(m_projLayout);
+    m_projLayout->addWidget(m_projNameLabel, Qt::AlignLeft);
+}
+
+void ProjectView::connectSiganlsAndSlots() { }

+ 9 - 3
QFD/view/ProjectView.h

@@ -22,13 +22,19 @@ public:
 
 signals:
 
+private:
+    void initialize();
+    void initLayout();
+    void connectSiganlsAndSlots();
+
 private:
     QHBoxLayout *m_hBoxLayout = nullptr;
 
     ProjectListWidget *m_projListWidget = nullptr;
-    QVBoxLayout *m_prioVBoxLayout       = nullptr;
-    QWidget *m_projContentWidget        = nullptr;
-    QLabel *m_projNameLabel             = nullptr;
+    QWidget *m_projDetailWidget         = nullptr;
+
+    QVBoxLayout *m_projLayout = nullptr;
+    QLabel *m_projNameLabel   = nullptr;
 };
 
 #endif  // PROJECTVIEW_H

+ 84 - 1
QFD/widgets/ProjectListWidget.cpp

@@ -1,6 +1,89 @@
-#include "ProjectListWidget.h"
+#include "ProjectListWidget.h"
+
+#include <Widgets/LineEdit.h>
+#include <Widgets/Button.h>
+
+#include <QBoxLayout>
+#include <QListWidget>
+#include <QLabel>
 
 ProjectListWidget::ProjectListWidget(QWidget *parent) : QWidget(parent)
 {
+    initialize();
+    initLayout();
+    connectSiganlsAndSlots();
+    refreshList();
+}
+
+void ProjectListWidget::refreshList()
+{
+    m_projListWidget->clear();
+
+    for (int i = 1; i <= 100; i++) {
+        QListWidgetItem *item = new QListWidgetItem;
+        item->setSizeHint(QSize(200, 60));
+        m_projListWidget->addItem(item);
+
+        QWidget *w = new QWidget();
+        m_projListWidget->setItemWidget(item, w);
+
+        QHBoxLayout *hBox = new QHBoxLayout(w);
+        hBox->setSpacing(0);
+        hBox->setMargin(10);
+
+        QLabel *idx = new QLabel(QString::number(i));
+        idx->setFixedWidth(20);
+        hBox->addWidget(idx);
+        hBox->addSpacing(10);
+        QLabel *name = new QLabel(QString("工程%1").arg(i));
+        hBox->addWidget(name);
+        hBox->addStretch();
+    }
+}
+
+void ProjectListWidget::initialize()
+{
+    QPalette pal(palette());
+    pal.setColor(QPalette::Background, QColor("#f3f3f3"));
+    setAutoFillBackground(true);
+    setPalette(pal);
 
+    m_vBoxLayout     = new QVBoxLayout(this);
+    m_buttonLayout   = new QHBoxLayout();
+    m_searchLineEdit = new LineEdit(this);
+    m_searchLineEdit->setIsClearButtonEnabled(true);
+    m_searchLineEdit->setPlaceholderText("搜索工程");
+    m_renameButton = new ToolButton(NEWFLICON(FluentIcon, EDIT), this);
+    m_renameButton->setToolTip("修改工程名");
+    m_newProjButton = new ToolButton(NEWFLICON(FluentIcon, ADD), this);
+    m_newProjButton->setToolTip("新建工程");
+    m_deleteButton = new ToolButton(NEWFLICON(FluentIcon, DELETE), this);
+    m_deleteButton->setToolTip("删除工程");
+    m_projListWidget = new QListWidget(this);
+
+    m_projListWidget->setAlternatingRowColors(true);
+    m_projListWidget->setStyleSheet("QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);background: rgb(255, 255, "
+                                    "255);alternate-background-color: rgb(244, 244, 255);}");
+
+    setProjButtonsEnabled(false);
+}
+
+void ProjectListWidget::initLayout()
+{
+    m_vBoxLayout->addLayout(m_buttonLayout);
+
+    m_buttonLayout->addWidget(m_searchLineEdit);
+    m_buttonLayout->addWidget(m_newProjButton);
+    m_buttonLayout->addWidget(m_renameButton);
+    m_buttonLayout->addWidget(m_deleteButton);
+
+    m_vBoxLayout->addWidget(m_projListWidget);
+}
+
+void ProjectListWidget::connectSiganlsAndSlots() { }
+
+void ProjectListWidget::setProjButtonsEnabled(bool enabled)
+{
+    m_renameButton->setEnabled(enabled);
+    m_deleteButton->setEnabled(enabled);
 }

+ 29 - 0
QFD/widgets/ProjectListWidget.h

@@ -3,6 +3,16 @@
 
 #include <QWidget>
 
+class PushButton;
+class ToolButton;
+class LineEdit;
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QLabel;
+class QListWidget;
+class QListWidgetItem;
+
 ///
 /// \brief The ProjectListWidget class
 /// 工程列表
@@ -12,7 +22,26 @@ class ProjectListWidget : public QWidget
 public:
     explicit ProjectListWidget(QWidget *parent = nullptr);
 
+    void refreshList();
+
+private:
+    void initialize();
+    void initLayout();
+    void connectSiganlsAndSlots();
+    void setProjButtonsEnabled(bool enabled);
+
 signals:
+
+private:
+    QVBoxLayout *m_vBoxLayout   = nullptr;
+    QHBoxLayout *m_buttonLayout = nullptr;
+
+    LineEdit *m_searchLineEdit  = nullptr;
+    ToolButton *m_renameButton  = nullptr;
+    ToolButton *m_newProjButton = nullptr;
+    ToolButton *m_deleteButton  = nullptr;
+
+    QListWidget *m_projListWidget = nullptr;
 };
 
 #endif  // PROJECTLISTWIDGET_H