clObjectiveScore.cpp 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #include "clObjectiveScore.h"
  2. #include "ui_clObjectiveScore.h"
  3. #include "CAppInfo.h"
  4. #include <QListWidgetItem>
  5. #include <QHBoxLayout>
  6. #include <QLabel>
  7. #include <QGraphicsDropShadowEffect>
  8. #include "logproc.h"
  9. #include "awMsgBox.h"
  10. clObjectiveScore::clObjectiveScore(int nRow, QString sExamStudentId, QWidget *parent) :
  11. QWidget(parent),
  12. ui(new Ui::clObjectiveScore), m_sExamStudentId(sExamStudentId), m_nRow(nRow)
  13. {
  14. ui->setupUi(this);
  15. setStyleSheet(g_appInfoPtr->m_sQssStr);
  16. qRegisterMetaType<CQueryObjectiveScoreList>("CQueryObjectiveScoreList");
  17. connect(g_httpBllPtr.get(), &CHttpBll::sgnQueryObjectiveScoreList, this, &clObjectiveScore::onQueryObjectiveScoreList);
  18. CHttpRequestPackage hrp;
  19. hrp.sUri = "/api/ecs_oe_admin/client/exam/process/queryObjectiveScoreList";
  20. hrp.nRequestType = RequestType::rtQueryObjectiveScoreList;
  21. hrp.eParamType = HttpParamType::hptUrl;
  22. hrp.sCommonStr = sExamStudentId;
  23. hrp.sParamList.push_back(QString("examStudentId,%1").arg(m_sExamStudentId));
  24. g_httpBllPtr->post(hrp);
  25. }
  26. clObjectiveScore::~clObjectiveScore()
  27. {
  28. delete ui;
  29. }
  30. void clObjectiveScore::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  31. {
  32. setGeometry(nLeft, nTop, nWidth, nHeight);
  33. ui->widget_objevtiveScore->setGeometry(g_appInfoPtr->m_fRate*5, g_appInfoPtr->m_fRate*5, width()-g_appInfoPtr->m_fRate*10, height()-g_appInfoPtr->m_fRate*10);
  34. ui->lw_objectiveScore->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*10,
  35. ui->widget_objevtiveScore->width() - g_appInfoPtr->m_fRate*20*2,
  36. ui->widget_objevtiveScore->height() - g_appInfoPtr->m_fRate*10*2);
  37. /*
  38. QListWidgetItem *pItem = new QListWidgetItem;
  39. QSize size = pItem->sizeHint();
  40. size.setHeight(g_appInfoPtr->m_fRate*46);
  41. pItem->setSizeHint(size);
  42. ui->lw_objectiveScore->addItem(pItem);
  43. QWidget *w = new QWidget;
  44. w->setStyleSheet(QString("QWidget{background:rgba(19, 187, 138, 1); border-radius:%1px}").arg((int)(g_appInfoPtr->m_fRate*10)));
  45. QHBoxLayout *l = new QHBoxLayout;
  46. QString sLabelStyle = QString(R"(QLabel{
  47. font-size:%1px;
  48. font-family:"Microsoft YaHei";
  49. font-weight:400;
  50. color:rgba(255,255,255,1);})").arg((int)(g_appInfoPtr->m_fRate*12));
  51. QLabel *label_times = new QLabel;
  52. label_times->setText(QString::fromLocal8Bit("次数"));
  53. label_times->setStyleSheet(sLabelStyle);
  54. label_times->adjustSize();
  55. QLabel *label_startTime = new QLabel;
  56. label_startTime->setText(QString::fromLocal8Bit("开始时间"));
  57. label_startTime->setStyleSheet(sLabelStyle);
  58. label_startTime->adjustSize();
  59. QLabel *label_handinPaperTime = new QLabel;
  60. label_handinPaperTime->setText(QString::fromLocal8Bit("交卷时间"));
  61. label_handinPaperTime->setStyleSheet(sLabelStyle);
  62. label_handinPaperTime->adjustSize();
  63. QLabel *label_score = new QLabel;
  64. label_score->setText(QString::fromLocal8Bit("客观分"));
  65. label_score->setStyleSheet(sLabelStyle);
  66. label_score->adjustSize();
  67. l->addSpacing(g_appInfoPtr->m_fRate*20);
  68. l->addWidget(label_times);
  69. l->addStretch();
  70. l->addWidget(label_startTime);
  71. l->addStretch();
  72. l->addWidget(label_handinPaperTime);
  73. l->addStretch();
  74. l->addWidget(label_score);
  75. l->addSpacing(g_appInfoPtr->m_fRate*20);
  76. w->setLayout(l);
  77. ui->lw_objectiveScore->setItemWidget(pItem, w);
  78. */
  79. QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
  80. effect->setOffset(g_appInfoPtr->m_fRate*4,g_appInfoPtr->m_fRate*4);
  81. effect->setColor(QColor(0,0,0,30));
  82. effect->setBlurRadius(g_appInfoPtr->m_fRate*16);
  83. ui->widget_objevtiveScore->setGraphicsEffect(effect);
  84. }
  85. void clObjectiveScore::onQueryObjectiveScoreList(CQueryObjectiveScoreList queryObjectiveScoreList)
  86. {
  87. if (queryObjectiveScoreList.nCode == 200)
  88. {
  89. if(m_sExamStudentId == queryObjectiveScoreList.sExamStudentId)
  90. {
  91. ui->lw_objectiveScore->clear();
  92. QListWidgetItem *pItem = new QListWidgetItem;
  93. QSize size = pItem->sizeHint();
  94. size.setHeight(g_appInfoPtr->m_fRate * 46);
  95. pItem->setSizeHint(size);
  96. ui->lw_objectiveScore->addItem(pItem);
  97. QWidget *w = new QWidget;
  98. w->setStyleSheet(QString("QWidget{background:rgba(19, 187, 138, 1); border-radius:%1px}").arg((int)(g_appInfoPtr->m_fRate * 10)));
  99. QHBoxLayout *l = new QHBoxLayout;
  100. QString sLabelStyle = QString(R"(QLabel{
  101. font-size:%1px;
  102. font-family:"Microsoft YaHei";
  103. font-weight:400;
  104. color:rgba(255,255,255,1);})").arg((int)(g_appInfoPtr->m_fRate * 12));
  105. QLabel *label_times = new QLabel;
  106. label_times->setText(QString::fromLocal8Bit("次数"));
  107. label_times->setStyleSheet(sLabelStyle);
  108. label_times->adjustSize();
  109. QLabel *label_startTime = new QLabel;
  110. label_startTime->setText(QString::fromLocal8Bit("开始时间"));
  111. label_startTime->setStyleSheet(sLabelStyle);
  112. label_startTime->adjustSize();
  113. QLabel *label_handinPaperTime = new QLabel;
  114. label_handinPaperTime->setText(QString::fromLocal8Bit("交卷时间"));
  115. label_handinPaperTime->setStyleSheet(sLabelStyle);
  116. label_handinPaperTime->adjustSize();
  117. QLabel *label_score = new QLabel;
  118. label_score->setText(QString::fromLocal8Bit("客观分"));
  119. label_score->setStyleSheet(sLabelStyle);
  120. label_score->adjustSize();
  121. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  122. l->addWidget(label_times);
  123. l->addStretch();
  124. l->addWidget(label_startTime);
  125. l->addStretch();
  126. l->addWidget(label_handinPaperTime);
  127. l->addStretch();
  128. l->addWidget(label_score);
  129. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  130. w->setLayout(l);
  131. ui->lw_objectiveScore->setItemWidget(pItem, w);
  132. int nSzie = queryObjectiveScoreList.vObjectiveScore.size();
  133. for (int i = nSzie - 1; i >= 0; --i)
  134. {
  135. CObjectiveScore os = queryObjectiveScoreList.vObjectiveScore[i];
  136. QListWidgetItem *pItem = new QListWidgetItem;
  137. QSize size = pItem->sizeHint();
  138. size.setHeight(g_appInfoPtr->m_fRate * 46);
  139. pItem->setSizeHint(size);
  140. ui->lw_objectiveScore->addItem(pItem);
  141. QWidget *w = new QWidget;
  142. w->setStyleSheet(QString("QWidget{background:rgba(255, 255, 255, 1); border-radius:%1px}").arg((int)(g_appInfoPtr->m_fRate * 10)));
  143. QHBoxLayout *l = new QHBoxLayout;
  144. QString sLabelStyle = QString(R"(QLabel{
  145. font-size:%1px;
  146. font-family:"Microsoft YaHei";
  147. font-weight:400;
  148. color:rgba(51,51,51,1);})").arg((int)(g_appInfoPtr->m_fRate * 12));
  149. QString sLabelScoreStyle = QString(R"(QLabel{
  150. font-size:%1px;
  151. font-family:"Microsoft YaHei";
  152. font-weight:500;
  153. color:rgba(51,51,51,1);})").arg((int)(g_appInfoPtr->m_fRate * 12));
  154. QLabel *label_times = new QLabel;
  155. label_times->setText(QString::number(os.nExamOrder));
  156. label_times->setStyleSheet(sLabelStyle);
  157. label_times->adjustSize();
  158. QLabel *label_startTime = new QLabel;
  159. label_startTime->setText(os.sStartTime);
  160. label_startTime->setStyleSheet(sLabelStyle);
  161. label_startTime->adjustSize();
  162. QLabel *label_handinPaperTime = new QLabel;
  163. label_handinPaperTime->setText(os.sEndTime);
  164. label_handinPaperTime->setStyleSheet(sLabelStyle);
  165. label_handinPaperTime->adjustSize();
  166. if (label_handinPaperTime->width() < label_startTime->width())
  167. {
  168. label_handinPaperTime->setFixedWidth(label_startTime->width());
  169. }
  170. QLabel *label_score = new QLabel;
  171. QString sScoreText = QString::number(os.fObjectiveScore);
  172. if (os.bIsAuditing)
  173. {
  174. sScoreText = QString::fromLocal8Bit("审核中");
  175. }
  176. if (os.bIsIllegality)
  177. {
  178. sScoreText = QString::fromLocal8Bit("违纪");
  179. }
  180. label_score->setText(sScoreText);
  181. label_score->setStyleSheet(sLabelScoreStyle);
  182. label_score->adjustSize();
  183. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  184. l->addWidget(label_times);
  185. l->addStretch();
  186. l->addWidget(label_startTime);
  187. l->addStretch();
  188. l->addWidget(label_handinPaperTime);
  189. l->addStretch();
  190. l->addWidget(label_score);
  191. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  192. w->setLayout(l);
  193. ui->lw_objectiveScore->setItemWidget(pItem, w);
  194. }
  195. int nHeight = g_appInfoPtr->m_fRate * 46*(nSzie+1) + g_appInfoPtr->m_fRate * (10 + 5) + g_appInfoPtr->m_fRate * (20 + 5);
  196. emit objectiveScoreHeight(m_nRow, nHeight);
  197. }
  198. }
  199. else
  200. {
  201. if(queryObjectiveScoreList.sMessage.isEmpty())
  202. {
  203. ShowMsg(QString::fromLocal8Bit("获取客观题成绩失败"), (QWidget*)(this->parent()));
  204. }
  205. else
  206. {
  207. ShowMsg(queryObjectiveScoreList.sMessage, (QWidget*)(this->parent()));
  208. }
  209. }
  210. }