clopReport.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include "clopReport.h"
  2. #include "ui_clopReport.h"
  3. #include "CAppInfo.h"
  4. #include "clOperation.h"
  5. #include "clopPaperReport.h"
  6. #include "clopPaperDetail.h"
  7. #include <QScrollBar>
  8. clopReport::clopReport(CPracticeRecord pr, bool bFromCache, QWidget *parent) :
  9. QWidget(parent),
  10. ui(new Ui::clopReport), m_pr(pr), m_bFromCache(bFromCache)
  11. {
  12. ui->setupUi(this);
  13. setStyleSheet(g_appInfoPtr->m_sQssStr);
  14. ui->lw_reportInfo->setVerticalScrollMode(QListWidget::ScrollPerPixel);
  15. ui->lw_reportInfo->verticalScrollBar()->setSingleStep(g_appInfoPtr->m_fRate*5);
  16. ui->label_clop_course->setText(QString::fromLocal8Bit("/ 科目:%1").arg(pr.sCourseName));
  17. ui->label_clop_correctRate->setText(QString::fromLocal8Bit("%1%").arg(pr.fObjectiveAccuracy));
  18. }
  19. clopReport::~clopReport()
  20. {
  21. delete ui;
  22. }
  23. void clopReport::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  24. {
  25. setGeometry(nLeft, nTop, nWidth, nHeight);
  26. ui->widget_clop_BG->setGeometry(0, 0, width(), height());
  27. ui->widget_clop_top->setGeometry(0, 0, width(), g_appInfoPtr->m_fRate*56);
  28. ui->btn_clop_goback->setGeometry(ui->widget_clop_top->width() - g_appInfoPtr->m_fRate*(108 + 30), (ui->widget_clop_top->height() - g_appInfoPtr->m_fRate*32)/2, g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*32);
  29. ui->btn_clop_goback->setIconSize(QSize(g_appInfoPtr->m_fRate*14, g_appInfoPtr->m_fRate*14));
  30. ui->btn_clop_goback->setIcon(QIcon(":/images/icon-goback-list.png"));
  31. ui->label_clop_reportTitle->adjustSize();
  32. ui->label_clop_reportTitle->setGeometry(g_appInfoPtr->m_fRate*30, (ui->widget_clop_top->height() - ui->label_clop_reportTitle->height())/2, ui->label_clop_reportTitle->width(), ui->label_clop_reportTitle->height());
  33. ui->label_clop_course->adjustSize();
  34. ui->label_clop_course->setGeometry(ui->label_clop_reportTitle->x() + ui->label_clop_reportTitle->width() + g_appInfoPtr->m_fRate*10,
  35. (ui->widget_clop_top->height() - ui->label_clop_course->height())/2,
  36. ui->label_clop_course->width(), ui->label_clop_course->height());
  37. ui->label_clop_correctRate->adjustSize();
  38. ui->label_clop_correctRate->setGeometry(ui->btn_clop_goback->x() - g_appInfoPtr->m_fRate*30 - ui->label_clop_correctRate->width(),
  39. (ui->widget_clop_top->height() - ui->label_clop_correctRate->height())/2,
  40. ui->label_clop_correctRate->width(), ui->label_clop_correctRate->height());
  41. ui->label_clop_correctRateHint->adjustSize();
  42. ui->label_clop_correctRateHint->setGeometry(ui->label_clop_correctRate->x() - ui->label_clop_correctRateHint->width() - g_appInfoPtr->m_fRate*10,
  43. (ui->widget_clop_top->height() - ui->label_clop_correctRateHint->height())/2,
  44. ui->label_clop_correctRateHint->width(), ui->label_clop_correctRateHint->height());
  45. ui->lw_reportInfo->setGeometry(0, ui->widget_clop_top->height(), width(), height() - ui->widget_clop_top->height());
  46. {
  47. clopPaperReport *paperReport = new clopPaperReport(m_pr.nId, m_bFromCache);
  48. connect(paperReport, &clopPaperReport::heightChange, this, [&](int nReportHeight) {
  49. QListWidgetItem *pItem = ui->lw_reportInfo->item(0);
  50. if (pItem)
  51. {
  52. QSize size = pItem->sizeHint();
  53. size.setHeight(nReportHeight);
  54. pItem->setSizeHint(size);
  55. }
  56. });
  57. connect(paperReport, &clopPaperReport::objectiveAccuracy, this, [&](double fAccuracy) {
  58. ui->label_clop_correctRate->setText(QString::fromLocal8Bit("%1%").arg(fAccuracy));
  59. ui->label_clop_correctRate->adjustSize();
  60. ui->label_clop_correctRate->setGeometry(ui->btn_clop_goback->x() - g_appInfoPtr->m_fRate*30 - ui->label_clop_correctRate->width(),
  61. (ui->widget_clop_top->height() - ui->label_clop_correctRate->height())/2,
  62. ui->label_clop_correctRate->width(), ui->label_clop_correctRate->height());
  63. ui->label_clop_correctRateHint->adjustSize();
  64. ui->label_clop_correctRateHint->setGeometry(ui->label_clop_correctRate->x() - ui->label_clop_correctRateHint->width() - g_appInfoPtr->m_fRate*10,
  65. (ui->widget_clop_top->height() - ui->label_clop_correctRateHint->height())/2,
  66. ui->label_clop_correctRateHint->width(), ui->label_clop_correctRateHint->height());
  67. });
  68. QListWidgetItem *pItem = new QListWidgetItem;
  69. ui->lw_reportInfo->addItem(pItem);
  70. ui->lw_reportInfo->setItemWidget(pItem, paperReport);
  71. int npaperReportHeight = paperReport->setUI(ui->lw_reportInfo->width() - g_appInfoPtr->m_fRate*60);
  72. QSize size = pItem->sizeHint();
  73. size.setHeight(npaperReportHeight);
  74. pItem->setSizeHint(size);
  75. }
  76. {
  77. clopPaperDetail *paperDetail = new clopPaperDetail(m_pr.nId, m_pr.sCourseCode, m_bFromCache);
  78. connect(paperDetail, &clopPaperDetail::heightChange, this, [&](int nReportHeight) {
  79. QListWidgetItem *pItem = ui->lw_reportInfo->item(1);
  80. if (pItem)
  81. {
  82. QSize size = pItem->sizeHint();
  83. size.setHeight(nReportHeight);
  84. pItem->setSizeHint(size);
  85. }
  86. });
  87. QListWidgetItem *pItem = new QListWidgetItem;
  88. ui->lw_reportInfo->addItem(pItem);
  89. ui->lw_reportInfo->setItemWidget(pItem, paperDetail);
  90. int nPaperDetailHeight = paperDetail->setUI(ui->lw_reportInfo->width() - g_appInfoPtr->m_fRate*60);
  91. QSize size = pItem->sizeHint();
  92. size.setHeight(nPaperDetailHeight);
  93. pItem->setSizeHint(size);
  94. }
  95. }
  96. void clopReport::on_btn_clop_goback_clicked()
  97. {
  98. emit goback();
  99. }