dcf047e4defb1345084c072ff1817573eb16b749
[speedfreak] / Client / carmainwindow.h
1 /*
2  * CarMainWindow main class
3  *
4  * @author     Toni Jussila <toni.jussila@fudeco.com>
5  * @author     Janne Änäkkälä <janne.anakkala@fudeco.com>
6  * @author     Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
7  * @author     Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
8  * @copyright  (c) 2010 Speed Freak team
9  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
10  */
11
12 #ifndef CARMAINWINDOW_H
13 #define CARMAINWINDOW_H
14
15 #include <QMainWindow>
16 #include <QStandardItemModel>
17 #include <QModelIndex>
18 #include <QStringList>
19 #include <QString>
20 #include <QNetworkAccessManager>
21 #include <QNetworkRequest>
22 #include <QNetworkReply>
23 #include <QMessageBox>
24 #include <QStandardItemModel>
25 #include <QBuffer>
26 #include <QByteArray>
27 #include <QDebug>
28 //#include "resultdialog.h"
29 //#include "measuredialog.h"
30 #include "loginwindow.h"
31 #include "registration.h"
32 #include "xmlwriter.h"
33 #include "xmlreader.h"
34 #include "ui_carmainwindow.h"
35 #include "stringlistmodel.h"
36 #include "measures.h"
37 #include "accelerometer.h"
38
39 namespace Ui {
40     class CarMainWindow;
41 }
42
43 class CarMainWindow : public QMainWindow {
44     Q_OBJECT
45 public:
46     CarMainWindow(QWidget *parent = 0);
47     ~CarMainWindow();
48
49     void setComboBoxStartTabUnits(QStringList units);    //Start-tab view
50     void setListViewStartTabAccelerationCategories(QStringList numbers); //Start-tab view
51     void setListViewTopList(QString category);  //Top-tab view
52     void setCategoryCompoBox(); //Top-tab
53
54 protected:
55     void changeEvent(QEvent *e);
56
57 private:
58     Ui::CarMainWindow *ui;
59     //ResultDialog *result;
60     //MeasureDialog *measure;
61     XmlReader *xmlreader;
62     XmlWriter *xmlwriter;
63     QNetworkAccessManager* manager;
64     LoginWindow *myLogin;
65     Registration *myRegistration;
66     //void initCategoryCompoBox();    //
67     void initComboBoxStartTabUnits();    //Start-tab view
68     void initListViewStartTabAccelerationCategories();   //Start-tab view
69
70     void initializeMeasures();
71
72 private:
73     QStringList accelerationCategoriesStartTab; //Start-tab view
74     QStringList units;  //Start-tab view
75     QStringList categories; //Top-tab view
76
77     QTimer *timer;
78     Accelerometer *accelerometer;
79     double time;
80     double speed;
81     Measures *measures;
82
83 signals:
84 void speedAchieved();
85 void sendresult();
86
87 private slots:
88     void on_pushButtonSendResult_clicked();
89     void on_pushButtonMeasureTabAbort_clicked();
90     void on_manualStartButton_clicked();
91     void on_setUserPushButton_clicked();
92     void on_registratePushButton_clicked();
93     void on_loginLogoutButton_clicked();
94     void on_comboBoxTopCategory_activated(QString );
95     void on_pushButton_clicked();
96     void networkResponse(QNetworkReply*);
97     void on_comboBoxTopCategory_currentIndexChanged(QString category); //Top-tab view
98     void on_listViewStartTabAccelerationCategories_clicked(QModelIndex index); //Start-tab view
99     void updateComboBoxStartTabUnits(QString unit);  //Start-tab view
100     void openResultView();
101     void on_buttonTopRefresh_clicked(); //Top-tab view: button
102     void on_autoStartButton_clicked();  //Start-tab view: button
103     void registrate();
104     void sendXml();
105     void requestTopList();
106     void ackOfResult(QNetworkReply* reply);
107     void ackOfRegistration(QNetworkReply* reply);
108     void errorFromServer(QNetworkReply* reply);
109
110     void after_timeout();
111 };
112
113 #endif // CARMAINWINDOW_H