#include "carmainwindow.h"
- #include "ui_carmainwindow.h"
- #include "stringlistmodel.h"
- #include "loginwindow.h"
- #include <QStandardItemModel>
- #include <QStringList>
- #include <QString>
- #include <QNetworkRequest>
/**
*Constructor of this class.
ui->setupUi(this);
result = new ResultDialog();
measure = new MeasureDialog();
+ xmlreader = new XmlReader();
initUnitCompoBox();
initSpeedListView();
++<<<<<<< HEAD:Client/carmainwindow.cpp
+ initCategoryCompoBox();
+
+ myLogin = new LoginWindow(this);
+ myRegistration = new Registration(this);
+ manager = new QNetworkAccessManager(this);
+ connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(networkResponse(QNetworkReply*)));
+
++=======
++>>>>>>> feature/XMLreader:Client/carmainwindow.cpp
}
/**
delete ui;
delete result;
delete measure;
+ delete xmlreader;
}
/**
}
/**
- *This slot function is called when ever list view is update.
- *@param QModelIndex index.
+ *This slot function is called when ever list view is update. Start-tab view.
*/
void CarMainWindow::on_listView_clicked(QModelIndex index)
{
}
/**
- *This slot function is called when ever auto start button clicked.
+ *This slot function is called when ever auto start button clicked. Start-tab view.
*/
void CarMainWindow::on_autoStartButton_clicked()
{
- if(measure)
- {
- delete measure;
- measure = NULL;
- measure = new MeasureDialog();
- }
- connect(measure, SIGNAL(speedAchieved()), this, SLOT(openResultView()));
+ delete measure;
+ measure = NULL;
+ measure = new MeasureDialog();
+ connect(measure, SIGNAL(speedAchieved()), this, SLOT(openResultView()));
// Show measure dialog.
measure->show();
}
/**
- *This slot function is called when ever list view is update.
+ *This slot function is called when ever list view is update. Start-tab view.
*@param QString unit.
*/
void CarMainWindow::updateUnitCompoBox(QString unit)
}
/**
- *This function is used to init unit combobox.
+ *This function is used to init unit combobox. Start-tab view.
*/
void CarMainWindow::initUnitCompoBox()
{
- units << "km/h" << "km" << "h" << "m" << "min" << "mil" << "in" << "ft" << "yrd";
+ units << "km/h" << "km" << "h" << "m" << "min" << "Mile" << "Mph" << "in" << "ft" << "yrd";
ui->unitComboBox->addItems(units);
}
/**
- *This function is used to set items to unit combobox.
+ *This function is used to set items to unit combobox. Start-tab view.
*@param QStringlist numbers
*/
void CarMainWindow::setUnitCompoBox(QStringList units)
}
/**
- *This function is used to init speed listview.
+ *This function is used to init speed listview. Start-tab view.
*/
void CarMainWindow::initSpeedListView()
{
++<<<<<<< HEAD:Client/carmainwindow.cpp
+ 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";
++=======
+ 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";
++>>>>>>> feature/XMLreader:Client/carmainwindow.cpp
QAbstractItemModel *model = new StringListModel(numbers);
ui->listView->setModel(model);
}
/**
- <<<<<<< HEAD:Client/carmainwindow.cpp
- *This function is used to set items to speed listview.
+ *This function is used to set items to speed listview. Start-tab view.
*@param QStringlist numbers
*/
void CarMainWindow::setSpeedListView(QStringList numbers)
}
/**
- *This function is used to init category combobox.
- */
- void CarMainWindow::initCategoryCompoBox()
- {
- categories << "Top 10 1/4 mile" << "Top 10 0-100 km/h" << "Top 10 car";
- ui->comboBoxTopCategory->addItems(categories);
- }
-
- /**
- *This function is used to set items to category combobox.
- *@param QStringlist categories
+ *This function is used to set items to category combobox. Top-tab view.
+ *@param
*/
- void CarMainWindow::setCategoryCompoBox(QStringList categories)
+ void CarMainWindow::setCategoryCompoBox()
{
- ui->comboBoxTopCategory->addItems(categories);
+ ui->comboBoxTopCategory->addItems(xmlreader->getTop10List());
}
/**
- *This slot function is called when ever categories combobox is update.
+ *This function is used to set items to labelTopList. Top-tab view.
*@param QString category
*/
- void CarMainWindow::on_comboBoxTopCategory_activated(QString category)
+ void CarMainWindow::setListViewTopList(QString category)
{
- //TODO: get top list
+ QString topList;
+
+ if (category == "acceleration-0-100")
+ {
+ topList.append(xmlreader->getTop10AccelerationList());
+ }
- QStringList topList;
- topList << "1. Pertti 7,5s" << "2. Ville 10,2s";
+ else if (category == "Speed")
+ {
+ topList.append(xmlreader->getTop10SpeedList());
+ }
- QAbstractItemModel *model = new StringListModel(topList);
- ui->listViewTopList->setModel(model);
+ else if (category == "G-force")
+ {
+ topList.append(xmlreader->getTop10GforceList());
+ }
+ ui->labelTopList->setText(topList);
}
/**
*/
void CarMainWindow::openResultView()
{
+ result->saveMeasuresToArray(measure->measures);
// Show result dialog.
result->show();
}
/**
++<<<<<<< HEAD:Client/carmainwindow.cpp
+ *This slot function is called when the server has finished guery.
+ */
+void CarMainWindow::networkResponse(QNetworkReply *reply)
+{
+}
+
+/**
+ *This slot function is called when the user will to send data to server.
+ */
+void CarMainWindow::on_pushButton_clicked()
+{
+ QNetworkRequest postData;
+ postData.setUrl(QString("http://weather.yahooapis.com/forecastrss?p=FIXX0013&u=c"));
+ manager->get(postData);
+
+}
+
+/**
+ *This slot function is called when login/logout button is clicked.
+ */
+void CarMainWindow::on_loginLogoutButton_clicked()
+{
+ //LoginWindow myLogin;
+
+ myLogin->show();
+ //ui->loginLogoutButton->setText("logout");
+}
+
+/**
+ *This slot function is called when registrate button is clicked.
+ */
+void CarMainWindow::on_registratePushButton_clicked()
+{
+ myRegistration->show();
++=======
+ *This slot function is called when ever refresh button clicked. Top-tab view.
+ */
+ void CarMainWindow::on_buttonTopRefresh_clicked()
+ {
+ setCategoryCompoBox();
+ }
+
+ /**
+ *This slot function is called when ever category combobox current index changed. Top-tab view.
+ *@param QString category
+ */
+ void CarMainWindow::on_comboBoxTopCategory_currentIndexChanged(QString category)
+ {
+ setListViewTopList(category);
++>>>>>>> feature/XMLreader:Client/carmainwindow.cpp
}
#ifndef CARMAINWINDOW_H
#define CARMAINWINDOW_H
- /**
- *This class
- *@author Toni Jussila
- *@version 0.0.1
- */
-
#include <QMainWindow>
+ #include <QStandardItemModel>
#include <QModelIndex>
#include <QStringList>
+ #include <QString>
+#include <QNetworkAccessManager>
++#include <QStandardItemModel>
++#include <QNetworkRequest>
#include "resultdialog.h"
#include "measuredialog.h"
+#include "loginwindow.h"
+#include "registration.h"
+ #include "xmlreader.h"
+ #include "ui_carmainwindow.h"
+ #include "stringlistmodel.h"
namespace Ui {
class CarMainWindow;
CarMainWindow(QWidget *parent = 0);
~CarMainWindow();
- void setUnitCompoBox(QStringList units);
- void setSpeedListView(QStringList numbers);
- void setCategoryCompoBox(QStringList categories);
+ void setUnitCompoBox(QStringList units); //Start-tab
+ void setSpeedListView(QStringList numbers); //Start-tab
+ void setListViewTopList(QString category); //Top-tab
+ void setCategoryCompoBox(); //Top-tab
protected:
void changeEvent(QEvent *e);
Ui::CarMainWindow *ui;
ResultDialog *result;
MeasureDialog *measure;
-
+ XmlReader *xmlreader;
-
+ QNetworkAccessManager* manager;
+ LoginWindow *myLogin;
+ Registration *myRegistration;
-
- void initUnitCompoBox();
- void initSpeedListView();
+ void initCategoryCompoBox();
+ void initUnitCompoBox(); //Start-tab
+ void initSpeedListView(); //Start-tab
private:
- QStringList numbers;
- QStringList units;
- QStringList categories;
+ QStringList numbers; //Start-tab
+ QStringList units; //Start-tab
+ QStringList categories; //Top-tab
private slots:
+ void on_registratePushButton_clicked();
+ void on_loginLogoutButton_clicked();
+ void on_comboBoxTopCategory_activated(QString );
- void on_autoStartButton_clicked();
- void on_listView_clicked(QModelIndex index);
- void updateUnitCompoBox(QString unit);
- void openResultView();
-
+ void on_pushButton_clicked();
+ void networkResponse(QNetworkReply*);
+ void on_comboBoxTopCategory_currentIndexChanged(QString category); //Top-tab
+ void on_listView_clicked(QModelIndex index); //Start-tab
+ void updateUnitCompoBox(QString unit); //Start-tab
+ void openResultView();
+ void on_buttonTopRefresh_clicked(); //Top-tab: button
+ void on_autoStartButton_clicked(); //Start-tab: button
-
};
#endif // CARMAINWINDOW_H
</rect>
</property>
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="StartTab">
<attribute name="title">
<string>Refresh list</string>
</property>
</widget>
+ <widget class="QListView" name="listViewTopList">
+ <property name="geometry">
+ <rect>
+ <x>360</x>
+ <y>10</y>
+ <width>411</width>
+ <height>311</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <family>Bitstream Charter</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="flow">
+ <enum>QListView::LeftToRight</enum>
+ </property>
+ </widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
</item>
</layout>
</widget>
+ <widget class="QLabel" name="labelTopList">
+ <property name="geometry">
+ <rect>
+ <x>380</x>
+ <y>10</y>
+ <width>371</width>
+ <height>311</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>9</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>TopList</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
</widget>
<widget class="QWidget" name="settingsTab">
<attribute name="title">
</item>
</layout>
</widget>
+ <widget class="QPushButton" name="loginLogoutButton">
+ <property name="geometry">
+ <rect>
+ <x>690</x>
+ <y>0</y>
+ <width>93</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Login</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="registratePushButton">
+ <property name="geometry">
+ <rect>
+ <x>580</x>
+ <y>0</y>
+ <width>93</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Registrate</string>
+ </property>
+ </widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">