From f289332316b844f9744dbaca08e1d0d47d5e9011 Mon Sep 17 00:00:00 2001 From: Toni Jussila Date: Mon, 1 Mar 2010 13:52:47 +0200 Subject: [PATCH] Display top performer in certain category. --- Client/UI.pro | 8 +++-- Client/carmainwindow.cpp | 61 ++++++++++++++++++++++++++++++++-- Client/carmainwindow.h | 14 ++++++-- Client/carmainwindow.ui | 83 +++++++++++++++++++++++++++++++++++++++++++--- Client/main.cpp | 1 - 5 files changed, 153 insertions(+), 14 deletions(-) diff --git a/Client/UI.pro b/Client/UI.pro index c9c3c77..c48d029 100644 --- a/Client/UI.pro +++ b/Client/UI.pro @@ -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 diff --git a/Client/carmainwindow.cpp b/Client/carmainwindow.cpp index ace503b..50a24e0 100644 --- a/Client/carmainwindow.cpp +++ b/Client/carmainwindow.cpp @@ -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); +} diff --git a/Client/carmainwindow.h b/Client/carmainwindow.h index 054b075..f284446 100644 --- a/Client/carmainwindow.h +++ b/Client/carmainwindow.h @@ -8,9 +8,10 @@ */ #include +#include +#include #include "resultdialog.h" #include "measuredialog.h" -#include 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); diff --git a/Client/carmainwindow.ui b/Client/carmainwindow.ui index acd8f94..af62383 100644 --- a/Client/carmainwindow.ui +++ b/Client/carmainwindow.ui @@ -18,13 +18,13 @@ 10 - 0 + 10 781 - 365 + 361 - 0 + 1 @@ -125,6 +125,79 @@ + + + Top + + + + + 20 + 270 + 169 + 37 + + + + + Bitstream Charter + 16 + 75 + true + + + + Refresh list + + + + + + 360 + 10 + 411 + 311 + + + + + Bitstream Charter + 10 + + + + QListView::LeftToRight + + + + + + 10 + 10 + 341 + 141 + + + + + + + + Bitstream Charter + 16 + + + + Category: + + + + + + + + + Settings @@ -135,9 +208,9 @@ 10 - 370 + 380 781 - 41 + 31 diff --git a/Client/main.cpp b/Client/main.cpp index 66ab41e..d7eceae 100644 --- a/Client/main.cpp +++ b/Client/main.cpp @@ -1,5 +1,4 @@ #include -#include #include "carmainwindow.h" int main(int argc, char *argv[]) -- 1.7.9.5