Browse Source

Create Proj.

chengxr 1 year ago
parent
commit
2e7d56a809
7 changed files with 226 additions and 5 deletions
  1. 2 0
      QFD/QFD.pro
  2. 2 2
      QFD/main.cpp
  3. 123 0
      QFD/view/CreateProjView.cpp
  4. 52 0
      QFD/view/CreateProjView.h
  5. 35 2
      QFD/view/HomeView.cpp
  6. 11 0
      QFD/view/HomeView.h
  7. 1 1
      QFD/view/MainWindow.cpp

+ 2 - 0
QFD/QFD.pro

@@ -62,6 +62,7 @@ INCLUDEPATH += $$PWD/common
 SOURCES += \
     main.cpp \
     view/AboutView.cpp \
+    view/CreateProjView.cpp \
     view/DataView.cpp \
     view/ExpertView.cpp \
     view/HomeView.cpp \
@@ -74,6 +75,7 @@ SOURCES += \
 
 HEADERS += \
     view/AboutView.h \
+    view/CreateProjView.h \
     view/DataView.h \
     view/ExpertView.h \
     view/HomeView.h \

+ 2 - 2
QFD/main.cpp

@@ -7,8 +7,8 @@ int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
 
-    //  Login l;
-    //  l.show();
+    //    LoginView l;
+    //    l.show();
 
     MainWindow m;
     m.show();

+ 123 - 0
QFD/view/CreateProjView.cpp

@@ -0,0 +1,123 @@
+#include "CreateProjView.h"
+
+#include <Widgets/LineEdit.h>
+#include <Widgets/Button.h>
+#include <Widgets/CheckBox.h>
+
+#include <QGridLayout>
+#include <QLabel>
+
+#include <QDebug>
+
+CreateProjView::CreateProjView(QWidget *parent) : QWidget(parent)
+{
+    initWindow();
+    initialize();
+    initLayout();
+    connectSignalsAndSlots();
+}
+
+const QString CreateProjView::projName() const
+{
+    return m_nameLineEdit->text();
+}
+
+bool CreateProjView::importanceSelected() const
+{
+    return m_importanceCheckBox->isChecked();
+}
+
+bool CreateProjView::schemeSelected() const
+{
+    return m_schemeCheckBox->isChecked();
+}
+
+void CreateProjView::clearInputs()
+{
+    m_nameLineEdit->clear();
+    m_importanceCheckBox->setChecked(false);
+    m_schemeCheckBox->setChecked(false);
+}
+
+void CreateProjView::initWindow()
+{
+    setWindowTitle("新建工程");
+    setWindowFlags(Qt::Window);
+    setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
+    resize(400, 200);
+}
+
+void CreateProjView::initialize()
+{
+    m_gridLayout = new QGridLayout(this);
+    m_nameLabel  = new QLabel(this);
+    m_nameLabel->setText("工程名:");
+    m_typeLabel = new QLabel(this);
+    m_typeLabel->setText("类型(多选):");
+    m_nameLineEdit = new LineEdit(this);
+    m_nameLineEdit->setPlaceholderText("请输入工程名");
+    m_nameLineEdit->setMaximumWidth(500);
+    m_nameLineEdit->setMinimumWidth(300);
+    m_importanceCheckBox = new CheckBox("能力与技术重要度评估", this);
+    m_schemeCheckBox     = new CheckBox("技术方案评估", this);
+    m_createButton       = new PushButton("创建", this);
+    m_createButton->setEnabled(false);
+    m_cancelButton = new PushButton("取消", this);
+}
+
+void CreateProjView::initLayout()
+{
+    m_gridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+    m_gridLayout->setContentsMargins(50, 20, 50, 20);
+    m_gridLayout->addWidget(m_nameLabel, 0, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_nameLineEdit, 0, 1, 1, 5, Qt::AlignLeft);
+
+    m_gridLayout->addWidget(new QWidget(this), 1, 1, 4, 1, Qt::AlignLeft);
+
+    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);
+}
+
+void CreateProjView::connectSignalsAndSlots()
+{
+    connect(m_nameLineEdit, &LineEdit::textChanged, this, &CreateProjView::slotTextChanged);
+    connect(m_importanceCheckBox, &CheckBox::stateChanged, this, &CreateProjView::slotCheckBoxChanged);
+    connect(m_schemeCheckBox, &CheckBox::stateChanged, this, &CreateProjView::slotCheckBoxChanged);
+    connect(m_createButton, &PushButton::clicked, this, &CreateProjView::slotCreateClicked);
+    connect(m_cancelButton, &PushButton::clicked, this, &CreateProjView::slotCancelClicked);
+}
+
+void CreateProjView::updateCreateButtonState()
+{
+    bool nameValid = m_nameLineEdit->text().length() > 0;
+    bool typeValid = m_importanceCheckBox->isChecked() || m_schemeCheckBox->isChecked();
+
+    m_createButton->setEnabled(nameValid && typeValid);
+}
+
+void CreateProjView::slotTextChanged(const QString &text)
+{
+    m_nameLineEdit->setText(text.trimmed());
+    updateCreateButtonState();
+}
+
+void CreateProjView::slotCheckBoxChanged(int)
+{
+    updateCreateButtonState();
+}
+
+void CreateProjView::slotCreateClicked()
+{
+    emit signalCreate();
+}
+
+void CreateProjView::slotCancelClicked()
+{
+    close();
+}

+ 52 - 0
QFD/view/CreateProjView.h

@@ -0,0 +1,52 @@
+#ifndef CREATEPROJVIEW_H
+#define CREATEPROJVIEW_H
+
+#include <QWidget>
+
+class QGridLayout;
+class QLabel;
+class LineEdit;
+class CheckBox;
+class PushButton;
+
+class CreateProjView : public QWidget
+{
+    Q_OBJECT
+public:
+    CreateProjView(QWidget *parent = nullptr);
+
+    const QString projName() const;
+
+    bool importanceSelected() const;
+    bool schemeSelected() const;
+
+    void clearInputs();
+
+signals:
+    void signalCreate();
+
+private:
+    void initWindow();
+    void initialize();
+    void initLayout();
+    void connectSignalsAndSlots();
+    void updateCreateButtonState();
+
+private slots:
+    void slotTextChanged(const QString &text);
+    void slotCheckBoxChanged(int state);
+    void slotCreateClicked();
+    void slotCancelClicked();
+
+private:
+    QGridLayout *m_gridLayout      = nullptr;
+    QLabel *m_nameLabel            = nullptr;
+    QLabel *m_typeLabel            = nullptr;
+    LineEdit *m_nameLineEdit       = nullptr;
+    CheckBox *m_importanceCheckBox = nullptr;
+    CheckBox *m_schemeCheckBox     = nullptr;
+    PushButton *m_createButton     = nullptr;
+    PushButton *m_cancelButton     = nullptr;
+};
+
+#endif  // CREATEPROJVIEW_H

+ 35 - 2
QFD/view/HomeView.cpp

@@ -1,10 +1,16 @@
 #include "HomeView.h"
 
+#include "CreateProjView.h"
+
 #include <Widgets/Button.h>
 #include <Widgets/LineEdit.h>
 
 #include <QBoxLayout>
 #include <QLabel>
+#include <QTableWidget>
+#include <QHeaderView>
+
+#include <QDebug>
 
 HomeView::HomeView(QWidget *parent) : QWidget(parent)
 {
@@ -28,18 +34,45 @@ void HomeView::initialize()
     m_searchLineEdit->setPlaceholderText("搜索工程");
     m_searchLineEdit->setMinimumWidth(300);
     m_createProjPushButton = new PushButton("新建工程", NEWFLICON(FluentIcon, ADD), this);
+
+    m_projTableWidget = new QTableWidget(this);
+    m_projTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
+    m_projTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+    m_projTableWidget->setSelectionMode(QAbstractItemView::NoSelection);
+    m_projTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+    m_projTableWidget->verticalHeader()->setVisible(false);
+    const QStringList headers = { "工程名", "工程类型", "专家信息", "评估状态" };
+    m_projTableWidget->setColumnCount(headers.count());
+    m_projTableWidget->setHorizontalHeaderLabels(headers);
+    m_projTableWidget->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0.073)");
+
+    m_createProjView = new CreateProjView(this);
 }
 
 void HomeView::initLayout()
 {
     m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
-    m_vBoxLayout->setContentsMargins(15, 10, 0, 0);
+    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->addSpacing(15);
+    m_vBoxLayout->addWidget(m_projTableWidget);
 }
 
-void HomeView::connectSignalsAndSlots() { }
+void HomeView::connectSignalsAndSlots()
+{
+    connect(m_createProjPushButton, &PushButton::clicked, this, &HomeView::slotCreateProjClicked);
+}
+
+void HomeView::slotCreateProjClicked()
+{
+    if (m_createProjView->isVisible() == false) {
+        m_createProjView->clearInputs();
+        m_createProjView->show();
+    }
+}

+ 11 - 0
QFD/view/HomeView.h

@@ -3,6 +3,8 @@
 
 #include <QWidget>
 
+class CreateProjView;
+
 class PushButton;
 class SearchLineEdit;
 
@@ -10,6 +12,8 @@ class QVBoxLayout;
 class QHBoxLayout;
 class QLabel;
 
+class QTableWidget;
+
 class HomeView : public QWidget
 {
     Q_OBJECT
@@ -21,12 +25,19 @@ private:
     void initLayout();
     void connectSignalsAndSlots();
 
+private slots:
+    void slotCreateProjClicked();
+
 private:
     QVBoxLayout *m_vBoxLayout          = nullptr;
     QLabel *m_titleLabel               = nullptr;
     QHBoxLayout *m_hBoxLayout          = nullptr;
     SearchLineEdit *m_searchLineEdit   = nullptr;
     PushButton *m_createProjPushButton = nullptr;
+
+    QTableWidget *m_projTableWidget = nullptr;
+
+    CreateProjView *m_createProjView = nullptr;
 };
 
 #endif  // HOMEVIEW_H

+ 1 - 1
QFD/view/MainWindow.cpp

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