123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- #include "CreateProjWidget.h"
- #include <dbService/ClassSet.h>
- #include <Widgets/LineEdit.h>
- #include <Widgets/Button.h>
- #include <Widgets/CheckBox.h>
- #include <QGridLayout>
- #include <QLabel>
- #include <QDebug>
- CreateProjWidget::CreateProjWidget(QWidget *parent) : QDialog(parent)
- {
- initWindow();
- initialize();
- initLayout();
- connectSignalsAndSlots();
- }
- const QString CreateProjWidget::projName() const
- {
- return m_nameLineEdit->text();
- }
- bool CreateProjWidget::importanceSelected() const
- {
- return m_importanceEvalCheckBox->isChecked();
- }
- bool CreateProjWidget::schemeSelected() const
- {
- return m_schemeEvalCheckBox->isChecked();
- }
- void CreateProjWidget::clearInputs()
- {
- m_nameLineEdit->clear();
- m_importanceEvalCheckBox->setChecked(false);
- m_schemeEvalCheckBox->setChecked(false);
- }
- void CreateProjWidget::initWindow()
- {
- setWindowTitle("新建工程");
- // setWindowFlags(Qt::Window);
- // setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
- setModal(true);
- setWindowFlags(Qt::Dialog);
- setWindowFlag(Qt::WindowContextHelpButtonHint, false);
- resize(400, 300);
- }
- void CreateProjWidget::initialize()
- {
- m_vBoxLayout = new QVBoxLayout(this);
- m_gridLayout = new QGridLayout();
- 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_importanceEvalCheckBox = new CheckBox(EngineerInfo::nameOFEvalType(EngineerInfo::Importance), this);
- m_capaIndexCheckBox = new CheckBox(EngineerInfo::nameOFIndexType(EngineerInfo::Capability), this);
- m_capaIndexCheckBox->setEnabled(false);
- m_techIndexCheckBox = new CheckBox(EngineerInfo::nameOFIndexType(EngineerInfo::TechMessaures), this);
- m_techIndexCheckBox->setEnabled(false);
- m_schemeEvalCheckBox = new CheckBox(EngineerInfo::nameOFEvalType(EngineerInfo::TechSchema), this);
- m_schemeIndexCheckBox = new CheckBox(EngineerInfo::nameOFIndexType(EngineerInfo::SchemaEval), this);
- m_schemeIndexCheckBox->setEnabled(false);
- m_buttonLayout = new QHBoxLayout();
- m_createButton = new PushButton("创建", this);
- m_createButton->setEnabled(false);
- m_cancelButton = new PushButton("取消", this);
- }
- void CreateProjWidget::initLayout()
- {
- 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);
- 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_importanceEvalCheckBox, 4, 1, 1, 5, Qt::AlignLeft);
- m_gridLayout->addWidget(m_capaIndexCheckBox, 5, 2, 1, 7, Qt::AlignLeft);
- m_gridLayout->addWidget(m_techIndexCheckBox, 6, 2, 1, 7, Qt::AlignLeft);
- m_gridLayout->addWidget(new QWidget(this), 7, 1, 4, 1, Qt::AlignLeft);
- m_gridLayout->addWidget(m_schemeEvalCheckBox, 8, 1, 1, 5, Qt::AlignLeft);
- m_gridLayout->addWidget(m_schemeIndexCheckBox, 9, 2, 1, 7, 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()
- {
- connect(m_nameLineEdit, &LineEdit::textChanged, this, &CreateProjWidget::slotTextChanged);
- connect(m_importanceEvalCheckBox, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);
- connect(m_schemeEvalCheckBox, &CheckBox::stateChanged, this, &CreateProjWidget::slotCheckBoxChanged);
- connect(m_createButton, &PushButton::clicked, this, &CreateProjWidget::slotCreateClicked);
- connect(m_cancelButton, &PushButton::clicked, this, &CreateProjWidget::slotCancelClicked);
- }
- void CreateProjWidget::updateCreateButtonState()
- {
- bool nameValid = m_nameLineEdit->text().length() > 0;
- bool typeValid = m_importanceEvalCheckBox->isChecked() || m_schemeEvalCheckBox->isChecked();
- m_createButton->setEnabled(nameValid && typeValid);
- }
- void CreateProjWidget::slotTextChanged(const QString &text)
- {
- m_nameLineEdit->setText(text.trimmed());
- updateCreateButtonState();
- }
- void CreateProjWidget::slotCheckBoxChanged(int)
- {
- m_capaIndexCheckBox->setChecked(m_importanceEvalCheckBox->isChecked());
- m_techIndexCheckBox->setChecked(m_importanceEvalCheckBox->isChecked());
- m_schemeIndexCheckBox->setChecked(m_schemeEvalCheckBox->isChecked());
- updateCreateButtonState();
- }
- void CreateProjWidget::slotCreateClicked()
- {
- emit signalCreate();
- close();
- }
- void CreateProjWidget::slotCancelClicked()
- {
- close();
- }
|