Read socket data if available.
[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     void onSocketData();
62
63 signals:
64     void disconnected();
65
66 protected:
67     void onEntry(QEvent *event);
68     void onExit(QEvent *event);
69     QTcpSocket* m_socket;
70 };
71
72 class DisconnectingState : public QState
73 {
74     Q_OBJECT
75 public:
76     DisconnectingState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
77
78 signals:
79     void disconnected();
80
81 private slots:
82     void onSocketError(QAbstractSocket::SocketError err);
83
84 protected:
85     void onEntry(QEvent *event);
86     void onExit(QEvent *event);
87     QTcpSocket* m_socket;
88 };
89
90 class MainWindow : public QMainWindow
91 {
92     Q_OBJECT
93 public:
94     enum ScreenOrientation {
95         ScreenOrientationLockPortrait,
96         ScreenOrientationLockLandscape,
97         ScreenOrientationAuto
98     };
99
100     explicit MainWindow(QWidget *parent = 0);
101     virtual ~MainWindow();
102
103     void setOrientation(ScreenOrientation orientation);
104     void showExpanded();
105
106 private slots:
107     // auto-connected slots
108     void on_actionSetup_triggered();
109
110 private:
111     void pendingNetworkOperation(bool pending);
112
113     void createStates();
114     void createTransitions();
115     void createConnections();
116
117     QTcpSocket m_serverSocket;
118     Ui::MainWindow *m_ui;
119
120     QStateMachine m_stateMachine;
121
122     DisconnectedState* m_disconnectedState;
123     ConnectingState* m_connectingState;
124     ConnectedState* m_connectedState;
125     DisconnectingState* m_disconnectingState;
126 };
127
128 #endif // MAINWINDOW_H