EvaluateOptionWidget.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include "EvaluateOptionWidget.h"
  2. #include "QFDIcon.h"
  3. #include <Widgets/LineEdit.h>
  4. #include <Widgets/Button.h>
  5. #include <QLabel>
  6. #include <QBoxLayout>
  7. #include <QListWidget>
  8. #include <QButtonGroup>
  9. EvaluateOptionWidget::EvaluateOptionWidget(QWidget *parent) : QWidget(parent)
  10. {
  11. initialize();
  12. initLayout();
  13. connectSignalsAndSlots();
  14. refreshExpertList();
  15. }
  16. void EvaluateOptionWidget::initialize()
  17. {
  18. m_vBoxLayout = new QVBoxLayout(this);
  19. m_expDataLabel = new QLabel("专家数据", this);
  20. m_listWidget = new QListWidget(this);
  21. m_listWidget->setFixedHeight(250);
  22. m_radioLayout = new QVBoxLayout();
  23. m_radioButton1 = new RadioButton("算术平均", this);
  24. m_radioButton1->setChecked(true);
  25. m_radioButton2 = new RadioButton("几何平均", this);
  26. QButtonGroup *group = new QButtonGroup(this);
  27. group->addButton(m_radioButton1);
  28. group->addButton(m_radioButton2);
  29. m_expInfoLabel = new QLabel("专家介绍", this);
  30. m_expInfoEdit = new TextEdit(this);
  31. m_expInfoEdit->setReadOnly(true);
  32. m_expInfoEdit->setText("awdsfawdvasdvasdvasdv");
  33. m_expInfoEdit->setFixedHeight(200);
  34. m_buttonLayout = new QHBoxLayout();
  35. m_exportButton = new PushButton("导出xlsx文件", NEWFLICON(FluentIcon, SHARE), this);
  36. setStyleSheet("QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);}"
  37. "QListView::item {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #ffffff, stop: 0.9 "
  38. "#ffffff,stop: 1 #eeeeee);height:44;}"
  39. "QPushButton {border: 0;background-color: qlineargradient(x1: 0, y1: 0, x2: "
  40. "0, y2: 1,stop: 0 #f8f8f8, stop: 1 #f8f8f8);}"
  41. "QPushButton::hover {border: 1px solid rgba(0, 0, 0, 0.073);}"
  42. "QPushButton::pressed {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, "
  43. "stop: 1 #f6f7fa);}");
  44. }
  45. void EvaluateOptionWidget::initLayout()
  46. {
  47. m_vBoxLayout->addWidget(m_expDataLabel);
  48. m_vBoxLayout->addWidget(m_listWidget);
  49. m_vBoxLayout->addSpacing(30);
  50. m_vBoxLayout->addLayout(m_radioLayout);
  51. m_radioLayout->addWidget(m_radioButton1);
  52. m_radioLayout->addWidget(m_radioButton2);
  53. m_vBoxLayout->addSpacing(30);
  54. m_vBoxLayout->addLayout(m_buttonLayout);
  55. m_buttonLayout->addWidget(m_exportButton, Qt::AlignRight);
  56. m_vBoxLayout->addStretch();
  57. m_vBoxLayout->addWidget(m_expInfoLabel);
  58. m_vBoxLayout->addWidget(m_expInfoEdit);
  59. }
  60. void EvaluateOptionWidget::connectSignalsAndSlots() { }
  61. void EvaluateOptionWidget::refreshExpertList()
  62. {
  63. m_listWidget->clear();
  64. for (int i = 1; i <= 50; i++) {
  65. QListWidgetItem *item = new QListWidgetItem;
  66. item->setSizeHint(QSize(100, 40));
  67. m_listWidget->addItem(item);
  68. QWidget *w = new QWidget();
  69. m_listWidget->setItemWidget(item, w);
  70. QHBoxLayout *hBox = new QHBoxLayout(w);
  71. hBox->setMargin(10);
  72. QLabel *avatar = new QLabel(w);
  73. avatar->setPixmap(NEWFLICON(QFDIcon, Expert)->icon().pixmap(16, 16));
  74. hBox->addWidget(avatar);
  75. hBox->addSpacing(10);
  76. QLabel *name = new QLabel(QString("专家%1").arg(i));
  77. hBox->addWidget(name);
  78. hBox->addStretch();
  79. QPushButton *button = new QPushButton(NEWFLICON(FluentIcon, DOWNLOAD)->icon(), "", w);
  80. button->setFixedSize(QSize(25, 25));
  81. button->setIconSize(QSize(15, 15));
  82. button->setToolTip("导入专家数据");
  83. hBox->addWidget(button);
  84. if (i % 2 == 0 && i < 6) {
  85. button->setIcon(NEWFLICON(FluentIcon, COMPLETED)->icon());
  86. button->setEnabled(false);
  87. button->setToolTip("已导入");
  88. }
  89. }
  90. }