clopReport.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. QListWidgetItem *pItem = new QListWidgetItem;
  58. ui->lw_reportInfo->addItem(pItem);
  59. ui->lw_reportInfo->setItemWidget(pItem, paperReport);
  60. int npaperReportHeight = paperReport->setUI(ui->lw_reportInfo->width() - g_appInfoPtr->m_fRate*60);
  61. QSize size = pItem->sizeHint();
  62. size.setHeight(npaperReportHeight);
  63. pItem->setSizeHint(size);
  64. }
  65. {
  66. clopPaperDetail *paperDetail = new clopPaperDetail(m_pr.nId, m_pr.sCourseCode, m_bFromCache);
  67. connect(paperDetail, &clopPaperDetail::heightChange, this, [&](int nReportHeight) {
  68. QListWidgetItem *pItem = ui->lw_reportInfo->item(1);
  69. if (pItem)
  70. {
  71. QSize size = pItem->sizeHint();
  72. size.setHeight(nReportHeight);
  73. pItem->setSizeHint(size);
  74. }
  75. });
  76. QListWidgetItem *pItem = new QListWidgetItem;
  77. ui->lw_reportInfo->addItem(pItem);
  78. ui->lw_reportInfo->setItemWidget(pItem, paperDetail);
  79. int nPaperDetailHeight = paperDetail->setUI(ui->lw_reportInfo->width() - g_appInfoPtr->m_fRate*60);
  80. QSize size = pItem->sizeHint();
  81. size.setHeight(nPaperDetailHeight);
  82. pItem->setSizeHint(size);
  83. }
  84. }
  85. void clopReport::on_btn_clop_goback_clicked()
  86. {
  87. emit goback();
  88. }