Youtube video and text (draft).
[speedfreak] / Client / categorylist.cpp
index 3226bbf..5d86f76 100644 (file)
@@ -6,6 +6,7 @@
  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  */
 
+#include <QDebug>
 #include "categorylist.h"
 
 /**
@@ -13,8 +14,7 @@
   */
 CategoryList::CategoryList()
 {
-    categoryList << "Speed" << "acceleration-0-40" << "acceleration-0-100" << "G-force"; // OLPU
-    //top10AccelerationList << "acc-tulos1\nacc-tulos2\nacc-tulos3\nacc-tulos4\nacc-tulos5\nacc-tulos6\nacc-tulos7\nacc-tulos8\nacc-tulos9\nacc-tulos10";
+
 }
 
 /**
@@ -26,47 +26,132 @@ CategoryList::~CategoryList()
 
 /**
   *This is return function.
-  *@todo Read real top 10 category list
   *@return QStringList categoryList
   */
 QStringList CategoryList::getCategoryList()
 {
+    qDebug() << "_getCategoryList" << realSizeOfCats;
+
+    if(sizeOfCategoryList() != 0) {
+        clearCategoryList();
+    }
+
+    for(int i = 0; i < realSizeOfCats; i++)
+    {
+        categoryList.append(cats[i].description);
+    }
+
     return categoryList;
 }
 
 /**
-  *This function is used to get items to top list of current category.
+  *Append an item in the end of the categorylist.
+  *@param Item.
+  */
+void CategoryList::appendCategoryList(QString item)
+{
+    categoryList.append(item);
+}
+
+/**
+  *Input an item into the categorylist.
+  *@param Index.
+  *@param Item to be appended.
+  */
+void CategoryList::fillCategoryList(int index, QString item)
+{
+    categoryList.insert(index, item);
+}
+
+/**
+  *Show an item of the categorylist.
+  *@param Index.
+  */
+QString CategoryList::itemOfCategoryList(int index)
+{
+    return categoryList.at(index);
+}
+
+/**
+  *Clear categorylist.
+  */
+void CategoryList::clearCategoryList()
+{
+    categoryList.clear();
+}
+
+/**
+  *Read size of categorylist.
+  */
+int CategoryList::sizeOfCategoryList()
+{
+    return categoryList.size();
+}
+
+/**
+  *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)
+{
+    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)
+{
+    return cats[ind].description;
+}
+
+/**
+  *Search category for an index af cats table.
+  *@param Index.
+  */
+QString CategoryList::getRecentCategory(int ind)
+{
+    return cats[ind].category;
+}
+
+/**
+  *Clear cats.
+  */
+void CategoryList::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)
 {
-    if (category == "acceleration-0-100")
-    {
-        //topList.append(xmlreader->getTop10AccelerationList());
-        //return top10AccelerationList;
-        return "acc-tulos1\nacc-tulos2\nacc-tulos3\nacc-tulos4\nacc-tulos5\nacc-tulos6\nacc-tulos7\nacc-tulos8\nacc-tulos9\nacc-tulos10";
+    qDebug() << "_getTopList";
 
-    }
-    else if (category == "acceleration-0-40")
+    if(!(top10List.isEmpty()))
     {
-                //topList.append(xmlreader->getTop10AccelerationList());
-                //return top10AccelerationList;
-                return "acc-40-tulos1\nacc-40-tulos2\nacc-40-tulos3\nacc-40-tulos4\nacc-40-tulos5\nacc-40-tulos6\nacc-40-tulos7\nacc-40-tulos8\nacc-40-tulos9\nacc-40-tulos10";
-
+        return top10List;
     }
-    else if (category == "Speed")
+    else
     {
-        //topList.append(xmlreader->getTop10SpeedList());
-        //return top10SpeedList;
-        return "speed-tulos1\nspeed-tulos2\nspeed-tulos3\nspeed-tulos4\nspeed-tulos5\nspeed-tulos6\nspeed-tulos7\nspeed-tulos8\nspeed-tulos9\nspeed-tulos10";
-    }
-    else if (category == "G-force")
-    {
-        //topList.append(xmlreader->getTop10GforceList());
-        //return top10GforceList;
-        return "g-tulos1\ng-tulos2\ng-tulos3\ng-tulos4\ng-tulos5\ng-tulos6\ng-tulos7\ng-tulos8\ng-tulos9\ng-tulos10";
-
+        QString emptyStr("");
+        qDebug() << "_getTopList: Category not found";
+        return emptyStr;
     }
 }