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();
16 <<<<<<< HEAD:Client/carmainwindow.cpp
17 initCategoryCompoBox();
19 myLogin = new LoginWindow(this);
20 myRegistration = new Registration(this);
21 manager = new QNetworkAccessManager(this);
22 connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(networkResponse(QNetworkReply*)));
25 >>>>>>> feature/XMLreader:Client/carmainwindow.cpp
29 *Destructor of this class. Should be used to release all allocated resources.
31 CarMainWindow::~CarMainWindow()
40 *This function is used to .
43 void CarMainWindow::changeEvent(QEvent *e)
45 QMainWindow::changeEvent(e);
47 case QEvent::LanguageChange:
48 ui->retranslateUi(this);
56 *This slot function is called when ever list view is update. Start-tab view.
58 void CarMainWindow::on_listView_clicked(QModelIndex index)
60 QString str = index.data().toString();
61 QStringList list = str.split("-");
62 QStringList list2 = list[1].split(" ");
64 ui->minLineEdit->setText(list[0]);
65 ui->maxLineEdit->setText(list2[0]);
66 updateUnitCompoBox(list2[1]);
70 *This slot function is called when ever auto start button clicked. Start-tab view.
72 void CarMainWindow::on_autoStartButton_clicked()
77 measure = new MeasureDialog();
79 connect(measure, SIGNAL(speedAchieved()), this, SLOT(openResultView()));
80 // Show measure dialog.
85 *This slot function is called when ever list view is update. Start-tab view.
88 void CarMainWindow::updateUnitCompoBox(QString unit)
90 ui->unitComboBox->setCurrentIndex(ui->unitComboBox->findText(unit, Qt::MatchExactly));
94 *This function is used to init unit combobox. Start-tab view.
96 void CarMainWindow::initUnitCompoBox()
98 units << "km/h" << "km" << "h" << "m" << "min" << "Mile" << "Mph" << "in" << "ft" << "yrd";
99 ui->unitComboBox->addItems(units);
103 *This function is used to set items to unit combobox. Start-tab view.
104 *@param QStringlist numbers
106 void CarMainWindow::setUnitCompoBox(QStringList units)
108 ui->unitComboBox->addItems(units);
112 *This function is used to init speed listview. Start-tab view.
114 void CarMainWindow::initSpeedListView()
116 <<<<<<< HEAD:Client/carmainwindow.cpp
117 numbers << "0-40 km/h" << "0-1/4 mil" << "0-50 km" << "50-100 mil" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
119 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";
120 >>>>>>> feature/XMLreader:Client/carmainwindow.cpp
121 QAbstractItemModel *model = new StringListModel(numbers);
122 ui->listView->setModel(model);
126 *This function is used to set items to speed listview. Start-tab view.
127 *@param QStringlist numbers
129 void CarMainWindow::setSpeedListView(QStringList numbers)
131 QAbstractItemModel *model = new StringListModel(numbers);
132 ui->listView->setModel(model);
136 *This function is used to set items to category combobox. Top-tab view.
139 void CarMainWindow::setCategoryCompoBox()
141 ui->comboBoxTopCategory->addItems(xmlreader->getTop10List());
145 *This function is used to set items to labelTopList. Top-tab view.
146 *@param QString category
148 void CarMainWindow::setListViewTopList(QString category)
152 if (category == "acceleration-0-100")
154 topList.append(xmlreader->getTop10AccelerationList());
157 else if (category == "Speed")
159 topList.append(xmlreader->getTop10SpeedList());
162 else if (category == "G-force")
164 topList.append(xmlreader->getTop10GforceList());
166 ui->labelTopList->setText(topList);
170 *This slot function is called when speed is achieved in measure dialog. Opens result dialog.
172 void CarMainWindow::openResultView()
174 result->saveMeasuresToArray(measure->measures);
175 // Show result dialog.
180 <<<<<<< HEAD:Client/carmainwindow.cpp
181 *This slot function is called when the server has finished guery.
183 void CarMainWindow::networkResponse(QNetworkReply *reply)
188 *This slot function is called when the user will to send data to server.
190 void CarMainWindow::on_pushButton_clicked()
192 QNetworkRequest postData;
193 postData.setUrl(QString("http://weather.yahooapis.com/forecastrss?p=FIXX0013&u=c"));
194 manager->get(postData);
199 *This slot function is called when login/logout button is clicked.
201 void CarMainWindow::on_loginLogoutButton_clicked()
203 //LoginWindow myLogin;
206 //ui->loginLogoutButton->setText("logout");
210 *This slot function is called when registrate button is clicked.
212 void CarMainWindow::on_registratePushButton_clicked()
214 myRegistration->show();
216 *This slot function is called when ever refresh button clicked. Top-tab view.
218 void CarMainWindow::on_buttonTopRefresh_clicked()
220 setCategoryCompoBox();
224 *This slot function is called when ever category combobox current index changed. Top-tab view.
225 *@param QString category
227 void CarMainWindow::on_comboBoxTopCategory_currentIndexChanged(QString category)
229 setListViewTopList(category);
230 >>>>>>> feature/XMLreader:Client/carmainwindow.cpp