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
11 #include "categorylist.h"
14 * Constructor of this class.
16 CategoryList::CategoryList()
18 qDebug() << "__CategoryList";
22 * Destructor of this class. Should be used to release all allocated resources.
24 CategoryList::~CategoryList()
26 qDebug() << "__~CategoryList";
30 * This is return function.
32 * @return QStringList categoryList
34 QStringList CategoryList::getCategoryList()
36 qDebug() << "__getCategoryList" << realSizeOfCats;
38 if(sizeOfCategoryList() != 0) {
42 for(int i = 0; i < realSizeOfCats; i++)
44 categoryList.append(cats[i].description);
51 * Append an item in the end of the categorylist.
55 void CategoryList::appendCategoryList(QString item)
57 qDebug() << "__appendCategoryList";
58 categoryList.append(item);
62 * Input an item into the categorylist.
65 * @param Item to be appended.
67 void CategoryList::fillCategoryList(int index, QString item)
69 qDebug() << "__fillCategoryList";
70 categoryList.insert(index, item);
74 * Show an item of the categorylist.
78 QString CategoryList::itemOfCategoryList(int index)
80 qDebug() << "__itemOfCategoryList";
81 return categoryList.at(index);
87 void CategoryList::clearCategoryList()
89 qDebug() << "__clearCategoryList";
94 * Read size of categorylist.
96 int CategoryList::sizeOfCategoryList()
98 qDebug() << "__sizeOfCategoryList";
99 return categoryList.size();
103 * Append an item in the end of the categoryelementable.
106 * @param QString Description of category.
107 * @param QString Unit.
108 * @param QString Category.
110 void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
112 qDebug() << "__appendCats";
113 cats[ind].description = des;
114 cats[ind].unit = uni;
115 cats[ind].category = cat;
119 * Search description for an index af cats table.
123 QString CategoryList::getRecentDescription(int ind)
125 qDebug() << "__getRecentDescription";
126 return cats[ind].description;
130 * Search category for an index af cats table.
134 QString CategoryList::getRecentCategory(int ind)
136 qDebug() << "__getRecentCategory";
137 return cats[ind].category;
143 void CategoryList::clearCats()
145 qDebug() << "__clearCats";
146 for(int i = 0; i < 20; i++)
148 cats[i].description.clear();
149 cats[i].unit.clear();
150 cats[i].category.clear();
155 * This function is used to get items to top list of the category that is chosen from combobox.
157 * @param QString category
160 QString CategoryList::getTopList( QString category, int size)
162 qDebug() << "_getTopList";
164 if(!(top10List.isEmpty()))
170 QString emptyStr("");
171 qDebug() << "_getTopList: Category not found";