1 #include "carmainwindow.h"
4 *Constructor of this class.
5 *@param QWidget pointer to parent object. By default the value is NULL.
7 CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::CarMainWindow)
10 result = new ResultDialog();
11 measure = new MeasureDialog();
12 xmlreader = new XmlReader();
19 *Destructor of this class. Should be used to release all allocated resources.
21 CarMainWindow::~CarMainWindow()
30 *This function is used to .
33 void CarMainWindow::changeEvent(QEvent *e)
35 QMainWindow::changeEvent(e);
37 case QEvent::LanguageChange:
38 ui->retranslateUi(this);
46 *This slot function is called when ever list view is update. Start-tab view.
48 void CarMainWindow::on_listView_clicked(QModelIndex index)
50 QString str = index.data().toString();
51 QStringList list = str.split("-");
52 QStringList list2 = list[1].split(" ");
54 ui->minLineEdit->setText(list[0]);
55 ui->maxLineEdit->setText(list2[0]);
56 updateUnitCompoBox(list2[1]);
60 *This slot function is called when ever auto start button clicked. Start-tab view.
62 void CarMainWindow::on_autoStartButton_clicked()
68 measure = new MeasureDialog();
71 connect(measure, SIGNAL(speedAchieved()), this, SLOT(openResultView()));
73 // Show measure dialog.
78 *This slot function is called when ever list view is update. Start-tab view.
81 void CarMainWindow::updateUnitCompoBox(QString unit)
83 ui->unitComboBox->setCurrentIndex(ui->unitComboBox->findText(unit, Qt::MatchExactly));
87 *This function is used to init unit combobox. Start-tab view.
89 void CarMainWindow::initUnitCompoBox()
91 units << "km/h" << "km" << "h" << "m" << "min" << "Mile" << "Mph" << "in" << "ft" << "yrd";
92 ui->unitComboBox->addItems(units);
96 *This function is used to set items to unit combobox. Start-tab view.
97 *@param QStringlist numbers
99 void CarMainWindow::setUnitCompoBox(QStringList units)
101 ui->unitComboBox->addItems(units);
105 *This function is used to init speed listview. Start-tab view.
107 void CarMainWindow::initSpeedListView()
109 numbers << "0-40 km/h" << "0-1/4 Mile" << "0-1/8 Mile" << "0-50 km" << "50-100 Mile" << "0-60 Mph" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
110 QAbstractItemModel *model = new StringListModel(numbers);
111 ui->listView->setModel(model);
115 *This function is used to set items to speed listview. Start-tab view.
116 *@param QStringlist numbers
118 void CarMainWindow::setSpeedListView(QStringList numbers)
120 QAbstractItemModel *model = new StringListModel(numbers);
121 ui->listView->setModel(model);
125 *This function is used to set items to category combobox. Top-tab view.
128 void CarMainWindow::setCategoryCompoBox()
130 ui->comboBoxTopCategory->addItems(xmlreader->getTop10List());
134 *This function is used to set items to labelTopList. Top-tab view.
135 *@param QString category
137 void CarMainWindow::setListViewTopList(QString category)
141 if (category == "acceleration-0-100")
143 topList.append(xmlreader->getTop10AccelerationList());
146 else if (category == "Speed")
148 topList.append(xmlreader->getTop10SpeedList());
151 else if (category == "G-force")
153 topList.append(xmlreader->getTop10GforceList());
155 ui->labelTopList->setText(topList);
159 *This slot function is called when speed is achieved in measure dialog. Opens result dialog.
161 void CarMainWindow::openResultView()
163 // Show result dialog.
168 *This slot function is called when ever refresh button clicked. Top-tab view.
170 void CarMainWindow::on_buttonTopRefresh_clicked()
172 setCategoryCompoBox();
176 *This slot function is called when ever category combobox current index changed. Top-tab view.
177 *@param QString category
179 void CarMainWindow::on_comboBoxTopCategory_currentIndexChanged(QString category)
181 setListViewTopList(category);