WWW, settings and info buttons changed to custom buttons.
[speedfreak] / Client / categorylist.cpp
1 /*
2  * Categorylist
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 "categorylist.h"
12
13 /**
14   *Constructor of this class.
15   */
16 CategoryList::CategoryList()
17 {
18     qDebug() << "__CategoryList";
19 }
20
21 /**
22   *Destructor of this class. Should be used to release all allocated resources.
23   */
24 CategoryList::~CategoryList()
25 {
26     qDebug() << "__~CategoryList";
27 }
28
29 /**
30   *This is return function.
31   *@return QStringList categoryList
32   */
33 QStringList CategoryList::getCategoryList()
34 {
35     qDebug() << "__getCategoryList" << realSizeOfCats;
36
37     if(sizeOfCategoryList() != 0) {
38         clearCategoryList();
39     }
40
41     for(int i = 0; i < realSizeOfCats; i++)
42     {
43         categoryList.append(cats[i].description);
44     }
45
46     return categoryList;
47 }
48
49 /**
50   *Append an item in the end of the categorylist.
51   *@param Item.
52   */
53 void CategoryList::appendCategoryList(QString item)
54 {
55     qDebug() << "__appendCategoryList";
56     categoryList.append(item);
57 }
58
59 /**
60   *Input an item into the categorylist.
61   *@param Index.
62   *@param Item to be appended.
63   */
64 void CategoryList::fillCategoryList(int index, QString item)
65 {
66     qDebug() << "__fillCategoryList";
67     categoryList.insert(index, item);
68 }
69
70 /**
71   *Show an item of the categorylist.
72   *@param Index.
73   */
74 QString CategoryList::itemOfCategoryList(int index)
75 {
76     qDebug() << "__itemOfCategoryList";
77     return categoryList.at(index);
78 }
79
80 /**
81   *Clear categorylist.
82   */
83 void CategoryList::clearCategoryList()
84 {
85     qDebug() << "__clearCategoryList";
86     categoryList.clear();
87 }
88
89 /**
90   *Read size of categorylist.
91   */
92 int CategoryList::sizeOfCategoryList()
93 {
94     qDebug() << "__sizeOfCategoryList";
95     return categoryList.size();
96 }
97
98 /**
99   *Append an item in the end of the categoryelementable.
100   *@param Index.
101   *@param Description of category.
102   *@param Unit.
103   *@param Category.
104   */
105 void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
106 {
107     qDebug() << "__appendCats";
108     cats[ind].description = des;
109     cats[ind].unit = uni;
110     cats[ind].category = cat;
111 }
112
113 /**
114   *Search description for an index af cats table.
115   *@param Index.
116   */
117 QString CategoryList::getRecentDescription(int ind)
118 {
119     qDebug() << "__getRecentDescription";
120     return cats[ind].description;
121 }
122
123 /**
124   *Search category for an index af cats table.
125   *@param Index.
126   */
127 QString CategoryList::getRecentCategory(int ind)
128 {
129     qDebug() << "__getRecentCategory";
130     return cats[ind].category;
131 }
132
133 /**
134   *Clear cats.
135   */
136 void CategoryList::clearCats()
137 {
138     qDebug() << "__clearCats";
139     for(int i = 0; i < 20; i++)
140     {
141         cats[i].description.clear();
142         cats[i].unit.clear();
143         cats[i].category.clear();
144     }
145 }
146
147 /**
148   *This function is used to get items to top list of the category that is chosen from combobox.
149   *@param QString category
150   *@param int size
151   *@todo Now there is only one (the latest top10List). Later picking up the requested category.
152   */
153 QString CategoryList::getTopList( QString category, int size)
154 {
155     qDebug() << "_getTopList";
156
157     if(!(top10List.isEmpty()))
158     {
159         return top10List;
160     }
161     else
162     {
163         QString emptyStr("");
164         qDebug() << "_getTopList: Category not found";
165         return emptyStr;
166     }
167 }
168