1 #include "carmainwindow.h"
2 #include "ui_carmainwindow.h"
3 #include "stringlistmodel.h"
4 #include <QStandardItemModel>
9 *Constructor of this class.
10 *@param QWidget pointer to parent object. By default the value is NULL.
12 CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::CarMainWindow)
15 result = new ResultDialog();
16 measure = new MeasureDialog();
20 initCategoryCompoBox();
24 *Destructor of this class. Should be used to release all allocated resources.
26 CarMainWindow::~CarMainWindow()
34 *This function is used to .
37 void CarMainWindow::changeEvent(QEvent *e)
39 QMainWindow::changeEvent(e);
41 case QEvent::LanguageChange:
42 ui->retranslateUi(this);
50 *This slot function is called when ever list view is update.
51 *@param QModelIndex index.
53 void CarMainWindow::on_listView_clicked(QModelIndex index)
55 QString str = index.data().toString();
56 QStringList list = str.split("-");
57 QStringList list2 = list[1].split(" ");
59 ui->minLineEdit->setText(list[0]);
60 ui->maxLineEdit->setText(list2[0]);
61 updateUnitCompoBox(list2[1]);
65 *This slot function is called when ever auto start button clicked.
67 void CarMainWindow::on_autoStartButton_clicked()
73 measure = new MeasureDialog();
76 connect(measure, SIGNAL(speedAchieved()), this, SLOT(openResultView()));
78 // Show measure dialog.
83 *This slot function is called when ever list view is update.
86 void CarMainWindow::updateUnitCompoBox(QString unit)
88 ui->unitComboBox->setCurrentIndex(ui->unitComboBox->findText(unit, Qt::MatchExactly));
92 *This function is used to init unit combobox.
94 void CarMainWindow::initUnitCompoBox()
96 units << "km/h" << "km" << "h" << "m" << "min" << "mil" << "in" << "ft" << "yrd";
97 ui->unitComboBox->addItems(units);
101 *This function is used to set items to unit combobox.
102 *@param QStringlist numbers
104 void CarMainWindow::setUnitCompoBox(QStringList units)
106 ui->unitComboBox->addItems(units);
110 *This function is used to init speed listview.
112 void CarMainWindow::initSpeedListView()
114 numbers << "0-100 km/h" << "0-1/4 mil" << "0-50 km" << "50-100 mil" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
115 QAbstractItemModel *model = new StringListModel(numbers);
116 ui->listView->setModel(model);
120 <<<<<<< HEAD:Client/carmainwindow.cpp
121 *This function is used to set items to speed listview.
122 *@param QStringlist numbers
124 void CarMainWindow::setSpeedListView(QStringList numbers)
126 QAbstractItemModel *model = new StringListModel(numbers);
127 ui->listView->setModel(model);
131 *This function is used to init category combobox.
133 void CarMainWindow::initCategoryCompoBox()
135 categories << "Top 10 1/4 mile" << "Top 10 0-100 km/h" << "Top 10 car";
136 ui->comboBoxTopCategory->addItems(categories);
140 *This function is used to set items to category combobox.
141 *@param QStringlist categories
143 void CarMainWindow::setCategoryCompoBox(QStringList categories)
145 ui->comboBoxTopCategory->addItems(categories);
149 *This slot function is called when ever categories combobox is update.
150 *@param QString category
152 void CarMainWindow::on_comboBoxTopCategory_activated(QString category)
157 topList << "1. Pertti 7,5s" << "2. Ville 10,2s";
159 QAbstractItemModel *model = new StringListModel(topList);
160 ui->listViewTopList->setModel(model);
164 *This slot function is called when speed is achieved in measure dialog. Opens result dialog.
166 void CarMainWindow::openResultView()
168 // Show result dialog.