update dict
[QFreeRecite.git] / src / gui / ReciterWidget.cpp
blob12263c5fb0a5ea6ce793505063effe07f1a8de96
1 #include <Reciter.h>
2 #include "ReciterWidget.h"
3 #include "ResultWidget.h"
5 ReciterWidget::ReciterWidget(QWidget *parent)
6 :ScannerWidget(parent)
7 { /* Do Nothing Here! */ }
9 void ReciterWidget::start(time_t taskID) {
10 freeRecite::Reciter *reciter = new freeRecite::Reciter;
11 reciter->load(taskID);
12 scanner = dynamic_cast<freeRecite::Scanner *>(reciter);
13 topicLabel->setText(tr("Reciting"));
14 setInfo();
15 showNext();
16 time(&startTime);
19 void ReciterWidget::displayResult() {
20 time_t endTime = 0;
21 time(&endTime);
22 startTime = endTime - startTime;
23 startTime /= 60;
24 startTime = startTime > 1 ? startTime : 1;
26 QString str11,str12,str21,str22,str31,str32,strTail;
27 str11 = tr("Amount: ");
28 str12 = QVariant(scanner->capability()).toString();
29 str21 = tr("Used Time: ");
30 str22 = QVariant(static_cast<unsigned>(startTime)).toString() + tr(" min");
31 str31 = tr("Recite Rate: ");
32 str32 =
33 QVariant(static_cast<float>(scanner->capability() -
34 scanner->getScore())/startTime).toString()
35 + tr(" word/min");
36 strTail = tr("There are ") + QVariant(scanner->getScore()).toString() +
37 tr(" words you have remembered before.");
38 resultWidget = new ResultWidget(this);
39 connect(resultWidget,SIGNAL(confirmed()),this,SIGNAL(finished()));
40 resultWidget->setInfo(str11,str12,str21,str22,str31,str32);
41 resultWidget->setTailer(strTail);
42 emit showResult();