chengxr 1 éve
szülő
commit
6820581b52
3 módosított fájl, 114 hozzáadás és 69 törlés
  1. 2 1
      QFD/view/HomeView.cpp
  2. 92 57
      QFD/widgets/CreateProjWidget.cpp
  3. 20 11
      QFD/widgets/CreateProjWidget.h

+ 2 - 1
QFD/view/HomeView.cpp

@@ -178,7 +178,8 @@ void HomeView::slotEditProject(ProjectInfo *proj)
 
 void HomeView::slotDeleteProject(ProjectInfo *proj)
 {
-    MessageBox *m = new MessageBox("确认删除?", "删除后无法恢复", this);
+    QString title = "确认删除工程 “" + proj->projectName + "” ?";
+    MessageBox *m = new MessageBox(title, "删除后无法恢复", this);
 
     if (m->exec()) {
         int code = ProjectManager::deleteProject(proj->id);

+ 92 - 57
QFD/widgets/CreateProjWidget.cpp

@@ -39,7 +39,7 @@ void CreateProjWidget::setMode(CreateProjWidget::Mode mode)
     }
     case Update: {
         setWindowTitle("修改项目");
-        m_confirm->setText("修改");
+        m_confirm->setText("保存");
         break;
     }
     case Info: {
@@ -51,14 +51,14 @@ void CreateProjWidget::setMode(CreateProjWidget::Mode mode)
     bool c  = (mode == Create);
     bool cu = (mode == Update || mode == Create);
 
-    m_taskName->setEnabled(cu);
-    m_evalTime->setEnabled(c);
-    m_evalPurpose->setEnabled(cu);
-    m_evalUnit->setEnabled(cu);
-    m_evalCrew->setEnabled(cu);
+    m_task->setEnabled(cu);
+    m_time->setEnabled(c);
+    m_purpose->setEnabled(cu);
+    m_unit->setEnabled(cu);
+    m_crew->setEnabled(cu);
     m_rank->setEnabled(cu);
     m_note->setEnabled(cu);
-    m_name->setEnabled(cu);
+    m_proj->setEnabled(cu);
     m_type1->setEnabled(c);
     m_type2->setEnabled(c);
     m_type3->setEnabled(c);
@@ -69,15 +69,15 @@ void CreateProjWidget::setMode(CreateProjWidget::Mode mode)
 
 void CreateProjWidget::resetInputs()
 {
-    m_taskName->clear();
-    m_evalTime->setDateTime(QDateTime::currentDateTime());
-    m_evalPurpose->clear();
-    m_evalUnit->clear();
-    m_evalCrew->clear();
+    m_task->clear();
+    m_time->setDateTime(QDateTime::currentDateTime());
+    m_purpose->clear();
+    m_unit->clear();
+    m_crew->clear();
     m_rank->clear();
     m_note->clear();
 
-    m_name->clear();
+    m_proj->clear();
     m_type1->setChecked(false);
     m_type2->setChecked(false);
     m_type3->setChecked(false);
@@ -91,15 +91,15 @@ ProjectInfo *CreateProjWidget::projInfo() const
 ProjectInfo CreateProjWidget::editedProjInfo() const
 {
     ProjectInfo proj;
-    proj.taskName          = m_taskName->text();
-    proj.estimateTime      = QString::number(m_evalTime->dateTime().toTime_t());
-    proj.estimateObjective = m_evalPurpose->text();
-    proj.estimateDept      = m_evalUnit->text();
-    proj.estimatePerson    = m_evalCrew->text();
+    proj.taskName          = m_task->text();
+    proj.estimateTime      = QString::number(m_time->dateTime().toTime_t());
+    proj.estimateObjective = m_purpose->text();
+    proj.estimateDept      = m_unit->text();
+    proj.estimatePerson    = m_crew->text();
     proj.positionalTitles  = m_rank->text();
     proj.remark            = m_note->toPlainText();
 
-    proj.projectName = m_name->text();
+    proj.projectName = m_proj->text();
 
     ProjectManager::EvalTypes t;
     t |= (m_type1->isChecked() ? ProjectManager::Requirements : ProjectManager::None);
@@ -115,21 +115,21 @@ ProjectInfo CreateProjWidget::editedProjInfo() const
 void CreateProjWidget::setProjectInfo(ProjectInfo *info)
 {
     m_projInfo = info;
-    m_taskName->setText(info->taskName);
+    m_task->setText(info->taskName);
     QDateTime time = QDateTime::fromTime_t(info->estimateTime.toUInt());
-    m_evalTime->setDateTime(time);
-    m_evalPurpose->setText(info->estimateObjective);
-    m_evalUnit->setText(info->estimateDept);
-    m_evalCrew->setText(info->estimatePerson);
+    m_time->setDateTime(time);
+    m_purpose->setText(info->estimateObjective);
+    m_unit->setText(info->estimateDept);
+    m_crew->setText(info->estimatePerson);
     m_rank->setText(info->positionalTitles);
     m_note->setPlainText(info->remark);
-    m_name->setText(info->projectName);
+    m_proj->setText(info->projectName);
 
     ProjectManager::EvalTypes types = ProjectManager::evalTypes(*info);
 
     m_type1->setChecked((types & ProjectManager::Requirements) == ProjectManager::Requirements);
-    m_type2->setChecked((types & ProjectManager::Requirements) == ProjectManager::SchemeOptimization);
-    m_type3->setChecked((types & ProjectManager::Requirements) == ProjectManager::OverallEfficiency);
+    m_type2->setChecked((types & ProjectManager::SchemeOptimization) == ProjectManager::SchemeOptimization);
+    m_type3->setChecked((types & ProjectManager::OverallEfficiency) == ProjectManager::OverallEfficiency);
 }
 
 void CreateProjWidget::initWindow()
@@ -148,28 +148,43 @@ void CreateProjWidget::initWidgets()
 {
     m_summary = new QLabel(this);
     m_summary->setText("项目概要:");
-    m_taskName = new LineEdit(this);
-    m_taskName->setPlaceholderText("任务名称");
-    m_evalTime    = new DateTimeEdit(this);
-    m_evalPurpose = new LineEdit(this);
-    m_evalPurpose->setPlaceholderText("评估目的");
-    m_evalUnit = new LineEdit(this);
-    m_evalUnit->setPlaceholderText("评估单位");
-    m_evalCrew = new LineEdit(this);
-    m_evalCrew->setPlaceholderText("评估人员");
+    m_task = new LineEdit(this);
+    m_task->setPlaceholderText("任务名称");
+    m_time    = new DateTimeEdit(this);
+    m_purpose = new LineEdit(this);
+    m_purpose->setPlaceholderText("评估目的");
+    m_unit = new LineEdit(this);
+    m_unit->setPlaceholderText("评估单位");
+    m_crew = new LineEdit(this);
+    m_crew->setPlaceholderText("评估人员");
     m_rank = new LineEdit(this);
     m_rank->setPlaceholderText("职称");
     m_note = new TextEdit(this);
     m_note->setPlaceholderText("备注");
 
+    m_taskLabel = new QLabel(this);
+    m_taskLabel->setText("任务名称:");
+    m_timeLabel = new QLabel(this);
+    m_timeLabel->setText("评估时间:");
+    m_purposeLabel = new QLabel(this);
+    m_purposeLabel->setText("评估目的:");
+    m_unitLabel = new QLabel(this);
+    m_unitLabel->setText("评估单位:");
+    m_crewLabel = new QLabel(this);
+    m_crewLabel->setText("评估人员:");
+    m_rankLabel = new QLabel(this);
+    m_rankLabel->setText("职称:");
+    m_noteLabel = new QLabel(this);
+    m_noteLabel->setText("备注:");
+
     m_separator = new QWidget(this);
     m_separator->setFixedHeight(1);
     m_separator->setStyleSheet("background-color:#dddddd");
 
-    m_nameLabel = new QLabel(this);
-    m_nameLabel->setText("项目名称:");
-    m_name = new LineEdit(this);
-    m_name->setPlaceholderText("请输入项目名称");
+    m_projLabel = new QLabel(this);
+    m_projLabel->setText("项目名称:");
+    m_proj = new LineEdit(this);
+    m_proj->setPlaceholderText("请输入项目名称");
     m_typeLabel = new QLabel(this);
     m_typeLabel->setText("评估类型:");
     m_type1 = new CheckBox(EngineerInfo::nameOfEvalType(EngineerInfo::Requirements), this);
@@ -182,10 +197,13 @@ void CreateProjWidget::initWidgets()
 
 void CreateProjWidget::initLayout()
 {
+    int minEditWidth = 240;
+
     // 总体布局
     m_layout = new QVBoxLayout(this);
     m_layout->setContentsMargins(50, 20, 50, 20);
-    m_summaryLayout = new QVBoxLayout();
+    m_layout->addWidget(m_summary);
+    m_summaryLayout = new QGridLayout();
     m_layout->addLayout(m_summaryLayout);
     m_layout->addWidget(m_separator);
     m_projLayout = new QGridLayout();
@@ -194,19 +212,36 @@ void CreateProjWidget::initLayout()
     m_layout->addLayout(m_btnLayout);
 
     // 项目概要布局
-    m_summaryLayout->addWidget(m_summary);
-    m_summaryLayout->addWidget(m_taskName);
-    m_summaryLayout->addWidget(m_evalTime);
-    m_summaryLayout->addWidget(m_evalPurpose);
-    m_summaryLayout->addWidget(m_evalUnit);
-    m_summaryLayout->addWidget(m_evalCrew);
-    m_summaryLayout->addWidget(m_rank);
-    m_summaryLayout->addWidget(m_note);
+    m_task->setMinimumWidth(minEditWidth);
+    m_time->setMinimumWidth(minEditWidth);
+    m_purpose->setMinimumWidth(minEditWidth);
+    m_unit->setMinimumWidth(minEditWidth);
+    m_crew->setMinimumWidth(minEditWidth);
+    m_rank->setMinimumWidth(minEditWidth);
+    m_note->setMinimumWidth(minEditWidth);
+
+    m_summaryLayout->setMargin(10);
+    m_summaryLayout->addWidget(m_taskLabel, 1, 0, 1, 1, Qt::AlignRight);
+    m_summaryLayout->addWidget(m_timeLabel, 2, 0, 1, 1, Qt::AlignRight);
+    m_summaryLayout->addWidget(m_purposeLabel, 3, 0, 1, 1, Qt::AlignRight);
+    m_summaryLayout->addWidget(m_unitLabel, 4, 0, 1, 1, Qt::AlignRight);
+    m_summaryLayout->addWidget(m_crewLabel, 5, 0, 1, 1, Qt::AlignRight);
+    m_summaryLayout->addWidget(m_rankLabel, 6, 0, 1, 1, Qt::AlignRight);
+    m_summaryLayout->addWidget(m_noteLabel, 7, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
+
+    m_summaryLayout->addWidget(m_task, 1, 1, 1, 1, Qt::AlignLeft);
+    m_summaryLayout->addWidget(m_time, 2, 1, 1, 1, Qt::AlignLeft);
+    m_summaryLayout->addWidget(m_purpose, 3, 1, 1, 1, Qt::AlignLeft);
+    m_summaryLayout->addWidget(m_unit, 4, 1, 1, 1, Qt::AlignLeft);
+    m_summaryLayout->addWidget(m_crew, 5, 1, 1, 1, Qt::AlignLeft);
+    m_summaryLayout->addWidget(m_rank, 6, 1, 1, 1, Qt::AlignLeft);
+    m_summaryLayout->addWidget(m_note, 7, 1, 1, 1, Qt::AlignLeft);
 
     // 项目信息布局
-    m_projLayout->addWidget(m_nameLabel, 0, 0, 1, 1, Qt::AlignLeft);
-    m_projLayout->addWidget(m_name, 0, 1, 1, 5, Qt::AlignLeft);
-    m_name->setMinimumWidth(200);
+    m_projLayout->setMargin(10);
+    m_proj->setMinimumWidth(minEditWidth);
+    m_projLayout->addWidget(m_projLabel, 0, 0, 1, 1, Qt::AlignLeft);
+    m_projLayout->addWidget(m_proj, 0, 1, 1, 5, Qt::AlignLeft);
     m_projLayout->addWidget(new QWidget(this), 1, 1, 4, 1, Qt::AlignLeft);
     m_projLayout->addWidget(m_typeLabel, 4, 0, 1, 1, Qt::AlignLeft);
     m_projLayout->addWidget(m_type1, 4, 1, 1, 5, Qt::AlignLeft);
@@ -221,13 +256,13 @@ void CreateProjWidget::initLayout()
 
 void CreateProjWidget::connectSignalsAndSlots()
 {
-    connect(m_taskName, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
-    connect(m_evalPurpose, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
-    connect(m_evalUnit, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
-    connect(m_evalCrew, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
+    connect(m_task, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
+    connect(m_purpose, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
+    connect(m_unit, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
+    connect(m_crew, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
     connect(m_rank, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
     connect(m_note, &TextEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
-    connect(m_name, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
+    connect(m_proj, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
     connect(m_type1, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);
     connect(m_type2, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);
     connect(m_type3, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);

+ 20 - 11
QFD/widgets/CreateProjWidget.h

@@ -61,20 +61,29 @@ private:
     ProjectInfo *m_projInfo = nullptr;
 
     // 项目概要
-    QLabel *m_summary        = nullptr;  // 项目概要
-    LineEdit *m_taskName     = nullptr;  // 任务名称
-    DateTimeEdit *m_evalTime = nullptr;  // 评估时间
-    LineEdit *m_evalPurpose  = nullptr;  // 评估目的
-    LineEdit *m_evalUnit     = nullptr;  // 评估单位
-    LineEdit *m_evalCrew     = nullptr;  // 评估人员
-    LineEdit *m_rank         = nullptr;  // 职称
-    TextEdit *m_note         = nullptr;  // 备注
+
+    QLabel *m_summary    = nullptr;  // 项目概要
+    LineEdit *m_task     = nullptr;  // 任务名称
+    DateTimeEdit *m_time = nullptr;  // 评估时间
+    LineEdit *m_purpose  = nullptr;  // 评估目的
+    LineEdit *m_unit     = nullptr;  // 评估单位
+    LineEdit *m_crew     = nullptr;  // 评估人员
+    LineEdit *m_rank     = nullptr;  // 职称
+    TextEdit *m_note     = nullptr;  // 备注
+
+    QLabel *m_taskLabel    = nullptr;
+    QLabel *m_timeLabel    = nullptr;
+    QLabel *m_purposeLabel = nullptr;
+    QLabel *m_unitLabel    = nullptr;
+    QLabel *m_crewLabel    = nullptr;
+    QLabel *m_rankLabel    = nullptr;
+    QLabel *m_noteLabel    = nullptr;
 
     QWidget *m_separator = nullptr;  // 分隔线
 
     // 项目信息
-    QLabel *m_nameLabel = nullptr;
-    LineEdit *m_name    = nullptr;
+    QLabel *m_projLabel = nullptr;
+    LineEdit *m_proj    = nullptr;
     QLabel *m_typeLabel = nullptr;
     CheckBox *m_type1   = nullptr;
     CheckBox *m_type2   = nullptr;
@@ -86,7 +95,7 @@ private:
 
     // 布局
     QVBoxLayout *m_layout        = nullptr;
-    QVBoxLayout *m_summaryLayout = nullptr;
+    QGridLayout *m_summaryLayout = nullptr;
     QGridLayout *m_projLayout    = nullptr;
     QHBoxLayout *m_btnLayout     = nullptr;
 };