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 measure = new MeasureDialog();
73 connect(measure, SIGNAL(speedAchieved()), this, SLOT(openResultView()));
75 // Show measure dialog.
80 *This slot function is called when ever list view is update.
83 void CarMainWindow::updateUnitCompoBox(QString unit)
85 ui->unitComboBox->setCurrentIndex(ui->unitComboBox->findText(unit, Qt::MatchExactly));
89 *This function is used to init combobox.
91 void CarMainWindow::initUnitCompoBox()
93 units << "km/h" << "km" << "h" << "m" << "min" << "mil" << "in" << "ft" << "yrd";
94 ui->unitComboBox->addItems(units);
98 *This function is used to init listview.
100 void CarMainWindow::initSpeedListView()
102 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";
103 QAbstractItemModel *model = new StringListModel(numbers);
104 ui->listView->setModel(model);
108 *This slot function is called when speed is achieved in measure dialog. Opens result dialog.
110 void CarMainWindow::openResultView()
112 // Show result dialog.