backup
[situare] / src / ui / mainwindow.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@ixonos.com
6       Kaj Wallin - kaj.wallin@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23
24 #ifndef MAINWINDOW_H
25 #define MAINWINDOW_H
26
27 #include <QtGui/QMainWindow>
28 #include <QWidget>
29 #include <QtWebKit>
30 #include <QDebug>
31 #include <QObject>
32 #include <QNetworkAccessManager>
33 #include "facebookservice/facebookauthentication.h"
34 #include "situareservice/situareservice.h"
35 #include "mapviewscreen.h"
36 #include "updatelocation/updatelocationdialog.h"
37 #include "ui/logindialog.h"
38
39 class QLabel;
40
41 /**
42 * @brief Main Window Class
43 *
44 * @class MainWindow mainwindow.h "src/ui/mainwindow.h"
45 */
46 class MainWindow : public QMainWindow
47 {
48     Q_OBJECT
49
50 public:
51     /**
52     * @brief Constructor
53     *
54     * @param parent Parent
55     */
56     MainWindow(QWidget *parent = 0);
57
58     /**
59     * @brief Destructor
60     *
61     */
62     ~MainWindow();
63
64 /*******************************************************************************
65  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
66  ******************************************************************************/
67 private:
68     /**
69       * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
70       */
71     void keyPressEvent(QKeyEvent* event);
72
73 /*******************************************************************************
74  * MEMBER FUNCTIONS AND SLOTS
75  ******************************************************************************/
76 public:
77     /**
78     * @brief Set auto centering button enabled.
79     *
80     * @param enabled true if enabled, false otherwise
81     */
82     void setAutoCenteringButton(bool enabled);
83
84     /**
85     * @brief Notify for auto centering enabling.
86     *
87     * @param enabled true if enabled, false otherwise
88     */
89     void autoCenteringEnabled(bool enabled);
90
91     /**
92     * @brief Set GPS button enabled.
93     *
94     * @param enabled true if enabled, false otherwise
95     */
96     void setGPSButton(bool enabled);
97
98 public slots:
99     /**
100     * @brief Slot for auto centering enabling.
101     *
102     * @param checked true if button state is checked, false otherwise
103     */
104     void autoCenteringToggled(bool checked);
105
106         /**
107     * @brief Slot for gps enabling.
108     *
109     * @param checked true if button state is checked, false otherwise
110     */
111     void gpsToggled(bool checked);
112
113     /**
114     * @brief Slot to intercept signal when user has pressed connect button from loginDialog
115     *
116     * @param email E-mail
117     * @param password Password
118     */
119     void loginDialogDone(const QString &email, const QString &password);
120
121     /**
122     * @brief Slot to intercept signal when login has failed (loginFailure signal)
123     *
124     */
125     void loginFailed();
126
127         /**
128     * @brief Slot for map location change.
129     */
130     void mapLocationChanged();
131
132     /**
133     * @brief Public slot, which open settings dialog
134     */
135     void openSettingsDialog();
136
137     /**
138     * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
139     *        doesn't exist yet
140     *
141     * @param url Login page url
142     */
143     void startLoginProcess(const QUrl &url);
144
145     /**
146     * @brief Toggle progress indicator.
147     *
148     * @param state true if progress indicator should be shown, false otherwise
149     */
150     void toggleProgressIndicator(bool state);
151
152 private:
153     /**
154     * @brief Private method to create the Menu items
155     */
156     void createMenus();
157
158     /**
159       * @brief Grab or release HW increase and decrease buttons.
160       *
161       * @param grab Use true for grabbing and false for releasing the keys
162       */
163     void grabZoomKeys(bool grab);
164
165     /**
166     * @brief Show Maemo information box with message.
167     *
168     * @brief message information message
169     */
170     void showMaemoInformationBox(const QString &message);
171
172 private slots:
173     /**
174     * @brief Slot for gps timeout.
175     *
176     * Called when request timeout occurs.
177     */
178     void gpsTimeout();
179
180     /**
181     * @brief Slot for gps error.
182     *
183     * @param message error message
184     */
185     void gpsError(const QString &message);
186
187     /**
188     * @brief Slot to intercept signal when webview has finished loading webpage
189     *
190     * @param done Status of the loading
191     */
192     void loadDone(bool done);
193
194     /**
195     * @brief Private slot, which starts UpdateLocationDialog
196     *
197     */
198     void openLocationUpdateDialog();
199
200 /*******************************************************************************
201  * SIGNALS
202  ******************************************************************************/
203 signals:
204     /**
205     * @brief Signal that indicates when user has cancelled login process
206     *
207     */
208     void cancelLoginProcess();
209
210     /**
211     * @brief Signal for map auto centering
212     *
213     * @param enabled true if map should auto center to gps location
214     */
215     void autoCentering(bool enabled);
216
217     /**
218     * @brief Signal for gps enabling.
219     *
220     * @param enabled true if gps should be enabled
221     */
222     void enableGPS(bool enabled);
223
224         /**
225     * @brief Signal for auto centering enabling.
226     *
227     * @param enabled if auto centering should be enabled
228     */
229     void enableAutoCentering(bool enabled);
230
231     /**
232     * @brief Signal for friend location ready.
233     *
234     * @param friendsList
235     */
236     void friendsLocationsReady(QList<User *> &friendsList);
237
238     /**
239     * @brief Signal for gps position.
240     *
241     * @param position longitude and latitude values
242     * @param accuracy coordinate accuracy in metres
243     */
244     void positionReceived(QPointF position, qreal accuracy);
245
246     /**
247     * @brief Signal for refreshing user data.
248     *
249     */
250     void refreshUserData();
251
252     /**
253     * @brief Signal for requesting reverseGeo from SituareEngine
254     *
255     */
256     void requestReverseGeo();
257
258     /**
259     * @brief Signals, when address data is ready
260     *
261     * @param address Street address
262     */
263     void reverseGeoReady(const QString &address);
264
265     /**
266     * @brief Signal for requestLocationUpdate from SituareEngine
267     *
268     * @param status Status message
269     * @param publish Publish on Facebook
270     */
271     void statusUpdate(const QString &status, const bool &publish);
272
273     /**
274     * @brief Signals when webview's urlChanged signal is emitted
275     *
276     * @param url New url
277     */
278     void updateCredentials(const QUrl &url);
279
280     /**
281     * @brief Signal for use location ready.
282     *
283     * @param user User object
284     */
285     void userLocationReady(User *user);
286
287     /**
288     * @brief Signal for HW increase button
289     */
290     void zoomInKeyPressed();
291
292     /**
293     * @brief Signal for HW decrease button
294     */
295     void zoomOutKeyPressed();
296
297     /**
298     * @brief Signal from SituareEngine to MapEngine is travelling here
299     */
300     void requestOwnLocation();
301
302     /**
303     * @brief Signal from MapEngine to SituareEngine is travelling here
304     */
305     void ownLocation(QPointF ownLatitudeLongitudeLocation);
306
307 /*******************************************************************************
308  * DATA MEMBERS
309  ******************************************************************************/
310 private:
311
312     QAction *m_autoCenteringAct;    ///< Action to auto center map using gps position
313     QString m_email; ///< Placeholder for email
314     QAction *m_gpsToggleAct;    ///< Action to trigger gps toggle
315     UpdateLocationDialog *m_locationDialog; ///< Message dialog
316     LoginDialog *m_loginDialog; ///< Login dialog
317     QUrl m_loginUrl; ///< Placeholder for login page url
318     MapViewScreen *m_mapViewScreen; ///< Instance of the map view
319     QString m_password; ///< Placeholder for password
320     bool m_refresh; ///< Indicates when webpage is refreshed
321     QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
322     QMenu *m_viewMenu; ///< Object that hold the view menu items
323     QWebView *m_webView; ///< Shows facebook login page
324 };
325
326 #endif // MAINWINDOW_H