Browse Source

工程列表,树结构
新建工程

chengxr 1 year ago
parent
commit
7d7abe1010

+ 58 - 1
QFD/view/EvaluateView.cpp

@@ -1,3 +1,60 @@
 #include "EvaluateView.h"
 
-EvaluateView::EvaluateView(QWidget *parent) : QWidget(parent) { }
+#include "ProjectListWidget.h"
+#include "RenameWidget.h"
+
+#include <Widgets/Button.h>
+#include <Widgets/LineEdit.h>
+
+#include <QBoxLayout>
+#include <QLabel>
+
+EvaluateView::EvaluateView(QWidget *parent) : QWidget(parent)
+{
+    initialize();
+    initLayout();
+    connectSiganlsAndSlots();
+}
+
+void EvaluateView::initialize()
+{
+    m_hBoxLayout = new QHBoxLayout(this);
+
+    m_listWidget = new QWidget(this);
+    m_listWidget->setFixedWidth(260);
+
+    QPalette pal(m_listWidget->palette());
+    pal.setColor(QPalette::Background, QColor("#f3f3f3"));
+    m_listWidget->setAutoFillBackground(true);
+    m_listWidget->setPalette(pal);
+
+    m_listLayout = new QVBoxLayout(m_listWidget);
+
+    m_searchLineEdit = new LineEdit(this);
+    m_searchLineEdit->setIsClearButtonEnabled(true);
+    m_searchLineEdit->setPlaceholderText("搜索工程");
+
+    m_projListWidget   = new ProjectListWidget(this);
+    m_projDetailWidget = new QWidget(this);
+    m_projLayout       = new QVBoxLayout();
+
+    m_projNameLabel = new QLabel(this);
+    m_projNameLabel->setText("工程名");
+}
+
+void EvaluateView::initLayout()
+{
+    m_hBoxLayout->setMargin(0);
+
+    m_hBoxLayout->addWidget(m_listWidget);
+
+    m_listLayout->addWidget(m_searchLineEdit);
+    m_listLayout->addWidget(m_projListWidget);
+
+    m_hBoxLayout->addWidget(m_projDetailWidget);
+
+    m_projDetailWidget->setLayout(m_projLayout);
+    m_projLayout->addWidget(m_projNameLabel, Qt::AlignTop);
+}
+
+void EvaluateView::connectSiganlsAndSlots() { }

+ 26 - 2
QFD/view/EvaluateView.h

@@ -3,8 +3,15 @@
 
 #include <QWidget>
 
-///
-/// \brief The EvaluateView class
+class ProjectListWidget;
+
+class LineEdit;
+class ToolButton;
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QLabel;
+
 /// 评估数据页面
 class EvaluateView : public QWidget
 {
@@ -13,6 +20,23 @@ public:
     explicit EvaluateView(QWidget *parent = nullptr);
 
 signals:
+
+private:
+    void initialize();
+    void initLayout();
+    void connectSiganlsAndSlots();
+
+private:
+    QHBoxLayout *m_hBoxLayout = nullptr;
+
+    QWidget *m_listWidget               = nullptr;
+    QVBoxLayout *m_listLayout           = nullptr;
+    LineEdit *m_searchLineEdit          = nullptr;
+    ProjectListWidget *m_projListWidget = nullptr;
+
+    QWidget *m_projDetailWidget = nullptr;
+    QVBoxLayout *m_projLayout   = nullptr;
+    QLabel *m_projNameLabel     = nullptr;
 };
 
 #endif  // EVALUATEVIEW_H

+ 1 - 1
QFD/view/MainWindow.cpp

@@ -104,7 +104,7 @@ void MainWindow::initialize()
 
 void MainWindow::initWindow()
 {
-    setMinimumSize(QSize(1000, 800));
+    setMinimumSize(QSize(1200, 800));
 
     QFramelessHelper *helper = new QFramelessHelper(this);
     helper->setTitleBar(m_titleBar);

+ 25 - 12
QFD/widgets/CreateProjWidget.cpp

@@ -44,12 +44,13 @@ void CreateProjWidget::initWindow()
     setWindowTitle("新建工程");
     setWindowFlags(Qt::Window);
     setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
-    resize(400, 200);
+    resize(400, 250);
 }
 
 void CreateProjWidget::initialize()
 {
-    m_gridLayout = new QGridLayout(this);
+    m_vBoxLayout = new QVBoxLayout(this);
+    m_gridLayout = new QGridLayout();
     m_nameLabel  = new QLabel(this);
     m_nameLabel->setText("工程名:");
     m_typeLabel = new QLabel(this);
@@ -59,16 +60,22 @@ void CreateProjWidget::initialize()
     m_nameLineEdit->setMaximumWidth(500);
     m_nameLineEdit->setMinimumWidth(300);
     m_importanceCheckBox = new CheckBox("能力与技术重要度评估", this);
-    m_schemeCheckBox     = new CheckBox("技术方案评估", this);
-    m_createButton       = new PushButton("创建", this);
+    m_capaCheckBox       = new CheckBox("能力重要度评估指标体系", this);
+    m_capaCheckBox->setEnabled(false);
+    m_techCheckBox = new CheckBox("技术措施重要度评估对象", this);
+    m_techCheckBox->setEnabled(false);
+    m_schemeCheckBox = new CheckBox("技术方案评估", this);
+    m_buttonLayout   = new QHBoxLayout();
+    m_createButton   = new PushButton("创建", this);
     m_createButton->setEnabled(false);
     m_cancelButton = new PushButton("取消", this);
 }
 
 void CreateProjWidget::initLayout()
 {
-    m_gridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
-    m_gridLayout->setContentsMargins(50, 20, 50, 20);
+    m_vBoxLayout->setContentsMargins(50, 20, 50, 20);
+
+    m_vBoxLayout->addLayout(m_gridLayout);
     m_gridLayout->addWidget(m_nameLabel, 0, 0, 1, 1, Qt::AlignRight);
     m_gridLayout->addWidget(m_nameLineEdit, 0, 1, 1, 5, Qt::AlignLeft);
 
@@ -76,12 +83,16 @@ void CreateProjWidget::initLayout()
 
     m_gridLayout->addWidget(m_typeLabel, 4, 0, 1, 1, Qt::AlignRight);
     m_gridLayout->addWidget(m_importanceCheckBox, 4, 1, 1, 5, Qt::AlignLeft);
-    m_gridLayout->addWidget(m_schemeCheckBox, 5, 1, 1, 5, Qt::AlignLeft);
-
-    m_gridLayout->addWidget(new QWidget(this), 6, 1, 4, 1, Qt::AlignLeft);
-
-    m_gridLayout->addWidget(m_createButton, 10, 4, 1, 1, Qt::AlignLeft);
-    m_gridLayout->addWidget(m_cancelButton, 10, 5, 1, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_capaCheckBox, 5, 2, 1, 7, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_techCheckBox, 6, 2, 1, 7, Qt::AlignLeft);
+    m_gridLayout->addWidget(new QWidget(this), 7, 1, 4, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_schemeCheckBox, 8, 1, 1, 5, Qt::AlignLeft);
+
+    m_vBoxLayout->addStretch();
+    m_vBoxLayout->addLayout(m_buttonLayout);
+    m_buttonLayout->addStretch();
+    m_buttonLayout->addWidget(m_createButton);
+    m_buttonLayout->addWidget(m_cancelButton);
 }
 
 void CreateProjWidget::connectSignalsAndSlots()
@@ -109,6 +120,8 @@ void CreateProjWidget::slotTextChanged(const QString &text)
 
 void CreateProjWidget::slotCheckBoxChanged(int)
 {
+    m_capaCheckBox->setChecked(m_importanceCheckBox->isChecked());
+    m_techCheckBox->setChecked(m_importanceCheckBox->isChecked());
     updateCreateButtonState();
 }
 

+ 9 - 2
QFD/widgets/CreateProjWidget.h

@@ -3,6 +3,8 @@
 
 #include <QWidget>
 
+class QVBoxLayout;
+class QHBoxLayout;
 class QGridLayout;
 class QLabel;
 class LineEdit;
@@ -40,14 +42,19 @@ private slots:
     void slotCancelClicked();
 
 private:
+    QVBoxLayout *m_vBoxLayout      = nullptr;
     QGridLayout *m_gridLayout      = nullptr;
     QLabel *m_nameLabel            = nullptr;
     QLabel *m_typeLabel            = nullptr;
     LineEdit *m_nameLineEdit       = nullptr;
     CheckBox *m_importanceCheckBox = nullptr;
+    CheckBox *m_capaCheckBox       = nullptr;
+    CheckBox *m_techCheckBox       = nullptr;
     CheckBox *m_schemeCheckBox     = nullptr;
-    PushButton *m_createButton     = nullptr;
-    PushButton *m_cancelButton     = nullptr;
+
+    QHBoxLayout *m_buttonLayout = nullptr;
+    PushButton *m_createButton  = nullptr;
+    PushButton *m_cancelButton  = nullptr;
 };
 
 #endif  // CREATEPROJWIDGET_H

+ 37 - 21
QFD/widgets/ProjectListWidget.cpp

@@ -2,6 +2,7 @@
 
 #include <Widgets/LineEdit.h>
 #include <Widgets/Button.h>
+#include <Widgets/TreeView.h>
 
 #include <QBoxLayout>
 #include <QListWidget>
@@ -19,49 +20,64 @@ ProjectListWidget::ProjectListWidget(QWidget *parent) : QWidget(parent)
 
 void ProjectListWidget::refreshList()
 {
-    m_listWidget->clear();
 
-    for (int i = 1; i <= 100; i++) {
-        QListWidgetItem *item = new QListWidgetItem;
-        item->setSizeHint(QSize(200, 80));
-        m_listWidget->addItem(item);
-
-        ProjectListItemWidget *w = new ProjectListItemWidget();
-        w->setIndex(i);
-        w->setName(QString("工程%1").arg(i));
-        m_listWidget->setItemWidget(item, w);
+    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_treeWidget->expandAll();
+
+    return;
+    //    m_listWidget->clear();
+
+    //    for (int i = 1; i <= 100; i++) {
+    //        QListWidgetItem *item = new QListWidgetItem;
+    //        item->setSizeHint(QSize(200, 80));
+    //        m_listWidget->addItem(item);
+
+    //        ProjectListItemWidget *w = new ProjectListItemWidget();
+    //        w->setIndex(i);
+    //        w->setName(QString("工程%1").arg(i));
+    //        m_listWidget->setItemWidget(item, w);
+    //    }
 }
 
 void ProjectListWidget::initialize()
 {
     QPalette pal(palette());
-    pal.setColor(QPalette::Background, QColor("#f3f3f3"));
+    pal.setColor(QPalette::Background, QColor("#eeeeee"));
     setAutoFillBackground(true);
     setPalette(pal);
 
     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_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);
 }
 
 void ProjectListWidget::initLayout()
 {
     m_vBoxLayout->setMargin(0);
-    m_vBoxLayout->addWidget(m_listWidget);
+    //    m_vBoxLayout->addWidget(m_listWidget);
+    m_vBoxLayout->addWidget(m_treeWidget);
 }
 
 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)

+ 3 - 1
QFD/widgets/ProjectListWidget.h

@@ -6,6 +6,7 @@
 class PushButton;
 class ToolButton;
 class LineEdit;
+class TreeWidget;
 
 class QVBoxLayout;
 class QHBoxLayout;
@@ -66,7 +67,8 @@ signals:
 
 private:
     QVBoxLayout *m_vBoxLayout = nullptr;
-    QListWidget *m_listWidget = nullptr;
+    //    QListWidget *m_listWidget = nullptr;
+    TreeWidget *m_treeWidget = nullptr;
 };
 
 #endif  // PROJECTLISTWIDGET_H

+ 4 - 3
QFD/widgets/RenameWidget.cpp

@@ -6,7 +6,7 @@
 #include <QBoxLayout>
 #include <QLabel>
 
-RenameWidget::RenameWidget(QWidget *parent) : QWidget(parent)
+RenameWidget::RenameWidget(QWidget *parent) : QDialog(parent)
 {
     initWindow();
     initialize();
@@ -22,8 +22,9 @@ void RenameWidget::clearInputs()
 void RenameWidget::initWindow()
 {
     setWindowTitle("修改工程名称");
-    setWindowFlags(Qt::Window);
-    setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
+    setModal(true);
+    setWindowFlags(Qt::Dialog);
+    setWindowFlag(Qt::WindowContextHelpButtonHint, false);
     resize(350, 180);
 }
 

+ 2 - 2
QFD/widgets/RenameWidget.h

@@ -1,7 +1,7 @@
 #ifndef RENAMEWIDGET_H
 #define RENAMEWIDGET_H
 
-#include <QWidget>
+#include <QDialog>
 
 class LineEdit;
 class PushButton;
@@ -10,7 +10,7 @@ class QHBoxLayout;
 class QVBoxLayout;
 class QLabel;
 
-class RenameWidget : public QWidget
+class RenameWidget : public QDialog
 {
     Q_OBJECT
 public: