Profile dialog development
[speedfreak] / Client / categorylist.cpp
index 3d3f451..1f05ffb 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * Categorylist
  *
- * @author     Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
+ * @author     Olavi Pulkkinen  <olavi.pulkkinena@fudeco.com>
+ * @author     Toni Jussila     <toni.jussila@fudeco.com>
  * @copyright  (c) 2010 Speed Freak team
  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  */
@@ -14,7 +15,7 @@
   */
 CategoryList::CategoryList()
 {
-
+    qDebug() << "__CategoryList";
 }
 
 /**
@@ -22,6 +23,7 @@ CategoryList::CategoryList()
   */
 CategoryList::~CategoryList()
 {
+    qDebug() << "__~CategoryList";
 }
 
 /**
@@ -30,31 +32,48 @@ CategoryList::~CategoryList()
   */
 QStringList CategoryList::getCategoryList()
 {
-    qDebug() << "_getCategoryList" ;
+    qDebug() << "__getCategoryList" << realSizeOfCats;
+
+    if(sizeOfCategoryList() != 0) {
+        clearCategoryList();
+    }
+
+    for(int i = 0; i < realSizeOfCats; i++)
+    {
+        categoryList.append(cats[i].description);
+    }
+
     return categoryList;
 }
 
 /**
   *Append an item in the end of the categorylist.
+  *@param Item.
   */
 void CategoryList::appendCategoryList(QString item)
 {
+    qDebug() << "__appendCategoryList";
     categoryList.append(item);
 }
 
 /**
   *Input an item into the categorylist.
+  *@param Index.
+  *@param Item to be appended.
   */
 void CategoryList::fillCategoryList(int index, QString item)
 {
+    qDebug() << "__fillCategoryList";
     categoryList.insert(index, item);
 }
 
 /**
   *Show an item of the categorylist.
+  *@param Index.
   */
 QString CategoryList::itemOfCategoryList(int index)
 {
+    qDebug() << "__itemOfCategoryList";
     return categoryList.at(index);
 }
 
@@ -63,8 +82,8 @@ QString CategoryList::itemOfCategoryList(int index)
   */
 void CategoryList::clearCategoryList()
 {
+    qDebug() << "__clearCategoryList";
     categoryList.clear();
-    qDebug() << "_clearCategoryList" ;
 }
 
 /**
@@ -72,13 +91,64 @@ void CategoryList::clearCategoryList()
   */
 int CategoryList::sizeOfCategoryList()
 {
+    qDebug() << "__sizeOfCategoryList";
     return categoryList.size();
 }
 
 /**
-  *This function is used to get items to top list of current category.
+  *Append an item in the end of the categoryelementable.
+  *@param Index.
+  *@param Description of category.
+  *@param Unit.
+  *@param Category.
+  */
+void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
+{
+    qDebug() << "__appendCats";
+    cats[ind].description = des;
+    cats[ind].unit = uni;
+    cats[ind].category = cat;
+}
+
+/**
+  *Search description for an index af cats table.
+  *@param Index.
+  */
+QString CategoryList::getRecentDescription(int ind)
+{
+    qDebug() << "__getRecentDescription";
+    return cats[ind].description;
+}
+
+/**
+  *Search category for an index af cats table.
+  *@param Index.
+  */
+QString CategoryList::getRecentCategory(int ind)
+{
+    qDebug() << "__getRecentCategory";
+    return cats[ind].category;
+}
+
+/**
+  *Clear cats.
+  */
+void CategoryList::clearCats()
+{
+    qDebug() << "__clearCats";
+    for(int i = 0; i < 20; i++)
+    {
+        cats[i].description.clear();
+        cats[i].unit.clear();
+        cats[i].category.clear();
+    }
+}
+
+/**
+  *This function is used to get items to top list of the category that is chosen from combobox.
   *@param QString category
   *@param int size
+  *@todo Now there is only one (the latest top10List). Later picking up the requested category.
   */
 QString CategoryList::getTopList( QString category, int size)
 {