SchemeOptionWidget.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #include "SchemeOptionWidget.h"
  2. #include "CreateSchemeWidget.h"
  3. #include <Widgets/Button.h>
  4. #include <Common/Icon.h>
  5. #include <QLabel>
  6. #include <QBoxLayout>
  7. #include <QListWidget>
  8. #include <QButtonGroup>
  9. SchemeOptionWidget::SchemeOptionWidget(QWidget *parent) : QWidget(parent)
  10. {
  11. initialize();
  12. initLayout();
  13. connectSignalsAndSlots();
  14. }
  15. void SchemeOptionWidget::initialize()
  16. {
  17. m_vBoxLayout = new QVBoxLayout(this);
  18. m_addButton = new PushButton("新增方案", NEWFLICON(FluentIcon, ADD), this);
  19. m_removeButton = new PushButton("删除方案", NEWFLICON(FluentIcon, DELETE), this);
  20. m_normalLabel = new QLabel("归一化公式", this);
  21. m_normalLayout = new QVBoxLayout();
  22. m_minButton = new RadioButton("最小值");
  23. m_minButton->setChecked(true);
  24. m_maxButton = new RadioButton("最大值");
  25. m_zscoreButton = new RadioButton("Z-Score法");
  26. QButtonGroup *normalGroup = new QButtonGroup(this);
  27. normalGroup->addButton(m_minButton);
  28. normalGroup->addButton(m_maxButton);
  29. normalGroup->addButton(m_zscoreButton);
  30. m_calcLabel = new QLabel("计算方法", this);
  31. m_calcLayout = new QVBoxLayout();
  32. m_pairButton = new RadioButton("集对分析法");
  33. m_pairButton->setChecked(true);
  34. m_averageButton = new RadioButton("平均值法");
  35. QButtonGroup *calcGroup = new QButtonGroup(this);
  36. calcGroup->addButton(m_pairButton);
  37. calcGroup->addButton(m_averageButton);
  38. m_buttonLayout = new QHBoxLayout();
  39. m_calcButton = new PushButton("计算", this);
  40. m_saveButton = new PushButton("保存", this);
  41. m_schemeLabel = new QLabel("方案排行榜", this);
  42. m_listWidget = new QListWidget(this);
  43. m_listWidget->setFixedHeight(200);
  44. m_addSchemeWidget = new CreateSchemeWidget(this);
  45. setStyleSheet("QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);background: rgb(255, 255, "
  46. "255);alternate-background-color: rgb(244, 244, 255);}");
  47. }
  48. void SchemeOptionWidget::initLayout()
  49. {
  50. m_vBoxLayout->addWidget(m_addButton);
  51. m_vBoxLayout->addWidget(m_removeButton);
  52. m_vBoxLayout->addSpacing(20);
  53. m_vBoxLayout->addWidget(m_normalLabel);
  54. m_vBoxLayout->addLayout(m_normalLayout);
  55. m_normalLayout->setContentsMargins(20, 0, 0, 0);
  56. m_normalLayout->addWidget(m_minButton);
  57. m_normalLayout->addWidget(m_maxButton);
  58. m_normalLayout->addWidget(m_zscoreButton);
  59. m_vBoxLayout->addSpacing(20);
  60. m_vBoxLayout->addWidget(m_calcLabel);
  61. m_vBoxLayout->addLayout(m_calcLayout);
  62. m_calcLayout->setContentsMargins(20, 0, 0, 0);
  63. m_calcLayout->addWidget(m_pairButton);
  64. m_calcLayout->addWidget(m_averageButton);
  65. m_vBoxLayout->addSpacing(20);
  66. m_vBoxLayout->addLayout(m_buttonLayout);
  67. m_buttonLayout->addStretch();
  68. m_buttonLayout->addWidget(m_calcButton);
  69. m_buttonLayout->addSpacing(30);
  70. m_buttonLayout->addWidget(m_saveButton);
  71. m_buttonLayout->addStretch();
  72. m_vBoxLayout->addSpacing(20);
  73. m_vBoxLayout->addStretch();
  74. m_vBoxLayout->addWidget(m_schemeLabel);
  75. m_vBoxLayout->addWidget(m_listWidget);
  76. }
  77. void SchemeOptionWidget::connectSignalsAndSlots()
  78. {
  79. connect(m_addButton, &PushButton::clicked, this, &SchemeOptionWidget::slotAddSchemeClicked);
  80. connect(m_removeButton, &PushButton::clicked, this, &SchemeOptionWidget::slotRemoveSchemeClicked);
  81. }
  82. void SchemeOptionWidget::slotAddSchemeClicked()
  83. {
  84. if (m_addSchemeWidget->isVisible() == false) {
  85. m_addSchemeWidget->clearInputs();
  86. m_addSchemeWidget->show();
  87. }
  88. }
  89. void SchemeOptionWidget::slotRemoveSchemeClicked() { }