Just testing...one header added to UI_design document.
[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     delete ui;
40 }
41
42 void TopResultDialog::changeEvent(QEvent *e)
43 {
44     QDialog::changeEvent(e);
45     switch (e->type()) {
46     case QEvent::LanguageChange:
47         ui->retranslateUi(this);
48         break;
49     default:
50         break;
51     }
52 }
53
54
55 void TopResultDialog::on_buttonTopRefresh_clicked()
56 {
57     ui->labelTopList->clear();
58     ui->comboBoxTopCategory->clear();
59     emit refreshCategoryList();
60 }
61
62 void TopResultDialog::setCompoBoxCategories(QStringList list)
63 {
64     ui->comboBoxTopCategory->addItems(list);
65 }
66
67 void TopResultDialog::showTopList(QString str)
68 {
69     ui->labelTopList->setText(str);
70 }
71
72 int TopResultDialog::getRecentCategoryIndex()
73 {
74     return recentCategoryIndex;
75 }
76
77 void TopResultDialog::setLimitNr(int number)
78 {
79     limitNr = number;
80 }
81
82 int TopResultDialog::getLimitNr()
83 {
84     return limitNr;
85 }
86
87 void TopResultDialog::on_comboBoxTopCategory_currentIndexChanged(int index)
88 {
89     ui->labelTopList->clear();
90     recentCategoryIndex = index;
91     emit refreshTopList(index);
92 }
93
94 void TopResultDialog::setLabelInfoToUser(QString infoText)
95 {
96     this->ui->labelInfoToUser->setText(infoText);
97 }
98
99 /**
100   * This slot function called when ever info button clicked.
101   */
102 void TopResultDialog::on_pushButtonInfo_clicked()
103 {
104     if(!helpResultsDialog)
105     {
106         helpResultsDialog = new HelpResultsDialog;
107     }
108     connect(helpResultsDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
109     helpResultsDialog->show();
110 }
111
112 /**
113   * This slot function called when ever dialog rejected.
114   */
115 void TopResultDialog::killHelpDialog()
116 {
117     if(helpResultsDialog)
118     {
119         qDebug() << "__Top result kill: helpResultsDialog";
120         delete helpResultsDialog;
121         helpResultsDialog = NULL;
122     }
123 }