Categorylist class
authorOlavi Pulkkinen <olavi.pulkkinen@fudeco.com>
Thu, 11 Mar 2010 11:15:07 +0000 (13:15 +0200)
committerOlavi Pulkkinen <olavi.pulkkinen@fudeco.com>
Thu, 11 Mar 2010 11:15:07 +0000 (13:15 +0200)
Client/UI.pro
Client/carmainwindow.cpp
Client/carmainwindow.h
Client/categorylist.cpp [new file with mode: 0644]
Client/categorylist.h [new file with mode: 0644]
Client/xmlreader.cpp
Client/xmlreader.h

index 7028d65..ef6e351 100644 (file)
@@ -21,7 +21,8 @@ SOURCES += main.cpp \
     measures.cpp \
     xmlwriter.cpp \
     xmlreader.cpp \
-    httpclient.cpp
+    httpclient.cpp \
+    categorylist.cpp
 HEADERS += carmainwindow.h \
     resultdialog.h \
     stringlistmodel.h \
@@ -33,7 +34,8 @@ HEADERS += carmainwindow.h \
     measures.h \
     xmlwriter.h \
     xmlreader.h \
-    httpclient.h
+    httpclient.h \
+    categorylist.h
 FORMS += carmainwindow.ui \
     resultdialog.ui \
     measuredialog.ui \
index 85282b5..19e6d09 100644 (file)
@@ -33,6 +33,8 @@ CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::Ca
     manager = new QNetworkAccessManager(this);
     connect(myRegistration,SIGNAL(sendregistration()),this,SLOT(registrate()));
 
+    categorylist = new CategoryList();
+
     time = 0;
     speed = 0;
     timer = new QTimer();
@@ -65,6 +67,7 @@ CarMainWindow::~CarMainWindow()
     delete xmlreader;
     delete xmlwriter;
     delete manager;
+    delete categorylist;
 }
 
 /**
@@ -167,7 +170,7 @@ void CarMainWindow::setListViewStartTabAccelerationCategories(QStringList accele
   */
 void CarMainWindow::setCategoryCompoBox()
 {
-    ui->comboBoxTopCategory->addItems(xmlreader->getCategoryList());
+    ui->comboBoxTopCategory->addItems(categorylist->getCategoryList());
 }
 
 /**
@@ -177,7 +180,7 @@ void CarMainWindow::setCategoryCompoBox()
 void CarMainWindow::setListViewTopList(QString category, int size)
 {
     QString topList;
-    topList.append( xmlreader->getTopList(category, size));
+    topList.append( categorylist->getTopList(category, size));
     ui->labelTopList->setText(topList);
 }
 
index e54a86c..2c29c9a 100644 (file)
@@ -35,6 +35,7 @@
 #include "stringlistmodel.h"
 #include "measures.h"
 #include "accelerometer.h"
+#include "categorylist.h"
 
 namespace Ui {
     class CarMainWindow;
@@ -73,6 +74,7 @@ private:
     QStringList accelerationCategoriesStartTab; //Start-tab view
     QStringList units;  //Start-tab view
     QStringList categories; //Top-tab view
+    CategoryList *categorylist;
 
     QTimer *timer;
     Accelerometer *accelerometer;
diff --git a/Client/categorylist.cpp b/Client/categorylist.cpp
new file mode 100644 (file)
index 0000000..3226bbf
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Categorylist
+ *
+ * @author     Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
+ * @copyright  (c) 2010 Speed Freak team
+ * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#include "categorylist.h"
+
+/**
+  *Constructor of this class.
+  */
+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";
+}
+
+/**
+  *Destructor of this class. Should be used to release all allocated resources.
+  */
+CategoryList::~CategoryList()
+{
+}
+
+/**
+  *This is return function.
+  *@todo Read real top 10 category list
+  *@return QStringList categoryList
+  */
+QStringList CategoryList::getCategoryList()
+{
+    return categoryList;
+}
+
+/**
+  *This function is used to get items to top list of current category.
+  *@param QString category
+  *@param int size
+  */
+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";
+
+    }
+    else if (category == "acceleration-0-40")
+    {
+                //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";
+
+    }
+    else if (category == "Speed")
+    {
+        //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";
+
+    }
+}
+
diff --git a/Client/categorylist.h b/Client/categorylist.h
new file mode 100644 (file)
index 0000000..c96faea
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Categorylist
+ *
+ * @author     Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
+ * @copyright  (c) 2010 Speed Freak team
+ * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#ifndef CATEGORYLIST_H
+#define CATEGORYLIST_H
+
+#include <QStringList>
+
+class CategoryList : public QObject
+{
+public:
+    CategoryList();
+    ~CategoryList();
+    QStringList getCategoryList();
+    QString getTopList( QString category, int size);
+
+private:
+    QStringList categoryList;
+    QString top10AccelerationList;
+    QString top10SpeedList;
+    QString top10GforceList;
+};
+
+#endif // CATEGORYLIST_H
index bcf9b15..393cd41 100644 (file)
@@ -17,8 +17,6 @@
 XmlReader::XmlReader()
 {
     xmlShow();
-    // Remove next line from final code
-    categoryList << "Speed" << "acceleration-0-40" << "acceleration-0-100" << "G-force";
 }
 
 /**
@@ -124,50 +122,3 @@ void XmlReader::xmlShow()
     file.close();
 }
 
-/**
-  *This is return function.
-  *@todo Read real category list
-  *@return QStringList categoryList
-  */
-QStringList XmlReader::getCategoryList()
-{
-    return categoryList;
-}
-
-/**
-  *This is return function.
-  *@todo Read real top 10 category list
-  *@return QStringList top10List
-  */
-QStringList XmlReader::getTop10List()
-{
-    //During development is needed some values for categorylist
-    top10List.clear();
-    top10List << "acceleration-0-10" << "acceleration-0-60" << "acceleration-0-100";
-
-    return top10List;
-}
-
-QString XmlReader::getTopList( QString category, int size)
-{
-    if (category == "acceleration-0-100")
-    {
-        //return top10AccelerationList;
-        return "acc-tulos1\nacc-tulos2\nacc-tulos3\nacc-tulos4\nacc-tulos5\nacc-tulos6\nacc-tulos7\nacc-tulos8\nacc-tulos9\nacc-tulos10";
-    }
-    else if (category == "acceleration-0-40")
-    {
-         //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";
-    }
-    else if (category == "Speed")
-    {
-        //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")
-    {
-        //return top10GforceList;
-        return "g-tulos1\ng-tulos2\ng-tulos3\ng-tulos4\ng-tulos5\ng-tulos6\ng-tulos7\ng-tulos8\ng-tulos9\ng-tulos10";
-    }
-}
index 2a77250..921ceb2 100644 (file)
@@ -19,14 +19,10 @@ class XmlReader : public QObject
 public:
     XmlReader();
     ~XmlReader();
-    QStringList getTop10List();
-    QStringList getCategoryList();
-    QString getTopList( QString category, int size);
 
 private:
     QXmlStreamReader xmlreader;
-    QStringList top10List;
-    QStringList categoryList;
+    QStringList top10List;              // Next 4 to be removed. Categorylist now in own class.
     QString top10AccelerationList;
     QString top10SpeedList;
     QString top10GforceList;