setinfowidget.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include "setinfowidget.h"
  2. #include "ui_setinfowidget.h"
  3. #include "UIStyleManager.h"
  4. SetInfoWidget::SetInfoWidget(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::SetInfoWidget)
  7. {
  8. ui->setupUi(this);
  9. /* 连接信号和槽 */
  10. connect(ui->pBtn_save, &QPushButton::clicked, this, &SetInfoWidget::do_pBtn_save_clicked);
  11. connect(ui->pBtn_cancel, &QPushButton::clicked, this, &SetInfoWidget::do_pBtn_cancel_clicked);
  12. /* 设置样式表 */
  13. UIStyle.registerWidget(this);
  14. }
  15. SetInfoWidget::~SetInfoWidget()
  16. {
  17. /* 注销样式表 */
  18. UIStyle.unregisterWidget(this);
  19. delete ui;
  20. }
  21. /* 设置WebAPI */
  22. void SetInfoWidget::setWebAPI(FromWebAPI* api)
  23. {
  24. m_fromWebAPI = api;
  25. /* 设置BasicWidget的WebAPI */
  26. BasicWidget* basicWidget = qobject_cast<BasicWidget*>(ui->tabWidget->widget(0));
  27. if(basicWidget)
  28. {
  29. basicWidget->setWebAPI(m_fromWebAPI);
  30. }
  31. }
  32. /* 保存按钮 */
  33. void SetInfoWidget::do_pBtn_save_clicked()
  34. {
  35. saveData();
  36. }
  37. /* 取消按钮 */
  38. void SetInfoWidget::do_pBtn_cancel_clicked()
  39. {
  40. }
  41. /* 保存数据 */
  42. void SetInfoWidget::saveData()
  43. {
  44. /* 获取当前页的编号 */
  45. int currentIndex = ui->tabWidget->currentIndex();
  46. QWidget* currentWidget = ui->tabWidget->currentWidget();
  47. switch(currentIndex)
  48. {
  49. case 0: /* 基础信息 */
  50. {
  51. BasicWidget* widget = qobject_cast<BasicWidget*>(currentWidget);
  52. if(widget)
  53. {
  54. /* 保存基础信息 */
  55. widget->saveBasicInfo();
  56. }
  57. }
  58. break;
  59. case 1: /* 对比项 */
  60. break;
  61. case 2: /* 噪音检测 */
  62. break;
  63. case 3: /* 数据库 */
  64. break;
  65. case 4: /* 检测时段 */
  66. break;
  67. default:
  68. break;
  69. }
  70. }