Added button for sending route to server.
[speedfreak] / Client / categorylist.cpp
1 /*
2  * Categorylist
3  *
4  * @author     Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
5  * @copyright  (c) 2010 Speed Freak team
6  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
7  */
8
9 #include <QDebug>
10 #include "categorylist.h"
11
12 /**
13   *Constructor of this class.
14   */
15 CategoryList::CategoryList()
16 {
17
18 }
19
20 /**
21   *Destructor of this class. Should be used to release all allocated resources.
22   */
23 CategoryList::~CategoryList()
24 {
25 }
26
27 /**
28   *This is return function.
29   *@return QStringList categoryList
30   */
31 QStringList CategoryList::getCategoryList()
32 {
33     qDebug() << "_getCategoryList" ;
34     return categoryList;
35 }
36
37 /**
38   *Append an item in the end of the categorylist.
39   *@param Item.
40   */
41 void CategoryList::appendCategoryList(QString item)
42 {
43     categoryList.append(item);
44 }
45
46 /**
47   *Input an item into the categorylist.
48   *@param Index.
49   *@param Item to be appended.
50   */
51 void CategoryList::fillCategoryList(int index, QString item)
52 {
53     categoryList.insert(index, item);
54 }
55
56 /**
57   *Show an item of the categorylist.
58   *@param Index.
59   */
60 QString CategoryList::itemOfCategoryList(int index)
61 {
62     return categoryList.at(index);
63 }
64
65 /**
66   *Clear categorylist.
67   */
68 void CategoryList::clearCategoryList()
69 {
70     categoryList.clear();
71 }
72
73 /**
74   *Read size of categorylist.
75   */
76 int CategoryList::sizeOfCategoryList()
77 {
78     return categoryList.size();
79 }
80
81 /**
82   *Append an item in the end of the categoryelementable.
83   *@param Index.
84   *@param Description of category.
85   *@param Unit.
86   *@param Category.
87   */
88 void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
89 {
90     cats[ind].description = des;
91     cats[ind].unit = uni;
92     cats[ind].category = cat;
93 }
94
95 /**
96   *Clear categs.
97   */
98 QString CategoryList::desOfCats(int ind)
99 {
100     return cats[ind].description;
101 }
102
103 /**
104   *Clear cats.
105   */
106 void CategoryList::clearCats()
107 {
108     for(int i = 0; i < 10; i++)
109     {
110         cats[i].description.clear();
111         cats[i].unit.clear();
112         cats[i].category.clear();
113     }
114 }
115
116 /**
117   *This function is used to get items to top list of the category that is chosen from combobox.
118   *@param QString category
119   *@param int size
120   */
121 QString CategoryList::getTopList( QString category, int size)
122 {
123     qDebug() << "_getTopList";
124
125     if(!(top10List.isEmpty()))
126     {
127         return top10List;
128     }
129     else
130     {
131         QString emptyStr("");
132         qDebug() << "_getTopList: Category not found";
133         return emptyStr;
134     }
135 }
136