update dict
[QFreeRecite.git] / src / gui / StressWidget.cpp
blobd7503f3926835b3f73f0b42254a37b4353f90d75
1 #include <Stress.h>
2 #include <Manager.h>
3 #include <Debug.h>
4 #include "StressWidget.h"
5 #include "ResultWidget.h"
7 using freeRecite::manager;
9 StressWidget::StressWidget(QWidget *parent)
10 : TesterWidget(parent)
12 D_OUTPUT("StressWidget::StressWidget()")
15 void StressWidget::start() {
16 freeRecite::Stress *stress = new freeRecite::Stress;
17 if(!stress->load()) {
18 //scanner = 0 by default;
19 displayResult();
20 return;
21 }else {
22 scanner = dynamic_cast<freeRecite::Scanner *>(stress);
23 topicLabel->setText(tr("Review Stress Words"));
24 setInfo();
25 showNext();
26 time(&startTime);
30 void StressWidget::displayResult() {
31 QString str11,str12,str21,str22,str31,str32;
32 str11 = tr("Amount: ");
33 str21 = tr("Used Time: ");
34 str31 = tr("Score: ");
35 resultWidget = new ResultWidget(this);
36 if(scanner != 0 && scanner->capability() != 0) {
37 time_t endTime = 0;
38 time(&endTime);
39 startTime = endTime - startTime;
40 startTime /= 60;
41 startTime = startTime > 1 ? startTime : 1;
42 str22 = QVariant(static_cast<unsigned>(startTime)).toString() + tr(" min");
43 str12 = QVariant(scanner->capability()).toString();
44 str22 = QVariant(static_cast<unsigned>(startTime)).toString() + tr(" min");
45 str32 = QVariant(scanner->getScore()).toString();
46 }else {
47 str12 = "0";
48 str22 = "0 min";
49 str32 = "0";
50 resultWidget->setTailer("There's no word needs to be reveiwed!");
52 resultWidget->setInfo(str11,str12,str21,str22,str31,str32);
53 connect(resultWidget,SIGNAL(confirmed()),this,SIGNAL(finished()));
54 emit showResult();