1#include "statisticsview.h"
4#include "ui_statisticsview.h"
6StatisticsView::StatisticsView(QWidget *parent)
9 connect(ui->games_combobox, SIGNAL(currentIndexChanged(
int)),
this,
10 SLOT(repeaterCurrentIndexChanged(
int)));
13void StatisticsView::repeaterCurrentIndexChanged(
int index) {
18 emit statisticsGameChanged(ui->games_combobox->itemData(index).toString());
21void StatisticsView::displayEmpty() {
22 ui->time_played_label->setText(
"0");
23 ui->games_played_label->setText(
"0");
24 ui->win_rate_label->setText(
"0");
27void StatisticsView::gotUserGameStatisticsUpdate(
29 ui->time_played_label->setText(
30 QString::number(userGameStatistics.time_played_sec));
31 ui->games_played_label->setText(
32 QString::number(userGameStatistics.games_played));
33 ui->win_rate_label->setText(QString::number(userGameStatistics.win_rate));
36StatisticsView::~StatisticsView() {
40void StatisticsView::on_backButton_clicked() {
42 emit shownStartView();
45void StatisticsView::gotGamesListUpdate(
46 const std::vector<GameInfo> &newGamesList) {
47 ui->games_combobox->clear();
48 for (
const auto &gameInfo : newGamesList) {
49 ui->games_combobox->addItem(gameInfo.display_name, gameInfo.id);
52void StatisticsView::gotUserStatisticsUpdate(
54 ui->total_time_played_label->setText(
55 QString::number(userStatistics.total_time_played_sec));
56 ui->total_games_played_label->setText(
57 QString::number(userStatistics.total_games_played));
60void StatisticsView::requestUpdates() {
61 emit requestedRefresh();
62 emit statisticsGameChanged(
63 ui->games_combobox->itemData(ui->games_combobox->currentIndex())
67void StatisticsView::on_refreshButton_clicked() {