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