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();
23 *Destructor of this class. Should be used to release all allocated resources.
25 CarMainWindow::~CarMainWindow()
31 *This function is used to .
34 void CarMainWindow::changeEvent(QEvent *e)
36 QMainWindow::changeEvent(e);
38 case QEvent::LanguageChange:
39 ui->retranslateUi(this);
47 *This slot function is called when ever list view is update.
48 *@param QModelIndex index.
50 void CarMainWindow::on_listView_clicked(QModelIndex index)
52 QString str = index.data().toString();
53 QStringList list = str.split("-");
54 QStringList list2 = list[1].split(" ");
56 ui->minLineEdit->setText(list[0]);
57 ui->maxLineEdit->setText(list2[0]);
58 updateUnitCompoBox(list2[1]);
62 *This slot function is called when ever auto start button clicked.
64 void CarMainWindow::on_autoStartButton_clicked()
70 *This slot function is called when ever list view is update.
73 void CarMainWindow::updateUnitCompoBox(QString unit)
75 ui->unitComboBox->setCurrentIndex(ui->unitComboBox->findText(unit, Qt::MatchExactly));
79 *This function is used to init combobox.
81 void CarMainWindow::initUnitCompoBox()
83 units << "km/h" << "km" << "h" << "m" << "min" << "mil" << "in" << "ft" << "yrd";
84 ui->unitComboBox->addItems(units);
88 *This function is used to init listview.
90 void CarMainWindow::initSpeedListView()
92 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";
93 QAbstractItemModel *model = new StringListModel(numbers);
94 ui->listView->setModel(model);