Added the UML to git. Made the state classes of their own and fixed networking.
[simple-xmbc-rem] / src / mainwindow.h
1 // checksum 0x9a77 version 0x20001
2 /*
3   This file was generated by the Mobile Qt Application wizard of Qt Creator.
4   MainWindow is a convenience class containing mobile device specific code
5   such as screen orientation handling.
6   It is recommended not to modify this file, since newer versions of Qt Creator
7   may offer an updated version of it.
8 */
9
10 #ifndef MAINWINDOW_H
11 #define MAINWINDOW_H
12
13 #include <QtGui/QMainWindow>
14 #include <QTcpSocket>
15 #include <QStateMachine>
16 #include <QState>
17 #include <QAbstractButton>
18
19 namespace Ui {
20     class MainWindow;
21 }
22
23 class DisconnectedState : public QState
24 {
25 public:
26     DisconnectedState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
27
28 protected:
29     void onEntry(QEvent *event);
30     void onExit(QEvent *event);
31     QTcpSocket* m_socket;
32 };
33
34 class ConnectingState : public QState
35 {
36     Q_OBJECT
37 public:
38     ConnectingState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
39
40 signals:
41     void connected();
42     void failed();
43
44 private slots:
45     void onSocketError(QAbstractSocket::SocketError err);
46
47 protected:
48     void onEntry(QEvent *event);
49     void onExit(QEvent *event);
50     QTcpSocket* m_socket;
51 };
52
53 class ConnectedState : public QState
54 {
55     Q_OBJECT
56 public:
57     ConnectedState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
58
59 private slots:
60     void onSocketError(QAbstractSocket::SocketError err);
61
62 signals:
63     void disconnected();
64
65 protected:
66     void onEntry(QEvent *event);
67     void onExit(QEvent *event);
68     QTcpSocket* m_socket;
69 };
70
71 class DisconnectingState : public QState
72 {
73     Q_OBJECT
74 public:
75     DisconnectingState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
76
77 signals:
78     void disconnected();
79
80 private slots:
81     void onSocketError(QAbstractSocket::SocketError err);
82
83 protected:
84     void onEntry(QEvent *event);
85     void onExit(QEvent *event);
86     QTcpSocket* m_socket;
87 };
88
89 class MainWindow : public QMainWindow
90 {
91     Q_OBJECT
92 public:
93     enum ScreenOrientation {
94         ScreenOrientationLockPortrait,
95         ScreenOrientationLockLandscape,
96         ScreenOrientationAuto
97     };
98
99     explicit MainWindow(QWidget *parent = 0);
100     virtual ~MainWindow();
101
102     void setOrientation(ScreenOrientation orientation);
103     void showExpanded();
104
105 private slots:
106     // auto-connected slots
107     void on_actionSetup_triggered();
108
109 private:
110     void pendingNetworkOperation(bool pending);
111
112     void createStates();
113     void createTransitions();
114     void createConnections();
115
116     QTcpSocket m_serverSocket;
117     Ui::MainWindow *m_ui;
118
119     QStateMachine m_stateMachine;
120
121     DisconnectedState* m_disconnectedState;
122     ConnectingState* m_connectingState;
123     ConnectedState* m_connectedState;
124     DisconnectingState* m_disconnectingState;
125 };
126
127 #endif // MAINWINDOW_H