2 Image Puzzle - A set your pieces straight game
3 Copyright (C) 2009 Timo Härkönen
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "statisticsdialog.h"
20 #include "statistics.h"
22 #include <QVBoxLayout>
23 #include <QHBoxLayout>
25 #include <QPushButton>
27 StatisticsDialog::StatisticsDialog(QWidget *parent) :
31 setWindowTitle(tr("Statistics"));
33 resetButton_ = new QPushButton(tr("Reset"));
34 doneButton_ = new QPushButton(tr("Close"));
36 buttonLayout_ = new QHBoxLayout;
37 buttonLayout_->addStretch();
38 buttonLayout_->addWidget(resetButton_);
39 buttonLayout_->addWidget(doneButton_);
45 mainLayout_ = new QVBoxLayout;
46 mainLayout_->addWidget(label_);
47 mainLayout_->addLayout(buttonLayout_);
49 setLayout(mainLayout_);
51 connect(resetButton_, SIGNAL(clicked()), this, SLOT(resetClicked()));
52 connect(doneButton_, SIGNAL(clicked()), this, SLOT(close()));
55 void StatisticsDialog::updateContent()
57 QString txt = QString("\tEasy\tHard\nGames\t%1\t%5\nBest\t%2\t%6\nAvg\t%3\t%7\nWorst\t%4\t%8\n")
58 .arg(QString::number(Statistics::instance()->gameCount(Statistics::easyDifficulty)))
59 .arg(QString::number(Statistics::instance()->minMoves(Statistics::easyDifficulty)))
60 .arg(QString::number(Statistics::instance()->averageMoves(Statistics::easyDifficulty)))
61 .arg(QString::number(Statistics::instance()->maxMoves(Statistics::easyDifficulty)))
62 .arg(QString::number(Statistics::instance()->gameCount(Statistics::hardDifficulty)))
63 .arg(QString::number(Statistics::instance()->minMoves(Statistics::hardDifficulty)))
64 .arg(QString::number(Statistics::instance()->averageMoves(Statistics::hardDifficulty)))
65 .arg(QString::number(Statistics::instance()->maxMoves(Statistics::hardDifficulty)));
70 void StatisticsDialog::resetClicked()
72 Statistics::instance()->resetStatistics();