|
@@ -1,3 +1,103 @@
|
|
|
#include "EditNodeWidget.h"
|
|
|
|
|
|
-EditNodeWidget::EditNodeWidget(CNodeData n, QWidget *parent) { }
|
|
|
+#include <Widgets/LineEdit.h>
|
|
|
+#include <Widgets/Button.h>
|
|
|
+
|
|
|
+#include <QLabel>
|
|
|
+#include <QBoxLayout>
|
|
|
+#include <QGridLayout>
|
|
|
+
|
|
|
+#include <QDebug>
|
|
|
+
|
|
|
+EditNodeWidget::EditNodeWidget(QWidget *parent) : QDialog(parent)
|
|
|
+{
|
|
|
+ initWindow();
|
|
|
+ initWidgets();
|
|
|
+ initLayout();
|
|
|
+ connectSignalsAndSlots();
|
|
|
+}
|
|
|
+
|
|
|
+CNodeData EditNodeWidget::node() const
|
|
|
+{
|
|
|
+ return m_node;
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::setNode(CNodeData n)
|
|
|
+{
|
|
|
+ m_node = n;
|
|
|
+ m_name->setText(n.name);
|
|
|
+ m_remark->setText(n.remark);
|
|
|
+ m_confirm->setEnabled(false);
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::initWindow()
|
|
|
+{
|
|
|
+ setWindowTitle("编辑节点");
|
|
|
+ // setWindowFlags(Qt::Window);
|
|
|
+ // setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
|
|
|
+
|
|
|
+ setModal(true);
|
|
|
+ setWindowFlags(Qt::Dialog);
|
|
|
+ setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
|
+ setFixedSize(350, 250);
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::initWidgets()
|
|
|
+{
|
|
|
+ m_nameLabel = new QLabel("名称:", this);
|
|
|
+ m_name = new LineEdit(this);
|
|
|
+ m_remarkLabel = new QLabel("内涵:", this);
|
|
|
+ m_remarkLabel->setContentsMargins(0, 10, 0, 10);
|
|
|
+ m_remark = new TextEdit(this);
|
|
|
+ m_confirm = new PushButton("保存", this);
|
|
|
+ m_cancel = new PushButton("取消", this);
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::initLayout()
|
|
|
+{
|
|
|
+ m_layout = new QVBoxLayout(this);
|
|
|
+ m_layout->setMargin(20);
|
|
|
+ m_gridLayout = new QGridLayout();
|
|
|
+ m_layout->addLayout(m_gridLayout);
|
|
|
+ m_layout->addSpacing(20);
|
|
|
+ m_btnLayout = new QHBoxLayout();
|
|
|
+ m_layout->addLayout(m_btnLayout);
|
|
|
+
|
|
|
+ m_name->setMinimumWidth(280);
|
|
|
+ m_remark->setMinimumWidth(280);
|
|
|
+ m_gridLayout->addWidget(m_nameLabel, 0, 0, 1, 1, Qt::AlignRight);
|
|
|
+ m_gridLayout->addWidget(m_name, 0, 1, 1, 1, Qt::AlignLeft);
|
|
|
+ m_gridLayout->addWidget(m_remarkLabel, 1, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
|
|
|
+ m_gridLayout->addWidget(m_remark, 1, 1, 1, 1, Qt::AlignLeft);
|
|
|
+
|
|
|
+ m_btnLayout->addStretch();
|
|
|
+ m_btnLayout->addWidget(m_confirm);
|
|
|
+ m_btnLayout->addSpacing(20);
|
|
|
+ m_btnLayout->addWidget(m_cancel);
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::connectSignalsAndSlots()
|
|
|
+{
|
|
|
+ connect(m_name, &LineEdit::textChanged, this, &EditNodeWidget::slotEditChanged);
|
|
|
+ connect(m_remark, &TextEdit::textChanged, this, &EditNodeWidget::slotEditChanged);
|
|
|
+ connect(m_confirm, &PushButton::clicked, this, &EditNodeWidget::slotConfirmCLicked);
|
|
|
+ connect(m_cancel, &PushButton::clicked, this, &EditNodeWidget::slotConcelClicked);
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::slotEditChanged()
|
|
|
+{
|
|
|
+ m_confirm->setEnabled(true);
|
|
|
+ m_node.name = m_name->text();
|
|
|
+ m_node.remark = m_remark->toPlainText();
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::slotConfirmCLicked()
|
|
|
+{
|
|
|
+ emit sigSaveNode(m_node);
|
|
|
+ close();
|
|
|
+}
|
|
|
+
|
|
|
+void EditNodeWidget::slotConcelClicked()
|
|
|
+{
|
|
|
+ close();
|
|
|
+}
|