Browse Source

ExpertInfo

chengxr 1 year ago
parent
commit
ed36a91395
2 changed files with 119 additions and 4 deletions
  1. 85 4
      QFD/view/ExpertInfoView.cpp
  2. 34 0
      QFD/view/ExpertInfoView.h

+ 85 - 4
QFD/view/ExpertInfoView.cpp

@@ -1,5 +1,12 @@
 #include "ExpertInfoView.h"
 
+#include <Widgets/LineEdit.h>
+#include <Widgets/Button.h>
+
+#include <QBoxLayout>
+#include <QGridLayout>
+#include <QLabel>
+
 ExpertInfoView::ExpertInfoView(QWidget *parent) : QWidget(parent)
 {
     initWindow();
@@ -20,9 +27,83 @@ void ExpertInfoView::initWindow()
     resize(400, 600);
 }
 
-void ExpertInfoView::initialize() { }
+void ExpertInfoView::initialize()
+{
+    int editWidth = 300;
+
+    m_vBoxLayout = new QVBoxLayout(this);
+    m_gridLayout = new QGridLayout();
+
+    m_idLabel = new QLabel(this);
+    m_idLabel->setText("账号ID:");
+    m_idLineEdit = new LineEdit(this);
+    m_idLineEdit->setFixedWidth(editWidth);
+    m_idLineEdit->setPlaceholderText("请输入a-z/A-Z/0-9数据字母组合");
+    m_passwordLabel = new QLabel(this);
+    m_passwordLabel->setText("用户密码:");
+    m_passwordLineEdit = new PasswordLineEdit(this);
+    m_passwordLineEdit->setFixedWidth(editWidth);
+    m_passwordLineEdit->setPlaceholderText("请输入密码");
+    m_nameLabel = new QLabel(this);
+    m_nameLabel->setText("专家名:");
+    m_nameLineEdit = new LineEdit(this);
+    m_nameLineEdit->setFixedWidth(editWidth);
+    m_nameLineEdit->setPlaceholderText("请输入专家名");
+    m_companyLabel = new QLabel(this);
+    m_companyLabel->setText("单位:");
+    m_companyLineEdit = new LineEdit(this);
+    m_companyLineEdit->setFixedWidth(editWidth);
+    m_jobLabel = new QLabel(this);
+    m_jobLabel->setText("职务:");
+    m_jobLineEdit = new LineEdit(this);
+    m_jobLineEdit->setFixedWidth(editWidth);
+    m_majorLabel = new QLabel(this);
+    m_majorLabel->setText("专业:");
+    m_majorLineEdit = new LineEdit(this);
+    m_majorLineEdit->setFixedWidth(editWidth);
+    m_contactInfoLabel = new QLabel(this);
+    m_contactInfoLabel->setText("联系方式:");
+    m_contactInfoLineEdit = new LineEdit(this);
+    m_contactInfoLineEdit->setFixedWidth(editWidth);
+    m_noteLabel = new QLabel(this);
+    m_noteLabel->setText("备注:");
+    m_noteTextEdit = new TextEdit(this);
+    m_noteTextEdit->setFixedWidth(editWidth);
+
+    m_hBoxLayout    = new QHBoxLayout();
+    m_confirmButton = new PushButton("确认", this);
+    m_cancelButton  = new PushButton("取消", this);
+}
+
+void ExpertInfoView::initLayout()
+{
+    m_vBoxLayout->setContentsMargins(20, 10, 20, 10);
+    m_vBoxLayout->addLayout(m_gridLayout);
+
+    m_gridLayout->addWidget(m_idLabel, 0, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_idLineEdit, 0, 1, 1, 2, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_passwordLabel, 1, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_passwordLineEdit, 1, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_nameLabel, 2, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_nameLineEdit, 2, 1, 1, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_companyLabel, 3, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_companyLineEdit, 3, 1, 1, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_jobLabel, 4, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_jobLineEdit, 4, 1, 1, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_majorLabel, 5, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_majorLineEdit, 5, 1, 1, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_contactInfoLabel, 6, 0, 1, 1, Qt::AlignRight);
+    m_gridLayout->addWidget(m_contactInfoLineEdit, 6, 1, 1, 1, Qt::AlignLeft);
+    m_gridLayout->addWidget(m_noteLabel, 7, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
+    m_gridLayout->addWidget(m_noteTextEdit, 7, 1, 1, 1, Qt::AlignLeft);
+
+    m_vBoxLayout->addStretch();
+    m_vBoxLayout->addLayout(m_hBoxLayout);
 
-void ExpertInfoView::initLayout() { }
+    m_hBoxLayout->addStretch();
+    m_hBoxLayout->addWidget(m_confirmButton);
+    m_hBoxLayout->addWidget(m_cancelButton);
+}
 
 void ExpertInfoView::connectSignalsAndSlots() { }
 
@@ -34,10 +115,10 @@ void ExpertInfoView::updateState()
         break;
     }
     case Update: {
-        setWindowTitle("专家1");
+        setWindowTitle("修改用户信息");
     }
     case Read: {
-        setWindowTitle("专家1");
+        setWindowTitle("用户信息");
     }
     }
 }

+ 34 - 0
QFD/view/ExpertInfoView.h

@@ -6,8 +6,10 @@
 class LineEdit;
 class PasswordLineEdit;
 class PushButton;
+class TextEdit;
 
 class QVBoxLayout;
+class QHBoxLayout;
 class QGridLayout;
 class QLabel;
 
@@ -40,6 +42,38 @@ signals:
 
 private:
     Mode m_mode = Add;
+
+    QVBoxLayout *m_vBoxLayout = nullptr;
+
+    QGridLayout *m_gridLayout = nullptr;
+
+    QLabel *m_idLabel      = nullptr;
+    LineEdit *m_idLineEdit = nullptr;
+
+    QLabel *m_passwordLabel              = nullptr;
+    PasswordLineEdit *m_passwordLineEdit = nullptr;
+
+    QLabel *m_nameLabel      = nullptr;
+    LineEdit *m_nameLineEdit = nullptr;
+
+    QLabel *m_companyLabel      = nullptr;
+    LineEdit *m_companyLineEdit = nullptr;
+
+    QLabel *m_jobLabel      = nullptr;
+    LineEdit *m_jobLineEdit = nullptr;
+
+    QLabel *m_majorLabel      = nullptr;
+    LineEdit *m_majorLineEdit = nullptr;
+
+    QLabel *m_contactInfoLabel      = nullptr;
+    LineEdit *m_contactInfoLineEdit = nullptr;
+
+    QLabel *m_noteLabel      = nullptr;
+    TextEdit *m_noteTextEdit = nullptr;
+
+    QHBoxLayout *m_hBoxLayout   = nullptr;
+    PushButton *m_confirmButton = nullptr;
+    PushButton *m_cancelButton  = nullptr;
 };
 
 #endif  // EXPERTINFOVIEW_H