Fixed bug 5709. Now result dialog shows only two decimals in time labels.
[speedfreak] / Client / topresultdialog.cpp
1 /*
2  * Topresultdialog
3  *
4  * @author     Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
5  * @author     Toni Jussila <toni.jussila@fudeco.com>
6  * @copyright  (c) 2010 Speed Freak team
7  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
8  */
9
10 #include <QDebug>
11 #include "topresultdialog.h"
12 #include "ui_topresultdialog.h"
13
14 TopResultDialog::TopResultDialog(QWidget *parent) :
15     QDialog(parent), ui(new Ui::TopResultDialog)
16 {
17     ui->setupUi(this);
18
19     helpResultsDialog = NULL;
20
21     this->setWindowTitle("Top Results");
22
23     //Set the amount of requested top results here, untill there is user input
24     setLimitNr(10);
25
26     //Button settings
27     ui->buttonTopRefresh->setAutoFillBackground(true);
28     ui->buttonTopRefresh->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
29     ui->pushButtonInfo->setAutoFillBackground(true);
30     ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
31
32     //Clear labels
33     ui->labelInfoToUser->setText("");
34     ui->labelTopList->setText("");
35 }
36
37 TopResultDialog::~TopResultDialog()
38 {
39     qDebug() << "__~TopResultDialog";
40     delete ui;
41 }
42
43 void TopResultDialog::changeEvent(QEvent *e)
44 {
45     QDialog::changeEvent(e);
46     switch (e->type()) {
47     case QEvent::LanguageChange:
48         ui->retranslateUi(this);
49         break;
50     default:
51         break;
52     }
53 }
54
55
56 void TopResultDialog::on_buttonTopRefresh_clicked()
57 {
58     ui->labelTopList->clear();
59     ui->comboBoxTopCategory->clear();
60     emit refreshCategoryList();
61 }
62
63 void TopResultDialog::setCompoBoxCategories(QStringList list)
64 {
65     ui->comboBoxTopCategory->addItems(list);
66 }
67
68 void TopResultDialog::showTopList(QString str)
69 {
70     qDebug() << "__showTopList";
71     ui->labelTopList->setText(str);
72 }
73
74 int TopResultDialog::getRecentCategoryIndex()
75 {
76     return recentCategoryIndex;
77 }
78
79 void TopResultDialog::setLimitNr(int number)
80 {
81     limitNr = number;
82 }
83
84 int TopResultDialog::getLimitNr()
85 {
86     return limitNr;
87 }
88
89 void TopResultDialog::on_comboBoxTopCategory_currentIndexChanged(int index)
90 {
91     ui->labelTopList->clear();
92     recentCategoryIndex = index;
93     emit refreshTopList(index);
94 }
95
96 void TopResultDialog::setLabelInfoToUser(QString infoText)
97 {
98     this->ui->labelInfoToUser->setText(infoText);
99 }
100
101 /**
102   * This slot function called when ever info button clicked.
103   */
104 void TopResultDialog::on_pushButtonInfo_clicked()
105 {
106     if(!helpResultsDialog)
107     {
108         helpResultsDialog = new HelpResultsDialog;
109     }
110     connect(helpResultsDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
111     helpResultsDialog->show();
112 }
113
114 /**
115   * This slot function called when ever dialog rejected.
116   */
117 void TopResultDialog::killHelpDialog()
118 {
119     if(helpResultsDialog)
120     {
121         qDebug() << "__Top result kill: helpResultsDialog";
122         delete helpResultsDialog;
123         helpResultsDialog = NULL;
124     }
125 }