ConfigMeasureDataWidget.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "ConfigMeasureDataWidget.h"
  2. #include "ProjectManager.h"
  3. #include "dbService/SchemeInfoService.h"
  4. #include <Widgets/Button.h>
  5. #include <Common/Icon.h>
  6. #include <QLabel>
  7. #include <QListWidget>
  8. #include <QBoxLayout>
  9. #include <QDebug>
  10. ConfigMeasureDataWidget::ConfigMeasureDataWidget(QWidget *parent) : QWidget(parent)
  11. {
  12. initWidget();
  13. initLayout();
  14. connectSignalsAndSlots();
  15. }
  16. void ConfigMeasureDataWidget::setProcess(SchemePlanManager::SchemeProcessInfo process)
  17. {
  18. m_process = process;
  19. addTestData();
  20. }
  21. void ConfigMeasureDataWidget::initWidget()
  22. {
  23. m_titleLabel = new QLabel("导入实测数据", this);
  24. m_titleLabel->setObjectName("titleLabel");
  25. m_titleLabel->setFixedHeight(50);
  26. m_titleLabel->setContentsMargins(10, 0, 0, 0);
  27. m_listTitleLabel = new QLabel("数据列表", this);
  28. m_listTitleLabel->setObjectName("listTitleLabel");
  29. m_tipsLabel = new QLabel("已导入的数据将会显示在这里", this);
  30. m_tipsLabel->setObjectName("tipsLabel");
  31. m_tipsLabel->setHidden(true);
  32. m_addButton = new QPushButton(NEWFLICON(FluentIcon, ADD)->icon(), "", this);
  33. m_addButton->setToolTip("添加数据");
  34. m_listWidget = new QListWidget(this);
  35. setStyleSheet("#titleLabel {color:#333333; font-size:16px}"
  36. "#listTitleLabel {color:#333333; font-size:12px}"
  37. "QPushButton {border: 0;background-color: qlineargradient(x1: 0, y1: 0, x2: "
  38. "0, y2: 1,stop: 0 #f8f8f8, stop: 1 #f8f8f8);}"
  39. "QPushButton::hover {border: 1px solid rgba(0, 0, 0, 0.073);}"
  40. "QPushButton::pressed {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, "
  41. "stop: 1 #f6f7fa);}"
  42. "QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);}"
  43. "QListView::item {height:44;}");
  44. }
  45. void ConfigMeasureDataWidget::initLayout()
  46. {
  47. m_layout = new QVBoxLayout(this);
  48. m_layout->setMargin(0);
  49. m_layout->setSpacing(0);
  50. m_layout->addWidget(m_titleLabel);
  51. m_headerLayout = new QHBoxLayout();
  52. m_layout->addLayout(m_headerLayout);
  53. m_layout->addSpacing(10);
  54. m_layout->addWidget(m_tipsLabel);
  55. m_layout->addWidget(m_listWidget);
  56. m_headerLayout->addWidget(m_listTitleLabel);
  57. m_headerLayout->addStretch();
  58. m_headerLayout->addWidget(m_addButton);
  59. }
  60. void ConfigMeasureDataWidget::connectSignalsAndSlots()
  61. {
  62. connect(m_addButton, &PushButton::clicked, this, &ConfigMeasureDataWidget::slotAddDataClicked);
  63. }
  64. void ConfigMeasureDataWidget::addTestData()
  65. {
  66. bool rightPage = (m_process.type == SchemePlanManager::ImportWeightData
  67. && m_process.indexType == ProjectManager::OptimalIndex);
  68. bool rightProj = m_process.projectId == 126;
  69. if (!rightPage || !rightProj) {
  70. return;
  71. }
  72. m_listWidget->clear();
  73. for (int i = 0; i < 20; i++) {
  74. QListWidgetItem *item = new QListWidgetItem;
  75. item->setText(QString("数据%1").arg(i + 1));
  76. m_listWidget->addItem(item);
  77. }
  78. }
  79. void ConfigMeasureDataWidget::slotAddDataClicked()
  80. {
  81. emit sigAddData();
  82. }