summaryrefslogtreecommitdiff
path: root/src/statistics/ProgressPage.cpp
blob: 7676173a32cb8d2b272b81a099d9921b9a3f60bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "ProgressPage.h"
#include "StatisticsParams.h"
#include "../charts/PieChart.h"
#include "../dictionary/CardPack.h"

ProgressPage::ProgressPage(const StatisticsParams* statParams):
    BaseStatPage(statParams)
{
    init();
}

QWidget* ProgressPage::createChart()
{
    chart = new PieChart;
    chart->setColors({"#39c900", "#ece900", "#ff0000"});
    return chart;
}

void ProgressPage::updateDataSet()
{
    updateCardsNumbers();
    totalReviewsLabel->setText(tr("Total: %1").arg(allCardsNum));
    chart->setDataSet(getDataSet());
}

void ProgressPage::updateCardsNumbers()
{
    const CardPack* pack = statParams->getCardPack();
    allCardsNum = pack->cardsNum();
    newCardsNum = pack->getNewCards().size();
    toBeRepeated = pack->getActiveCards().size();
}

QList<DataPoint> ProgressPage::getDataSet() const
{
    QList<DataPoint> dataSet;
    dataSet << DataPoint(tr("Studied"), allCardsNum - newCardsNum - toBeRepeated);
    dataSet << DataPoint(tr("Scheduled for today"), toBeRepeated);
    dataSet << DataPoint(tr("New"), newCardsNum);
    return dataSet;
}