Maemo package folder added.
[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 /**
15   * Constructor of this class
16   */
17 TopResultDialog::TopResultDialog(QWidget *parent) :
18     QDialog(parent), ui(new Ui::TopResultDialog)
19 {
20     ui->setupUi(this);
21
22     helpResultsDialog = NULL;
23
24     this->setWindowTitle("Top Results");
25
26     //Set the amount of requested top results here, untill there is user input
27     setLimitNr(10);
28
29     //Button settings
30     ui->buttonTopRefresh->setAutoFillBackground(true);
31     ui->buttonTopRefresh->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
32     ui->pushButtonInfo->setAutoFillBackground(true);
33     ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
34
35     //Clear labels
36     ui->labelInfoToUser->setText("");
37     ui->labelTopList->setText("");
38 }
39
40 /**
41   * Destructor of this class
42   */
43 TopResultDialog::~TopResultDialog()
44 {
45     qDebug() << "__~TopResultDialog";
46     delete ui;
47 }
48
49 /**
50   *
51   */
52 void TopResultDialog::changeEvent(QEvent *e)
53 {
54     QDialog::changeEvent(e);
55     switch (e->type()) {
56     case QEvent::LanguageChange:
57         ui->retranslateUi(this);
58         break;
59     default:
60         break;
61     }
62 }
63
64 /**
65   * This slot function called when ever refresh button clicked.
66   */
67 void TopResultDialog::on_buttonTopRefresh_clicked()
68 {
69     ui->labelTopList->clear();
70     ui->comboBoxTopCategory->clear();
71     emit refreshCategoryList();
72 }
73
74 /**
75   * Set categories compobox.
76   *
77   * @param QStringList list
78   */
79 void TopResultDialog::setCompoBoxCategories(QStringList list)
80 {
81     ui->comboBoxTopCategory->addItems(list);
82 }
83
84 /**
85   * Show top list.
86   *
87   * @param QString str
88   */
89 void TopResultDialog::showTopList(QString str)
90 {
91     qDebug() << "__showTopList";
92     ui->labelTopList->setText(str);
93 }
94
95 /**
96   * Get recent category index.
97   *
98   * @return int category index
99   */
100 int TopResultDialog::getRecentCategoryIndex()
101 {
102     return recentCategoryIndex;
103 }
104
105 /**
106   * Set limit nr.
107   *
108   * @param int number
109   */
110 void TopResultDialog::setLimitNr(int number)
111 {
112     limitNr = number;
113 }
114
115 /**
116   * Get limit nr.
117   *
118   * @return int limit nr
119   */
120 int TopResultDialog::getLimitNr()
121 {
122     return limitNr;
123 }
124
125 /**
126   * This slot function called when ever top category combobox current index changed.
127   *
128   * @param int index
129   */
130 void TopResultDialog::on_comboBoxTopCategory_currentIndexChanged(int index)
131 {
132     ui->labelTopList->clear();
133     recentCategoryIndex = index;
134     emit refreshTopList(index);
135 }
136
137 /**
138   * Set label info to user.
139   *
140   * @param QString info text
141   */
142 void TopResultDialog::setLabelInfoToUser(QString infoText)
143 {
144     this->ui->labelInfoToUser->setText(infoText);
145 }
146
147 /**
148   * This slot function called when ever info button clicked.
149   */
150 void TopResultDialog::on_pushButtonInfo_clicked()
151 {
152     if(!helpResultsDialog)
153     {
154         helpResultsDialog = new HelpResultsDialog;
155     }
156     connect(helpResultsDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
157     helpResultsDialog->show();
158 }
159
160 /**
161   * This slot function called when ever dialog rejected.
162   */
163 void TopResultDialog::killHelpDialog()
164 {
165     if(helpResultsDialog)
166     {
167         qDebug() << "__Top result kill: helpResultsDialog";
168         delete helpResultsDialog;
169         helpResultsDialog = NULL;
170     }
171 }