ExpertInfoView.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include "ExpertInfoView.h"
  2. #include <Widgets/LineEdit.h>
  3. #include <Widgets/Button.h>
  4. #include <QBoxLayout>
  5. #include <QGridLayout>
  6. #include <QLabel>
  7. ExpertInfoView::ExpertInfoView(QWidget *parent) : QWidget(parent)
  8. {
  9. initWindow();
  10. initialize();
  11. initLayout();
  12. connectSignalsAndSlots();
  13. updateState();
  14. }
  15. void ExpertInfoView::setMode(ExpertInfoView::Mode mode) { }
  16. void ExpertInfoView::clearInputs() { }
  17. void ExpertInfoView::initWindow()
  18. {
  19. setWindowFlags(Qt::Window);
  20. setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
  21. resize(400, 600);
  22. }
  23. void ExpertInfoView::initialize()
  24. {
  25. int editWidth = 300;
  26. m_vBoxLayout = new QVBoxLayout(this);
  27. m_gridLayout = new QGridLayout();
  28. m_idLabel = new QLabel(this);
  29. m_idLabel->setText("账号ID:");
  30. m_idLineEdit = new LineEdit(this);
  31. m_idLineEdit->setFixedWidth(editWidth);
  32. m_idLineEdit->setPlaceholderText("请输入a-z/A-Z/0-9数字字母组合");
  33. m_passwordLabel = new QLabel(this);
  34. m_passwordLabel->setText("用户密码:");
  35. m_passwordLineEdit = new PasswordLineEdit(this);
  36. m_passwordLineEdit->setFixedWidth(editWidth);
  37. m_passwordLineEdit->setPlaceholderText("请输入密码");
  38. m_nameLabel = new QLabel(this);
  39. m_nameLabel->setText("专家名:");
  40. m_nameLineEdit = new LineEdit(this);
  41. m_nameLineEdit->setFixedWidth(editWidth);
  42. m_nameLineEdit->setPlaceholderText("请输入专家名");
  43. m_companyLabel = new QLabel(this);
  44. m_companyLabel->setText("单位:");
  45. m_companyLineEdit = new LineEdit(this);
  46. m_companyLineEdit->setFixedWidth(editWidth);
  47. m_jobLabel = new QLabel(this);
  48. m_jobLabel->setText("职务:");
  49. m_jobLineEdit = new LineEdit(this);
  50. m_jobLineEdit->setFixedWidth(editWidth);
  51. m_majorLabel = new QLabel(this);
  52. m_majorLabel->setText("专业:");
  53. m_majorLineEdit = new LineEdit(this);
  54. m_majorLineEdit->setFixedWidth(editWidth);
  55. m_contactInfoLabel = new QLabel(this);
  56. m_contactInfoLabel->setText("联系方式:");
  57. m_contactInfoLineEdit = new LineEdit(this);
  58. m_contactInfoLineEdit->setFixedWidth(editWidth);
  59. m_noteLabel = new QLabel(this);
  60. m_noteLabel->setText("备注:");
  61. m_noteTextEdit = new TextEdit(this);
  62. m_noteTextEdit->setFixedWidth(editWidth);
  63. m_hBoxLayout = new QHBoxLayout();
  64. m_confirmButton = new PushButton("确认", this);
  65. m_cancelButton = new PushButton("取消", this);
  66. }
  67. void ExpertInfoView::initLayout()
  68. {
  69. m_vBoxLayout->setContentsMargins(20, 10, 20, 10);
  70. m_vBoxLayout->addLayout(m_gridLayout);
  71. m_gridLayout->addWidget(m_idLabel, 0, 0, 1, 1, Qt::AlignRight);
  72. m_gridLayout->addWidget(m_idLineEdit, 0, 1, 1, 2, Qt::AlignLeft);
  73. m_gridLayout->addWidget(m_passwordLabel, 1, 0, 1, 1, Qt::AlignRight);
  74. m_gridLayout->addWidget(m_passwordLineEdit, 1, 1, Qt::AlignLeft);
  75. m_gridLayout->addWidget(m_nameLabel, 2, 0, 1, 1, Qt::AlignRight);
  76. m_gridLayout->addWidget(m_nameLineEdit, 2, 1, 1, 1, Qt::AlignLeft);
  77. m_gridLayout->addWidget(m_companyLabel, 3, 0, 1, 1, Qt::AlignRight);
  78. m_gridLayout->addWidget(m_companyLineEdit, 3, 1, 1, 1, Qt::AlignLeft);
  79. m_gridLayout->addWidget(m_jobLabel, 4, 0, 1, 1, Qt::AlignRight);
  80. m_gridLayout->addWidget(m_jobLineEdit, 4, 1, 1, 1, Qt::AlignLeft);
  81. m_gridLayout->addWidget(m_majorLabel, 5, 0, 1, 1, Qt::AlignRight);
  82. m_gridLayout->addWidget(m_majorLineEdit, 5, 1, 1, 1, Qt::AlignLeft);
  83. m_gridLayout->addWidget(m_contactInfoLabel, 6, 0, 1, 1, Qt::AlignRight);
  84. m_gridLayout->addWidget(m_contactInfoLineEdit, 6, 1, 1, 1, Qt::AlignLeft);
  85. m_gridLayout->addWidget(m_noteLabel, 7, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
  86. m_gridLayout->addWidget(m_noteTextEdit, 7, 1, 1, 1, Qt::AlignLeft);
  87. m_vBoxLayout->addStretch();
  88. m_vBoxLayout->addLayout(m_hBoxLayout);
  89. m_hBoxLayout->addStretch();
  90. m_hBoxLayout->addWidget(m_confirmButton);
  91. m_hBoxLayout->addWidget(m_cancelButton);
  92. }
  93. void ExpertInfoView::connectSignalsAndSlots() { }
  94. void ExpertInfoView::updateState()
  95. {
  96. switch (m_mode) {
  97. case Add: {
  98. setWindowTitle("添加用户");
  99. break;
  100. }
  101. case Update: {
  102. setWindowTitle("修改用户信息");
  103. }
  104. case Read: {
  105. setWindowTitle("用户信息");
  106. }
  107. }
  108. }