|
@@ -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();
|
|
|
+}
|