ExpertManageView.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include "ExpertManageView.h"
  2. #include "QFDIcon.h"
  3. #include "ExpertInfoWidget.h"
  4. #include "ExpertListWidget.h"
  5. #include <Widgets/Button.h>
  6. #include <Widgets/LineEdit.h>
  7. #include <DialogBox/Dialog.h>
  8. #include <QBoxLayout>
  9. #include <QLabel>
  10. #include <QDebug>
  11. ExpertManageView::ExpertManageView(QWidget *parent) : QWidget(parent)
  12. {
  13. initialize();
  14. initLayout();
  15. connectSignalsAndSlots();
  16. }
  17. void ExpertManageView::initialize()
  18. {
  19. m_vBoxLayout = new QVBoxLayout(this);
  20. m_titleLabel = new QLabel(this);
  21. m_titleLabel->setText("专家列表");
  22. QFont ft("Microsoft YaHei", 12);
  23. m_titleLabel->setFont(ft);
  24. m_hBoxLayout = new QHBoxLayout();
  25. m_searchLineEdit = new SearchLineEdit(this);
  26. m_searchLineEdit->setPlaceholderText("搜索");
  27. m_searchLineEdit->setMinimumWidth(300);
  28. m_addExpertPushButton = new PushButton("添加", NEWFLICON(FluentIcon, ADD), this);
  29. m_detailPushButton = new PushButton("查看详情", NEWFLICON(QFDIcon, Detail), this);
  30. m_deletePushButton = new PushButton("删除", NEWFLICON(FluentIcon, DELETE), this);
  31. m_expertInfoWidget = new ExpertInfoWidget(this);
  32. m_expertListWidget = new ExpertListWidget(this);
  33. }
  34. void ExpertManageView::initLayout()
  35. {
  36. m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
  37. m_vBoxLayout->setContentsMargins(15, 10, 10, 15);
  38. m_vBoxLayout->addLayout(m_hBoxLayout);
  39. m_hBoxLayout->setContentsMargins(10, 0, 10, 0);
  40. m_hBoxLayout->addWidget(m_titleLabel);
  41. m_hBoxLayout->addSpacing(15);
  42. m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
  43. m_hBoxLayout->addWidget(m_addExpertPushButton, 1, Qt::AlignLeft);
  44. m_hBoxLayout->addStretch();
  45. m_hBoxLayout->addWidget(m_detailPushButton);
  46. m_hBoxLayout->addWidget(m_deletePushButton);
  47. setListButtonHidden(true);
  48. m_vBoxLayout->addWidget(m_expertListWidget);
  49. }
  50. void ExpertManageView::connectSignalsAndSlots()
  51. {
  52. connect(m_addExpertPushButton, &PushButton::clicked, this, &ExpertManageView::slotAddExpertClicked);
  53. connect(m_detailPushButton, &PushButton::clicked, this, &ExpertManageView::slotDetailClicked);
  54. connect(m_deletePushButton, &PushButton::clicked, this, &ExpertManageView::slotDeleteClicked);
  55. connect(m_expertListWidget, &ExpertListWidget::signalSelectionChanged, this,
  56. &ExpertManageView::slotListSelectionChanged);
  57. connect(m_expertListWidget, &ExpertListWidget::siganlItemDoubleClicked, this,
  58. &ExpertManageView::slotListItemDoubleClicked);
  59. }
  60. void ExpertManageView::setListButtonHidden(bool hidden)
  61. {
  62. m_detailPushButton->setHidden(hidden);
  63. m_deletePushButton->setHidden(hidden);
  64. }
  65. void ExpertManageView::showExpertInfo()
  66. {
  67. if (m_expertInfoWidget->isVisible() == false) {
  68. m_expertInfoWidget->clearInputs();
  69. m_expertInfoWidget->show();
  70. }
  71. }
  72. void ExpertManageView::slotAddExpertClicked()
  73. {
  74. m_expertInfoWidget->setMode(ExpertInfoWidget::Add);
  75. showExpertInfo();
  76. }
  77. void ExpertManageView::slotDetailClicked()
  78. {
  79. m_expertInfoWidget->setMode(ExpertInfoWidget::Read);
  80. showExpertInfo();
  81. }
  82. void ExpertManageView::slotDeleteClicked()
  83. {
  84. MessageBox *m = new MessageBox("删除专家信息", "删除后不可恢复,确认删除?", this);
  85. m->exec();
  86. }
  87. void ExpertManageView::slotListSelectionChanged()
  88. {
  89. setListButtonHidden(!m_expertListWidget->isItemSelected());
  90. }
  91. void ExpertManageView::slotListItemDoubleClicked()
  92. {
  93. m_expertInfoWidget->setMode(ExpertInfoWidget::Read);
  94. showExpertInfo();
  95. }