Add Setting and Status
[QFreeRecite.git] / src / gui / ReciterWidget.cpp
blobee1ff40d14e29486d3ed5d720a1697cedbf9492a
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 scanner = new freeRecite::Reciter();
11 scanner->load(taskID);
12 topicLabel->setText(tr("Reciting"));
13 setInfo();
14 showNext();
15 time(&startTime);
18 void ReciterWidget::displayResult() {
19 time_t endTime = 0;
20 time(&endTime);
21 startTime = endTime - startTime;
22 startTime /= 60;
23 startTime = startTime > 1 ? startTime : 1;
25 QString str11,str12,str21,str22,str31,str32,strTail;
26 str11 = tr("Amount: ");
27 str12 = QVariant(scanner->capability()).toString();
28 str21 = tr("Used Time: ");
29 str22 = QVariant(static_cast<unsigned>(startTime)).toString() + tr(" min");
30 str31 = tr("Recite Rate: ");
31 str32 =
32 QVariant(static_cast<float>(scanner->capability() -
33 scanner->getScore())/startTime).toString()
34 + tr(" word/min");
35 strTail = "There are " + QVariant(scanner->getScore()).toString() +
36 " words you have remembered before.";
37 resultWidget = new ResultWidget(this);
38 connect(resultWidget,SIGNAL(confirmed()),this,SIGNAL(finished()));
39 resultWidget->setInfo(str11,str12,str21,str22,str31,str32);
40 resultWidget->setTailer(strTail);
41 emit showResult();