chengxr 1 year ago
parent
commit
e53187bf3a
2 changed files with 21 additions and 3 deletions
  1. 19 3
      QFD/widgets/CreateProjWidget.cpp
  2. 2 0
      QFD/widgets/CreateProjWidget.h

+ 19 - 3
QFD/widgets/CreateProjWidget.cpp

@@ -50,6 +50,7 @@ void CreateProjWidget::setMode(CreateProjWidget::Mode mode)
 
     bool c  = (mode == Create);
     bool cu = (mode == Update || mode == Create);
+    bool i  = (mode == Info);
 
     m_task->setEnabled(cu);
     m_time->setEnabled(c);
@@ -63,6 +64,7 @@ void CreateProjWidget::setMode(CreateProjWidget::Mode mode)
     m_type2->setEnabled(c);
     m_type3->setEnabled(c);
 
+    m_edit->setVisible(i);
     m_confirm->setVisible(cu);
     m_cancel->setVisible(cu);
 }
@@ -141,7 +143,7 @@ void CreateProjWidget::initWindow()
     setModal(true);
     setWindowFlags(Qt::Dialog);
     setWindowFlag(Qt::WindowContextHelpButtonHint, false);
-    resize(400, 600);
+    setFixedSize(400, 600);
 }
 
 void CreateProjWidget::initWidgets()
@@ -191,13 +193,14 @@ void CreateProjWidget::initWidgets()
     m_type2 = new CheckBox(EngineerInfo::nameOfEvalType(EngineerInfo::SchemeOptimization), this);
     m_type3 = new CheckBox(EngineerInfo::nameOfEvalType(EngineerInfo::OverallEfficiency), this);
 
+    m_edit    = new PushButton("修改", this);
     m_confirm = new PushButton("创建", this);
     m_cancel  = new PushButton("取消", this);
 }
 
 void CreateProjWidget::initLayout()
 {
-    int minEditWidth = 240;
+    int minEditWidth = 220;
 
     // 总体布局
     m_layout = new QVBoxLayout(this);
@@ -219,6 +222,7 @@ void CreateProjWidget::initLayout()
     m_crew->setMinimumWidth(minEditWidth);
     m_rank->setMinimumWidth(minEditWidth);
     m_note->setMinimumWidth(minEditWidth);
+    m_noteLabel->setContentsMargins(0, 10, 0, 10);
 
     m_summaryLayout->setMargin(10);
     m_summaryLayout->addWidget(m_taskLabel, 1, 0, 1, 1, Qt::AlignRight);
@@ -250,6 +254,7 @@ void CreateProjWidget::initLayout()
 
     // 按钮布局
     m_btnLayout->addStretch();
+    m_btnLayout->addWidget(m_edit);
     m_btnLayout->addWidget(m_confirm);
     m_btnLayout->addWidget(m_cancel);
 }
@@ -266,6 +271,7 @@ void CreateProjWidget::connectSignalsAndSlots()
     connect(m_type1, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);
     connect(m_type2, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);
     connect(m_type3, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);
+    connect(m_edit, &PushButton::clicked, this, &CreateProjWidget::slotEditClicked);
     connect(m_confirm, &PushButton::clicked, this, &CreateProjWidget::slotCreateClicked);
     connect(m_cancel, &PushButton::clicked, this, &CreateProjWidget::slotCancelClicked);
 }
@@ -289,6 +295,11 @@ void CreateProjWidget::slotTextChanged()
 
 void CreateProjWidget::slotCheckBoxChanged() { }
 
+void CreateProjWidget::slotEditClicked()
+{
+    setMode(Update);
+}
+
 void CreateProjWidget::slotCreateClicked()
 {
     ProjectInfo p = editedProjInfo();
@@ -300,5 +311,10 @@ void CreateProjWidget::slotCreateClicked()
 
 void CreateProjWidget::slotCancelClicked()
 {
-    close();
+    if (m_mode == Update) {
+        setMode(Info);
+        setProjectInfo(m_projInfo);
+    } else {
+        close();
+    }
 }

+ 2 - 0
QFD/widgets/CreateProjWidget.h

@@ -52,6 +52,7 @@ private:
 private slots:
     void slotTextChanged();
     void slotCheckBoxChanged();
+    void slotEditClicked();
     void slotCreateClicked();
     void slotCancelClicked();
 
@@ -90,6 +91,7 @@ private:
     CheckBox *m_type3   = nullptr;
 
     // 按钮
+    PushButton *m_edit    = nullptr;
     PushButton *m_confirm = nullptr;
     PushButton *m_cancel  = nullptr;