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.
31 *@return QStringList categoryList
33 QStringList CategoryList::getCategoryList()
35 qDebug() << "__getCategoryList" << realSizeOfCats;
37 if(sizeOfCategoryList() != 0) {
41 for(int i = 0; i < realSizeOfCats; i++)
43 categoryList.append(cats[i].description);
50 *Append an item in the end of the categorylist.
53 void CategoryList::appendCategoryList(QString item)
55 qDebug() << "__appendCategoryList";
56 categoryList.append(item);
60 *Input an item into the categorylist.
62 *@param Item to be appended.
64 void CategoryList::fillCategoryList(int index, QString item)
66 qDebug() << "__fillCategoryList";
67 categoryList.insert(index, item);
71 *Show an item of the categorylist.
74 QString CategoryList::itemOfCategoryList(int index)
76 qDebug() << "__itemOfCategoryList";
77 return categoryList.at(index);
83 void CategoryList::clearCategoryList()
85 qDebug() << "__clearCategoryList";
90 *Read size of categorylist.
92 int CategoryList::sizeOfCategoryList()
94 qDebug() << "__sizeOfCategoryList";
95 return categoryList.size();
99 *Append an item in the end of the categoryelementable.
101 *@param Description of category.
105 void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
107 qDebug() << "__appendCats";
108 cats[ind].description = des;
109 cats[ind].unit = uni;
110 cats[ind].category = cat;
114 *Search description for an index af cats table.
117 QString CategoryList::getRecentDescription(int ind)
119 qDebug() << "__getRecentDescription";
120 return cats[ind].description;
124 *Search category for an index af cats table.
127 QString CategoryList::getRecentCategory(int ind)
129 qDebug() << "__getRecentCategory";
130 return cats[ind].category;
136 void CategoryList::clearCats()
138 qDebug() << "__clearCats";
139 for(int i = 0; i < 20; i++)
141 cats[i].description.clear();
142 cats[i].unit.clear();
143 cats[i].category.clear();
148 *This function is used to get items to top list of the category that is chosen from combobox.
149 *@param QString category
151 *@todo Now there is only one (the latest top10List). Later picking up the requested category.
153 QString CategoryList::getTopList( QString category, int size)
155 qDebug() << "_getTopList";
157 if(!(top10List.isEmpty()))
163 QString emptyStr("");
164 qDebug() << "_getTopList: Category not found";