Display top performer in certain category.
authorToni Jussila <toni.jussila@gmail.com>
Mon, 1 Mar 2010 11:52:47 +0000 (13:52 +0200)
committerToni Jussila <toni.jussila@gmail.com>
Mon, 1 Mar 2010 11:52:47 +0000 (13:52 +0200)
Client/UI.pro
Client/carmainwindow.cpp
Client/carmainwindow.h
Client/carmainwindow.ui
Client/main.cpp

index c9c3c77..c48d029 100644 (file)
@@ -9,11 +9,15 @@ SOURCES += main.cpp \
     carmainwindow.cpp \
     resultdialog.cpp \
     stringlistmodel.cpp \
-    measuredialog.cpp
+    measuredialog.cpp \
+    calculate.cpp \
+    accelerometer.cpp
 HEADERS += carmainwindow.h \
     resultdialog.h \
     stringlistmodel.h \
-    measuredialog.h
+    measuredialog.h \
+    calculate.h \
+    accelerometer.h
 FORMS += carmainwindow.ui \
     resultdialog.ui \
     measuredialog.ui
index ace503b..50a24e0 100644 (file)
@@ -17,14 +17,17 @@ CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::Ca
 
     initUnitCompoBox();
     initSpeedListView();
+    initCategoryCompoBox();
 }
 
 /**
-  *Destructor of this class.  Should be used to release all allocated resources.
+  *Destructor of this class. Should be used to release all allocated resources.
   */
 CarMainWindow::~CarMainWindow()
 {
     delete ui;
+    delete result;
+    delete measure;
 }
 
 /**
@@ -76,7 +79,7 @@ void CarMainWindow::updateUnitCompoBox(QString unit)
 }
 
 /**
-  *This function is used to init combobox.
+  *This function is used to init unit combobox.
   */
 void CarMainWindow::initUnitCompoBox()
 {
@@ -85,7 +88,16 @@ void CarMainWindow::initUnitCompoBox()
 }
 
 /**
-  *This function is used to init listview.
+  *This function is used to set items to unit combobox.
+  *@param QStringlist numbers
+  */
+void CarMainWindow::setUnitCompoBox(QStringList units)
+{
+    ui->unitComboBox->addItems(units);
+}
+
+/**
+  *This function is used to init speed listview.
   */
 void CarMainWindow::initSpeedListView()
 {
@@ -93,3 +105,46 @@ void CarMainWindow::initSpeedListView()
     QAbstractItemModel *model = new StringListModel(numbers);
     ui->listView->setModel(model);
 }
+
+/**
+  *This function is used to set items to speed listview.
+  *@param QStringlist numbers
+  */
+void CarMainWindow::setSpeedListView(QStringList numbers)
+{
+    QAbstractItemModel *model = new StringListModel(numbers);
+    ui->listView->setModel(model);
+}
+
+/**
+  *This function is used to init category combobox.
+  */
+void CarMainWindow::initCategoryCompoBox()
+{
+    categories << "Top 10 1/4 mile" << "Top 10 0-100 km/h" << "Top 10 car";
+    ui->comboBoxTopCategory->addItems(categories);
+}
+
+/**
+  *This function is used to set items to category combobox.
+  *@param QStringlist categories
+  */
+void CarMainWindow::setCategoryCompoBox(QStringList categories)
+{
+    ui->comboBoxTopCategory->addItems(categories);
+}
+
+/**
+  *This slot function is called when ever categories combobox is update.
+  *@param QString category
+  */
+void CarMainWindow::on_comboBoxTopCategory_activated(QString category)
+{
+    //TODO: get top list
+
+    QStringList topList;
+    topList << "1. Pertti 7,5s" << "2. Ville 10,2s";
+
+    QAbstractItemModel *model = new StringListModel(topList);
+    ui->listViewTopList->setModel(model);
+}
index 054b075..f284446 100644 (file)
@@ -8,9 +8,10 @@
   */
 
 #include <QMainWindow>
+#include <QModelIndex>
+#include <QStringList>
 #include "resultdialog.h"
 #include "measuredialog.h"
-#include <QModelIndex>
 
 namespace Ui {
     class CarMainWindow;
@@ -22,22 +23,29 @@ public:
     CarMainWindow(QWidget *parent = 0);
     ~CarMainWindow();
 
+    void setUnitCompoBox(QStringList units);
+    void setSpeedListView(QStringList numbers);
+    void setCategoryCompoBox(QStringList categories);
+
 protected:
     void changeEvent(QEvent *e);
 
 private:
     Ui::CarMainWindow *ui;
     ResultDialog *result;
-    void initUnitCompoBox();
-    void initSpeedListView();
     MeasureDialog *measure;
 
+    void initUnitCompoBox();
+    void initSpeedListView();
+    void initCategoryCompoBox();
 
 private:
     QStringList numbers;
     QStringList units;
+    QStringList categories;
 
 private slots:
+    void on_comboBoxTopCategory_activated(QString );
     void on_autoStartButton_clicked();
     void on_listView_clicked(QModelIndex index);
     void updateUnitCompoBox(QString unit);
index acd8f94..af62383 100644 (file)
     <property name="geometry">
      <rect>
       <x>10</x>
-      <y>0</y>
+      <y>10</y>
       <width>781</width>
-      <height>365</height>
+      <height>361</height>
      </rect>
     </property>
     <property name="currentIndex">
-     <number>0</number>
+     <number>1</number>
     </property>
     <widget class="QWidget" name="StartTab">
      <attribute name="title">
       </layout>
      </widget>
     </widget>
+    <widget class="QWidget" name="tab">
+     <attribute name="title">
+      <string>Top</string>
+     </attribute>
+     <widget class="QPushButton" name="buttonTopRefresh">
+      <property name="geometry">
+       <rect>
+        <x>20</x>
+        <y>270</y>
+        <width>169</width>
+        <height>37</height>
+       </rect>
+      </property>
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>16</pointsize>
+        <weight>75</weight>
+        <bold>true</bold>
+       </font>
+      </property>
+      <property name="text">
+       <string>Refresh list</string>
+      </property>
+     </widget>
+     <widget class="QListView" name="listViewTopList">
+      <property name="geometry">
+       <rect>
+        <x>360</x>
+        <y>10</y>
+        <width>411</width>
+        <height>311</height>
+       </rect>
+      </property>
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>10</pointsize>
+       </font>
+      </property>
+      <property name="flow">
+       <enum>QListView::LeftToRight</enum>
+      </property>
+     </widget>
+     <widget class="QWidget" name="">
+      <property name="geometry">
+       <rect>
+        <x>10</x>
+        <y>10</y>
+        <width>341</width>
+        <height>141</height>
+       </rect>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <widget class="QLabel" name="labelCategory">
+         <property name="font">
+          <font>
+           <family>Bitstream Charter</family>
+           <pointsize>16</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>Category:</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QComboBox" name="comboBoxTopCategory"/>
+       </item>
+      </layout>
+     </widget>
+    </widget>
     <widget class="QWidget" name="settingsTab">
      <attribute name="title">
       <string>Settings</string>
     <property name="geometry">
      <rect>
       <x>10</x>
-      <y>370</y>
+      <y>380</y>
       <width>781</width>
-      <height>41</height>
+      <height>31</height>
      </rect>
     </property>
     <layout class="QHBoxLayout" name="horizontalLayout">
index 66ab41e..d7eceae 100644 (file)
@@ -1,5 +1,4 @@
 #include <QtGui/QApplication>
-#include <QStyleFactory>
 #include "carmainwindow.h"
 
 int main(int argc, char *argv[])